Use X86_PROPERTY_MAX_VIRT_ADDR in is_canonical() instead of open coding a *very* rough equivalent. Default to a maximum virtual address width of 48 bits instead of 64 bits to better match real x86 CPUs (and Intel and AMD architectures). Reviewed-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> --- lib/x86/processor.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/x86/processor.h b/lib/x86/processor.h index e6bd964f..10391cc0 100644 --- a/lib/x86/processor.h +++ b/lib/x86/processor.h @@ -1022,9 +1022,14 @@ static inline void write_pkru(u32 pkru) static inline bool is_canonical(u64 addr) { - int va_width = (raw_cpuid(0x80000008, 0).a & 0xff00) >> 8; - int shift_amt = 64 - va_width; + int va_width, shift_amt; + if (this_cpu_has_p(X86_PROPERTY_MAX_VIRT_ADDR)) + va_width = this_cpu_property(X86_PROPERTY_MAX_VIRT_ADDR); + else + va_width = 48; + + shift_amt = 64 - va_width; return (s64)(addr << shift_amt) >> shift_amt == addr; } -- 2.50.0.rc0.642.g800a2b2222-goog