linux/arch/x86/kernel/cpu
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
..
mce - Change the fixed-size buffer for MCE records to a dynamically sized 2024-05-14 08:39:42 -07:00
microcode - Fix a clang-15 build warning and other cleanups 2024-05-14 09:09:32 -07:00
mtrr x86/CPU/AMD: Track SNP host status with cc_platform_*() 2024-04-04 10:40:30 +02:00
resctrl x86/resctrl: Don't try to free nonexistent RMIDs 2024-06-19 11:39:09 +02:00
sgx mm: switch mm->get_unmapped_area() to a flag 2024-04-25 20:56:25 -07:00
.gitignore
acrn.c x86/traps: Add sysvec_install() to install a system interrupt handler 2024-01-31 22:02:36 +01:00
amd.c x86/cpu changes for v6.10: 2024-05-13 18:44:44 -07:00
aperfmperf.c sched/x86: Export 'percpu arch_freq_scale' 2024-05-31 11:48:42 +02:00
bugs.c x86/cpu changes for v6.10: 2024-05-13 18:44:44 -07:00
cacheinfo.c - Relax the PAT MSR programming which was unnecessarily using the MTRR 2024-03-11 17:27:12 -07:00
centaur.c x86/cpu: Use common topology code for Centaur and Zhaoxin 2024-02-15 22:07:37 +01:00
common.c x86/topology/intel: Unlock CPUID before evaluating anything 2024-05-31 20:25:56 +02:00
cpu.h x86/topology/intel: Unlock CPUID before evaluating anything 2024-05-31 20:25:56 +02:00
cpuid-deps.c - Switch the in-place instruction patching which lead to at least one weird bug 2024-05-14 08:51:37 -07:00
cyrix.c
debugfs.c x86/cpu/topology: Get rid of cpuinfo::x86_max_cores 2024-02-16 15:51:32 +01:00
feat_ctl.c x86/cpu: Add a VMX flag to enumerate 5-level EPT support to userspace 2024-02-22 16:03:56 -08:00
hygon.c x86/cpu: Use common topology code for HYGON 2024-02-15 22:07:38 +01:00
hypervisor.c
intel.c x86/topology/intel: Unlock CPUID before evaluating anything 2024-05-31 20:25:56 +02:00
intel_epb.c x86/cpu/intel_epb: Switch to new Intel CPU model defines 2024-04-29 10:31:16 +02:00
intel_pconfig.c x86/msr: Prepare for including <linux/percpu.h> into <asm/msr.h> 2024-03-04 12:01:39 +01:00
Makefile kbuild: use $(src) instead of $(srctree)/$(src) for source directory 2024-05-10 04:34:52 +09:00
match.c x86/cpu: Fix x86_match_cpu() to match just X86_VENDOR_INTEL 2024-05-22 11:31:10 +02:00
mkcapflags.sh
mshyperv.c hyperv-next for v6.9 2024-03-21 10:01:02 -07:00
perfctr-watchdog.c
powerflags.c
proc.c x86/cpu: Move cpu_core_id into topology info 2023-10-10 14:38:17 +02:00
rdrand.c x86/msr: Prepare for including <linux/percpu.h> into <asm/msr.h> 2024-03-04 12:01:39 +01:00
scattered.c x86/bhi: Define SPEC_CTRL_BHI_DIS_S 2024-04-08 19:27:05 +02:00
topology.c x86/topology: Handle bogus ACPI tables correctly 2024-05-21 14:52:35 +02:00
topology.h x86/cpu/topology: Retrieve cores per package from topology bitmaps 2024-02-15 22:07:45 +01:00
topology_amd.c x86/topology/amd: Evaluate SMT in CPUID leaf 0x8000001e only on family 0x17 and greater 2024-05-30 15:58:55 +02:00
topology_common.c x86/topology: Don't evaluate logical IDs during early boot 2024-03-23 12:28:06 +01:00
topology_ext.c x86/cpu/topology: Add support for the AMD 0x80000026 leaf 2024-03-22 11:22:14 +01:00
transmeta.c
tsx.c
umc.c
umwait.c
vmware.c
vortex.c
zhaoxin.c x86/cpu: Use common topology code for Centaur and Zhaoxin 2024-02-15 22:07:37 +01:00