linux-stable/drivers
Ryan Roberts c33c794828 mm: ptep_get() conversion
Convert all instances of direct pte_t* dereferencing to instead use
ptep_get() helper.  This means that by default, the accesses change from a
C dereference to a READ_ONCE().  This is technically the correct thing to
do since where pgtables are modified by HW (for access/dirty) they are
volatile and therefore we should always ensure READ_ONCE() semantics.

But more importantly, by always using the helper, it can be overridden by
the architecture to fully encapsulate the contents of the pte.  Arch code
is deliberately not converted, as the arch code knows best.  It is
intended that arch code (arm64) will override the default with its own
implementation that can (e.g.) hide certain bits from the core code, or
determine young/dirty status by mixing in state from another source.

Conversion was done using Coccinelle:

----

// $ make coccicheck \
//          COCCI=ptepget.cocci \
//          SPFLAGS="--include-headers" \
//          MODE=patch

virtual patch

@ depends on patch @
pte_t *v;
@@

- *v
+ ptep_get(v)

----

Then reviewed and hand-edited to avoid multiple unnecessary calls to
ptep_get(), instead opting to store the result of a single call in a
variable, where it is correct to do so.  This aims to negate any cost of
READ_ONCE() and will benefit arch-overrides that may be more complex.

Included is a fix for an issue in an earlier version of this patch that
was pointed out by kernel test robot.  The issue arose because config
MMU=n elides definition of the ptep helper functions, including
ptep_get().  HUGETLB_PAGE=n configs still define a simple
huge_ptep_clear_flush() for linking purposes, which dereferences the ptep.
So when both configs are disabled, this caused a build error because
ptep_get() is not defined.  Fix by continuing to do a direct dereference
when MMU=n.  This is safe because for this config the arch code cannot be
trying to virtualize the ptes because none of the ptep helpers are
defined.

Link: https://lkml.kernel.org/r/20230612151545.3317766-4-ryan.roberts@arm.com
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202305120142.yXsNEo6H-lkp@intel.com/
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dave Airlie <airlied@gmail.com>
Cc: Dimitri Sivanich <dimitri.sivanich@hpe.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: SeongJae Park <sj@kernel.org>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-06-19 16:19:25 -07:00
..
accel accel/qaic: Fix NNC message corruption 2023-05-23 09:51:38 -06:00
accessibility braille_console: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:53 -07:00
acpi ACPI: resource: Add IRQ override quirk for LG UltraPC 17U70P 2023-05-15 14:21:58 +02:00
amba
android binder: fix UAF of alloc->vma in race with munmap() 2023-05-20 17:56:23 +01:00
ata Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
atm
auxdisplay
base drivers/base: use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN 2023-06-19 16:19:20 -07:00
bcma bcma: Add explicit of_device.h include 2023-04-14 15:32:56 +03:00
block xen: branch for v6.4-rc4 2023-05-27 09:42:56 -07:00
bluetooth Bluetooth: btnxpuart: Fix compiler warnings 2023-05-19 15:38:29 -07:00
bus modules-6.4-rc1 2023-04-27 16:36:55 -07:00
cdrom
cdx cdx: fix build failure due to sysfs 'bus_type' argument needing to be const 2023-04-27 16:21:32 -07:00
char parisc architecture fixes for kernel v6.4-rc4: 2023-05-25 18:50:18 -07:00
clk A couple more patches that would be good to get into -rc1. 2023-05-07 10:31:45 -07:00
clocksource Timekeeping and clocksource/event driver updates the second batch: 2023-04-29 10:24:30 -07:00
comedi
connector
counter - New Drivers 2023-05-02 10:41:31 -07:00
cpufreq cpufreq: amd-pstate: Update policy->cur in amd_pstate_adjust_perf() 2023-05-25 19:35:13 +02:00
cpuidle RISC-V: Align SBI probe implementation with spec 2023-04-29 13:04:50 -07:00
crypto This push fixes the following problems: 2023-05-07 10:57:14 -07:00
cxl cxl: Explicitly initialize resources when media is not ready 2023-05-26 13:34:39 -07:00
dax
dca Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
devfreq Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
dio
dma dmaengine updates for v6.4 2023-05-03 11:11:56 -07:00
dma-buf - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
edac Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
eisa
extcon
firewire firewire: net: fix unexpected release of object for asynchronous request packet 2023-05-11 09:06:49 +09:00
firmware Arm FF-A fixes for v6.4 2023-05-26 16:49:15 +02:00
fpga Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
fsi
gnss
gpio gpio-f7188x: fix chip name and pin count on Nuvoton chip 2023-05-23 10:47:41 +02:00
gpu mm: ptep_get() conversion 2023-06-19 16:19:25 -07:00
greybus
hid Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
hsi
hte Devicetree updates for v6.4, part 2: 2023-04-27 10:09:05 -07:00
hv hyperv-next for v6.4 2023-04-27 17:17:12 -07:00
hwmon hwmon: (k10temp) Add PCI ID for family 19, model 78h 2023-05-08 11:36:19 +02:00
hwspinlock
hwtracing coresight: perf: Release Coresight path when alloc trace id failed 2023-05-11 11:18:21 +01:00
i2c i2c: gxp: fix build failure without CONFIG_I2C_SLAVE 2023-05-03 17:27:29 +02:00
i3c i3c: ast2600: set variable ast2600_i3c_ops storage-class-specifier to static 2023-04-30 23:50:26 +02:00
idle intel_idle: mark few variables as __read_mostly 2023-04-27 19:37:36 +02:00
iio Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
infiniband mm/gup: remove vmas parameter from pin_user_pages() 2023-06-09 16:25:26 -07:00
input Input updates for 6.4 merge window: 2023-05-01 17:18:56 -07:00
interconnect modules-6.4-rc1 2023-04-27 16:36:55 -07:00
iommu iommu/dma: force bouncing if the size is not cacheline-aligned 2023-06-19 16:19:23 -07:00
ipack
irqchip irqchip/mbigen: Unify the error handling in mbigen_of_create_domain() 2023-05-16 11:19:29 +01:00
isdn Including fixes from netfilter. 2023-05-05 19:12:01 -07:00
leds - New Drivers 2023-05-02 10:36:02 -07:00
macintosh powerpc updates for 6.4 2023-04-28 16:24:32 -07:00
mailbox - mailbox api: allow direct registration to a channel 2023-05-07 10:17:33 -07:00
mcb mcb-lpc: Reallocate memory region to avoid memory overlapping 2023-04-20 14:24:01 +02:00
md dm-crypt: use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN 2023-06-19 16:19:21 -07:00
media mm/gup: remove vmas parameter from pin_user_pages() 2023-06-09 16:25:26 -07:00
memory ARM: SoC drivers for v6.4 2023-04-25 12:02:16 -07:00
memstick
message Objtool changes for v6.4: 2023-04-28 14:02:54 -07:00
mfd - New Drivers 2023-05-02 10:41:31 -07:00
misc mm: ptep_get() conversion 2023-06-19 16:19:25 -07:00
mmc mmc: sdhci-esdhc-imx: make "no-mmc-hs400" works 2023-05-09 11:55:02 +02:00
most
mtd This pull request contains updates for UBI and UBIFS 2023-05-03 18:58:59 -07:00
mux
net net: phy: mscc: enable VSC8501/2 RGMII RX clock 2023-05-24 22:14:23 -07:00
nfc drivers: nfc: nfcsim: remove return value check of `dev_dir` 2023-04-24 18:12:42 -07:00
ntb
nubus
nvdimm
nvme NVMe: Add MAXIO 1602 to bogus nid list. 2023-05-26 08:21:50 -07:00
nvmem modules-6.4-rc1 2023-04-27 16:36:55 -07:00
of Devicetree fixes for 6.4, part 1: 2023-05-05 13:27:59 -07:00
opp Devicetree updates for v6.4, part 2: 2023-04-27 10:09:05 -07:00
parisc parisc: Replace regular spinlock with spin_trylock on panic path 2023-05-03 17:43:26 +02:00
parport
pci scatterlist: add dedicated config for DMA flags 2023-06-19 16:19:22 -07:00
pcmcia
peci
perf RISC-V: Align SBI probe implementation with spec 2023-04-29 13:04:50 -07:00
phy phy fixes for 6.4 2023-05-05 11:57:29 -07:00
pinctrl Pin control bulk changes for the v6.4 kernel: 2023-05-02 15:40:41 -07:00
platform platform/x86/intel/ifs: Annotate work queue on stack so object debug does not complain 2023-05-23 12:55:16 +02:00
pnp
power power: supply: Fix logic checking if system is running from battery 2023-05-16 23:02:56 +02:00
powercap
pps
ps3
ptp Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
pwm pwm: Changes for v6.4-rc1 2023-05-03 11:25:01 -07:00
rapidio Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
ras
regulator regulator: mt6359: add read check for PMIC MT6359 2023-05-18 19:24:47 +09:00
remoteproc Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
reset Nothing looks out of the ordinary in this batch of clk driver updates. There 2023-04-29 17:29:39 -07:00
rpmsg Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
rtc - New Drivers 2023-05-02 10:41:31 -07:00
s390 block-6.4-2023-05-20 2023-05-20 08:48:04 -07:00
sbus Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
scsi scsi: core: Decrease scsi_device's iorequest_cnt if dispatch failed 2023-05-16 21:56:35 -04:00
sh
siox
slimbus
soc modules-6.4-rc1 2023-04-27 16:36:55 -07:00
soundwire
spi drivers/spi: use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN 2023-06-19 16:19:21 -07:00
spmi spmi: Add a check for remove callback when removing a SPMI driver 2023-04-20 14:16:39 +02:00
ssb
staging modules-6.4-rc1 2023-04-27 16:36:55 -07:00
target
tc
tee Fixes an uninitialized variable in OP-TEE driver 2023-05-25 17:16:52 +02:00
thermal thermal: intel: int340x: Add new line for UUID display 2023-05-24 19:50:04 +02:00
thunderbolt thunderbolt: Clear registers properly when auto clear isn't in use 2023-05-09 09:39:03 +03:00
tty vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF 2023-05-13 20:01:13 +09:00
ufs scsi: ufs: core: Fix MCQ nr_hw_queues 2023-05-16 21:07:26 -04:00
uio
usb drivers/usb: use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN 2023-06-19 16:19:21 -07:00
vdpa mm/gup: remove vmas parameter from pin_user_pages() 2023-06-09 16:25:26 -07:00
vfio mm: ptep_get() conversion 2023-06-19 16:19:25 -07:00
vhost mm/gup: remove vmas parameter from pin_user_pages() 2023-06-09 16:25:26 -07:00
video fbdev: stifb: Whitespace cleanups 2023-05-20 22:48:46 +02:00
virt Devicetree updates for v6.4, part 2: 2023-04-27 10:09:05 -07:00
virtio - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
vlynq
w1 Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
watchdog linux-watchdog 6.4-rc1 tag 2023-05-04 18:33:56 -07:00
xen mm: ptep_get() conversion 2023-06-19 16:19:25 -07:00
zorro
Kconfig
Makefile