From: Mingwei Zhang <mizhang@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com,
seanjc@google.com
Subject: Re: [PATCH v3 7/8] KVM: selftests: Add XFEATURE masks to common code
Date: Fri, 3 Mar 2023 21:16:18 +0000 [thread overview]
Message-ID: <ZAJjoiZopqIXDoDc@google.com> (raw)
In-Reply-To: <20230224223607.1580880-8-aaronlewis@google.com>
On Fri, Feb 24, 2023, Aaron Lewis wrote:
> Add XFEATURE masks to processor.h to make them more broadly available
> in KVM selftests.
>
> Use the names from the kernel's fpu/types.h for consistency, i.e.
> rename XTILECFG and XTILEDATA to XTILE_CFG and XTILE_DATA respectively.
>
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
> .../selftests/kvm/include/x86_64/processor.h | 17 ++++++++++++++
> tools/testing/selftests/kvm/x86_64/amx_test.c | 22 +++++++------------
> 2 files changed, 25 insertions(+), 14 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
> index 62dc54c8e0c4..ebe83cfe521c 100644
> --- a/tools/testing/selftests/kvm/include/x86_64/processor.h
> +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
> @@ -48,6 +48,23 @@ extern bool host_cpu_is_amd;
> #define X86_CR4_SMAP (1ul << 21)
> #define X86_CR4_PKE (1ul << 22)
>
> +#define XFEATURE_MASK_FP BIT_ULL(0)
> +#define XFEATURE_MASK_SSE BIT_ULL(1)
> +#define XFEATURE_MASK_YMM BIT_ULL(2)
> +#define XFEATURE_MASK_BNDREGS BIT_ULL(3)
> +#define XFEATURE_MASK_BNDCSR BIT_ULL(4)
> +#define XFEATURE_MASK_OPMASK BIT_ULL(5)
> +#define XFEATURE_MASK_ZMM_Hi256 BIT_ULL(6)
> +#define XFEATURE_MASK_Hi16_ZMM BIT_ULL(7)
> +#define XFEATURE_MASK_XTILE_CFG BIT_ULL(17)
> +#define XFEATURE_MASK_XTILE_DATA BIT_ULL(18)
> +
> +#define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK | \
> + XFEATURE_MASK_ZMM_Hi256 | \
> + XFEATURE_MASK_Hi16_ZMM)
> +#define XFEATURE_MASK_XTILE (XFEATURE_MASK_XTILE_DATA | \
> + XFEATURE_MASK_XTILE_CFG)
> +
> /* Note, these are ordered alphabetically to match kvm_cpuid_entry2. Eww. */
> enum cpuid_output_regs {
> KVM_CPUID_EAX,
> diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
> index 4b733ad21831..14a7656620d5 100644
> --- a/tools/testing/selftests/kvm/x86_64/amx_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
> @@ -33,12 +33,6 @@
> #define MAX_TILES 16
> #define RESERVED_BYTES 14
>
> -#define XFEATURE_XTILECFG 17
> -#define XFEATURE_XTILEDATA 18
> -#define XFEATURE_MASK_XTILECFG (1 << XFEATURE_XTILECFG)
> -#define XFEATURE_MASK_XTILEDATA (1 << XFEATURE_XTILEDATA)
> -#define XFEATURE_MASK_XTILE (XFEATURE_MASK_XTILECFG | XFEATURE_MASK_XTILEDATA)
> -
> #define XSAVE_HDR_OFFSET 512
>
> struct xsave_data {
> @@ -187,14 +181,14 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
> __tilerelease();
> GUEST_SYNC(5);
> /* bit 18 not in the XCOMP_BV after xsavec() */
> - set_xstatebv(xsave_data, XFEATURE_MASK_XTILEDATA);
> - __xsavec(xsave_data, XFEATURE_MASK_XTILEDATA);
> - GUEST_ASSERT((get_xstatebv(xsave_data) & XFEATURE_MASK_XTILEDATA) == 0);
> + set_xstatebv(xsave_data, XFEATURE_MASK_XTILE_DATA);
> + __xsavec(xsave_data, XFEATURE_MASK_XTILE_DATA);
> + GUEST_ASSERT((get_xstatebv(xsave_data) & XFEATURE_MASK_XTILE_DATA) == 0);
>
> /* xfd=0x40000, disable amx tiledata */
> - wrmsr(MSR_IA32_XFD, XFEATURE_MASK_XTILEDATA);
> + wrmsr(MSR_IA32_XFD, XFEATURE_MASK_XTILE_DATA);
> GUEST_SYNC(6);
> - GUEST_ASSERT(rdmsr(MSR_IA32_XFD) == XFEATURE_MASK_XTILEDATA);
> + GUEST_ASSERT(rdmsr(MSR_IA32_XFD) == XFEATURE_MASK_XTILE_DATA);
> set_tilecfg(amx_cfg);
> __ldtilecfg(amx_cfg);
> /* Trigger #NM exception */
> @@ -206,11 +200,11 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
>
> void guest_nm_handler(struct ex_regs *regs)
> {
> - /* Check if #NM is triggered by XFEATURE_MASK_XTILEDATA */
> + /* Check if #NM is triggered by XFEATURE_MASK_XTILE_DATA */
> GUEST_SYNC(7);
> - GUEST_ASSERT(rdmsr(MSR_IA32_XFD_ERR) == XFEATURE_MASK_XTILEDATA);
> + GUEST_ASSERT(rdmsr(MSR_IA32_XFD_ERR) == XFEATURE_MASK_XTILE_DATA);
> GUEST_SYNC(8);
> - GUEST_ASSERT(rdmsr(MSR_IA32_XFD_ERR) == XFEATURE_MASK_XTILEDATA);
> + GUEST_ASSERT(rdmsr(MSR_IA32_XFD_ERR) == XFEATURE_MASK_XTILE_DATA);
> /* Clear xfd_err */
> wrmsr(MSR_IA32_XFD_ERR, 0);
> /* xfd=0, enable amx */
> --
> 2.39.2.637.g21b0678d19-goog
>
Can I take your commit into my series? This seems to be closely related
with amx_test itself without much relationship with the xcr0 test.
Thoughts?
next prev parent reply other threads:[~2023-03-03 21:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 22:35 [PATCH v3 0/8] Clean up the supported xfeatures Aaron Lewis
2023-02-24 22:36 ` [PATCH v3 1/8] KVM: x86: Add kvm_permitted_xcr0() Aaron Lewis
2023-03-03 21:13 ` Mingwei Zhang
2023-02-24 22:36 ` [PATCH v3 2/8] KVM: x86: Clear all supported MPX xfeatures if they are not all set Aaron Lewis
2023-03-03 21:23 ` Mingwei Zhang
2023-03-03 22:23 ` Aaron Lewis
2023-03-07 16:32 ` Mingwei Zhang
2023-03-23 20:29 ` Sean Christopherson
2023-03-23 21:10 ` Mingwei Zhang
2023-03-23 21:16 ` Mingwei Zhang
2023-03-23 21:30 ` Sean Christopherson
2023-03-23 21:29 ` Sean Christopherson
2023-02-24 22:36 ` [PATCH v3 3/8] KVM: x86: Clear all supported AVX-512 " Aaron Lewis
2023-02-24 22:36 ` [PATCH v3 4/8] KVM: x86: Clear AVX-512 xfeatures if SSE or AVX is clear Aaron Lewis
2023-02-24 22:36 ` [PATCH v3 5/8] KVM: x86: Clear all supported AMX xfeatures if they are not all set Aaron Lewis
2023-03-03 21:12 ` Mingwei Zhang
2023-02-24 22:36 ` [PATCH v3 6/8] KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible Aaron Lewis
2023-03-03 21:24 ` Mingwei Zhang
2023-02-24 22:36 ` [PATCH v3 7/8] KVM: selftests: Add XFEATURE masks to common code Aaron Lewis
2023-03-03 21:16 ` Mingwei Zhang [this message]
2023-03-03 22:25 ` Aaron Lewis
2023-03-07 16:33 ` Mingwei Zhang
2023-02-24 22:36 ` [PATCH v3 8/8] KVM: selftests: Add XCR0 Test Aaron Lewis
2023-03-02 20:34 ` Mingwei Zhang
2023-03-02 22:50 ` Aaron Lewis
2023-03-03 21:11 ` Mingwei Zhang
2023-03-23 21:46 ` Sean Christopherson
2023-03-20 15:45 ` [PATCH v3 0/8] Clean up the supported xfeatures Mingwei Zhang
2023-03-23 21:47 ` 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=ZAJjoiZopqIXDoDc@google.com \
--to=mizhang@google.com \
--cc=aaronlewis@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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 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.