[PATCH kvm-unit-tests] x86: Added LA57 support to is_canonical

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In case LA57 is enabled, the function is_canonical would need to
check if the address is correctly sign-extended from bit 57 (instead of 48)
to bit 63.

Signed-off-by: Lara Lazier <laramglazier@xxxxxxxxx>
---
 lib/x86/processor.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index a08ea1f..3b43fc4 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -640,7 +640,10 @@ static inline void write_pkru(u32 pkru)
 
 static inline bool is_canonical(u64 addr)
 {
-	return (s64)(addr << 16) >> 16 == addr;
+	int va_width = (raw_cpuid(0x80000008, 0).a & 0xff00) >> 8;
+	int shift_amt = 64 - va_width;
+
+	return (s64)(addr << shift_amt) >> shift_amt == addr;
 }
 
 static inline void clear_bit(int bit, u8 *addr)
-- 
2.25.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux