diff mbox series

[kvm-unit-tests,3/3] x86: Define wrtsc(tsc) as wrmsr(MSR_IA32_TSC, tsc)

Message ID 20220127215548.2016946-3-jmattson@google.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests,1/3] x86: tsc_adjust: Remove flaky timing test | expand

Commit Message

Jim Mattson Jan. 27, 2022, 9:55 p.m. UTC
Remove some inline assembly code duplication and opportunistically
replace the magic constant, "0x10," with "MSR_IA32_TSC."

Signed-off-by: Jim Mattson <jmattson@google.com>
---
 lib/x86/processor.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Paolo Bonzini Jan. 28, 2022, 3:17 p.m. UTC | #1
On 1/27/22 22:55, Jim Mattson wrote:
> Remove some inline assembly code duplication and opportunistically
> replace the magic constant, "0x10," with "MSR_IA32_TSC."
> 
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
>   lib/x86/processor.h | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/lib/x86/processor.h b/lib/x86/processor.h
> index fe5add548261..117032a4895c 100644
> --- a/lib/x86/processor.h
> +++ b/lib/x86/processor.h
> @@ -592,9 +592,7 @@ static inline unsigned long long rdtscp(u32 *aux)
>   
>   static inline void wrtsc(u64 tsc)
>   {
> -	unsigned a = tsc, d = tsc >> 32;
> -
> -	asm volatile("wrmsr" : : "a"(a), "d"(d), "c"(0x10));
> +	wrmsr(MSR_IA32_TSC, tsc);
>   }
>   
>   static inline void irq_disable(void)

Queued all three, thanks.

Paolo
diff mbox series

Patch

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index fe5add548261..117032a4895c 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -592,9 +592,7 @@  static inline unsigned long long rdtscp(u32 *aux)
 
 static inline void wrtsc(u64 tsc)
 {
-	unsigned a = tsc, d = tsc >> 32;
-
-	asm volatile("wrmsr" : : "a"(a), "d"(d), "c"(0x10));
+	wrmsr(MSR_IA32_TSC, tsc);
 }
 
 static inline void irq_disable(void)