Merge tag 'dma-mapping-4.16' of git://git.infradead.org/users/hch/dma-mapping
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Jan 2018 19:32:27 +0000 (11:32 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Jan 2018 19:32:27 +0000 (11:32 -0800)
Pull dma mapping updates from Christoph Hellwig:
 "Except for a runtime warning fix from Christian this is all about
  consolidation of the generic no-IOMMU code, a well as the glue code
  for swiotlb.

  All the code is based on the x86 implementation with hooks to allow
  all architectures that aren't cache coherent to use it.

  The x86 conversion itself has been deferred because the x86
  maintainers were a little busy in the last months"

* tag 'dma-mapping-4.16' of git://git.infradead.org/users/hch/dma-mapping: (57 commits)
  MAINTAINERS: add the iommu list for swiotlb and xen-swiotlb
  arm64: use swiotlb_alloc and swiotlb_free
  arm64: replace ZONE_DMA with ZONE_DMA32
  mips: use swiotlb_{alloc,free}
  mips/netlogic: remove swiotlb support
  tile: use generic swiotlb_ops
  tile: replace ZONE_DMA with ZONE_DMA32
  unicore32: use generic swiotlb_ops
  ia64: remove an ifdef around the content of pci-dma.c
  ia64: clean up swiotlb support
  ia64: use generic swiotlb_ops
  ia64: replace ZONE_DMA with ZONE_DMA32
  swiotlb: remove various exports
  swiotlb: refactor coherent buffer allocation
  swiotlb: refactor coherent buffer freeing
  swiotlb: wire up ->dma_supported in swiotlb_dma_ops
  swiotlb: add common swiotlb_map_ops
  swiotlb: rename swiotlb_free to swiotlb_exit
  x86: rename swiotlb_dma_ops
  powerpc: rename swiotlb_dma_ops
  ...

12 files changed:
1  2 
MAINTAINERS
arch/Kconfig
arch/arm64/Kconfig
arch/arm64/mm/init.c
arch/ia64/Kconfig
arch/mips/Kconfig
arch/powerpc/Kconfig
arch/powerpc/kernel/setup-common.c
arch/x86/Kconfig
arch/x86/mm/mem_encrypt.c
drivers/mtd/nand/qcom_nandc.c
lib/Kconfig

diff --combined MAINTAINERS
index 98ee6febcf452c9deac22bdc4230b8caf22413ac,30dcafd388acc501b01e940a02513ac717d2ddeb..7b5ef9a58c382de62491a43d15dc0e623e13fb6a
@@@ -62,15 -62,7 +62,15 @@@ trivial patch so apply some common sens
  
  7.    When sending security related changes or reports to a maintainer
        please Cc: security@kernel.org, especially if the maintainer
 -      does not respond.
 +      does not respond. Please keep in mind that the security team is
 +      a small set of people who can be efficient only when working on
 +      verified bugs. Please only Cc: this list when you have identified
 +      that the bug would present a short-term risk to other users if it
 +      were publicly disclosed. For example, reports of address leaks do
 +      not represent an immediate threat and are better handled publicly,
 +      and ideally, should come with a patch proposal. Please do not send
 +      automated reports to this list either. Such bugs will be handled
 +      better and faster in the usual public places.
  
  8.    Happy hacking.
  
@@@ -329,7 -321,7 +329,7 @@@ F: drivers/acpi/apei
  
  ACPI COMPONENT ARCHITECTURE (ACPICA)
  M:    Robert Moore <robert.moore@intel.com>
 -M:    Lv Zheng <lv.zheng@intel.com>
 +M:    Erik Schmauss <erik.schmauss@intel.com>
  M:    "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
  L:    linux-acpi@vger.kernel.org
  L:    devel@acpica.org
@@@ -875,12 -867,6 +875,12 @@@ S:       Supporte
  F:    drivers/android/
  F:    drivers/staging/android/
  
 +ANDROID GOLDFISH PIC DRIVER
 +M:    Miodrag Dinic <miodrag.dinic@mips.com>
 +S:    Supported
 +F:    Documentation/devicetree/bindings/interrupt-controller/google,goldfish-pic.txt
 +F:    drivers/irqchip/irq-goldfish-pic.c
 +
  ANDROID GOLDFISH RTC DRIVER
  M:    Miodrag Dinic <miodrag.dinic@mips.com>
  S:    Supported
@@@ -1327,8 -1313,7 +1327,8 @@@ F:      tools/perf/arch/arm/util/pmu.
  F:    tools/perf/arch/arm/util/auxtrace.c
  F:    tools/perf/arch/arm/util/cs-etm.c
  F:    tools/perf/arch/arm/util/cs-etm.h
 -F:    tools/perf/util/cs-etm.h
 +F:    tools/perf/util/cs-etm.*
 +F:    tools/perf/util/cs-etm-decoder/*
  
  ARM/CORGI MACHINE SUPPORT
  M:    Richard Purdie <rpurdie@rpsys.net>
@@@ -1598,7 -1583,6 +1598,7 @@@ F:      arch/arm/boot/dts/kirkwood
  F:    arch/arm/configs/mvebu_*_defconfig
  F:    arch/arm/mach-mvebu/
  F:    arch/arm64/boot/dts/marvell/armada*
 +F:    drivers/cpufreq/armada-37xx-cpufreq.c
  F:    drivers/cpufreq/mvebu-cpufreq.c
  F:    drivers/irqchip/irq-armada-370-xp.c
  F:    drivers/irqchip/irq-mvebu-*
@@@ -2399,6 -2383,13 +2399,6 @@@ F:     Documentation/devicetree/bindings/in
  F:    drivers/input/touchscreen/atmel_mxt_ts.c
  F:    include/linux/platform_data/atmel_mxt_ts.h
  
 -ATMEL NAND DRIVER
 -M:    Wenyou Yang <wenyou.yang@atmel.com>
 -M:    Josh Wu <rainyfeeling@outlook.com>
 -L:    linux-mtd@lists.infradead.org
 -S:    Supported
 -F:    drivers/mtd/nand/atmel/*
 -
  ATMEL SAMA5D2 ADC DRIVER
  M:    Ludovic Desroches <ludovic.desroches@microchip.com>
  L:    linux-iio@vger.kernel.org
@@@ -4343,10 -4334,12 +4343,12 @@@ T:   git git://git.infradead.org/users/hc
  W:    http://git.infradead.org/users/hch/dma-mapping.git
  S:    Supported
  F:    lib/dma-debug.c
- F:    lib/dma-noop.c
+ F:    lib/dma-direct.c
  F:    lib/dma-virt.c
  F:    drivers/base/dma-mapping.c
  F:    drivers/base/dma-coherent.c
+ F:    include/asm-generic/dma-mapping.h
+ F:    include/linux/dma-direct.h
  F:    include/linux/dma-mapping.h
  
  DME1737 HARDWARE MONITOR DRIVER
@@@ -5148,12 -5141,6 +5150,12 @@@ L:    linux-edac@vger.kernel.or
  S:    Maintained
  F:    drivers/edac/skx_edac.c
  
 +EDAC-TI
 +M:    Tero Kristo <t-kristo@ti.com>
 +L:    linux-edac@vger.kernel.org
 +S:    Maintained
 +F:    drivers/edac/ti_edac.c
 +
  EDIROL UA-101/UA-1000 DRIVER
  M:    Clemens Ladisch <clemens@ladisch.de>
  L:    alsa-devel@alsa-project.org (moderated for non-subscribers)
@@@ -6624,6 -6611,16 +6626,6 @@@ L:     linux-i2c@vger.kernel.or
  S:    Maintained
  F:    drivers/i2c/i2c-stub.c
  
 -i386 BOOT CODE
 -M:    "H. Peter Anvin" <hpa@zytor.com>
 -S:    Maintained
 -F:    arch/x86/boot/
 -
 -i386 SETUP CODE / CPU ERRATA WORKAROUNDS
 -M:    "H. Peter Anvin" <hpa@zytor.com>
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/hpa/linux-2.6-x86setup.git
 -S:    Maintained
 -
  IA64 (Itanium) PLATFORM
  M:    Tony Luck <tony.luck@intel.com>
  M:    Fenghua Yu <fenghua.yu@intel.com>
@@@ -8197,7 -8194,6 +8199,7 @@@ F:      arch/*/include/asm/rwsem.
  F:    include/linux/seqlock.h
  F:    lib/locking*.[ch]
  F:    kernel/locking/
 +X:    kernel/locking/locktorture.c
  
  LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP/Vista Dynamic Disks)
  M:    "Richard Russon (FlatCap)" <ldm@flatcap.org>
@@@ -8413,13 -8409,6 +8415,13 @@@ L:    linux-wireless@vger.kernel.or
  S:    Odd Fixes
  F:    drivers/net/wireless/marvell/mwl8k.c
  
 +MARVELL NAND CONTROLLER DRIVER
 +M:    Miquel Raynal <miquel.raynal@free-electrons.com>
 +L:    linux-mtd@lists.infradead.org
 +S:    Maintained
 +F:    drivers/mtd/nand/marvell_nand.c
 +F:    Documentation/devicetree/bindings/mtd/marvell-nand.txt
 +
  MARVELL SOC MMC/SD/SDIO CONTROLLER DRIVER
  M:    Nicolas Pitre <nico@fluxnic.net>
  S:    Odd Fixes
@@@ -8967,7 -8956,7 +8969,7 @@@ L:      linux-mtd@lists.infradead.or
  W:    http://www.linux-mtd.infradead.org/
  Q:    http://patchwork.ozlabs.org/project/linux-mtd/list/
  T:    git git://git.infradead.org/linux-mtd.git master
 -T:    git git://git.infradead.org/l2-mtd.git master
 +T:    git git://git.infradead.org/linux-mtd.git mtd/next
  S:    Maintained
  F:    Documentation/devicetree/bindings/mtd/
  F:    drivers/mtd/
@@@ -9056,14 -9045,6 +9058,14 @@@ F:    drivers/media/platform/atmel/atmel-i
  F:    drivers/media/platform/atmel/atmel-isc-regs.h
  F:    devicetree/bindings/media/atmel-isc.txt
  
 +MICROCHIP / ATMEL NAND DRIVER
 +M:    Wenyou Yang <wenyou.yang@microchip.com>
 +M:    Josh Wu <rainyfeeling@outlook.com>
 +L:    linux-mtd@lists.infradead.org
 +S:    Supported
 +F:    drivers/mtd/nand/atmel/*
 +F:    Documentation/devicetree/bindings/mtd/atmel-nand.txt
 +
  MICROCHIP KSZ SERIES ETHERNET SWITCH DRIVER
  M:    Woojung Huh <Woojung.Huh@microchip.com>
  M:    Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
@@@ -9106,7 -9087,6 +9108,7 @@@ F:      drivers/usb/image/microtek.
  
  MIPS
  M:    Ralf Baechle <ralf@linux-mips.org>
 +M:    James Hogan <jhogan@kernel.org>
  L:    linux-mips@linux-mips.org
  W:    http://www.linux-mips.org/
  T:    git git://git.linux-mips.org/pub/scm/ralf/linux.git
@@@ -9364,7 -9344,7 +9366,7 @@@ L:      linux-mtd@lists.infradead.or
  W:    http://www.linux-mtd.infradead.org/
  Q:    http://patchwork.ozlabs.org/project/linux-mtd/list/
  T:    git git://git.infradead.org/linux-mtd.git nand/fixes
 -T:    git git://git.infradead.org/l2-mtd.git nand/next
 +T:    git git://git.infradead.org/linux-mtd.git nand/next
  S:    Maintained
  F:    drivers/mtd/nand/
  F:    include/linux/mtd/*nand*.h
@@@ -9660,8 -9640,8 +9662,8 @@@ F:      include/uapi/linux/sunrpc
  NILFS2 FILESYSTEM
  M:    Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
  L:    linux-nilfs@vger.kernel.org
 -W:    http://nilfs.sourceforge.net/
 -W:    http://nilfs.osdn.jp/
 +W:    https://nilfs.sourceforge.io/
 +W:    https://nilfs.osdn.jp/
  T:    git git://github.com/konis/nilfs2.git
  S:    Supported
  F:    Documentation/filesystems/nilfs2.txt
@@@ -9765,15 -9745,6 +9767,15 @@@ S:    Supporte
  F:    Documentation/filesystems/ntfs.txt
  F:    fs/ntfs/
  
 +NUBUS SUBSYSTEM
 +M:    Finn Thain <fthain@telegraphics.com.au>
 +L:    linux-m68k@lists.linux-m68k.org
 +S:    Maintained
 +F:    arch/*/include/asm/nubus.h
 +F:    drivers/nubus/
 +F:    include/linux/nubus.h
 +F:    include/uapi/linux/nubus.h
 +
  NVIDIA (rivafb and nvidiafb) FRAMEBUFFER DRIVER
  M:    Antonino Daplas <adaplas@gmail.com>
  L:    linux-fbdev@vger.kernel.org
@@@ -9834,7 -9805,6 +9836,7 @@@ NXP TFA9879 DRIVE
  M:    Peter Rosin <peda@axentia.se>
  L:    alsa-devel@alsa-project.org (moderated for non-subscribers)
  S:    Maintained
 +F:    Documentation/devicetree/bindings/sound/tfa9879.txt
  F:    sound/soc/codecs/tfa9879*
  
  NXP-NCI NFC DRIVER
@@@ -10166,7 -10136,7 +10168,7 @@@ F:   drivers/irqchip/irq-ompic.
  F:    drivers/irqchip/irq-or1k-*
  
  OPENVSWITCH
 -M:    Pravin Shelar <pshelar@nicira.com>
 +M:    Pravin B Shelar <pshelar@ovn.org>
  L:    netdev@vger.kernel.org
  L:    dev@openvswitch.org
  W:    http://openvswitch.org
@@@ -10921,7 -10891,6 +10923,7 @@@ F:   include/linux/pm.
  F:    include/linux/pm_*
  F:    include/linux/powercap.h
  F:    drivers/powercap/
 +F:    kernel/configs/nopm.config
  
  POWER STATE COORDINATION INTERFACE (PSCI)
  M:    Mark Rutland <mark.rutland@arm.com>
@@@ -11482,6 -11451,15 +11484,6 @@@ L:  linux-wireless@vger.kernel.or
  S:    Orphan
  F:    drivers/net/wireless/ray*
  
 -RCUTORTURE MODULE
 -M:    Josh Triplett <josh@joshtriplett.org>
 -M:    "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
 -L:    linux-kernel@vger.kernel.org
 -S:    Supported
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
 -F:    Documentation/RCU/torture.txt
 -F:    kernel/rcu/rcutorture.c
 -
  RCUTORTURE TEST FRAMEWORK
  M:    "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
  M:    Josh Triplett <josh@joshtriplett.org>
@@@ -11674,8 -11652,8 +11676,8 @@@ F:   drivers/mtd/nand/r852.
  RISC-V ARCHITECTURE
  M:    Palmer Dabbelt <palmer@sifive.com>
  M:    Albert Ou <albert@sifive.com>
 -L:    patches@groups.riscv.org
 -T:    git https://github.com/riscv/riscv-linux
 +L:    linux-riscv@lists.infradead.org
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux.git
  S:    Supported
  F:    arch/riscv/
  K:    riscv
@@@ -12256,7 -12234,7 +12258,7 @@@ M:   Security Officers <security@kernel.o
  S:    Supported
  
  SECURITY SUBSYSTEM
 -M:    James Morris <james.l.morris@oracle.com>
 +M:    James Morris <jmorris@namei.org>
  M:    "Serge E. Hallyn" <serge@hallyn.com>
  L:    linux-security-module@vger.kernel.org (suggested Cc:)
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git
@@@ -12615,12 -12593,6 +12617,12 @@@ F: include/media/soc
  F:    drivers/media/i2c/soc_camera/
  F:    drivers/media/platform/soc_camera/
  
 +SOCIONEXT UNIPHIER SOUND DRIVER
 +M:    Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>
 +L:    alsa-devel@alsa-project.org (moderated for non-subscribers)
 +S:    Maintained
 +F:    sound/soc/uniphier/
 +
  SOEKRIS NET48XX LED SUPPORT
  M:    Chris Boot <bootc@bootc.net>
  S:    Maintained
@@@ -12645,15 -12617,6 +12647,15 @@@ L: linux-media@vger.kernel.or
  S:    Supported
  F:    drivers/media/pci/solo6x10/
  
 +SOFTWARE DELEGATED EXCEPTION INTERFACE (SDEI)
 +M:    James Morse <james.morse@arm.com>
 +L:    linux-arm-kernel@lists.infradead.org
 +S:    Maintained
 +F:    Documentation/devicetree/bindings/arm/firmware/sdei.txt
 +F:    drivers/firmware/arm_sdei.c
 +F:    include/linux/sdei.h
 +F:    include/uapi/linux/sdei.h
 +
  SOFTWARE RAID (Multiple Disks) SUPPORT
  M:    Shaohua Li <shli@kernel.org>
  L:    linux-raid@vger.kernel.org
@@@ -12818,7 -12781,7 +12820,7 @@@ L:   linux-mtd@lists.infradead.or
  W:    http://www.linux-mtd.infradead.org/
  Q:    http://patchwork.ozlabs.org/project/linux-mtd/list/
  T:    git git://git.infradead.org/linux-mtd.git spi-nor/fixes
 -T:    git git://git.infradead.org/l2-mtd.git spi-nor/next
 +T:    git git://git.infradead.org/linux-mtd.git spi-nor/next
  S:    Maintained
  F:    drivers/mtd/spi-nor/
  F:    include/linux/mtd/spi-nor.h
@@@ -13071,7 -13034,7 +13073,7 @@@ F:   arch/x86/boot/video
  
  SWIOTLB SUBSYSTEM
  M:    Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
- L:    linux-kernel@vger.kernel.org
+ L:    iommu@lists.linux-foundation.org
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git
  S:    Supported
  F:    lib/swiotlb.c
@@@ -13805,18 -13768,6 +13807,18 @@@ L: platform-driver-x86@vger.kernel.or
  S:    Maintained
  F:    drivers/platform/x86/topstar-laptop.c
  
 +TORTURE-TEST MODULES
 +M:    Davidlohr Bueso <dave@stgolabs.net>
 +M:    "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
 +M:    Josh Triplett <josh@joshtriplett.org>
 +L:    linux-kernel@vger.kernel.org
 +S:    Supported
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
 +F:    Documentation/RCU/torture.txt
 +F:    kernel/torture.c
 +F:    kernel/rcu/rcutorture.c
 +F:    kernel/locking/locktorture.c
 +
  TOSHIBA ACPI EXTRAS DRIVER
  M:    Azael Avalos <coproscefalo@gmail.com>
  L:    platform-driver-x86@vger.kernel.org
@@@ -13900,13 -13851,6 +13902,13 @@@ T: git git://git.kernel.org/pub/scm/lin
  S:    Maintained
  K:    ^Subject:.*(?i)trivial
  
 +TEMPO SEMICONDUCTOR DRIVERS
 +M:    Steven Eckhoff <steven.eckhoff.opensource@gmail.com>
 +S:    Maintained
 +F:    sound/soc/codecs/tscs*.c
 +F:    sound/soc/codecs/tscs*.h
 +F:    Documentation/devicetree/bindings/sound/tscs*.txt
 +
  TTY LAYER
  M:    Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  M:    Jiri Slaby <jslaby@suse.com>
@@@ -14705,7 -14649,6 +14707,7 @@@ W:   http://www.slimlogic.co.uk/?p=4
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
  S:    Supported
  F:    Documentation/devicetree/bindings/regulator/
 +F:    Documentation/power/regulator/
  F:    drivers/regulator/
  F:    include/dt-bindings/regulator/
  F:    include/linux/regulator/
@@@ -14916,7 -14859,7 +14918,7 @@@ F:   net/x25
  X86 ARCHITECTURE (32-BIT AND 64-BIT)
  M:    Thomas Gleixner <tglx@linutronix.de>
  M:    Ingo Molnar <mingo@redhat.com>
 -M:    "H. Peter Anvin" <hpa@zytor.com>
 +R:    "H. Peter Anvin" <hpa@zytor.com>
  M:    x86@kernel.org
  L:    linux-kernel@vger.kernel.org
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core
@@@ -15026,6 -14969,7 +15028,7 @@@ F:   include/xen/interface/io/vscsiif.
  XEN SWIOTLB SUBSYSTEM
  M:    Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  L:    xen-devel@lists.xenproject.org (moderated for non-subscribers)
+ L:    iommu@lists.linux-foundation.org
  S:    Supported
  F:    arch/x86/xen/*swiotlb*
  F:    drivers/xen/*swiotlb*
diff --combined arch/Kconfig
index a26d6f8ab9678d625b77e28516a0f6d96d1f2e34,3edf118ad777015073528f65dfae82858122dd4c..1b560e7f06dc9acc8b51e3f7ab39d223bfd4d8d5
@@@ -234,8 -234,8 +234,8 @@@ config ARCH_HAS_FORTIFY_SOURC
  config ARCH_HAS_SET_MEMORY
        bool
  
 -# Select if arch init_task initializer is different to init/init_task.c
 -config ARCH_INIT_TASK
 +# Select if arch init_task must go in the __init_task_data section
 +config ARCH_TASK_STRUCT_ON_STACK
         bool
  
  # Select if arch has its private alloc_task_struct() function
@@@ -938,6 -938,10 +938,10 @@@ config STRICT_MODULE_RW
          and non-text memory will be made non-executable. This provides
          protection against certain security exploits (e.g. writing to text)
  
+ # select if the architecture provides an asm/dma-direct.h header
+ config ARCH_HAS_PHYS_TO_DMA
+       bool
  config ARCH_HAS_REFCOUNT
        bool
        help
diff --combined arch/arm64/Kconfig
index b488076d63c2c389bd3b2fe94bffdd63f84adb7c,53205c02b18a9c8341cb80b27eacdedc24899a09..b2b95f79c746892a3d17d0eea6fe2d05c4b0f6a6
@@@ -59,6 -59,7 +59,7 @@@ config ARM6
        select COMMON_CLK
        select CPU_PM if (SUSPEND || CPU_IDLE)
        select DCACHE_WORD_ACCESS
+       select DMA_DIRECT_OPS
        select EDAC_SUPPORT
        select FRAME_POINTER
        select GENERIC_ALLOCATOR
@@@ -227,7 -228,7 +228,7 @@@ config GENERIC_CSU
  config GENERIC_CALIBRATE_DELAY
        def_bool y
  
- config ZONE_DMA
+ config ZONE_DMA32
        def_bool y
  
  config HAVE_GENERIC_GUP
@@@ -522,13 -523,20 +523,13 @@@ config CAVIUM_ERRATUM_3011
  config QCOM_FALKOR_ERRATUM_1003
        bool "Falkor E1003: Incorrect translation due to ASID change"
        default y
 -      select ARM64_PAN if ARM64_SW_TTBR0_PAN
        help
          On Falkor v1, an incorrect ASID may be cached in the TLB when ASID
 -        and BADDR are changed together in TTBRx_EL1. The workaround for this
 -        issue is to use a reserved ASID in cpu_do_switch_mm() before
 -        switching to the new ASID. Saying Y here selects ARM64_PAN if
 -        ARM64_SW_TTBR0_PAN is selected. This is done because implementing and
 -        maintaining the E1003 workaround in the software PAN emulation code
 -        would be an unnecessary complication. The affected Falkor v1 CPU
 -        implements ARMv8.1 hardware PAN support and using hardware PAN
 -        support versus software PAN emulation is mutually exclusive at
 -        runtime.
 -
 -        If unsure, say Y.
 +        and BADDR are changed together in TTBRx_EL1. Since we keep the ASID
 +        in TTBR1_EL1, this situation only occurs in the entry trampoline and
 +        then only for entries in the walk cache, since the leaf translation
 +        is unchanged. Work around the erratum by invalidating the walk cache
 +        entries for the trampoline before entering the kernel proper.
  
  config QCOM_FALKOR_ERRATUM_1009
        bool "Falkor E1009: Prematurely complete a DSB after a TLBI"
@@@ -649,35 -657,6 +650,35 @@@ config ARM64_VA_BIT
        default 47 if ARM64_VA_BITS_47
        default 48 if ARM64_VA_BITS_48
  
 +choice
 +      prompt "Physical address space size"
 +      default ARM64_PA_BITS_48
 +      help
 +        Choose the maximum physical address range that the kernel will
 +        support.
 +
 +config ARM64_PA_BITS_48
 +      bool "48-bit"
 +
 +config ARM64_PA_BITS_52
 +      bool "52-bit (ARMv8.2)"
 +      depends on ARM64_64K_PAGES
 +      depends on ARM64_PAN || !ARM64_SW_TTBR0_PAN
 +      help
 +        Enable support for a 52-bit physical address space, introduced as
 +        part of the ARMv8.2-LPA extension.
 +
 +        With this enabled, the kernel will also continue to work on CPUs that
 +        do not support ARMv8.2-LPA, but with some added memory overhead (and
 +        minor performance overhead).
 +
 +endchoice
 +
 +config ARM64_PA_BITS
 +      int
 +      default 48 if ARM64_PA_BITS_48
 +      default 52 if ARM64_PA_BITS_52
 +
  config CPU_BIG_ENDIAN
         bool "Build big-endian kernel"
         help
@@@ -872,35 -851,6 +873,35 @@@ config FORCE_MAX_ZONEORDE
          However for 4K, we choose a higher default value, 11 as opposed to 10, giving us
          4M allocations matching the default size used by generic code.
  
 +config UNMAP_KERNEL_AT_EL0
 +      bool "Unmap kernel when running in userspace (aka \"KAISER\")" if EXPERT
 +      default y
 +      help
 +        Speculation attacks against some high-performance processors can
 +        be used to bypass MMU permission checks and leak kernel data to
 +        userspace. This can be defended against by unmapping the kernel
 +        when running in userspace, mapping it back in on exception entry
 +        via a trampoline page in the vector table.
 +
 +        If unsure, say Y.
 +
 +config HARDEN_BRANCH_PREDICTOR
 +      bool "Harden the branch predictor against aliasing attacks" if EXPERT
 +      default y
 +      help
 +        Speculation attacks against some high-performance processors rely on
 +        being able to manipulate the branch predictor for a victim context by
 +        executing aliasing branches in the attacker context.  Such attacks
 +        can be partially mitigated against by clearing internal branch
 +        predictor state and limiting the prediction logic in some situations.
 +
 +        This config option will take CPU-specific actions to harden the
 +        branch predictor against aliasing attacks and may rely on specific
 +        instruction sequences or control bits being set by the system
 +        firmware.
 +
 +        If unsure, say Y.
 +
  menuconfig ARMV8_DEPRECATED
        bool "Emulate deprecated/obsolete ARMv8 instructions"
        depends on COMPAT
@@@ -1072,22 -1022,6 +1073,22 @@@ config ARM64_PME
          operations if DC CVAP is not supported (following the behaviour of
          DC CVAP itself if the system does not define a point of persistence).
  
 +config ARM64_RAS_EXTN
 +      bool "Enable support for RAS CPU Extensions"
 +      default y
 +      help
 +        CPUs that support the Reliability, Availability and Serviceability
 +        (RAS) Extensions, part of ARMv8.2 are able to track faults and
 +        errors, classify them and report them to software.
 +
 +        On CPUs with these extensions system software can use additional
 +        barriers to determine if faults are pending and read the
 +        classification from a new set of registers.
 +
 +        Selecting this feature will allow the kernel to use these barriers
 +        and access the new registers if the system supports the extension.
 +        Platform RAS features may additionally depend on firmware support.
 +
  endmenu
  
  config ARM64_SVE
diff --combined arch/arm64/mm/init.c
index c903f7ccbdd22e5530637aba20a720aaaadfa993,8f03276443c91f0d0ab2b34f2ba172d6e8f20561..9f3c47acf8ffb1170ad411985dcb1a288dfea2df
@@@ -217,7 -217,7 +217,7 @@@ static void __init reserve_elfcorehdr(v
  }
  #endif /* CONFIG_CRASH_DUMP */
  /*
-  * Return the maximum physical address for ZONE_DMA (DMA_BIT_MASK(32)). It
+  * Return the maximum physical address for ZONE_DMA32 (DMA_BIT_MASK(32)). It
   * currently assumes that for memory starting above 4G, 32-bit devices will
   * use a DMA offset.
   */
@@@ -233,8 -233,8 +233,8 @@@ static void __init zone_sizes_init(unsi
  {
        unsigned long max_zone_pfns[MAX_NR_ZONES]  = {0};
  
-       if (IS_ENABLED(CONFIG_ZONE_DMA))
-               max_zone_pfns[ZONE_DMA] = PFN_DOWN(max_zone_dma_phys());
+       if (IS_ENABLED(CONFIG_ZONE_DMA32))
+               max_zone_pfns[ZONE_DMA32] = PFN_DOWN(max_zone_dma_phys());
        max_zone_pfns[ZONE_NORMAL] = max;
  
        free_area_init_nodes(max_zone_pfns);
@@@ -251,9 -251,9 +251,9 @@@ static void __init zone_sizes_init(unsi
        memset(zone_size, 0, sizeof(zone_size));
  
        /* 4GB maximum for 32-bit only capable devices */
- #ifdef CONFIG_ZONE_DMA
+ #ifdef CONFIG_ZONE_DMA32
        max_dma = PFN_DOWN(arm64_dma_phys_limit);
-       zone_size[ZONE_DMA] = max_dma - min;
+       zone_size[ZONE_DMA32] = max_dma - min;
  #endif
        zone_size[ZONE_NORMAL] = max - max_dma;
  
                if (start >= max)
                        continue;
  
- #ifdef CONFIG_ZONE_DMA
+ #ifdef CONFIG_ZONE_DMA32
                if (start < max_dma) {
                        unsigned long dma_end = min(end, max_dma);
-                       zhole_size[ZONE_DMA] -= dma_end - start;
+                       zhole_size[ZONE_DMA32] -= dma_end - start;
                }
  #endif
                if (end > max_dma) {
@@@ -366,9 -366,6 +366,9 @@@ void __init arm64_memblock_init(void
        /* Handle linux,usable-memory-range property */
        fdt_enforce_memory_region();
  
 +      /* Remove memory above our supported physical address size */
 +      memblock_remove(1ULL << PHYS_MASK_SHIFT, ULLONG_MAX);
 +
        /*
         * Ensure that the linear region takes up exactly half of the kernel
         * virtual address space. This way, we can distinguish a linear address
        early_init_fdt_scan_reserved_mem();
  
        /* 4GB maximum for 32-bit only capable devices */
-       if (IS_ENABLED(CONFIG_ZONE_DMA))
+       if (IS_ENABLED(CONFIG_ZONE_DMA32))
                arm64_dma_phys_limit = max_zone_dma_phys();
        else
                arm64_dma_phys_limit = PHYS_MASK + 1;
@@@ -603,6 -600,49 +603,6 @@@ void __init mem_init(void
  
        mem_init_print_info(NULL);
  
 -#define MLK(b, t) b, t, ((t) - (b)) >> 10
 -#define MLM(b, t) b, t, ((t) - (b)) >> 20
 -#define MLG(b, t) b, t, ((t) - (b)) >> 30
 -#define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K)
 -
 -      pr_notice("Virtual kernel memory layout:\n");
 -#ifdef CONFIG_KASAN
 -      pr_notice("    kasan   : 0x%16lx - 0x%16lx   (%6ld GB)\n",
 -              MLG(KASAN_SHADOW_START, KASAN_SHADOW_END));
 -#endif
 -      pr_notice("    modules : 0x%16lx - 0x%16lx   (%6ld MB)\n",
 -              MLM(MODULES_VADDR, MODULES_END));
 -      pr_notice("    vmalloc : 0x%16lx - 0x%16lx   (%6ld GB)\n",
 -              MLG(VMALLOC_START, VMALLOC_END));
 -      pr_notice("      .text : 0x%p" " - 0x%p" "   (%6ld KB)\n",
 -              MLK_ROUNDUP(_text, _etext));
 -      pr_notice("    .rodata : 0x%p" " - 0x%p" "   (%6ld KB)\n",
 -              MLK_ROUNDUP(__start_rodata, __init_begin));
 -      pr_notice("      .init : 0x%p" " - 0x%p" "   (%6ld KB)\n",
 -              MLK_ROUNDUP(__init_begin, __init_end));
 -      pr_notice("      .data : 0x%p" " - 0x%p" "   (%6ld KB)\n",
 -              MLK_ROUNDUP(_sdata, _edata));
 -      pr_notice("       .bss : 0x%p" " - 0x%p" "   (%6ld KB)\n",
 -              MLK_ROUNDUP(__bss_start, __bss_stop));
 -      pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
 -              MLK(FIXADDR_START, FIXADDR_TOP));
 -      pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
 -              MLM(PCI_IO_START, PCI_IO_END));
 -#ifdef CONFIG_SPARSEMEM_VMEMMAP
 -      pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
 -              MLG(VMEMMAP_START, VMEMMAP_START + VMEMMAP_SIZE));
 -      pr_notice("              0x%16lx - 0x%16lx   (%6ld MB actual)\n",
 -              MLM((unsigned long)phys_to_page(memblock_start_of_DRAM()),
 -                  (unsigned long)virt_to_page(high_memory)));
 -#endif
 -      pr_notice("    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n",
 -              MLM(__phys_to_virt(memblock_start_of_DRAM()),
 -                  (unsigned long)high_memory));
 -
 -#undef MLK
 -#undef MLM
 -#undef MLK_ROUNDUP
 -
        /*
         * Check boundaries twice: Some fundamental inconsistencies can be
         * detected at build time already.
diff --combined arch/ia64/Kconfig
index 315c51f58811e74a9213b8a030fc8f6fd023698d,29148fe4bf5a73e39434df12a61a49cc30c7492f..bbe12a038d210c6acd3fe9c3f691d2a2ec27b7d2
@@@ -33,6 -33,7 +33,7 @@@ config IA6
        select HAVE_MEMBLOCK
        select HAVE_MEMBLOCK_NODE_MAP
        select HAVE_VIRT_CPU_ACCOUNTING
+       select ARCH_HAS_DMA_MARK_CLEAN
        select ARCH_HAS_SG_CHAIN
        select VIRT_TO_BUS
        select ARCH_DISCARD_MEMBLOCK
@@@ -43,7 -44,7 +44,7 @@@
        select ARCH_HAVE_NMI_SAFE_CMPXCHG
        select GENERIC_IOMAP
        select GENERIC_SMP_IDLE_THREAD
 -      select ARCH_INIT_TASK
 +      select ARCH_TASK_STRUCT_ON_STACK
        select ARCH_TASK_STRUCT_ALLOCATOR
        select ARCH_THREAD_STACK_ALLOCATOR
        select ARCH_CLOCKSOURCE_DATA
@@@ -65,7 -66,7 +66,7 @@@ config 64BI
        select ATA_NONSTANDARD if ATA
        default y
  
- config ZONE_DMA
+ config ZONE_DMA32
        def_bool y
        depends on !IA64_SGI_SN2
  
@@@ -145,6 -146,7 +146,7 @@@ config IA64_GENERI
        bool "generic"
        select NUMA
        select ACPI_NUMA
+       select DMA_DIRECT_OPS
        select SWIOTLB
        select PCI_MSI
        help
  
  config IA64_DIG
        bool "DIG-compliant"
+       select DMA_DIRECT_OPS
        select SWIOTLB
  
  config IA64_DIG_VTD
@@@ -180,6 -183,7 +183,7 @@@ config IA64_HP_ZX
  
  config IA64_HP_ZX1_SWIOTLB
        bool "HP-zx1/sx1000 with software I/O TLB"
+       select DMA_DIRECT_OPS
        select SWIOTLB
        help
          Build a kernel that runs on HP zx1 and sx1000 systems even when they
@@@ -203,6 -207,7 +207,7 @@@ config IA64_SGI_U
        bool "SGI-UV"
        select NUMA
        select ACPI_NUMA
+       select DMA_DIRECT_OPS
        select SWIOTLB
        help
          Selecting this option will optimize the kernel for use on UV based
  
  config IA64_HP_SIM
        bool "Ski-simulator"
+       select DMA_DIRECT_OPS
        select SWIOTLB
        depends on !PM
  
diff --combined arch/mips/Kconfig
index 8e0b3702f1c082c8d38d6de568ce5e71370ac284,4b0c26b2e9b77e66a2e999563b4b5ea6cc6f233b..ab98569994f0f61cf61d62b6b8c2757f9533c5e3
@@@ -259,7 -259,6 +259,7 @@@ config BCM47X
        select LEDS_GPIO_REGISTER
        select BCM47XX_NVRAM
        select BCM47XX_SPROM
 +      select BCM47XX_SSB if !BCM47XX_BCMA
        help
         Support for BCM47XX based boards
  
@@@ -390,7 -389,6 +390,7 @@@ config LANTI
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_MIPS16
        select SYS_SUPPORTS_MULTITHREADING
 +      select SYS_SUPPORTS_VPE_LOADER
        select SYS_HAS_EARLY_PRINTK
        select GPIOLIB
        select SWAP_IO_SPACE
@@@ -431,6 -429,7 +431,7 @@@ config MACH_LOONGSON3
  
  config MACH_LOONGSON64
        bool "Loongson-2/3 family of machines"
+       select ARCH_HAS_PHYS_TO_DMA
        select SYS_SUPPORTS_ZBOOT
        help
          This enables the support of Loongson-2/3 family of machines.
@@@ -518,7 -517,6 +519,7 @@@ config MIPS_MALT
        select SYS_SUPPORTS_MIPS16
        select SYS_SUPPORTS_MULTITHREADING
        select SYS_SUPPORTS_SMARTMIPS
 +      select SYS_SUPPORTS_VPE_LOADER
        select SYS_SUPPORTS_ZBOOT
        select SYS_SUPPORTS_RELOCATABLE
        select USE_OF
@@@ -880,6 -878,7 +881,7 @@@ config MIKROTIK_RB53
  config CAVIUM_OCTEON_SOC
        bool "Cavium Networks Octeon SoC based boards"
        select CEVT_R4K
+       select ARCH_HAS_PHYS_TO_DMA
        select ARCH_PHYS_ADDR_T_64BIT
        select DMA_COHERENT
        select SYS_SUPPORTS_64BIT_KERNEL
@@@ -2284,16 -2283,9 +2286,16 @@@ config MIPSR2_TO_R6_EMULATO
          The only reason this is a build-time option is to save ~14K from the
          final kernel image.
  
 +config SYS_SUPPORTS_VPE_LOADER
 +      bool
 +      depends on SYS_SUPPORTS_MULTITHREADING
 +      help
 +        Indicates that the platform supports the VPE loader, and provides
 +        physical_memsize.
 +
  config MIPS_VPE_LOADER
        bool "VPE loader support."
 -      depends on SYS_SUPPORTS_MULTITHREADING && MODULES
 +      depends on SYS_SUPPORTS_VPE_LOADER && MODULES
        select CPU_MIPSR2_IRQ_VI
        select CPU_MIPSR2_IRQ_EI
        select MIPS_MT
diff --combined arch/powerpc/Kconfig
index 2ed525a44734cfaa62ba7125fab11225c1778a7a,887285eb684a4e9d28a117fa130068b0582374f4..e92432ae97378c3966c95cfdba497c2a50408134
@@@ -139,6 -139,7 +139,7 @@@ config PP
        select ARCH_HAS_ELF_RANDOMIZE
        select ARCH_HAS_FORTIFY_SOURCE
        select ARCH_HAS_GCOV_PROFILE_ALL
+       select ARCH_HAS_PHYS_TO_DMA
        select ARCH_HAS_PMEM_API                if PPC64
        select ARCH_HAS_SCALED_CPUTIME          if VIRT_CPU_ACCOUNTING_NATIVE
        select ARCH_HAS_SG_CHAIN
        select GENERIC_CLOCKEVENTS_BROADCAST    if SMP
        select GENERIC_CMOS_UPDATE
        select GENERIC_CPU_AUTOPROBE
 +      select GENERIC_CPU_VULNERABILITIES      if PPC_BOOK3S_64
        select GENERIC_IRQ_SHOW
        select GENERIC_IRQ_SHOW_LEVEL
        select GENERIC_SMP_IDLE_THREAD
index 8fd3a70047f1dae91f5e3d11479a178aa64b2ed3,9b89df1e71abc500489d5e3527d08c51474f8b28..3f33869c6486eb1b8bd4e9ea86d7f7dd918a8258
@@@ -242,6 -242,14 +242,6 @@@ static int show_cpuinfo(struct seq_fil
        unsigned short maj;
        unsigned short min;
  
 -      /* We only show online cpus: disable preempt (overzealous, I
 -       * knew) to prevent cpu going down. */
 -      preempt_disable();
 -      if (!cpu_online(cpu_id)) {
 -              preempt_enable();
 -              return 0;
 -      }
 -
  #ifdef CONFIG_SMP
        pvr = per_cpu(cpu_pvr, cpu_id);
  #else
  #ifdef CONFIG_SMP
        seq_printf(m, "\n");
  #endif
 -
 -      preempt_enable();
 -
        /* If this is the last cpu, print the summary */
        if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)
                show_cpuinfo_summary(m);
@@@ -780,7 -791,7 +780,7 @@@ void arch_setup_pdev_archdata(struct pl
  {
        pdev->archdata.dma_mask = DMA_BIT_MASK(32);
        pdev->dev.dma_mask = &pdev->archdata.dma_mask;
-       set_dma_ops(&pdev->dev, &dma_direct_ops);
+       set_dma_ops(&pdev->dev, &dma_nommu_ops);
  }
  
  static __init void print_system_info(void)
diff --combined arch/x86/Kconfig
index 423e4b64e683d960ce1e50d02be879705b524617,f6f4328103c0d6e6cc181b3bac0b535f625c31a5..dbe5542a66666bc79c414618a3d5234a1168d8ef
@@@ -54,7 -54,9 +54,8 @@@ config X8
        select ARCH_HAS_FORTIFY_SOURCE
        select ARCH_HAS_GCOV_PROFILE_ALL
        select ARCH_HAS_KCOV                    if X86_64
+       select ARCH_HAS_PHYS_TO_DMA
        select ARCH_HAS_PMEM_API                if X86_64
 -      # Causing hangs/crashes, see the commit that added this change for details.
        select ARCH_HAS_REFCOUNT
        select ARCH_HAS_UACCESS_FLUSHCACHE      if X86_64
        select ARCH_HAS_SET_MEMORY
@@@ -88,7 -90,6 +89,7 @@@
        select GENERIC_CLOCKEVENTS_MIN_ADJUST
        select GENERIC_CMOS_UPDATE
        select GENERIC_CPU_AUTOPROBE
 +      select GENERIC_CPU_VULNERABILITIES
        select GENERIC_EARLY_IOREMAP
        select GENERIC_FIND_FIRST_BIT
        select GENERIC_IOMAP
@@@ -429,19 -430,6 +430,19 @@@ config GOLDFIS
         def_bool y
         depends on X86_GOLDFISH
  
 +config RETPOLINE
 +      bool "Avoid speculative indirect branches in kernel"
 +      default y
 +      help
 +        Compile kernel with the retpoline compiler options to guard against
 +        kernel-to-user data leaks by avoiding speculative indirect
 +        branches. Requires a compiler with -mindirect-branch=thunk-extern
 +        support for full protection. The kernel may run slower.
 +
 +        Without compiler support, at least indirect branches in assembler
 +        code are eliminated. Since this includes the syscall entry path,
 +        it is not entirely pointless.
 +
  config INTEL_RDT
        bool "Intel Resource Director Technology support"
        default n
@@@ -810,15 -798,6 +811,15 @@@ config PARAVIRT_TIME_ACCOUNTIN
  config PARAVIRT_CLOCK
        bool
  
 +config JAILHOUSE_GUEST
 +      bool "Jailhouse non-root cell support"
 +      depends on X86_64 && PCI
 +      select X86_PM_TIMER
 +      ---help---
 +        This option allows to run Linux as guest in a Jailhouse non-root
 +        cell. You can leave this option disabled if you only want to start
 +        Jailhouse and run Linux afterwards in the root cell.
 +
  endif #HYPERVISOR_GUEST
  
  config NO_BOOTMEM
index e1d61e8500f9b84790c2f289708f9a61a5d2ecb7,09532c935da08955a1dea38de27f9e77ee8eb6c3..1a53071e2e179c2513d04f6713655af130f75f67
@@@ -15,7 -15,7 +15,7 @@@
  #include <linux/linkage.h>
  #include <linux/init.h>
  #include <linux/mm.h>
- #include <linux/dma-mapping.h>
+ #include <linux/dma-direct.h>
  #include <linux/swiotlb.h>
  #include <linux/mem_encrypt.h>
  
@@@ -464,62 -464,37 +464,62 @@@ void swiotlb_set_mem_attributes(void *v
        set_memory_decrypted((unsigned long)vaddr, size >> PAGE_SHIFT);
  }
  
 -static void __init sme_clear_pgd(pgd_t *pgd_base, unsigned long start,
 -                               unsigned long end)
 +struct sme_populate_pgd_data {
 +      void    *pgtable_area;
 +      pgd_t   *pgd;
 +
 +      pmdval_t pmd_flags;
 +      pteval_t pte_flags;
 +      unsigned long paddr;
 +
 +      unsigned long vaddr;
 +      unsigned long vaddr_end;
 +};
 +
 +static void __init sme_clear_pgd(struct sme_populate_pgd_data *ppd)
  {
        unsigned long pgd_start, pgd_end, pgd_size;
        pgd_t *pgd_p;
  
 -      pgd_start = start & PGDIR_MASK;
 -      pgd_end = end & PGDIR_MASK;
 +      pgd_start = ppd->vaddr & PGDIR_MASK;
 +      pgd_end = ppd->vaddr_end & PGDIR_MASK;
  
 -      pgd_size = (((pgd_end - pgd_start) / PGDIR_SIZE) + 1);
 -      pgd_size *= sizeof(pgd_t);
 +      pgd_size = (((pgd_end - pgd_start) / PGDIR_SIZE) + 1) * sizeof(pgd_t);
  
 -      pgd_p = pgd_base + pgd_index(start);
 +      pgd_p = ppd->pgd + pgd_index(ppd->vaddr);
  
        memset(pgd_p, 0, pgd_size);
  }
  
 -#define PGD_FLAGS     _KERNPG_TABLE_NOENC
 -#define P4D_FLAGS     _KERNPG_TABLE_NOENC
 -#define PUD_FLAGS     _KERNPG_TABLE_NOENC
 -#define PMD_FLAGS     (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL)
 +#define PGD_FLAGS             _KERNPG_TABLE_NOENC
 +#define P4D_FLAGS             _KERNPG_TABLE_NOENC
 +#define PUD_FLAGS             _KERNPG_TABLE_NOENC
 +#define PMD_FLAGS             _KERNPG_TABLE_NOENC
 +
 +#define PMD_FLAGS_LARGE               (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL)
 +
 +#define PMD_FLAGS_DEC         PMD_FLAGS_LARGE
 +#define PMD_FLAGS_DEC_WP      ((PMD_FLAGS_DEC & ~_PAGE_CACHE_MASK) | \
 +                               (_PAGE_PAT | _PAGE_PWT))
 +
 +#define PMD_FLAGS_ENC         (PMD_FLAGS_LARGE | _PAGE_ENC)
 +
 +#define PTE_FLAGS             (__PAGE_KERNEL_EXEC & ~_PAGE_GLOBAL)
 +
 +#define PTE_FLAGS_DEC         PTE_FLAGS
 +#define PTE_FLAGS_DEC_WP      ((PTE_FLAGS_DEC & ~_PAGE_CACHE_MASK) | \
 +                               (_PAGE_PAT | _PAGE_PWT))
 +
 +#define PTE_FLAGS_ENC         (PTE_FLAGS | _PAGE_ENC)
  
 -static void __init *sme_populate_pgd(pgd_t *pgd_base, void *pgtable_area,
 -                                   unsigned long vaddr, pmdval_t pmd_val)
 +static pmd_t __init *sme_prepare_pgd(struct sme_populate_pgd_data *ppd)
  {
        pgd_t *pgd_p;
        p4d_t *p4d_p;
        pud_t *pud_p;
        pmd_t *pmd_p;
  
 -      pgd_p = pgd_base + pgd_index(vaddr);
 +      pgd_p = ppd->pgd + pgd_index(ppd->vaddr);
        if (native_pgd_val(*pgd_p)) {
                if (IS_ENABLED(CONFIG_X86_5LEVEL))
                        p4d_p = (p4d_t *)(native_pgd_val(*pgd_p) & ~PTE_FLAGS_MASK);
                pgd_t pgd;
  
                if (IS_ENABLED(CONFIG_X86_5LEVEL)) {
 -                      p4d_p = pgtable_area;
 +                      p4d_p = ppd->pgtable_area;
                        memset(p4d_p, 0, sizeof(*p4d_p) * PTRS_PER_P4D);
 -                      pgtable_area += sizeof(*p4d_p) * PTRS_PER_P4D;
 +                      ppd->pgtable_area += sizeof(*p4d_p) * PTRS_PER_P4D;
  
                        pgd = native_make_pgd((pgdval_t)p4d_p + PGD_FLAGS);
                } else {
 -                      pud_p = pgtable_area;
 +                      pud_p = ppd->pgtable_area;
                        memset(pud_p, 0, sizeof(*pud_p) * PTRS_PER_PUD);
 -                      pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD;
 +                      ppd->pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD;
  
                        pgd = native_make_pgd((pgdval_t)pud_p + PGD_FLAGS);
                }
        }
  
        if (IS_ENABLED(CONFIG_X86_5LEVEL)) {
 -              p4d_p += p4d_index(vaddr);
 +              p4d_p += p4d_index(ppd->vaddr);
                if (native_p4d_val(*p4d_p)) {
                        pud_p = (pud_t *)(native_p4d_val(*p4d_p) & ~PTE_FLAGS_MASK);
                } else {
                        p4d_t p4d;
  
 -                      pud_p = pgtable_area;
 +                      pud_p = ppd->pgtable_area;
                        memset(pud_p, 0, sizeof(*pud_p) * PTRS_PER_PUD);
 -                      pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD;
 +                      ppd->pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD;
  
                        p4d = native_make_p4d((pudval_t)pud_p + P4D_FLAGS);
                        native_set_p4d(p4d_p, p4d);
                }
        }
  
 -      pud_p += pud_index(vaddr);
 +      pud_p += pud_index(ppd->vaddr);
        if (native_pud_val(*pud_p)) {
                if (native_pud_val(*pud_p) & _PAGE_PSE)
 -                      goto out;
 +                      return NULL;
  
                pmd_p = (pmd_t *)(native_pud_val(*pud_p) & ~PTE_FLAGS_MASK);
        } else {
                pud_t pud;
  
 -              pmd_p = pgtable_area;
 +              pmd_p = ppd->pgtable_area;
                memset(pmd_p, 0, sizeof(*pmd_p) * PTRS_PER_PMD);
 -              pgtable_area += sizeof(*pmd_p) * PTRS_PER_PMD;
 +              ppd->pgtable_area += sizeof(*pmd_p) * PTRS_PER_PMD;
  
                pud = native_make_pud((pmdval_t)pmd_p + PUD_FLAGS);
                native_set_pud(pud_p, pud);
        }
  
 -      pmd_p += pmd_index(vaddr);
 +      return pmd_p;
 +}
 +
 +static void __init sme_populate_pgd_large(struct sme_populate_pgd_data *ppd)
 +{
 +      pmd_t *pmd_p;
 +
 +      pmd_p = sme_prepare_pgd(ppd);
 +      if (!pmd_p)
 +              return;
 +
 +      pmd_p += pmd_index(ppd->vaddr);
        if (!native_pmd_val(*pmd_p) || !(native_pmd_val(*pmd_p) & _PAGE_PSE))
 -              native_set_pmd(pmd_p, native_make_pmd(pmd_val));
 +              native_set_pmd(pmd_p, native_make_pmd(ppd->paddr | ppd->pmd_flags));
 +}
  
 -out:
 -      return pgtable_area;
 +static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd)
 +{
 +      pmd_t *pmd_p;
 +      pte_t *pte_p;
 +
 +      pmd_p = sme_prepare_pgd(ppd);
 +      if (!pmd_p)
 +              return;
 +
 +      pmd_p += pmd_index(ppd->vaddr);
 +      if (native_pmd_val(*pmd_p)) {
 +              if (native_pmd_val(*pmd_p) & _PAGE_PSE)
 +                      return;
 +
 +              pte_p = (pte_t *)(native_pmd_val(*pmd_p) & ~PTE_FLAGS_MASK);
 +      } else {
 +              pmd_t pmd;
 +
 +              pte_p = ppd->pgtable_area;
 +              memset(pte_p, 0, sizeof(*pte_p) * PTRS_PER_PTE);
 +              ppd->pgtable_area += sizeof(*pte_p) * PTRS_PER_PTE;
 +
 +              pmd = native_make_pmd((pteval_t)pte_p + PMD_FLAGS);
 +              native_set_pmd(pmd_p, pmd);
 +      }
 +
 +      pte_p += pte_index(ppd->vaddr);
 +      if (!native_pte_val(*pte_p))
 +              native_set_pte(pte_p, native_make_pte(ppd->paddr | ppd->pte_flags));
 +}
 +
 +static void __init __sme_map_range_pmd(struct sme_populate_pgd_data *ppd)
 +{
 +      while (ppd->vaddr < ppd->vaddr_end) {
 +              sme_populate_pgd_large(ppd);
 +
 +              ppd->vaddr += PMD_PAGE_SIZE;
 +              ppd->paddr += PMD_PAGE_SIZE;
 +      }
 +}
 +
 +static void __init __sme_map_range_pte(struct sme_populate_pgd_data *ppd)
 +{
 +      while (ppd->vaddr < ppd->vaddr_end) {
 +              sme_populate_pgd(ppd);
 +
 +              ppd->vaddr += PAGE_SIZE;
 +              ppd->paddr += PAGE_SIZE;
 +      }
 +}
 +
 +static void __init __sme_map_range(struct sme_populate_pgd_data *ppd,
 +                                 pmdval_t pmd_flags, pteval_t pte_flags)
 +{
 +      unsigned long vaddr_end;
 +
 +      ppd->pmd_flags = pmd_flags;
 +      ppd->pte_flags = pte_flags;
 +
 +      /* Save original end value since we modify the struct value */
 +      vaddr_end = ppd->vaddr_end;
 +
 +      /* If start is not 2MB aligned, create PTE entries */
 +      ppd->vaddr_end = ALIGN(ppd->vaddr, PMD_PAGE_SIZE);
 +      __sme_map_range_pte(ppd);
 +
 +      /* Create PMD entries */
 +      ppd->vaddr_end = vaddr_end & PMD_PAGE_MASK;
 +      __sme_map_range_pmd(ppd);
 +
 +      /* If end is not 2MB aligned, create PTE entries */
 +      ppd->vaddr_end = vaddr_end;
 +      __sme_map_range_pte(ppd);
 +}
 +
 +static void __init sme_map_range_encrypted(struct sme_populate_pgd_data *ppd)
 +{
 +      __sme_map_range(ppd, PMD_FLAGS_ENC, PTE_FLAGS_ENC);
 +}
 +
 +static void __init sme_map_range_decrypted(struct sme_populate_pgd_data *ppd)
 +{
 +      __sme_map_range(ppd, PMD_FLAGS_DEC, PTE_FLAGS_DEC);
 +}
 +
 +static void __init sme_map_range_decrypted_wp(struct sme_populate_pgd_data *ppd)
 +{
 +      __sme_map_range(ppd, PMD_FLAGS_DEC_WP, PTE_FLAGS_DEC_WP);
  }
  
  static unsigned long __init sme_pgtable_calc(unsigned long len)
  {
 -      unsigned long p4d_size, pud_size, pmd_size;
 +      unsigned long p4d_size, pud_size, pmd_size, pte_size;
        unsigned long total;
  
        /*
         * Perform a relatively simplistic calculation of the pagetable
 -       * entries that are needed. That mappings will be covered by 2MB
 -       * PMD entries so we can conservatively calculate the required
 +       * entries that are needed. Those mappings will be covered mostly
 +       * by 2MB PMD entries so we can conservatively calculate the required
         * number of P4D, PUD and PMD structures needed to perform the
 -       * mappings. Incrementing the count for each covers the case where
 -       * the addresses cross entries.
 +       * mappings.  For mappings that are not 2MB aligned, PTE mappings
 +       * would be needed for the start and end portion of the address range
 +       * that fall outside of the 2MB alignment.  This results in, at most,
 +       * two extra pages to hold PTE entries for each range that is mapped.
 +       * Incrementing the count for each covers the case where the addresses
 +       * cross entries.
         */
        if (IS_ENABLED(CONFIG_X86_5LEVEL)) {
                p4d_size = (ALIGN(len, PGDIR_SIZE) / PGDIR_SIZE) + 1;
        }
        pmd_size = (ALIGN(len, PUD_SIZE) / PUD_SIZE) + 1;
        pmd_size *= sizeof(pmd_t) * PTRS_PER_PMD;
 +      pte_size = 2 * sizeof(pte_t) * PTRS_PER_PTE;
  
 -      total = p4d_size + pud_size + pmd_size;
 +      total = p4d_size + pud_size + pmd_size + pte_size;
  
        /*
         * Now calculate the added pagetable structures needed to populate
        return total;
  }
  
 -void __init sme_encrypt_kernel(void)
 +void __init __nostackprotector sme_encrypt_kernel(struct boot_params *bp)
  {
        unsigned long workarea_start, workarea_end, workarea_len;
        unsigned long execute_start, execute_end, execute_len;
        unsigned long kernel_start, kernel_end, kernel_len;
 +      unsigned long initrd_start, initrd_end, initrd_len;
 +      struct sme_populate_pgd_data ppd;
        unsigned long pgtable_area_len;
 -      unsigned long paddr, pmd_flags;
        unsigned long decrypted_base;
 -      void *pgtable_area;
 -      pgd_t *pgd;
  
        if (!sme_active())
                return;
  
        /*
 -       * Prepare for encrypting the kernel by building new pagetables with
 -       * the necessary attributes needed to encrypt the kernel in place.
 +       * Prepare for encrypting the kernel and initrd by building new
 +       * pagetables with the necessary attributes needed to encrypt the
 +       * kernel in place.
         *
         *   One range of virtual addresses will map the memory occupied
 -       *   by the kernel as encrypted.
 +       *   by the kernel and initrd as encrypted.
         *
         *   Another range of virtual addresses will map the memory occupied
 -       *   by the kernel as decrypted and write-protected.
 +       *   by the kernel and initrd as decrypted and write-protected.
         *
         *     The use of write-protect attribute will prevent any of the
         *     memory from being cached.
        kernel_end = ALIGN(__pa_symbol(_end), PMD_PAGE_SIZE);
        kernel_len = kernel_end - kernel_start;
  
 +      initrd_start = 0;
 +      initrd_end = 0;
 +      initrd_len = 0;
 +#ifdef CONFIG_BLK_DEV_INITRD
 +      initrd_len = (unsigned long)bp->hdr.ramdisk_size |
 +                   ((unsigned long)bp->ext_ramdisk_size << 32);
 +      if (initrd_len) {
 +              initrd_start = (unsigned long)bp->hdr.ramdisk_image |
 +                             ((unsigned long)bp->ext_ramdisk_image << 32);
 +              initrd_end = PAGE_ALIGN(initrd_start + initrd_len);
 +              initrd_len = initrd_end - initrd_start;
 +      }
 +#endif
 +
        /* Set the encryption workarea to be immediately after the kernel */
        workarea_start = kernel_end;
  
         */
        pgtable_area_len = sizeof(pgd_t) * PTRS_PER_PGD;
        pgtable_area_len += sme_pgtable_calc(execute_end - kernel_start) * 2;
 +      if (initrd_len)
 +              pgtable_area_len += sme_pgtable_calc(initrd_len) * 2;
  
        /* PUDs and PMDs needed in the current pagetables for the workarea */
        pgtable_area_len += sme_pgtable_calc(execute_len + pgtable_area_len);
  
        /*
         * The total workarea includes the executable encryption area and
 -       * the pagetable area.
 +       * the pagetable area. The start of the workarea is already 2MB
 +       * aligned, align the end of the workarea on a 2MB boundary so that
 +       * we don't try to create/allocate PTE entries from the workarea
 +       * before it is mapped.
         */
        workarea_len = execute_len + pgtable_area_len;
 -      workarea_end = workarea_start + workarea_len;
 +      workarea_end = ALIGN(workarea_start + workarea_len, PMD_PAGE_SIZE);
  
        /*
         * Set the address to the start of where newly created pagetable
         * pagetables and when the new encrypted and decrypted kernel
         * mappings are populated.
         */
 -      pgtable_area = (void *)execute_end;
 +      ppd.pgtable_area = (void *)execute_end;
  
        /*
         * Make sure the current pagetable structure has entries for
         * addressing the workarea.
         */
 -      pgd = (pgd_t *)native_read_cr3_pa();
 -      paddr = workarea_start;
 -      while (paddr < workarea_end) {
 -              pgtable_area = sme_populate_pgd(pgd, pgtable_area,
 -                                              paddr,
 -                                              paddr + PMD_FLAGS);
 -
 -              paddr += PMD_PAGE_SIZE;
 -      }
 +      ppd.pgd = (pgd_t *)native_read_cr3_pa();
 +      ppd.paddr = workarea_start;
 +      ppd.vaddr = workarea_start;
 +      ppd.vaddr_end = workarea_end;
 +      sme_map_range_decrypted(&ppd);
  
        /* Flush the TLB - no globals so cr3 is enough */
        native_write_cr3(__native_read_cr3());
  
        /*
         * A new pagetable structure is being built to allow for the kernel
 -       * to be encrypted. It starts with an empty PGD that will then be
 -       * populated with new PUDs and PMDs as the encrypted and decrypted
 -       * kernel mappings are created.
 +       * and initrd to be encrypted. It starts with an empty PGD that will
 +       * then be populated with new PUDs and PMDs as the encrypted and
 +       * decrypted kernel mappings are created.
         */
 -      pgd = pgtable_area;
 -      memset(pgd, 0, sizeof(*pgd) * PTRS_PER_PGD);
 -      pgtable_area += sizeof(*pgd) * PTRS_PER_PGD;
 -
 -      /* Add encrypted kernel (identity) mappings */
 -      pmd_flags = PMD_FLAGS | _PAGE_ENC;
 -      paddr = kernel_start;
 -      while (paddr < kernel_end) {
 -              pgtable_area = sme_populate_pgd(pgd, pgtable_area,
 -                                              paddr,
 -                                              paddr + pmd_flags);
 -
 -              paddr += PMD_PAGE_SIZE;
 -      }
 +      ppd.pgd = ppd.pgtable_area;
 +      memset(ppd.pgd, 0, sizeof(pgd_t) * PTRS_PER_PGD);
 +      ppd.pgtable_area += sizeof(pgd_t) * PTRS_PER_PGD;
  
        /*
         * A different PGD index/entry must be used to get different
         * the base of the mapping.
         */
        decrypted_base = (pgd_index(workarea_end) + 1) & (PTRS_PER_PGD - 1);
 +      if (initrd_len) {
 +              unsigned long check_base;
 +
 +              check_base = (pgd_index(initrd_end) + 1) & (PTRS_PER_PGD - 1);
 +              decrypted_base = max(decrypted_base, check_base);
 +      }
        decrypted_base <<= PGDIR_SHIFT;
  
 +      /* Add encrypted kernel (identity) mappings */
 +      ppd.paddr = kernel_start;
 +      ppd.vaddr = kernel_start;
 +      ppd.vaddr_end = kernel_end;
 +      sme_map_range_encrypted(&ppd);
 +
        /* Add decrypted, write-protected kernel (non-identity) mappings */
 -      pmd_flags = (PMD_FLAGS & ~_PAGE_CACHE_MASK) | (_PAGE_PAT | _PAGE_PWT);
 -      paddr = kernel_start;
 -      while (paddr < kernel_end) {
 -              pgtable_area = sme_populate_pgd(pgd, pgtable_area,
 -                                              paddr + decrypted_base,
 -                                              paddr + pmd_flags);
 -
 -              paddr += PMD_PAGE_SIZE;
 +      ppd.paddr = kernel_start;
 +      ppd.vaddr = kernel_start + decrypted_base;
 +      ppd.vaddr_end = kernel_end + decrypted_base;
 +      sme_map_range_decrypted_wp(&ppd);
 +
 +      if (initrd_len) {
 +              /* Add encrypted initrd (identity) mappings */
 +              ppd.paddr = initrd_start;
 +              ppd.vaddr = initrd_start;
 +              ppd.vaddr_end = initrd_end;
 +              sme_map_range_encrypted(&ppd);
 +              /*
 +               * Add decrypted, write-protected initrd (non-identity) mappings
 +               */
 +              ppd.paddr = initrd_start;
 +              ppd.vaddr = initrd_start + decrypted_base;
 +              ppd.vaddr_end = initrd_end + decrypted_base;
 +              sme_map_range_decrypted_wp(&ppd);
        }
  
        /* Add decrypted workarea mappings to both kernel mappings */
 -      paddr = workarea_start;
 -      while (paddr < workarea_end) {
 -              pgtable_area = sme_populate_pgd(pgd, pgtable_area,
 -                                              paddr,
 -                                              paddr + PMD_FLAGS);
 +      ppd.paddr = workarea_start;
 +      ppd.vaddr = workarea_start;
 +      ppd.vaddr_end = workarea_end;
 +      sme_map_range_decrypted(&ppd);
  
 -              pgtable_area = sme_populate_pgd(pgd, pgtable_area,
 -                                              paddr + decrypted_base,
 -                                              paddr + PMD_FLAGS);
 -
 -              paddr += PMD_PAGE_SIZE;
 -      }
 +      ppd.paddr = workarea_start;
 +      ppd.vaddr = workarea_start + decrypted_base;
 +      ppd.vaddr_end = workarea_end + decrypted_base;
 +      sme_map_range_decrypted(&ppd);
  
        /* Perform the encryption */
        sme_encrypt_execute(kernel_start, kernel_start + decrypted_base,
 -                          kernel_len, workarea_start, (unsigned long)pgd);
 +                          kernel_len, workarea_start, (unsigned long)ppd.pgd);
 +
 +      if (initrd_len)
 +              sme_encrypt_execute(initrd_start, initrd_start + decrypted_base,
 +                                  initrd_len, workarea_start,
 +                                  (unsigned long)ppd.pgd);
  
        /*
         * At this point we are running encrypted.  Remove the mappings for
         * the decrypted areas - all that is needed for this is to remove
         * the PGD entry/entries.
         */
 -      sme_clear_pgd(pgd, kernel_start + decrypted_base,
 -                    kernel_end + decrypted_base);
 +      ppd.vaddr = kernel_start + decrypted_base;
 +      ppd.vaddr_end = kernel_end + decrypted_base;
 +      sme_clear_pgd(&ppd);
 +
 +      if (initrd_len) {
 +              ppd.vaddr = initrd_start + decrypted_base;
 +              ppd.vaddr_end = initrd_end + decrypted_base;
 +              sme_clear_pgd(&ppd);
 +      }
  
 -      sme_clear_pgd(pgd, workarea_start + decrypted_base,
 -                    workarea_end + decrypted_base);
 +      ppd.vaddr = workarea_start + decrypted_base;
 +      ppd.vaddr_end = workarea_end + decrypted_base;
 +      sme_clear_pgd(&ppd);
  
        /* Flush the TLB - no globals so cr3 is enough */
        native_write_cr3(__native_read_cr3());
index 6be555806ecaa87eac5d921bf1defa76bd607eca,411cdfd12a85ed8db14309c79d66cdf9ea04b5d6..563b759ffca65115c1717c34975b93aeefdb1187
@@@ -23,6 -23,7 +23,7 @@@
  #include <linux/of_device.h>
  #include <linux/delay.h>
  #include <linux/dma/qcom_bam_dma.h>
+ #include <linux/dma-direct.h> /* XXX: drivers shall never use this directly! */
  
  /* NANDc reg offsets */
  #define       NAND_FLASH_CMD                  0x00
@@@ -1725,7 -1726,6 +1726,7 @@@ static int qcom_nandc_read_page(struct 
        u8 *data_buf, *oob_buf = NULL;
        int ret;
  
 +      nand_read_page_op(chip, page, 0, NULL, 0);
        data_buf = buf;
        oob_buf = oob_required ? chip->oob_poi : NULL;
  
@@@ -1751,7 -1751,6 +1752,7 @@@ static int qcom_nandc_read_page_raw(str
        int i, ret;
        int read_loc;
  
 +      nand_read_page_op(chip, page, 0, NULL, 0);
        data_buf = buf;
        oob_buf = chip->oob_poi;
  
@@@ -1852,8 -1851,6 +1853,8 @@@ static int qcom_nandc_write_page(struc
        u8 *data_buf, *oob_buf;
        int i, ret;
  
 +      nand_prog_page_begin_op(chip, page, 0, NULL, 0);
 +
        clear_read_regs(nandc);
        clear_bam_transaction(nandc);
  
  
        free_descs(nandc);
  
 +      if (!ret)
 +              ret = nand_prog_page_end_op(chip);
 +
        return ret;
  }
  
@@@ -1923,7 -1917,6 +1924,7 @@@ static int qcom_nandc_write_page_raw(st
        u8 *data_buf, *oob_buf;
        int i, ret;
  
 +      nand_prog_page_begin_op(chip, page, 0, NULL, 0);
        clear_read_regs(nandc);
        clear_bam_transaction(nandc);
  
  
        free_descs(nandc);
  
 +      if (!ret)
 +              ret = nand_prog_page_end_op(chip);
 +
        return ret;
  }
  
@@@ -2001,7 -1991,7 +2002,7 @@@ static int qcom_nandc_write_oob(struct 
        struct nand_ecc_ctrl *ecc = &chip->ecc;
        u8 *oob = chip->oob_poi;
        int data_size, oob_size;
 -      int ret, status = 0;
 +      int ret;
  
        host->use_ecc = true;
  
                return -EIO;
        }
  
 -      chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
 -
 -      status = chip->waitfunc(mtd, chip);
 -
 -      return status & NAND_STATUS_FAIL ? -EIO : 0;
 +      return nand_prog_page_end_op(chip);
  }
  
  static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs)
@@@ -2088,7 -2082,7 +2089,7 @@@ static int qcom_nandc_block_markbad(str
        struct qcom_nand_host *host = to_qcom_nand_host(chip);
        struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
        struct nand_ecc_ctrl *ecc = &chip->ecc;
 -      int page, ret, status = 0;
 +      int page, ret;
  
        clear_read_regs(nandc);
        clear_bam_transaction(nandc);
                return -EIO;
        }
  
 -      chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
 -
 -      status = chip->waitfunc(mtd, chip);
 -
 -      return status & NAND_STATUS_FAIL ? -EIO : 0;
 +      return nand_prog_page_end_op(chip);
  }
  
  /*
@@@ -2639,9 -2637,6 +2640,9 @@@ static int qcom_nand_host_init(struct q
  
        nand_set_flash_node(chip, dn);
        mtd->name = devm_kasprintf(dev, GFP_KERNEL, "qcom_nand.%d", host->cs);
 +      if (!mtd->name)
 +              return -ENOMEM;
 +
        mtd->owner = THIS_MODULE;
        mtd->dev.parent = dev;
  
diff --combined lib/Kconfig
index 4dd5c11366f91f11f6cba060b66a66963f833c15,9d3d649c9dc90f7b56d8692b1bf1d2b8fc9b5153..e96089499371091938083bbc4cbdc45333d3aa79
@@@ -409,11 -409,7 +409,11 @@@ config HAS_DM
        depends on !NO_DMA
        default y
  
- config DMA_NOOP_OPS
 +config SGL_ALLOC
 +      bool
 +      default n
 +
+ config DMA_DIRECT_OPS
        bool
        depends on HAS_DMA && (!64BIT || ARCH_DMA_ADDR_T_64BIT)
        default n