kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: Sean Christopherson <seanjc@google.com>
Cc: kvm list <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 07/12] KVM: nVMX: Disable vmcs02 posted interrupts if vmcs12 PID isn't mappable
Date: Mon, 24 May 2021 16:27:16 -0700	[thread overview]
Message-ID: <CALMp9eQikiZRzX+UtdTW4rHO+jT2uo5xmrtGGs1V96kEZAHh_A@mail.gmail.com> (raw)
In-Reply-To: <YKw1FGuq5YzSiael@google.com>

On Mon, May 24, 2021 at 4:22 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Thu, May 20, 2021, Jim Mattson wrote:
> > Don't allow posted interrupts to modify a stale posted interrupt
> > descriptor (including the initial value of 0).
> >
> > Empirical tests on real hardware reveal that a posted interrupt
> > descriptor referencing an unbacked address has PCI bus error semantics
> > (reads as all 1's; writes are ignored). However, kvm can't distinguish
> > unbacked addresses from device-backed (MMIO) addresses, so it should
> > really ask userspace for an MMIO completion. That's overly
> > complicated, so just punt with KVM_INTERNAL_ERROR.
> >
> > Don't return the error until the posted interrupt descriptor is
> > actually accessed. We don't want to break the existing kvm-unit-tests
> > that assume they can launch an L2 VM with a posted interrupt
> > descriptor that references MMIO space in L1.
> >
> > Fixes: 6beb7bd52e48 ("kvm: nVMX: Refactor nested_get_vmcs12_pages()")
> > Signed-off-by: Jim Mattson <jmattson@google.com>
> > ---
> >  arch/x86/kvm/vmx/nested.c | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> > index 706c31821362..defd42201bb4 100644
> > --- a/arch/x86/kvm/vmx/nested.c
> > +++ b/arch/x86/kvm/vmx/nested.c
> > @@ -3175,6 +3175,15 @@ static bool nested_get_vmcs12_pages(struct kvm_vcpu *vcpu)
> >                               offset_in_page(vmcs12->posted_intr_desc_addr));
> >                       vmcs_write64(POSTED_INTR_DESC_ADDR,
> >                                    pfn_to_hpa(map->pfn) + offset_in_page(vmcs12->posted_intr_desc_addr));
> > +             } else {
> > +                     /*
> > +                      * Defer the KVM_INTERNAL_ERROR exit until
> > +                      * someone tries to trigger posted interrupt
> > +                      * processing on this vCPU, to avoid breaking
> > +                      * existing kvm-unit-tests.
>
> Run the lines out to 80 chars.  Also, can we change the comment to tie it to
> CPU behavior in someway?  A few years down the road, "existing kvm-unit-tests"
> may not have any relevant meaning, and it's not like kvm-unit-tests is bug free
> either.  E.g. something like
>
>                         /*
>                          * Defer the KVM_INTERNAL_ERROR exit until posted
>                          * interrupt processing actually occurs on this vCPU.
>                          * Until that happens, the descriptor is not accessed,
>                          * and userspace can technically rely on that behavior.
>                          */
Okay...except for the fact that kvm will rather gratuitously process
posted interrupts in situations where hardware won't. That makes it
difficult to tie this to hardware behavior.

  reply	other threads:[~2021-05-24 23:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 23:03 [PATCH 00/12] KVM: nVMX: Fix vmcs02 PID use-after-free issue Jim Mattson
2021-05-20 23:03 ` [PATCH 01/12] KVM: x86: Remove guest mode check from kvm_check_nested_events Jim Mattson
2021-05-20 23:03 ` [PATCH 02/12] KVM: x86: Wake up a vCPU when kvm_check_nested_events fails Jim Mattson
2021-05-24 15:43   ` Paolo Bonzini
2021-05-24 16:39     ` Jim Mattson
2021-05-24 16:43       ` Paolo Bonzini
2021-05-24 17:10         ` Jim Mattson
2021-05-24 23:10         ` Sean Christopherson
2021-05-24 23:23           ` Jim Mattson
2021-05-24 23:24             ` Sean Christopherson
2021-05-24 23:29               ` Jim Mattson
2021-05-24 23:34                 ` Sean Christopherson
2021-05-20 23:03 ` [PATCH 03/12] KVM: nVMX: Add a return code to vmx_complete_nested_posted_interrupt Jim Mattson
2021-05-20 23:03 ` [PATCH 04/12] KVM: x86: Add a return code to inject_pending_event Jim Mattson
2021-05-20 23:03 ` [PATCH 05/12] KVM: x86: Add a return code to kvm_apic_accept_events Jim Mattson
2021-05-25 19:24   ` Reiji Watanabe
2021-05-25 20:35     ` Jim Mattson
2021-05-20 23:03 ` [PATCH 06/12] KVM: nVMX: Fail on MMIO completion for nested posted interrupts Jim Mattson
2021-05-20 23:03 ` [PATCH 07/12] KVM: nVMX: Disable vmcs02 posted interrupts if vmcs12 PID isn't mappable Jim Mattson
2021-05-24 23:21   ` Sean Christopherson
2021-05-24 23:27     ` Jim Mattson [this message]
2021-05-24 23:45       ` Sean Christopherson
2021-05-25  0:03         ` Jim Mattson
2021-05-25  0:11           ` Sean Christopherson
2021-05-25  0:15             ` Jim Mattson
2021-05-25  0:57               ` Sean Christopherson
2021-05-20 23:03 ` [PATCH 08/12] KVM: selftests: Move APIC definitions into a separate file Jim Mattson
2021-05-20 23:03 ` [PATCH 09/12] KVM: selftests: Hoist APIC functions out of individual tests Jim Mattson
2021-05-20 23:03 ` [PATCH 10/12] KVM: selftests: Introduce x2APIC register manipulation functions Jim Mattson
2021-05-20 23:03 ` [PATCH 11/12] KVM: selftests: Introduce prepare_tpr_shadow Jim Mattson
2021-05-20 23:03 ` [PATCH 12/12] KVM: selftests: Add a test of an unbacked nested PI descriptor Jim Mattson
2021-05-21  0:58 ` [PATCH 00/12] KVM: nVMX: Fix vmcs02 PID use-after-free issue Sean Christopherson
2021-05-21 12:04 ` Jim Mattson
2021-05-24 15:50 ` Paolo Bonzini
2021-05-24 16:46 ` 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=CALMp9eQikiZRzX+UtdTW4rHO+jT2uo5xmrtGGs1V96kEZAHh_A@mail.gmail.com \
    --to=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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;
as well as URLs for NNTP newsgroup(s).