diff mbox series

[v2,2/7] KVM: selftests: x86: Fix an error in comment of amx_test

Message ID 20230214184606.510551-3-mizhang@google.com (mailing list archive)
State Accepted
Commit bec357a4af5579a60eaba6d42f7d3662d4323767
Headers show
Series Overhauling amx_test | expand

Commit Message

Mingwei Zhang Feb. 14, 2023, 6:46 p.m. UTC
After the execution of __tilerelease(), AMX component will be in INIT
state. Therefore, execution of XSAVEC saving the AMX state into memory will
cause the xstate_bv[18] cleared in xheader. However, the xcomp_bv[18] will
remain set. Fix the error in comment. Also, update xsavec() to XSAVEC
because xcomp_bv[18] is set due to the instruction, not the function.
Finally, use XTILEDATA instead 'bit 18' in comments.

Cc: Jim Mattson <jmattson@google.com>
Cc: Venkatesh Srinivas <venkateshs@google.com>
Cc: Aaron Lewis <aaronlewis@google.com>
Signed-off-by: Mingwei Zhang <mizhang@google.com>
---
 tools/testing/selftests/kvm/x86_64/amx_test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Chao Gao Feb. 19, 2023, 8:46 a.m. UTC | #1
On Tue, Feb 14, 2023 at 06:46:01PM +0000, Mingwei Zhang wrote:
>After the execution of __tilerelease(), AMX component will be in INIT
>state. Therefore, execution of XSAVEC saving the AMX state into memory will
>cause the xstate_bv[18] cleared in xheader. However, the xcomp_bv[18] will
>remain set. Fix the error in comment. Also, update xsavec() to XSAVEC
>because xcomp_bv[18] is set due to the instruction, not the function.
>Finally, use XTILEDATA instead 'bit 18' in comments.
>
>Cc: Jim Mattson <jmattson@google.com>
>Cc: Venkatesh Srinivas <venkateshs@google.com>
>Cc: Aaron Lewis <aaronlewis@google.com>
>Signed-off-by: Mingwei Zhang <mizhang@google.com>
>---
> tools/testing/selftests/kvm/x86_64/amx_test.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
>index d506821a5a26..aac727ff7cf8 100644
>--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
>+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
>@@ -190,7 +190,10 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
> 	GUEST_SYNC(4);
> 	__tilerelease();
> 	GUEST_SYNC(5);
>-	/* bit 18 not in the XCOMP_BV after xsavec() */
>+	/*
>+	 * After XSAVEC, XTILEDATA is cleared in the xstate_bv but is set in
>+	 * the xcomp_bv.
>+	 */
> 	xstate->header.xstate_bv = XFEATURE_MASK_XTILEDATA;
> 	__xsavec(xstate, XFEATURE_MASK_XTILEDATA);
> 	GUEST_ASSERT(!(xstate->header.xstate_bv & XFEATURE_MASK_XTILEDATA));

maybe it would be better to add another GUEST_ASSERT() to enforce that
XTILEDATA is set in the xcomp_bv.

>-- 
>2.39.1.581.gbfd45094c4-goog
>
Mingwei Zhang Feb. 19, 2023, 5:58 p.m. UTC | #2
On Sun, Feb 19, 2023, Chao Gao wrote:
> On Tue, Feb 14, 2023 at 06:46:01PM +0000, Mingwei Zhang wrote:
> >After the execution of __tilerelease(), AMX component will be in INIT
> >state. Therefore, execution of XSAVEC saving the AMX state into memory will
> >cause the xstate_bv[18] cleared in xheader. However, the xcomp_bv[18] will
> >remain set. Fix the error in comment. Also, update xsavec() to XSAVEC
> >because xcomp_bv[18] is set due to the instruction, not the function.
> >Finally, use XTILEDATA instead 'bit 18' in comments.
> >
> >Cc: Jim Mattson <jmattson@google.com>
> >Cc: Venkatesh Srinivas <venkateshs@google.com>
> >Cc: Aaron Lewis <aaronlewis@google.com>
> >Signed-off-by: Mingwei Zhang <mizhang@google.com>
> >---
> > tools/testing/selftests/kvm/x86_64/amx_test.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> >diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
> >index d506821a5a26..aac727ff7cf8 100644
> >--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
> >+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
> >@@ -190,7 +190,10 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
> > 	GUEST_SYNC(4);
> > 	__tilerelease();
> > 	GUEST_SYNC(5);
> >-	/* bit 18 not in the XCOMP_BV after xsavec() */
> >+	/*
> >+	 * After XSAVEC, XTILEDATA is cleared in the xstate_bv but is set in
> >+	 * the xcomp_bv.
> >+	 */
> > 	xstate->header.xstate_bv = XFEATURE_MASK_XTILEDATA;
> > 	__xsavec(xstate, XFEATURE_MASK_XTILEDATA);
> > 	GUEST_ASSERT(!(xstate->header.xstate_bv & XFEATURE_MASK_XTILEDATA));
> 
> maybe it would be better to add another GUEST_ASSERT() to enforce that
> XTILEDATA is set in the xcomp_bv.

yeah. The check has been added in the 6th patch of the series, but I
think it is hard to see. I will reorder the change next to this one in
the next version.
> 
> >-- 
> >2.39.1.581.gbfd45094c4-goog
> >
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
index d506821a5a26..aac727ff7cf8 100644
--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
@@ -190,7 +190,10 @@  static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
 	GUEST_SYNC(4);
 	__tilerelease();
 	GUEST_SYNC(5);
-	/* bit 18 not in the XCOMP_BV after xsavec() */
+	/*
+	 * After XSAVEC, XTILEDATA is cleared in the xstate_bv but is set in
+	 * the xcomp_bv.
+	 */
 	xstate->header.xstate_bv = XFEATURE_MASK_XTILEDATA;
 	__xsavec(xstate, XFEATURE_MASK_XTILEDATA);
 	GUEST_ASSERT(!(xstate->header.xstate_bv & XFEATURE_MASK_XTILEDATA));