* [PATCH 0/2] target/arm: Two SME fixes
@ 2022-07-13 4:58 Richard Henderson
2022-07-13 4:58 ` [PATCH 1/2] target/arm: Fill in VL for tbflags when SME enabled and SVE disabled Richard Henderson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Richard Henderson @ 2022-07-13 4:58 UTC (permalink / raw)
To: qemu-devel; +Cc: broonie, qemu-arm
Ho hum. Let a feature loose on users and they find bugs. Mark noticed
that the wrong value was being picked up for VL when SVE is disabled.
I had run the same test but failed to notice the vector length wasn't
as expected, though the test otherwise produced expected results.
r~
Richard Henderson (2):
target/arm: Fill in VL for tbflags when SME enabled and SVE disabled
target/arm: Fix aarch64_sve_change_el for SME
target/arm/helper.c | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] target/arm: Fill in VL for tbflags when SME enabled and SVE disabled
2022-07-13 4:58 [PATCH 0/2] target/arm: Two SME fixes Richard Henderson
@ 2022-07-13 4:58 ` Richard Henderson
2022-07-13 4:58 ` [PATCH 2/2] target/arm: Fix aarch64_sve_change_el for SME Richard Henderson
2022-07-14 14:39 ` [PATCH 0/2] target/arm: Two SME fixes Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2022-07-13 4:58 UTC (permalink / raw)
To: qemu-devel; +Cc: broonie, qemu-arm
When PSTATE.SM, VL = SVL even if SVE is disabled.
This is visible in kselftest ssve-test.
Reported-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/helper.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index cfcad97ce0..6fff7fc64f 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -10882,13 +10882,19 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
}
if (cpu_isar_feature(aa64_sme, env_archcpu(env))) {
int sme_el = sme_exception_el(env, el);
+ bool sm = FIELD_EX64(env->svcr, SVCR, SM);
DP_TBFLAG_A64(flags, SMEEXC_EL, sme_el);
if (sme_el == 0) {
/* Similarly, do not compute SVL if SME is disabled. */
- DP_TBFLAG_A64(flags, SVL, sve_vqm1_for_el_sm(env, el, true));
+ int svl = sve_vqm1_for_el_sm(env, el, true);
+ DP_TBFLAG_A64(flags, SVL, svl);
+ if (sm) {
+ /* If SVE is disabled, we will not have set VL above. */
+ DP_TBFLAG_A64(flags, VL, svl);
+ }
}
- if (FIELD_EX64(env->svcr, SVCR, SM)) {
+ if (sm) {
DP_TBFLAG_A64(flags, PSTATE_SM, 1);
DP_TBFLAG_A64(flags, SME_TRAP_NONSTREAMING, !sme_fa64(env, el));
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] target/arm: Fix aarch64_sve_change_el for SME
2022-07-13 4:58 [PATCH 0/2] target/arm: Two SME fixes Richard Henderson
2022-07-13 4:58 ` [PATCH 1/2] target/arm: Fill in VL for tbflags when SME enabled and SVE disabled Richard Henderson
@ 2022-07-13 4:58 ` Richard Henderson
2022-07-14 14:39 ` [PATCH 0/2] target/arm: Two SME fixes Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2022-07-13 4:58 UTC (permalink / raw)
To: qemu-devel; +Cc: broonie, qemu-arm
We were only checking for SVE disabled and not taking into
account PSTATE.SM to check SME disabled, which resulted in
vectors being incorrectly truncated.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/helper.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 6fff7fc64f..24c45a9bf3 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -11228,6 +11228,21 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq)
}
}
+static uint32_t sve_vqm1_for_el_sm_ena(CPUARMState *env, int el, bool sm)
+{
+ int exc_el;
+
+ if (sm) {
+ exc_el = sme_exception_el(env, el);
+ } else {
+ exc_el = sve_exception_el(env, el);
+ }
+ if (exc_el) {
+ return 0; /* disabled */
+ }
+ return sve_vqm1_for_el_sm(env, el, sm);
+}
+
/*
* Notice a change in SVE vector size when changing EL.
*/
@@ -11236,7 +11251,7 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el,
{
ARMCPU *cpu = env_archcpu(env);
int old_len, new_len;
- bool old_a64, new_a64;
+ bool old_a64, new_a64, sm;
/* Nothing to do if no SVE. */
if (!cpu_isar_feature(aa64_sve, cpu)) {
@@ -11256,7 +11271,8 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el,
* invoke ResetSVEState when taking an exception from, or
* returning to, AArch32 state when PSTATE.SM is enabled.
*/
- if (old_a64 != new_a64 && FIELD_EX64(env->svcr, SVCR, SM)) {
+ sm = FIELD_EX64(env->svcr, SVCR, SM);
+ if (old_a64 != new_a64 && sm) {
arm_reset_sve_state(env);
return;
}
@@ -11273,10 +11289,13 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el,
* we already have the correct register contents when encountering the
* vq0->vq0 transition between EL0->EL1.
*/
- old_len = (old_a64 && !sve_exception_el(env, old_el)
- ? sve_vqm1_for_el(env, old_el) : 0);
- new_len = (new_a64 && !sve_exception_el(env, new_el)
- ? sve_vqm1_for_el(env, new_el) : 0);
+ old_len = new_len = 0;
+ if (old_a64) {
+ old_len = sve_vqm1_for_el_sm_ena(env, old_el, sm);
+ }
+ if (new_a64) {
+ new_len = sve_vqm1_for_el_sm_ena(env, new_el, sm);
+ }
/* When changing vector length, clear inaccessible state. */
if (new_len < old_len) {
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] target/arm: Two SME fixes
2022-07-13 4:58 [PATCH 0/2] target/arm: Two SME fixes Richard Henderson
2022-07-13 4:58 ` [PATCH 1/2] target/arm: Fill in VL for tbflags when SME enabled and SVE disabled Richard Henderson
2022-07-13 4:58 ` [PATCH 2/2] target/arm: Fix aarch64_sve_change_el for SME Richard Henderson
@ 2022-07-14 14:39 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2022-07-14 14:39 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, broonie, qemu-arm
On Wed, 13 Jul 2022 at 05:59, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Ho hum. Let a feature loose on users and they find bugs. Mark noticed
> that the wrong value was being picked up for VL when SVE is disabled.
> I had run the same test but failed to notice the vector length wasn't
> as expected, though the test otherwise produced expected results.
>
>
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-14 14:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-13 4:58 [PATCH 0/2] target/arm: Two SME fixes Richard Henderson
2022-07-13 4:58 ` [PATCH 1/2] target/arm: Fill in VL for tbflags when SME enabled and SVE disabled Richard Henderson
2022-07-13 4:58 ` [PATCH 2/2] target/arm: Fix aarch64_sve_change_el for SME Richard Henderson
2022-07-14 14:39 ` [PATCH 0/2] target/arm: Two SME fixes Peter Maydell
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).