|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/MSR: improve code gen for rdmsr_safe() and rdtsc()
commit 66878a8b7566e9a98d20b69ab95ddaffe1130683
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Oct 1 09:47:32 2024 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Oct 1 09:47:32 2024 +0200
x86/MSR: improve code gen for rdmsr_safe() and rdtsc()
To fold two 32-bit outputs from the asm()-s into a single 64-bit value
the compiler needs to emit a zero-extension insn for the low half. Both
RDMSR and RDTSC clear the upper halves of their output registers anyway,
though. So despite that zero-extending insn (a simple MOV) being cheap,
we can do better: Without one, by declaring the local variables as 64-
bit ones.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/arch/x86/include/asm/msr.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/include/asm/msr.h b/xen/arch/x86/include/asm/msr.h
index c95330a5a1..e1e7439d6c 100644
--- a/xen/arch/x86/include/asm/msr.h
+++ b/xen/arch/x86/include/asm/msr.h
@@ -54,17 +54,17 @@ static inline void wrmsr_ns(uint32_t msr, uint32_t lo,
uint32_t hi)
/* rdmsr with exception handling */
#define rdmsr_safe(msr,val) ({\
int rc_; \
- uint32_t lo_, hi_; \
+ uint64_t lo_, hi_; \
__asm__ __volatile__( \
"1: rdmsr\n2:\n" \
".section .fixup,\"ax\"\n" \
- "3: xorl %0,%0\n; xorl %1,%1\n" \
+ "3: xorl %k0,%k0\n; xorl %k1,%k1\n" \
" movl %5,%2\n; jmp 2b\n" \
".previous\n" \
_ASM_EXTABLE(1b, 3b) \
: "=a" (lo_), "=d" (hi_), "=&r" (rc_) \
: "c" (msr), "2" (0), "i" (-EFAULT)); \
- val = lo_ | ((uint64_t)hi_ << 32); \
+ val = lo_ | (hi_ << 32); \
rc_; })
/* wrmsr with exception handling */
@@ -99,11 +99,11 @@ static inline void msr_split(struct cpu_user_regs *regs,
uint64_t val)
static inline uint64_t rdtsc(void)
{
- uint32_t low, high;
+ uint64_t low, high;
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high));
- return ((uint64_t)high << 32) | low;
+ return (high << 32) | low;
}
static inline uint64_t rdtsc_ordered(void)
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |