From: Sean Christopherson <seanjc@google.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/5] KVM: nVMX: Allow VMREAD when Enlightened VMCS is in use
Date: Fri, 7 Jan 2022 23:18:13 +0000 [thread overview]
Message-ID: <YdjKNcTcd2rFaA27@google.com> (raw)
In-Reply-To: <20220107102859.1471362-6-vkuznets@redhat.com>
On Fri, Jan 07, 2022, Vitaly Kuznetsov wrote:
> Hyper-V TLFS explicitly forbids VMREAD and VMWRITE instructions when
> Enlightened VMCS interface is in use:
>
> "Any VMREAD or VMWRITE instructions while an enlightened VMCS is
> active is unsupported and can result in unexpected behavior.""
>
> Windows 11 + WSL2 seems to ignore this, attempts to VMREAD VMCS field
> 0x4404 ("VM-exit interruption information") are observed. Failing
> these attempts with nested_vmx_failInvalid() makes such guests
> unbootable.
>
> Microsoft confirms this is a Hyper-V bug and claims that it'll get fixed
> eventually but for the time being we need a workaround. (Temporary) allow
> VMREAD to get data from the currently loaded Enlightened VMCS.
>
> Note: VMWRITE instructions remain forbidden, it is not clear how to
> handle them properly and hopefully won't ever be needed.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
Reviewed-by: Sean Christopherson <seanjc@google.com>
> + /*
> + * Hyper-V TLFS (as of 6.0b) explicitly states, that while an
> + * enlightened VMCS is active VMREAD/VMWRITE instructions are
> + * unsupported. Unfortunately, certain versions of Windows 11
> + * don't comply with this requirement which is not enforced in
> + * genuine Hyper-V so KVM has implement a workaround allowing to
Nit, missing a "to". But rather say what KVM "has" to do, maybe this?
* genuine Hyper-V. Allow VMREAD from an enlightened VMCS as a
* workaround, as misbehaving guests will panic on VM-Fail.
> + * read from enlightened VMCS with VMREAD.
> + * Note, enlightened VMCS is incompatible with shadow VMCS so
> + * all VMREADs from L2 should go to L1.
> + */
> + if (WARN_ON_ONCE(is_guest_mode(vcpu)))
> + return nested_vmx_failInvalid(vcpu);
>
> - /* Read the field, zero-extended to a u64 value */
> - value = vmcs12_read_any(vmcs12, field, offset);
> + offset = evmcs_field_offset(field, NULL);
> + if (offset < 0)
> + return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT);
> +
> + /* Read the field, zero-extended to a u64 value */
> + value = evmcs_read_any(vmx->nested.hv_evmcs, field, offset);
> + }
>
> /*
> * Now copy part of this value to register or memory, as requested.
> --
> 2.33.1
>
prev parent reply other threads:[~2022-01-07 23:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-07 10:28 [PATCH v2 0/5] KVM: nVMX: Fix Windows 11 + WSL2 + Enlightened VMCS Vitaly Kuznetsov
2022-01-07 10:28 ` [PATCH v2 1/5] KVM: nVMX: Also filter MSR_IA32_VMX_TRUE_PINBASED_CTLS when eVMCS Vitaly Kuznetsov
2022-01-07 10:28 ` [PATCH v2 2/5] KVM: nVMX: eVMCS: Filter out VM_EXIT_SAVE_VMX_PREEMPTION_TIMER Vitaly Kuznetsov
2022-01-07 10:28 ` [PATCH v2 3/5] KVM: nVMX: Rename vmcs_to_field_offset{,_table} Vitaly Kuznetsov
2022-01-07 23:09 ` Sean Christopherson
2022-01-07 10:28 ` [PATCH v2 4/5] KVM: nVMX: Implement evmcs_field_offset() suitable for handle_vmread() Vitaly Kuznetsov
2022-01-07 10:28 ` [PATCH v2 5/5] KVM: nVMX: Allow VMREAD when Enlightened VMCS is in use Vitaly Kuznetsov
2022-01-07 23:18 ` Sean Christopherson [this message]
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=YdjKNcTcd2rFaA27@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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).