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]
Message-Id: <20200610110037.11853-2-bp@alien8.de>
Date:   Wed, 10 Jun 2020 13:00:35 +0200
From:   Borislav Petkov <bp@...en8.de>
To:     X86 ML <x86@...nel.org>
Cc:     Tom Lendacky <thomas.lendacky@....com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 1/3] x86/msr: Pass a single MSR value to __rwmsr_on_cpus() too

From: Borislav Petkov <bp@...e.de>

__rwmsr_on_cpus() is the low-level worker function which is called by
the exported {rd,wr}msr_on_cpus() when an MSR is supposed to be set with
values for CPUs or an MSR is supposed to be read from CPUs into an array
of percpu variables in @msrs.

The low-level machinery supports also passing a single MSR value for the
single CPU {rd,wr}msr_on_cpu() handlers.

Pass that value to __rwmsr_on_cpus() too and enforce a mutually
exclusive either a single MSR value "XOR" an array of per-CPU MSR
values.

This is the prerequisite for supporting writing the same MSR value on
multiple CPUs.

Signed-off-by: Borislav Petkov <bp@...e.de>
---
 arch/x86/lib/msr-smp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/lib/msr-smp.c b/arch/x86/lib/msr-smp.c
index fee8b9c0520c..15e1157d6b29 100644
--- a/arch/x86/lib/msr-smp.c
+++ b/arch/x86/lib/msr-smp.c
@@ -97,7 +97,7 @@ int wrmsrl_on_cpu(unsigned int cpu, u32 msr_no, u64 q)
 EXPORT_SYMBOL(wrmsrl_on_cpu);
 
 static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
-			    struct msr *msrs,
+			    struct msr *msrs, u64 reg_val,
 			    void (*msr_func) (void *info))
 {
 	struct msr_info rv;
@@ -105,8 +105,13 @@ static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
 
 	memset(&rv, 0, sizeof(rv));
 
+	/* Can't have both. */
+	if (WARN_ON(msrs && reg_val))
+		return;
+
 	rv.msrs	  = msrs;
 	rv.msr_no = msr_no;
+	rv.reg.q  = reg_val;
 
 	this_cpu = get_cpu();
 
@@ -126,7 +131,7 @@ static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
  */
 void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
 {
-	__rwmsr_on_cpus(mask, msr_no, msrs, __rdmsr_on_cpu);
+	__rwmsr_on_cpus(mask, msr_no, msrs, 0, __rdmsr_on_cpu);
 }
 EXPORT_SYMBOL(rdmsr_on_cpus);
 
@@ -140,7 +145,7 @@ EXPORT_SYMBOL(rdmsr_on_cpus);
  */
 void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
 {
-	__rwmsr_on_cpus(mask, msr_no, msrs, __wrmsr_on_cpu);
+	__rwmsr_on_cpus(mask, msr_no, msrs, 0, __wrmsr_on_cpu);
 }
 EXPORT_SYMBOL(wrmsr_on_cpus);
 
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ