[PATCH v1 3/6] x86/resctrl: Disallow mongroup rename on MPAM

From: Peter Newman
Date: Mon Mar 25 2024 - 16:51:51 EST


Moving a monitoring group to a different parent control assumes that the
monitors will not be impacted. This is not the case on MPAM where the
PMG is an extension of the PARTID.

Detect this situation by requiring the change in CLOSID not to affect
the result of resctrl_arch_rmid_idx_encode(), otherwise return
-EOPNOTSUPP.

Signed-off-by: Peter Newman <peternewman@xxxxxxxxxx>
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 9b1969e4235a..8d6979dbfd02 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -3879,6 +3879,19 @@ static int rdtgroup_rename(struct kernfs_node *kn,
goto out;
}

+ /*
+ * If changing the CLOSID impacts the RMID, this operation is not
+ * supported.
+ */
+ if (resctrl_arch_rmid_idx_encode(rdtgrp->mon.parent->closid,
+ rdtgrp->mon.rmid) !=
+ resctrl_arch_rmid_idx_encode(new_prdtgrp->closid,
+ rdtgrp->mon.rmid)) {
+ rdt_last_cmd_puts("changing parent control group not supported\n");
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
+
/*
* If the MON group is monitoring CPUs, the CPUs must be assigned to the
* current parent CTRL_MON group and therefore cannot be assigned to
--
2.44.0.396.g6e790dbe36-goog