lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 20 Apr 2023 15:06:35 -0700
From:   Tony Luck <tony.luck@...el.com>
To:     Fenghua Yu <fenghua.yu@...el.com>,
        Reinette Chatre <reinette.chatre@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Shaopeng Tan <tan.shaopeng@...itsu.com>,
        Jamie Iles <quic_jiles@...cinc.com>,
        James Morse <james.morse@....com>,
        Babu Moger <babu.moger@....com>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org,
        Tony Luck <tony.luck@...el.com>
Subject: [RFC PATCH 6/7] x86/resctrl: Allow a device to override an existing schemata entry

Remove that entry from the resctrl_schema_all list when driver
is loaded. Put it back again when driver is unloaded.

Signed-off-by: Tony Luck <tony.luck@...el.com>
---
 include/linux/resctrl.h                |  4 ++++
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 691805214f41..246644f53bde 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -223,6 +223,8 @@ struct resctrl_fileinfo {
  * @rmdir:	Callback when a resctrl directory is removed.
  * @ctrlfiles:	Array of files to create in ctrlmon directories.
  * @schema:	Driver supplied to manage a line in schemata file.
+ * @schema_override: Name of resource in schemata to override.
+ * @save_schema: List to save overridden schema while driver loaded
  */
 struct resctrl_driver {
 	struct list_head	list;
@@ -232,6 +234,8 @@ struct resctrl_driver {
 	int			(*rmdir)(int oclos, int ormid, int nclos, int nrmid);
 	struct resctrl_fileinfo	*ctrlfiles;
 	struct resctrl_schema	schema;
+	char			*schema_override;
+	struct list_head	save_schema;
 };
 
 int resctrl_register_driver(struct resctrl_driver *d);
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index cc2292a7435b..4fc12ad56843 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2547,6 +2547,19 @@ static void rdtgroup_update_ctrl_dir(struct resctrl_fileinfo *files, bool add)
 	}
 }
 
+static void driver_override(struct resctrl_driver *d)
+{
+	struct resctrl_schema *rs;
+
+	list_for_each_entry(rs, &resctrl_schema_all, list) {
+		if (strncmp(d->schema_override, rs->name, sizeof(rs->name)))
+			continue;
+		INIT_LIST_HEAD(&d->save_schema);
+		list_move(&rs->list, &d->save_schema);
+		break;
+	}
+}
+
 static void driver_up(struct resctrl_driver *d)
 {
 	if (d->mount)
@@ -2575,6 +2588,9 @@ int resctrl_register_driver(struct resctrl_driver *d)
 	if (d->schema.name[0])
 		list_add(&d->schema.list, &resctrl_schema_all);
 
+	if (d->schema_override)
+		driver_override(d);
+
 	if (resctrl_is_mounted)
 		driver_up(d);
 	mutex_unlock(&rdtgroup_mutex);
@@ -2592,6 +2608,9 @@ void resctrl_unregister_driver(struct resctrl_driver *d)
 	if (d->schema.name[0])
 		list_del(&d->schema.list);
 
+	if (d->schema_override && !list_empty(&d->save_schema))
+		list_move(d->save_schema.next, &resctrl_schema_all);
+
 	if (resctrl_is_mounted)
 		driver_down(d);
 	mutex_unlock(&rdtgroup_mutex);
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ