Skip to contentSkip to conversation

x86, msr: fix rdmsrl_safe_on_cpu()

PATCH In review Eric Dumazet 4 participants 4 messages Mar 28, 2018 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, msr: fix rdmsrl_safe_on_cpu()

When changing rdmsr_safe_on_cpu() to schedule, I missed that __rdmsr_safe_on_cpu() was also used by rdmsrl_safe_on_cpu()

Lets make rdmsrl_safe_on_cpu() a wrapper instead of copy/pasting the code I added for the completion handling.

Fixes 07cde313b2d2 ("x86/msr: Allow rdmsr_safe_on_cpu() to schedule")
Cc "H. Peter Anvin" <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
---
 arch/x86/lib/msr-smp.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/x86/lib/msr-smp.c +4 -7
index 761ba062afdaf7f7d0603ed94ed6cc3e46b37f76..fee8b9c0520c9954e3cf9093332e1a9b53009b8b 100644
@@ -225,16 +225,13 @@ EXPORT_SYMBOL(wrmsrl_safe_on_cpu);
 
 int rdmsrl_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q)
 {
+	u32 low, high;
 	int err;
-	struct msr_info rv;
 
-	memset(&rv, 0, sizeof(rv));
+	err = rdmsr_safe_on_cpu(cpu, msr_no, &low, &high);
+	*q = (u64)high << 32 | low;
 
-	rv.msr_no = msr_no;
-	err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
-	*q = rv.reg.q;
-
-	return err ? err : rv.err;
+	return err;
 }
 EXPORT_SYMBOL(rdmsrl_safe_on_cpu);
 
Signature · 1 line
2.17.0.rc1.321.gba9d0f2565-goog
#1 lore raw

[tip:x86/cleanups] x86/msr: Make rdmsrl_safe_on_cpu() scheduling safe as well

x86/msr: Make rdmsrl_safe_on_cpu() scheduling safe as well
Commit-ID:  9b9a51354cae933f5640b5bb73bbcd32f989122f
Gitweb:     https://git.kernel.org/tip/9b9a51354cae933f5640b5bb73bbcd32f989122f
Author:     Eric Dumazet <[email protected]>
AuthorDate: Tue, 27 Mar 2018 20:22:33 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 28 Mar 2018 10:34:13 +0200

x86/msr: Make rdmsrl_safe_on_cpu() scheduling safe as well

When changing rdmsr_safe_on_cpu() to schedule, it was missed that __rdmsr_safe_on_cpu() was also used by rdmsrl_safe_on_cpu()

Make rdmsrl_safe_on_cpu() a wrapper instead of copy/pasting the code which was added for the completion handling.

Fixes 07cde313b2d2 ("x86/msr: Allow rdmsr_safe_on_cpu() to schedule")
Cc Borislav Petkov <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/lib/msr-smp.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/x86/lib/msr-smp.c +4 -7
index 761ba062afda..fee8b9c0520c 100644
@@ -225,16 +225,13 @@ EXPORT_SYMBOL(wrmsrl_safe_on_cpu);
 
 int rdmsrl_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q)
 {
+	u32 low, high;
 	int err;
-	struct msr_info rv;
 
-	memset(&rv, 0, sizeof(rv));
+	err = rdmsr_safe_on_cpu(cpu, msr_no, &low, &high);
+	*q = (u64)high << 32 | low;
 
-	rv.msr_no = msr_no;
-	err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
-	*q = rv.reg.q;
-
-	return err ? err : rv.err;
+	return err;
 }
 EXPORT_SYMBOL(rdmsrl_safe_on_cpu);
 
maintainer
#2 lore raw
In reply to Eric Dumazet
Quoted 33 lines · Eric Dumazet

When changing rdmsr_safe_on_cpu() to schedule, I missed that __rdmsr_safe_on_cpu() was also used by rdmsrl_safe_on_cpu()

Lets make rdmsrl_safe_on_cpu() a wrapper instead of copy/pasting the code I added for the completion handling.

Fixes 07cde313b2d2 ("x86/msr: Allow rdmsr_safe_on_cpu() to schedule")
Cc "H. Peter Anvin" <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
---
 arch/x86/lib/msr-smp.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/x86/lib/msr-smp.c +3 -2
index 761ba062afdaf7f7d0603ed94ed6cc3e46b37f76..fee8b9c0520c9954e3cf9093332e1a9b53009b8b 100644
@@ -225,16 +225,13 @@ EXPORT_SYMBOL(wrmsrl_safe_on_cpu);
 
 int rdmsrl_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q)
 {
+	u32 low, high;
 	int err;
-	struct msr_info rv;
 
-	memset(&rv, 0, sizeof(rv));
+	err = rdmsr_safe_on_cpu(cpu, msr_no, &low, &high);
+	*q = (u64)high << 32 | low;

arch/x86/lib/msr-smp.c EXPORT_SYMBOL(wrmsrl_safe_on_cpu); · line 237

Quoted 10 lines
arch/x86/lib/msr-smp.c +1 -5
 
-	rv.msr_no = msr_no;
-	err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
-	*q = rv.reg.q;
-
-	return err ? err : rv.err;
+	return err;
 }
 EXPORT_SYMBOL(rdmsrl_safe_on_cpu);
 

I guess now that the rdmsr* side does this, you probably should convert the wrmsr* side as well.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#3 lore raw
Quoted 2 lines · Borislav Petkov

I guess now that the rdmsr* side does this, you probably should convert the wrmsr* side as well.

Yes indeed, thanks for the reminder.