x86: Added LA57 support to is_canonical
PATCH 1/1 x86: Added LA57 support to is_canonical
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 <[email protected]>
--- lib/x86/processor.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/x86/processor.h +4 -1
@@ -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)
Signature · 1 line
2.25.1
Quoted 16 lines · Lara Lazier
In case LA57 is enabled, the function
is_canonicalwould need to check if the address is correctly sign-extended from bit 57 (instead of 48) to bit 63.Signed-off-by Lara Lazier <[email protected]>--- lib/x86/processor.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)lib/x86/processor.h +0
-0@@ -640,7 +640,10 @@ static inline void write_pkru(u32 pkru)
lib/x86/processor.h static inline void write_pkru(u32 pkru) · line 649
Quoted 10 lines
lib/x86/processor.h +4
-1static 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)
Queued, thanks.
Paolo