Skip to contentSkip to conversation

SSB fixup patch #1

PATCH In review [email protected] 4 participants 5 messages May 13, 2018 – May 14, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SSB fixup patch #1

Cast val and (val >> 32) to uintptr_t, so that they fit in a general-purpose register in both 32-bit and 64-bit code.

Fixes c65732e4f721 ("x86/cpu: Restore CPUID_8000_0008_EBX reload")
---
 arch/x86/include/asm/nospec-branch.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/nospec-branch.h +2 -2
index 328ea3cb769f..979aa050d311 100644
@@ -265,8 +265,8 @@ void alternative_msr_write(unsigned int msr, u64 val, unsigned int feature)
 {
 	asm volatile(ALTERNATIVE("", "wrmsr", %c[feature])
 		: : "c" (msr),
-		    "a" (val),
-		    "d" (val >> 32),
+		    "a" ((uintptr_t)val),
+		    "d" ((uintptr_t)(val >> 32)),
 		    [feature] "i" (feature)
 		: "memory");
 }
Signature · 1 line
2.14.3
#1 lore raw
Quoted 17 lines · speck for konrad.wilk_at_oracle.com

x86/cpu: Make alternative_msr_write work for 32-bit code

Cast val and (val >> 32) to uintptr_t, so that they fit in a general-purpose register in both 32-bit and 64-bit code.

Fixes c65732e4f721 ("x86/cpu: Restore CPUID_8000_0008_EBX reload")
---
 arch/x86/include/asm/nospec-branch.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/nospec-branch.h +0 -0
index 328ea3cb769f..979aa050d311 100644

arch/x86/include/asm/nospec-branch.h void alternative_msr_write(unsigned int msr, u64 val, unsigned int feature) · line 269

Quoted 7 lines
arch/x86/include/asm/nospec-branch.h +2 -2
@@ -265,8 +265,8 @@ void alternative_msr_write(unsigned int msr, u64 val, unsigned int feature)
 {
 	asm volatile(ALTERNATIVE("", "wrmsr", %c[feature])
 		: : "c" (msr),
-		    "a" (val),
-		    "d" (val >> 32),
+		    "a" ((uintptr_t)val),
+		    "d" ((uintptr_t)(val >> 32)),

Make those casts (u32) simply as the rest of the MSR code does.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#2 lore raw
Quoted 2 lines · speck for Borislav Petkov

Make those casts (u32) simply as the rest of the MSR code does.

Yeah, that's probably the right type.

Linus

#3 lore raw
Quoted 5 lines · speck for Linus Torvalds
Quoted 2 lines · speck for Borislav Petkov

Make those casts (u32) simply as the rest of the MSR code does.

Yeah, that's probably the right type.

Indeed. I fixed it up and applied it.

Thanks,

tglx

#4 lore raw
In reply to [email protected]
Quoted 3 lines · speck for konrad.wilk_at_oracle.com

Cast val and (val >> 32) to uintptr_t, so that they fit in a general-purpose register in both 32-bit and 64-bit code.

Fair enough. Except why "uintptr_t"? That feels like an odd choice. The values have nothing to do with pointers.

It's a fine type, and I guess it approximates "native register size", but so does "long".

So "Ack", albeit with a query about why that particular type was chosen..

Linus