public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Marc Orr <marcorr@google.com>, Ben Gardon <bgardon@google.com>,
	Venkatesh Srinivas <venkateshs@chromium.org>
Subject: Re: [PATCH 2/6] KVM: x86: Inject #GP on x2APIC WRMSR that sets reserved bits 63:32
Date: Sun, 08 Jan 2023 18:41:36 +0200	[thread overview]
Message-ID: <d1dd4636735912700198cfade57670a968ce433f.camel@redhat.com> (raw)
In-Reply-To: <20230107011025.565472-3-seanjc@google.com>

On Sat, 2023-01-07 at 01:10 +0000, Sean Christopherson wrote:
> Reject attempts to set bits 63:32 for 32-bit x2APIC registers, i.e. all
> x2APIC registers except ICR.  Per Intel's SDM:
> 
>   Non-zero writes (by WRMSR instruction) to reserved bits to these
>   registers will raise a general protection fault exception
> 
> Opportunistically fix a typo in a nearby comment.
> 
> Reported-by: Marc Orr <marcorr@google.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Christopherson <seanjc@google.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 f77da92c6ea6..bf53e4752f30 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -3108,13 +3108,17 @@ static int kvm_lapic_msr_read(struct kvm_lapic *apic, u32 reg, u64 *data)
>  static int kvm_lapic_msr_write(struct kvm_lapic *apic, u32 reg, u64 data)
>  {
>  	/*
> -	 * ICR is a 64-bit register in x2APIC mode (and Hyper'v PV vAPIC) and
> +	 * ICR is a 64-bit register in x2APIC mode (and Hyper-V PV vAPIC) and
>  	 * can be written as such, all other registers remain accessible only
>  	 * through 32-bit reads/writes.
>  	 */
>  	if (reg == APIC_ICR)
>  		return kvm_x2apic_icr_write(apic, data);
>  
> +	/* Bits 63:32 are reserved in all other registers. */
> +	if (data >> 32)
> +		return 1;
> +
>  	return kvm_lapic_reg_write(apic, reg, (u32)data);
>  }
>  
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky


  reply	other threads:[~2023-01-08 16:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07  1:10 [PATCH 0/6] KVM: x86: x2APIC reserved bits/regs fixes Sean Christopherson
2023-01-07  1:10 ` [PATCH 1/6] KVM: x86: Inject #GP if WRMSR sets reserved bits in APIC Self-IPI Sean Christopherson
2023-01-08 16:40   ` Maxim Levitsky
2023-01-07  1:10 ` [PATCH 2/6] KVM: x86: Inject #GP on x2APIC WRMSR that sets reserved bits 63:32 Sean Christopherson
2023-01-08 16:41   ` Maxim Levitsky [this message]
2023-01-07  1:10 ` [PATCH 3/6] KVM: x86: Mark x2APIC DFR reg as non-existent for x2APIC Sean Christopherson
2023-01-08 16:43   ` Maxim Levitsky
2023-01-07  1:10 ` [PATCH 4/6] KVM: x86: Split out logic to generate "readable" APIC regs mask to helper Sean Christopherson
2023-01-08 17:38   ` Maxim Levitsky
2023-01-07  1:10 ` [PATCH 5/6] KVM: VMX: Always intercept accesses to unsupported "extended" x2APIC regs Sean Christopherson
2023-01-08 18:07   ` Maxim Levitsky
2023-01-09 16:32     ` Sean Christopherson
2023-01-09 17:25   ` Jim Mattson
2023-01-07  1:10 ` [PATCH 6/6] KVM: VMX: Intercept reads to invalid and write-only x2APIC registers Sean Christopherson
2023-01-08 18:09   ` Maxim Levitsky
2023-01-13 18:06 ` [PATCH 0/6] KVM: x86: x2APIC reserved bits/regs fixes Paolo Bonzini
2023-01-13 18:41   ` Sean Christopherson
2023-01-20  0:19 ` Sean Christopherson

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=d1dd4636735912700198cfade57670a968ce433f.camel@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=bgardon@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=venkateshs@chromium.org \
    /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