From: Paolo Bonzini <pbonzini@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>, kvm@vger.kernel.org
Cc: "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Sean Christopherson <seanjc@google.com>,
Ingo Molnar <mingo@redhat.com>, Jim Mattson <jmattson@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>,
Wanpeng Li <wanpengli@tencent.com>,
Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH 2/2] KVM: nSVM: improve SYSENTER emulation on AMD
Date: Tue, 16 Mar 2021 09:16:48 +0100 [thread overview]
Message-ID: <f1ee6230-760e-b614-5290-663b44fe1436@redhat.com> (raw)
In-Reply-To: <1a4f35e356c50e38916acef6c86175b24efca0a3.camel@redhat.com>
On 15/03/21 19:19, Maxim Levitsky wrote:
> On Mon, 2021-03-15 at 18:56 +0100, Paolo Bonzini wrote:
>> On 15/03/21 18:43, Maxim Levitsky wrote:
>>> + if (!guest_cpuid_is_intel(vcpu)) {
>>> + /*
>>> + * If hardware supports Virtual VMLOAD VMSAVE then enable it
>>> + * in VMCB and clear intercepts to avoid #VMEXIT.
>>> + */
>>> + if (vls) {
>>> + svm_clr_intercept(svm, INTERCEPT_VMLOAD);
>>> + svm_clr_intercept(svm, INTERCEPT_VMSAVE);
>>> + svm->vmcb->control.virt_ext |= VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK;
>>> + }
>>> + /* No need to intercept these msrs either */
>>> + set_msr_interception(vcpu, svm->msrpm, MSR_IA32_SYSENTER_EIP, 1, 1);
>>> + set_msr_interception(vcpu, svm->msrpm, MSR_IA32_SYSENTER_ESP, 1, 1);
>>> + }
>>
>> An "else" is needed here to do the opposite setup (removing the "if
>> (vls)" from init_vmcb).
>
> init_vmcb currently set the INTERCEPT_VMLOAD and INTERCEPT_VMSAVE and it doesn't enable vls
There's also this towards the end of the function:
/*
* If hardware supports Virtual VMLOAD VMSAVE then enable it
* in VMCB and clear intercepts to avoid #VMEXIT.
*/
if (vls) {
svm_clr_intercept(svm, INTERCEPT_VMLOAD);
svm_clr_intercept(svm, INTERCEPT_VMSAVE);
svm->vmcb->control.virt_ext |=
VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK;
}
> thus there is nothing to do if I don't want to enable vls.
> It seems reasonable to me.
>
> Both msrs I marked as '.always = false' in the
> 'direct_access_msrs', which makes them be intercepted by the default.
> If I were to use '.always = true' it would feel a bit wrong as the intercept is not always
> enabled.
I agree that .always = false is correct.
> What do you think?
You can set the CPUID multiple times, so you could go from AMD to Intel
and back.
Thanks,
Paolo
next prev parent reply other threads:[~2021-03-16 8:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 17:43 [PATCH 0/2] KVM: x86: nSVM: fixes for SYSENTER emulation Maxim Levitsky
2021-03-15 17:43 ` [PATCH 1/2] KVM: x86: add guest_cpuid_is_intel Maxim Levitsky
2021-03-15 17:43 ` [PATCH 2/2] KVM: nSVM: improve SYSENTER emulation on AMD Maxim Levitsky
2021-03-15 17:56 ` Paolo Bonzini
2021-03-15 18:19 ` Maxim Levitsky
2021-03-16 8:16 ` Paolo Bonzini [this message]
2021-03-16 10:39 ` Maxim Levitsky
2021-04-01 11:16 [PATCH 0/2] KVM: x86: nSVM: fixes for SYSENTER emulation Maxim Levitsky
2021-04-01 11:16 ` [PATCH 2/2] KVM: nSVM: improve SYSENTER emulation on AMD Maxim Levitsky
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=f1ee6230-760e-b614-5290-663b44fe1436@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®