From: Sean Christopherson <seanjc@google.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Jing Liu <jing2.liu@linux.intel.com>,
pbonzini@redhat.com, Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] kvm: x86: Revise guest_fpu xcomp_bv field
Date: Mon, 8 Feb 2021 09:24:30 -0800 [thread overview]
Message-ID: <YCFzztFESzcnKRqQ@google.com> (raw)
In-Reply-To: <4e4b37d1-e2f8-6757-003c-d19ae8184088@intel.com>
On Mon, Feb 08, 2021, Dave Hansen wrote:
> On 2/8/21 8:16 AM, Jing Liu wrote:
> > -#define XSTATE_COMPACTION_ENABLED (1ULL << 63)
> > -
> > static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
> > {
> > struct xregs_state *xsave = &vcpu->arch.guest_fpu->state.xsave;
> > @@ -4494,7 +4492,8 @@ static void load_xsave(struct kvm_vcpu *vcpu, u8 *src)
> > /* Set XSTATE_BV and possibly XCOMP_BV. */
> > xsave->header.xfeatures = xstate_bv;
> > if (boot_cpu_has(X86_FEATURE_XSAVES))
> > - xsave->header.xcomp_bv = host_xcr0 | XSTATE_COMPACTION_ENABLED;
> > + xsave->header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
> > + xfeatures_mask_all;
This is wrong, xfeatures_mask_all also tracks supervisor states.
> Are 'host_xcr0' and 'xfeatures_mask_all' really interchangeable? If so,
> shouldn't we just remove 'host_xcr0' everywhere?
I think so? But use xfeatures_mask_user().
In theory, host_xss can also be replaced with the _supervisor() and _dynamic()
variants. That code needs a good hard look at the _dynamic() features, which is
currently just architectural LBRs. E.g. I wouldn't be surprised if KVM currently
fails to save/restore arch LBRs due to the bit not being set in host_xss.
next prev parent reply other threads:[~2021-02-08 17:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-08 16:16 [PATCH v1] kvm: x86: Revise guest_fpu xcomp_bv field Jing Liu
2021-02-08 15:23 ` Dave Hansen
2021-02-08 17:24 ` Sean Christopherson [this message]
2021-02-22 3:21 ` Liu, Jing2
2021-02-22 16:06 ` Sean Christopherson
2021-02-23 3:06 ` Liu, Jing2
2021-02-24 20:40 ` Sean Christopherson
2021-02-25 2:02 ` Liu, Jing2
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=YCFzztFESzcnKRqQ@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=jing2.liu@linux.intel.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=pbonzini@redhat.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 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.