All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Venkatesh Srinivas <venkateshs@chromium.org>
Cc: kvm@vger.kernel.org, marcorr@google.com
Subject: Re: [PATCH v2 1/2] KVM: Inject #GP on invalid write to APIC_SELF_IPI register
Date: Wed, 25 May 2022 18:42:35 +0000	[thread overview]
Message-ID: <Yo54m3UlJNImnepr@google.com> (raw)
In-Reply-To: <20220525173933.1611076-1-venkateshs@chromium.org>

On Wed, May 25, 2022, Venkatesh Srinivas wrote:
> From: Marc Orr <marcorr@google.com>
> 
> From: Venkatesh Srinivas <venkateshs@chromium.org>

Only Marc should have an explicit From:.  git am processes only the first From:,
e.g. your From: line ends up in the changelog.

> The upper bytes of the x2APIC APIC_SELF_IPI register are reserved.

Uber nit, please be more precise than "upper bytes".  The comment about "Bits 7:0"
saved me from having to lookup up APIC_VECTOR_MASK, but it'd be nice to have that
in the changelog.

E.g.

  Inject a #GP if the guest attempts to set reserved bits in the x2APIC-only
  Self-IPI register.  Bits 7:0 hold the vector, all other bits are reserved.

> Inject a #GP into the guest if any of these reserved bits are set.
> 
> Signed-off-by: Marc Orr <marcorr@google.com>
> Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>
> ---
>  arch/x86/kvm/lapic.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 21ab69db689b..6f8522e8c492 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -2169,10 +2169,16 @@ static int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
>  		break;
>  
>  	case APIC_SELF_IPI:
> -		if (apic_x2apic_mode(apic))
> -			kvm_apic_send_ipi(apic, APIC_DEST_SELF | (val & APIC_VECTOR_MASK), 0);
> -		else
> +		/*
> +		 * Self-IPI exists only when x2APIC is enabled.  Bits 7:0 hold
> +		 * the vector, everything else is reserved.
> +		 */
> +		if (!apic_x2apic_mode(apic) || (val & ~APIC_VECTOR_MASK)) {
>  			ret = 1;
> +			break;
> +		}
> +		kvm_lapic_reg_write(apic, APIC_ICR,
> +				    APIC_DEST_SELF | (val & APIC_VECTOR_MASK));
>  		break;
>  	default:
>  		ret = 1;
> -- 
> 2.36.1.124.g0e6072fb45-goog
> 

  parent reply	other threads:[~2022-05-25 18:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 17:39 [PATCH v2 1/2] KVM: Inject #GP on invalid write to APIC_SELF_IPI register Venkatesh Srinivas
2022-05-25 17:39 ` [PATCH v2 2/2] KVM: Inject #GP on invalid writes to x2APIC registers Venkatesh Srinivas
2022-05-25 18:30   ` Sean Christopherson
2022-05-27  8:15   ` [KVM] 317463a437: kvm-unit-tests.apic-split.fail kernel test robot
2022-05-27  8:15     ` kernel test robot
2022-05-25 18:42 ` Sean Christopherson [this message]
2022-09-14 21:46 ` [PATCH v2 1/2] KVM: Inject #GP on invalid write to APIC_SELF_IPI register Jim Mattson

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=Yo54m3UlJNImnepr@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=marcorr@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 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.