linux/arch/x86/kernel
Dave Martin 739c976579 x86/resctrl: Don't try to free nonexistent RMIDs
Commit

  6791e0ea30 ("x86/resctrl: Access per-rmid structures by index")

adds logic to map individual monitoring groups into a global index space used
for tracking allocated RMIDs.

Attempts to free the default RMID are ignored in free_rmid(), and this works
fine on x86.

With arm64 MPAM, there is a latent bug here however: on platforms with no
monitors exposed through resctrl, each control group still gets a different
monitoring group ID as seen by the hardware, since the CLOSID always forms part
of the monitoring group ID.

This means that when removing a control group, the code may try to free this
group's default monitoring group RMID for real.  If there are no monitors
however, the RMID tracking table rmid_ptrs[] would be a waste of memory and is
never allocated, leading to a splat when free_rmid() tries to dereference the
table.

One option would be to treat RMID 0 as special for every CLOSID, but this would
be ugly since bookkeeping still needs to be done for these monitoring group IDs
when there are monitors present in the hardware.

Instead, add a gating check of resctrl_arch_mon_capable() in free_rmid(), and
just do nothing if the hardware doesn't have monitors.

This fix mirrors the gating checks already present in
mkdir_rdt_prepare_rmid_alloc() and elsewhere.

No functional change on x86.

  [ bp: Massage commit message. ]

Fixes: 6791e0ea30 ("x86/resctrl: Access per-rmid structures by index")
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lore.kernel.org/r/20240618140152.83154-1-Dave.Martin@arm.com
2024-06-19 11:39:09 +02:00
..
acpi ACPI updates for 6.9-rc1 2024-03-13 11:54:05 -07:00
apic genirq/cpuhotplug, x86/vector: Prevent vector leak during CPU offline 2024-05-23 21:51:50 +02:00
cpu x86/resctrl: Don't try to free nonexistent RMIDs 2024-06-19 11:39:09 +02:00
fpu ARM: 2024-05-15 14:46:43 -07:00
kprobes Probes updates for v6.10: 2024-05-17 18:29:30 -07:00
.gitignore
alternative.c x86/alternatives: Use the correct length when optimizing NOPs 2024-05-17 09:27:06 +02:00
amd_gart_64.c change alloc_pages name in dma_map_ops to avoid name conflicts 2024-04-25 20:55:53 -07:00
amd_nb.c x86/amd_nb: Check for invalid SMN reads 2024-06-05 21:23:34 +02:00
aperture_64.c
apm_32.c
asm-offsets_32.c
asm-offsets_64.c
asm-offsets.c
audit_64.c
bootflag.c
callthunks.c x86/alternatives: Use a temporary buffer when optimizing NOPs 2024-04-09 18:08:11 +02:00
cet.c
cfi.c
check.c
cpuid.c
crash_dump_32.c
crash_dump_64.c
crash.c crash: add a new kexec flag for hotplug support 2024-04-23 14:59:01 +10:00
devicetree.c x86/of: Change x86_dtb_parse_smp_config() to static 2024-04-03 08:49:56 +02:00
doublefault_32.c
dumpstack_32.c
dumpstack_64.c
dumpstack.c x86/dumpstack: Use uniform "Oops: " prefix for die() messages 2024-03-27 08:45:19 +01:00
e820.c x86/e820: Add a new e820 table update helper 2024-04-29 11:15:31 +02:00
early_printk.c
early-quirks.c
ebda.c
eisa.c x86/sev: Skip ROM range scans and validation for SEV-SNP guests 2024-03-26 15:22:35 +01:00
espfix_64.c
fred.c
ftrace_32.S
ftrace_64.S
ftrace.c x86/ftrace: enable dynamic ftrace without CONFIG_MODULES 2024-05-14 00:31:44 -07:00
head_32.S x86/cleanups changes for v6.10: 2024-05-13 18:21:24 -07:00
head_64.S x86/cleanups changes for v6.10: 2024-05-13 18:21:24 -07:00
head32.c
head64.c x86/boot/64: Move 5-level paging global variable assignments back 2024-03-24 05:00:36 +01:00
hpet.c
hw_breakpoint.c
i8237.c
i8253.c
i8259.c
ibt_selftest.S
idt.c x86/irq: Install posted MSI notification handler 2024-04-30 00:54:42 +02:00
io_delay.c
ioport.c
irq_32.c
irq_64.c fix missing vmalloc.h includes 2024-04-25 20:55:49 -07:00
irq_work.c
irq.c x86/irq: Factor out common code for checking pending interrupts 2024-04-30 00:54:43 +02:00
irqflags.S
irqinit.c
itmt.c
jailhouse.c
jump_label.c
kdebugfs.c
kexec-bzimage64.c - Sumanth Korikkar has taught s390 to allocate hotplug-time page frames 2024-03-14 17:43:30 -07:00
kgdb.c
ksysfs.c
kvm.c Linux 6.9-rc3 2024-04-09 09:48:09 +02:00
kvmclock.c
ldt.c
machine_kexec_32.c
machine_kexec_64.c x86/kexec: Fix bug with call depth tracking 2024-06-03 17:19:03 +02:00
Makefile Kbuild updates for v6.10 2024-05-18 12:39:20 -07:00
mmconf-fam10h_64.c
module.c arch: make execmem setup available regardless of CONFIG_MODULES 2024-05-14 00:31:44 -07:00
mpparse.c x86/mpparse: Register APIC address only once 2024-03-23 12:41:48 +01:00
msr.c
nmi_selftest.c
nmi.c x86/nmi: Upgrade NMI backtrace stall checks & messages 2024-03-26 10:07:59 +01:00
paravirt-spinlocks.c
paravirt.c
pci-dma.c
pcspeaker.c
perf_regs.c
platform-quirks.c
pmem.c
probe_roms.c x86/sev: Skip ROM range scans and validation for SEV-SNP guests 2024-03-26 15:22:35 +01:00
process_32.c
process_64.c x86/cpu: Fix check for RDPKRU in __show_regs() 2024-04-24 14:30:21 +02:00
process.c Core x86 changes for v6.9: 2024-03-11 19:53:15 -07:00
process.h
ptrace.c
pvclock.c
quirks.c
reboot_fixups_32.c
reboot.c
relocate_kernel_32.S
relocate_kernel_64.S
resource.c
rethook.c
rtc.c x86/rtc: Remove unused intel-mid.h 2024-04-03 08:24:48 -07:00
setup_percpu.c
setup.c The usual shower of singleton fixes and minor series all over MM, 2024-05-19 09:21:03 -07:00
sev_verify_cbit.S
sev-shared.c x86/sev: Check for MWAITX and MONITORX opcodes in the #VC handler 2024-04-22 18:38:28 +02:00
sev.c - Small cleanups and improvements 2024-05-14 09:18:52 -07:00
shstk.c x86/shstk: Enable shadow stacks for x32 2024-03-22 10:17:11 +01:00
signal_32.c x86/syscall/compat: Remove ia32_unistd.h 2024-03-22 09:37:09 +01:00
signal_64.c x86/shstk: Enable shadow stacks for x32 2024-03-22 10:17:11 +01:00
signal.c
smp.c - Sumanth Korikkar has taught s390 to allocate hotplug-time page frames 2024-03-14 17:43:30 -07:00
smpboot.c x86/cpu: Switch to new Intel CPU model defines 2024-04-29 10:31:30 +02:00
stacktrace.c
static_call.c
step.c x86/msr: Prepare for including <linux/percpu.h> into <asm/msr.h> 2024-03-04 12:01:39 +01:00
sys_ia32.c
sys_x86_64.c x86/mm: care about shadow stack guard gap during placement 2024-04-25 20:56:28 -07:00
tboot.c
time.c
tls.c
tls.h
trace_clock.c
trace.c
tracepoint.c
traps.c Core x86 changes for v6.9: 2024-03-11 19:53:15 -07:00
tsc_msr.c x86/tsc_msr: Switch to new Intel CPU model defines 2024-04-29 10:31:34 +02:00
tsc_sync.c x86/tsc: Trust initial offset in architectural TSC-adjust MSRs 2024-04-29 23:27:16 +02:00
tsc.c x86/cpu changes for v6.10: 2024-05-13 18:44:44 -07:00
umip.c
unwind_frame.c
unwind_guess.c
unwind_orc.c
uprobes.c
verify_cpu.S
vm86_32.c
vmcore_info_32.c
vmcore_info_64.c
vmlinux.lds.S x86/build changes for v6.10: 2024-05-13 18:05:08 -07:00
vsmp_64.c
x86_init.c x86/sev: Skip ROM range scans and validation for SEV-SNP guests 2024-03-26 15:22:35 +01:00