From: Lara Lazier <laramglazier@gmail.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, Lara Lazier <laramglazier@gmail.com>
Subject: [PATCH kvm-unit-tests] x86: Added LA57 support to is_canonical
Date: Fri, 13 Aug 2021 13:18:33 +0200 [thread overview]
Message-ID: <20210813111833.42377-1-laramglazier@gmail.com> (raw)
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@gmail.com>
---
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
next reply other threads:[~2021-08-13 11:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-13 11:18 Lara Lazier [this message]
2021-08-13 11:29 ` [PATCH kvm-unit-tests] x86: Added LA57 support to is_canonical Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210813111833.42377-1-laramglazier@gmail.com \
--to=laramglazier@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox