mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liran Alon <liran.alon@oracle.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: LAPIC: ARBPRI is a reserved register for x2APIC
Date: Fri, 5 Jul 2019 15:37:41 +0300	[thread overview]
Message-ID: <D76638DF-1934-4B1C-84CD-FFCE11AA175F@oracle.com> (raw)
In-Reply-To: <1562328872-27659-1-git-send-email-pbonzini@redhat.com>



> On 5 Jul 2019, at 15:14, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> kvm-unit-tests were adjusted to match bare metal behavior, but KVM
> itself was not doing what bare metal does; fix that.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/lapic.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index d6ca5c4f29f1..2e4470f2685a 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1318,7 +1318,7 @@ int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len,
> 	unsigned char alignment = offset & 0xf;
> 	u32 result;
> 	/* this bitmask has a bit cleared for each reserved register */
> -	static const u64 rmask = 0x43ff01ffffffe70cULL;
> +	u64 rmask = 0x43ff01ffffffe70cULL;

Why not rename this to “used_bits_mask” and calculate it properly by macros?
It seems a lot nicer than having a pre-calculated magic.

-Liran

> 
> 	if ((alignment + len) > 4) {
> 		apic_debug("KVM_APIC_READ: alignment error %x %d\n",
> @@ -1326,6 +1326,10 @@ int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len,
> 		return 1;
> 	}
> 
> +	/* ARBPRI is also reserved on x2APIC */
> +	if (apic_x2apic_mode(apic))
> +		rmask &= ~(1 << (APIC_ARBPRI >> 4));
> +
> 	if (offset > 0x3f0 || !(rmask & (1ULL << (offset >> 4)))) {
> 		apic_debug("KVM_APIC_READ: read reserved register %x\n",
> 			   offset);
> -- 
> 1.8.3.1
> 


  reply	other threads:[~2019-07-05 12:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05 12:14 Paolo Bonzini
2019-07-05 12:37 ` Liran Alon [this message]
2019-07-05 12:46   ` Paolo Bonzini
2019-07-05 13:37 ` Nadav Amit
2019-07-05 13:43   ` Paolo Bonzini
2019-07-05 13:47     ` Nadav Amit

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=D76638DF-1934-4B1C-84CD-FFCE11AA175F@oracle.com \
    --to=liran.alon@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®