linux-stable/drivers
Ricardo Neri b3fce429a1 cacheinfo: Allocate memory during CPU hotplug if not done from the primary CPU
Commit

  5944ce092b ("arch_topology: Build cacheinfo from primary CPU")

adds functionality that architectures can use to optionally allocate and
build cacheinfo early during boot. Commit

  6539cffa94 ("cacheinfo: Add arch specific early level initializer")

lets secondary CPUs correct (and reallocate memory) cacheinfo data if
needed.

If the early build functionality is not used and cacheinfo does not need
correction, memory for cacheinfo is never allocated. x86 does not use
the early build functionality. Consequently, during the cacheinfo CPU
hotplug callback, last_level_cache_is_valid() attempts to dereference
a NULL pointer:

  BUG: kernel NULL pointer dereference, address: 0000000000000100
  #PF: supervisor read access in kernel mode
  #PF: error_code(0x0000) - not present page
  PGD 0 P4D 0
  Oops: 0000 [#1] PREEPMT SMP NOPTI
  CPU: 0 PID 19 Comm: cpuhp/0 Not tainted 6.4.0-rc2 #1
  RIP: 0010: last_level_cache_is_valid+0x95/0xe0a

Allocate memory for cacheinfo during the cacheinfo CPU hotplug callback
if not done earlier.

Moreover, before determining the validity of the last-level cache info,
ensure that it has been allocated. Simply checking for non-zero
cache_leaves() is not sufficient, as some architectures (e.g., Intel
processors) have non-zero cache_leaves() before allocation.

Dereferencing NULL cacheinfo can occur in update_per_cpu_data_slice_size().
This function iterates over all online CPUs. However, a CPU may have come
online recently, but its cacheinfo may not have been allocated yet.

While here, remove an unnecessary indentation in allocate_cache_info().

  [ bp: Massage. ]

Fixes: 6539cffa94 ("cacheinfo: Add arch specific early level initializer")
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Radu Rendec <rrendec@redhat.com>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Cc: stable@vger.kernel.org # 6.3+
Link: https://lore.kernel.org/r/20241128002247.26726-2-ricardo.neri-calderon@linux.intel.com
2024-12-06 13:07:47 +01:00
..
accel
accessibility
acpi power supply and reset changes for the 6.13 series 2024-11-28 09:28:09 -08:00
amba ARM: 9415/1: amba: Add dev_is_amba() function and export it for modules 2024-11-12 16:41:45 +00:00
android Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
ata pci-v6.13-changes 2024-11-26 18:05:44 -08:00
atm
auxdisplay auxdisplay for v6.13-1 2024-11-20 12:55:41 -08:00
base cacheinfo: Allocate memory during CPU hotplug if not done from the primary CPU 2024-12-06 13:07:47 +01:00
bcma
block block-6.13-20242901 2024-11-30 15:47:29 -08:00
bluetooth Networking changes for 6.13. 2024-11-21 08:28:08 -08:00
bus Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
cache
cdrom
cdx cdx: Fix cdx_mmap_resource() after constifying attr in ->mmap() 2024-11-10 10:53:21 +01:00
char Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
clk The core framework gained a clk provider helper, a clk consumer helper, and 2024-11-22 17:02:25 -08:00
clocksource clocksource/drivers/arm_arch_timer: Use of_property_present() for non-boolean properties 2024-11-13 13:49:33 +01:00
comedi
connector
counter Counter fixes for 6.12 2024-11-07 08:25:08 +01:00
cpufreq powerpc updates for 6.13 2024-11-23 10:44:31 -08:00
cpuidle RISC-V Paches for the 6.13 Merge Window, Part 1 2024-11-27 11:19:09 -08:00
crypto pci-v6.13-changes 2024-11-26 18:05:44 -08:00
cxl Driver core changes for 6.13-rc1 2024-11-29 11:43:29 -08:00
dax libnvdimm additions for 6.13 2024-11-25 18:31:48 -08:00
dca
devfreq
dio
dma dmaengine updates for v6.13 2024-11-27 13:25:47 -08:00
dma-buf dma-buf: use atomic64_inc_return() in dma_buf_getfile() 2024-11-06 13:36:37 -08:00
dpll
edac powerpc updates for 6.13 2024-11-23 10:44:31 -08:00
eisa
extcon
firewire firewire updates for v6.13 2024-11-25 17:12:54 -08:00
firmware Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
fpga Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
fsi
gnss
gpio Driver core changes for 6.13-rc1 2024-11-29 11:43:29 -08:00
gpu drm fixes for v6.13-rc1 2024-11-29 13:06:06 -08:00
greybus
hid Revert "HID: bpf: allow write access to quirks field in struct hid_device" 2024-11-25 09:21:47 -08:00
hsi
hte
hv
hwmon hwmon: (aquacomputer_d5next) Fix length of speed_input array 2024-11-24 07:36:47 -08:00
hwspinlock
hwtracing
i2c i2c: Fix whitespace style issue 2024-11-27 12:23:43 +01:00
i3c i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock 2024-11-18 14:29:13 +01:00
idle intel_idle: add Granite Rapids Xeon D support 2024-11-11 15:48:50 +01:00
iio Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
infiniband Driver core changes for 6.13-rc1 2024-11-29 11:43:29 -08:00
input Input updates for v6.13-rc0 2024-11-25 10:31:39 -08:00
interconnect
iommu iommufd 6.13 merge window pull #2 2024-11-27 14:24:34 -08:00
ipack
irqchip - Move the ->select callback to the correct ops structure in irq-mvebu-sei to 2024-12-01 12:37:58 -08:00
isdn mISDN: Fix typos 2024-11-09 09:14:12 -08:00
leds - Removed unused local header files from various drivers. 2024-11-22 16:25:20 -08:00
macintosh macintosh: Use common error handling code in via_pmu_led_init() 2024-11-14 22:54:28 +11:00
mailbox TTY / Serial driver updates for 6.13-rc1 2024-11-30 09:03:16 -08:00
mcb
md block-6.13-20242901 2024-11-30 15:47:29 -08:00
media media updates for v6.13-rc1 2024-11-20 14:05:34 -08:00
memory
memstick
message scsi: fusion: Remove unused variable 'rc' 2024-11-06 20:46:07 -05:00
mfd - Several drivers, including atmel-flexcom/rk8xx-core, palmas, and 2024-11-22 16:19:47 -08:00
misc TTY / Serial driver updates for 6.13-rc1 2024-11-30 09:03:16 -08:00
mmc MMC core: 2024-11-20 12:51:32 -08:00
most
mtd This pull request contains updates for JFFS2, UBI and UBIFS: 2024-11-30 10:32:47 -08:00
mux
net Including fixes from bluetooth. 2024-11-28 10:15:20 -08:00
nfc
ntb
nubus
nvdimm virtio: features, fixes, cleanups 2024-11-27 13:11:58 -08:00
nvme block-6.13-20242901 2024-11-30 15:47:29 -08:00
nvmem Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
of i2c-for-6.13-rc1-part3 2024-12-01 13:38:24 -08:00
opp Additional power management updates for 6.13-rc1 2024-11-27 14:40:33 -08:00
parisc
parport
pci pci-v6.13-fixes-1 2024-11-30 18:23:05 -08:00
pcmcia pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW 2024-11-09 14:55:33 +01:00
peci
perf arm64 fixes for 6.13-rc1: 2024-11-30 14:33:44 -08:00
phy Driver core changes for 6.13-rc1 2024-11-29 11:43:29 -08:00
pinctrl Driver core changes for 6.13-rc1 2024-11-29 11:43:29 -08:00
platform i2c-for-6.13-rc1-part3 2024-12-01 13:38:24 -08:00
pmdomain pmdomain: qcom: rpmhpd: Add rpmhpd support for SM8750 2024-11-12 19:46:51 +01:00
pnp
power power supply and reset changes for the 6.13 series 2024-11-28 09:28:09 -08:00
powercap
pps
ps3 ps3: Correct some typos in comments 2024-11-15 00:32:29 +11:00
ptp
pwm pwm: Assume a disabled PWM to emit a constant inactive output 2024-11-07 12:03:39 +01:00
rapidio
ras
regulator regulator: Fixes for v6.13 2024-11-28 09:40:53 -08:00
remoteproc remoteproc: qcom: wcss: Remove double assignment in q6v5_wcss_probe() 2024-11-15 20:36:27 -08:00
reset The core framework gained a clk provider helper, a clk consumer helper, and 2024-11-22 17:02:25 -08:00
rpmsg rpmsg updates for v6.13 2024-11-26 18:36:55 -08:00
rtc RTC for 6.13 2024-11-30 11:18:16 -08:00
s390 Driver core changes for 6.13-rc1 2024-11-29 11:43:29 -08:00
sbus
scsi Driver core changes for 6.13-rc1 2024-11-29 11:43:29 -08:00
sh sh updates for v6.13 2024-11-30 14:45:29 -08:00
siox
slimbus
soc Networking changes for 6.13. 2024-11-21 08:28:08 -08:00
soundwire soundwire updates for 6.13 2024-11-27 13:38:09 -08:00
spi spi: Fixes for v6.13 2024-11-28 10:06:00 -08:00
spmi spmi: pmic-arb: fix return path in for_each_available_child_of_node() 2024-11-10 10:56:46 +01:00
ssb
staging Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
target SCSI misc on 20241125 2024-11-25 18:50:55 -08:00
tc TC: Fix the wrong format specifier 2024-11-12 15:48:08 +01:00
tee
thermal Additional thermal control updates for 6.13-rc1 2024-11-27 14:36:00 -08:00
thunderbolt USB / Thunderbolt (USB4) changes for 6.13-rc1 2024-11-29 11:19:31 -08:00
tty TTY / Serial driver updates for 6.13-rc1 2024-11-30 09:03:16 -08:00
ufs SCSI misc on 20241125 2024-11-25 18:50:55 -08:00
uio Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
usb Kbuild updates for v6.13 2024-11-30 13:41:50 -08:00
vdpa vdpa/mlx5: Fix suboptimal range on iotlb iteration 2024-11-12 18:05:05 -05:00
vfio VFIO updates for v6.13 2024-11-27 12:57:03 -08:00
vhost mm: page_frag: avoid caller accessing 'page_frag_cache' directly 2024-11-11 10:56:27 -08:00
video fbdev fixes and updates for 6.13-rc1: 2024-11-25 12:07:45 -08:00
virt - Do the proper memory conversion of guest memory in order to be able to kexec 2024-11-19 12:21:35 -08:00
virtio virtio: features, fixes, cleanups 2024-11-27 13:11:58 -08:00
w1
watchdog asm-generic updates for 6.13 2024-11-20 15:13:02 -08:00
xen A set of updates for the interrupt subsystem: 2024-11-19 15:54:19 -08:00
zorro
Kconfig
Makefile