All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Lara Lazier <laramglazier@gmail.com>, kvm@vger.kernel.org
Subject: Re: [PATCH kvm-unit-tests] x86: Added LA57 support to is_canonical
Date: Fri, 13 Aug 2021 13:29:35 +0200	[thread overview]
Message-ID: <69b1ab87-239e-742f-3839-cb194ac6ec94@redhat.com> (raw)
In-Reply-To: <20210813111833.42377-1-laramglazier@gmail.com>

On 13/08/21 13:18, Lara Lazier wrote:
> 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)
> 

Queued, thanks.

Paolo


      reply	other threads:[~2021-08-13 11:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 11:18 [PATCH kvm-unit-tests] x86: Added LA57 support to is_canonical Lara Lazier
2021-08-13 11:29 ` Paolo Bonzini [this message]

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=69b1ab87-239e-742f-3839-cb194ac6ec94@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=laramglazier@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.