From: Sean Christopherson <seanjc@google.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Alexandru Matei <alexandru.matei@uipath.com>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Mihai Petrisor <mihai.petrisor@uipath.com>,
Viorel Canja <viorel.canja@uipath.com>
Subject: Re: [PATCH v3] KVM: VMX: Fix crash due to uninitialized current_vmcs
Date: Mon, 23 Jan 2023 19:00:45 +0000 [thread overview]
Message-ID: <Y87ZXRBfY9RThKHT@google.com> (raw)
In-Reply-To: <878rhtchjo.fsf@ovpn-194-126.brq.redhat.com>
On Mon, Jan 23, 2023, Vitaly Kuznetsov wrote:
> Alexandru Matei <alexandru.matei@uipath.com> writes:
>
> > KVM enables 'Enlightened VMCS' and 'Enlightened MSR Bitmap' when running as
> > a nested hypervisor on top of Hyper-V. When MSR bitmap is updated,
> > evmcs_touch_msr_bitmap function uses current_vmcs per-cpu variable to mark
> > that the msr bitmap was changed.
...
> > @@ -219,7 +223,7 @@ static inline u64 evmcs_read64(unsigned long field) { return 0; }
> > static inline u32 evmcs_read32(unsigned long field) { return 0; }
> > static inline u16 evmcs_read16(unsigned long field) { return 0; }
> > static inline void evmcs_load(u64 phys_addr) {}
> > -static inline void evmcs_touch_msr_bitmap(void) {}
> > +static inline void evmcs_touch_msr_bitmap(struct hv_enlightened_vmcs *evmcs) {}
> > #endif /* IS_ENABLED(CONFIG_HYPERV) */
> >
> > #define EVMPTR_INVALID (-1ULL)
> > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> > index fe5615fd8295..1d482a80bca8 100644
> > --- a/arch/x86/kvm/vmx/vmx.c
> > +++ b/arch/x86/kvm/vmx/vmx.c
> > @@ -3869,7 +3869,7 @@ static void vmx_msr_bitmap_l01_changed(struct vcpu_vmx *vmx)
> > * bitmap has changed.
> > */
> > if (static_branch_unlikely(&enable_evmcs))
> > - evmcs_touch_msr_bitmap();
> > + evmcs_touch_msr_bitmap((struct hv_enlightened_vmcs *)vmx->vmcs01.vmcs);
> >
> > vmx->nested.force_msr_bitmap_recalc = true;
> > }
>
> Just in case we decide to follow this path and not merge
> evmcs_touch_msr_bitmap() into vmx_msr_bitmap_l01_changed():
This is the only approach that I'm outright opposed to. The evmcs_touch_msr_bitmap()
stub is a lie in that it should never be reached with CONFIG_HYPERV=n, i.e. should
really WARN. Ditto for the WARN_ON_ONCE() in the actual helper; if vmx->vmcs01.vmcs
is NULL then KVM is completely hosed.
KVM already consumes hv_enlightenments_control.msr_bitmap in vmx.c and in nested.c,
shoving this case into hyperv.h but leaving those in VMX proper is odd/kludgy.
next prev parent reply other threads:[~2023-01-23 19:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 16:29 [PATCH v3] KVM: VMX: Fix crash due to uninitialized current_vmcs Alexandru Matei
2023-01-23 17:00 ` Vitaly Kuznetsov
2023-01-23 19:00 ` Sean Christopherson [this message]
2023-01-23 20:03 ` Alexandru Matei
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=Y87ZXRBfY9RThKHT@google.com \
--to=seanjc@google.com \
--cc=alexandru.matei@uipath.com \
--cc=kvm@vger.kernel.org \
--cc=mihai.petrisor@uipath.com \
--cc=pbonzini@redhat.com \
--cc=viorel.canja@uipath.com \
--cc=vkuznets@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 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.