From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jim Mattson <jmattson@google.com>
Cc: Aaron Lewis <aaronlewis@google.com>,
Babu Moger <Babu.Moger@amd.com>,
Yang Weijiang <weijiang.yang@intel.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
kvm list <kvm@vger.kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 2/5] KVM: VMX: Use wrmsr for switching between guest and host IA32_XSS
Date: Mon, 14 Oct 2019 16:55:20 -0700 [thread overview]
Message-ID: <20191014235520.GP22962@linux.intel.com> (raw)
In-Reply-To: <CALMp9eQg+8eg_2dXaR51MMcjxLU=m48KW8hVoZWA_4mPAhU_uw@mail.gmail.com>
On Mon, Oct 14, 2019 at 02:01:41PM -0700, Jim Mattson wrote:
> On Mon, Oct 14, 2019 at 12:05 PM Sean Christopherson
> <sean.j.christopherson@intel.com> wrote:
> >
> > On Sat, Oct 12, 2019 at 10:36:15AM -0700, Jim Mattson wrote:
> > > On Fri, Oct 11, 2019 at 5:18 PM Sean Christopherson
> > > <sean.j.christopherson@intel.com> wrote:
> > > >
> > > > On Fri, Oct 11, 2019 at 12:40:29PM -0700, Aaron Lewis wrote:
> > > > > @@ -5887,6 +5887,9 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
> > > > > {
> > > > > struct vcpu_svm *svm = to_svm(vcpu);
> > > > >
> > > > > + vcpu->arch.xsaves_enabled = guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
> > > > > + boot_cpu_has(X86_FEATURE_XSAVES);
> > > >
> > > > This looks very much like a functional change to SVM, which feels wrong
> > > > for a patch with a subject of "KVM: VMX: Use wrmsr for switching between
> > > > guest and host IA32_XSS" feels wrong. Shouldn't this be unconditionally
> > > > set false in this patch, and then enabled in " kvm: svm: Add support for
> > > > XSAVES on AMD"?
> > >
> > > Nothing is being enabled here. Vcpu->arch.xsaves_enabled simply tells
> > > us whether or not the guest can execute the XSAVES instruction. Any
> > > guest with the ability to set CR4.OSXSAVE on an AMD host that supports
> > > XSAVES can use the instruction.
> >
> > Not enabling per se, but it's a functional change as it means MSR_IA32_XSS
> > will be written in kvm_load_{guest,host}_xsave_controls() if host_xss!=0.
>
> Fortunately, host_xss is guaranteed to be zero for the nonce. :-)
And then someone backports something and things go sideways.
> Perhaps the commit message just needs to be updated? The only
> alternatives I see are:
> 1. Deliberately introducing buggy code to be removed later in the series, or
> 2. Introducing SVM-specific code first, to be removed later in the series.
I'd go with:
2a. Make the change actually local to VMX as the subject implies, and
introduce SVM-specific code in a separate patch, to be removed
later.
Then the series looks like:
KVM: VMX: Remove unneeded check for X86_FEATURE_XSAVE
KVM: VMX: Use wrmsr for switching between guest and host IA32_XSS
kvm: svm: Add support for XSAVES on AMD
KVM: x86: Move IA32_XSS handling to common x86 code
KVM: x86: Add IA32_XSS to the emulated_msrs list
It'd mean introducing vcpu->arch.xsaves_enabled in the VMX patch and
temporarily having it unused by SVM, but that's minor and can't backfire
if host_xss suddently is non-zero.
Side topic, I'm pretty sure vcpu->guest_xcr0_loaded is a waste of an 'int'
and a conditional branch. VMX and SVM are the only users, and both
unconditionally pair kvm_load_guest_xcr0() with kvm_put_guest_xcr0().
Removing the useless flag as another prerequisite patch would make the
intermediate VMX and SVM patches slightly less awkward as they wouldn't
have to decide between adding a kludgy check on guest_xcr0_loaded and
ignoring it altogether.
next prev parent reply other threads:[~2019-10-14 23:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-11 19:40 [PATCH v2 0/5] Add support for XSAVES on AMD and unify it with Intel Aaron Lewis
2019-10-11 19:40 ` [PATCH v2 1/5] KVM: VMX: Remove unneeded check for X86_FEATURE_XSAVE Aaron Lewis
2019-10-11 19:40 ` [PATCH v2 2/5] KVM: VMX: Use wrmsr for switching between guest and host IA32_XSS Aaron Lewis
2019-10-12 0:18 ` Sean Christopherson
2019-10-12 17:36 ` Jim Mattson
2019-10-14 19:05 ` Sean Christopherson
2019-10-14 21:01 ` Jim Mattson
2019-10-14 23:55 ` Sean Christopherson [this message]
2019-10-11 19:40 ` [PATCH v2 3/5] kvm: svm: Add support for XSAVES on AMD Aaron Lewis
2019-10-11 19:40 ` [PATCH v2 4/5] kvm: x86: Add IA32_XSS to the emulated_msrs list Aaron Lewis
2019-10-11 19:40 ` [PATCH v2 5/5] kvm: tests: Add test to verify MSR_IA32_XSS Aaron Lewis
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=20191014235520.GP22962@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=Babu.Moger@amd.com \
--cc=aaronlewis@google.com \
--cc=bigeasy@linutronix.de \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=weijiang.yang@intel.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).