All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/resctrl: avoid divide by 0 num_rmid
@ 2025-07-21 18:00 Barret Rhoden
  2025-07-22 18:19 ` Reinette Chatre
  0 siblings, 1 reply; 5+ messages in thread
From: Barret Rhoden @ 2025-07-21 18:00 UTC (permalink / raw)
  To: Tony Luck, Reinette Chatre; +Cc: Dave Martin, James Morse, linux-kernel

x86_cache_max_rmid's default is -1.  If the hardware or VM doesn't set
the right cpuid bits, num_rmid can be 0.

Signed-off-by: Barret Rhoden <brho@google.com>

---
I ran into this on a VM on granite rapids.  I guess the VMM told the
kernel it was a GNR, but didn't set all the cache/rsctl bits.

 arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index c261558276cd..226dee05f96e 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -359,6 +359,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 	else if (mbm_offset > MBM_CNTR_WIDTH_OFFSET_MAX)
 		pr_warn("Ignoring impossible MBM counter offset\n");
 
+	if (r->num_rmid < 1) {
+		pr_warn("Invalid num_rmid %d, cach_max_rmid was %d\n",
+			r->num_rmid, boot_cpu_data.x86_cache_max_rmid);
+		r->num_rmid = 1;
+	}
+
 	/*
 	 * A reasonable upper limit on the max threshold is the number
 	 * of lines tagged per RMID if all RMIDs have the same number of
-- 
2.50.0.727.gbf7dc18ff4-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-22 21:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 18:00 [PATCH] x86/resctrl: avoid divide by 0 num_rmid Barret Rhoden
2025-07-22 18:19 ` Reinette Chatre
2025-07-22 18:51   ` Barret Rhoden
2025-07-22 21:16     ` Reinette Chatre
2025-07-22 21:33       ` Reinette Chatre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.