From: Sean Christopherson <seanjc@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com
Subject: Re: [PATCH v2 2/6] KVM: x86: Clear all supported AVX-512 xfeatures if they are not all set
Date: Wed, 4 Jan 2023 16:33:34 +0000 [thread overview]
Message-ID: <Y7WqXkjW16aA3gaT@google.com> (raw)
In-Reply-To: <20221230162442.3781098-3-aaronlewis@google.com>
On Fri, Dec 30, 2022, Aaron Lewis wrote:
> Be a good citizen and don't allow any of the supported AVX-512
> xfeatures[1] to be set if they can't all be set. That way userspace or
> a guest doesn't fail if it attempts to set them in XCR0.
The form letter shortlog+changelo+code doesn't fit AVX-512. There's only one
AVX512 flag, SSE and AVX and are pure prerequisites and exist independently of
AVX512.
> It's important to note that in order to set any of the AVX-512
> xfeatures, the SSE[bit-1] and AVX[bit-2] must also be set.
>
> [1] CPUID.(EAX=0DH,ECX=0):EAX.OPMASK[bit-5]
> CPUID.(EAX=0DH,ECX=0):EAX.ZMM_Hi256[bit-6]
> CPUID.(EAX=0DH,ECX=0):EAX.ZMM_Hi16_ZMM[bit-7]
>
> Suggested-by: Jim Mattson <jmattson@google.com>
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
> arch/x86/kvm/cpuid.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 2431c46d456b4..89ad8cd865173 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -862,6 +862,10 @@ static u64 sanitize_xcr0(u64 xcr0) {
> if ((xcr0 & mask) != mask)
> xcr0 &= ~mask;
>
> + mask = XFEATURE_MASK_SSE | XFEATURE_MASK_YMM | XFEATURE_MASK_AVX512;
Checking AVX512 is unnecessary. If it's not set, the AND-NOT is a nop.
> + if ((xcr0 & mask) != mask)
> + xcr0 &= ~XFEATURE_MASK_AVX512;
This can be:
if (!(xcr0 & XFEATURE_MASK_SSE) || !(xcr0 & XFEATURE_MASK_YMM))
xcr0 &= ~XFEATURE_MASK_AVX512
to better capture the dependency.
next prev parent reply other threads:[~2023-01-04 16:33 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-30 16:24 [PATCH v2 0/6] Clean up the supported xfeatures Aaron Lewis
2022-12-30 16:24 ` [PATCH v2 1/6] KVM: x86: Clear all supported MPX xfeatures if they are not all set Aaron Lewis
2023-01-02 15:03 ` Xiaoyao Li
2023-01-03 18:47 ` Sean Christopherson
2023-01-03 18:46 ` Sean Christopherson
2023-01-10 14:49 ` Aaron Lewis
2023-01-10 18:32 ` Chang S. Bae
2023-01-12 18:21 ` Mingwei Zhang
2023-01-12 18:44 ` Chang S. Bae
2023-01-12 19:17 ` Mingwei Zhang
2023-01-12 20:31 ` Chang S. Bae
2023-01-12 21:21 ` Mingwei Zhang
2023-01-12 21:33 ` Chang S. Bae
2023-01-13 0:25 ` Mingwei Zhang
2023-01-13 14:43 ` Aaron Lewis
2023-01-17 20:32 ` Chang S. Bae
2023-01-17 22:39 ` Mingwei Zhang
2023-01-18 0:34 ` Chang S. Bae
2022-12-30 16:24 ` [PATCH v2 2/6] KVM: x86: Clear all supported AVX-512 " Aaron Lewis
2023-01-04 16:33 ` Sean Christopherson [this message]
2023-01-04 16:39 ` Sean Christopherson
2022-12-30 16:24 ` [PATCH v2 3/6] KVM: x86: Clear all supported AMX " Aaron Lewis
2022-12-30 16:24 ` [PATCH v2 4/6] KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible Aaron Lewis
2022-12-30 16:24 ` [PATCH v2 5/6] KVM: selftests: Add XFEATURE masks to common code Aaron Lewis
2023-01-04 16:43 ` Sean Christopherson
2022-12-30 16:24 ` [PATCH v2 6/6] KVM: selftests: Add XCR0 Test Aaron Lewis
2023-01-04 17:13 ` Sean Christopherson
2023-01-05 22:46 ` Aaron Lewis
2023-01-05 23:10 ` Sean Christopherson
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=Y7WqXkjW16aA3gaT@google.com \
--to=seanjc@google.com \
--cc=aaronlewis@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.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).