Skip to content

Commit cf991de

Browse files
amlutoIngo Molnar
authored andcommitted
x86/asm/msr: Make wrmsrl_safe() a function
The wrmsrl_safe macro performs invalid shifts if the value argument is 32 bits. This makes it unnecessarily awkward to write code that puts an unsigned long into an MSR. Convert it to a real inline function. For inspiration, see: 7c74d5b ("x86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value"). Signed-off-by: Andy Lutomirski <[email protected]> Cc: <[email protected]> Cc: Andrew Morton <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> [ Applied small improvements. ] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 00398a0 commit cf991de

File tree

1 file changed

+7
-2
lines changed
  • arch/x86/include/asm

1 file changed

+7
-2
lines changed

arch/x86/include/asm/msr.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,13 @@ do { \
205205

206206
#endif /* !CONFIG_PARAVIRT */
207207

208-
#define wrmsrl_safe(msr, val) wrmsr_safe((msr), (u32)(val), \
209-
(u32)((val) >> 32))
208+
/*
209+
* 64-bit version of wrmsr_safe():
210+
*/
211+
static inline int wrmsrl_safe(u32 msr, u64 val)
212+
{
213+
return wrmsr_safe(msr, (u32)val, (u32)(val >> 32));
214+
}
210215

211216
#define write_tsc(low, high) wrmsr(MSR_IA32_TSC, (low), (high))
212217

0 commit comments

Comments
 (0)