From: Like Xu <like.xu.linux@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>,
Jim Mattson <jmattson@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [DROP][PATCH] KVM: x86: Fix the #GP(0) and #UD conditions for XSETBV emulation
Date: Thu, 20 Jan 2022 15:48:19 +0800 [thread overview]
Message-ID: <92b16faf-c9a7-4be3-43f7-3450259346e9@gmail.com> (raw)
In-Reply-To: <0d7ed850-8791-42b4-ef9a-bbaa8c52279e@redhat.com>
On 17/1/2022 7:18 pm, Paolo Bonzini wrote:
> On 1/17/22 10:44, Like Xu wrote:
>>> Also, the "Fixes" tag is not really correct as the behavior was the same
>>> before. Rather, it fixes commit 02d4160fbd76 ("x86: KVM: add xsetbv to the
>>
>> It seems the original code comes from 81dd35d42c9a ("KVM: SVM: Add xsetbv
>> intercept").
>> 2acf923e38 ("KVM: VMX: Enable XSAVE/XRSTOR for guest") and 92f9895c146d.
>>
>>> emulator", 2019-08-22). Checking OSXSAVE is a bug in the emulator path, even
>>> though it's not needed in the XSETBV vmexit case.
>>
>> The kvm_emulate_xsetbv() has been removed from the emulator path.
>> I'm not really sure why it's not needed in the XSETBV vmexit case. More details ?
>
> Nevermind, I confused AMD (where #UD is generated before checking for
> exceptions) with Intel where it's unconditional.
>
> So the bug should be there since 2acf923e38 by executing XSETBV with
> CR4.XSAVE=0. If so, please include a testcase.
In the testcase "executing XSETBV with CR4.XSAVE=0",
- on the VMX, #UD delivery does not require vm-exit;
- on the SVM, #UD is trapped but goes to the ud_interception() path;
There is no room to run this pointless patch.
Thank you and sorry for the noise.
>
> Paolo
>
>>>
>>> Thanks,
>>>
>>> Paolo
>>>
>>>> + if ((is_protmode(vcpu) && static_call(kvm_x86_get_cpl)(vcpu) != 0) ||
>>>> __kvm_set_xcr(vcpu, kvm_rcx_read(vcpu), kvm_read_edx_eax(vcpu))) {
>>>> kvm_inject_gp(vcpu, 0);
>>>> return 1;
>>>
>>>
>>
>
>
next prev parent reply other threads:[~2022-01-20 7:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 7:24 [PATCH] KVM: x86: Fix the #GP(0) and #UD conditions for XSETBV emulation Like Xu
2022-01-17 8:31 ` Paolo Bonzini
2022-01-17 9:44 ` Like Xu
2022-01-17 11:18 ` Paolo Bonzini
2022-01-20 7:48 ` Like Xu [this message]
2022-01-20 9:17 ` [DROP][PATCH] " Paolo Bonzini
2022-01-20 9:31 ` Xiaoyao Li
2022-01-20 9:49 ` 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=92b16faf-c9a7-4be3-43f7-3450259346e9@gmail.com \
--to=like.xu.linux@gmail.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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).