Skip to content

Commit dc993a0

Browse files
rth7680pm215
authored andcommitted
target/arm: Add the SME ZA storage to CPUARMState
Place this late in the resettable section of the structure, to keep the most common element offsets from being > 64k. Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-id: [email protected] [PMM: expanded comment on zarray[] format] Signed-off-by: Peter Maydell <[email protected]>
1 parent a3637e8 commit dc993a0

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

target/arm/cpu.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,28 @@ typedef struct CPUArchState {
694694
} keys;
695695

696696
uint64_t scxtnum_el[4];
697+
698+
/*
699+
* SME ZA storage -- 256 x 256 byte array, with bytes in host word order,
700+
* as we do with vfp.zregs[]. This corresponds to the architectural ZA
701+
* array, where ZA[N] is in the least-significant bytes of env->zarray[N].
702+
* When SVL is less than the architectural maximum, the accessible
703+
* storage is restricted, such that if the SVL is X bytes the guest can
704+
* see only the bottom X elements of zarray[], and only the least
705+
* significant X bytes of each element of the array. (In other words,
706+
* the observable part is always square.)
707+
*
708+
* The ZA storage can also be considered as a set of square tiles of
709+
* elements of different sizes. The mapping from tiles to the ZA array
710+
* is architecturally defined, such that for tiles of elements of esz
711+
* bytes, the Nth row (or "horizontal slice") of tile T is in
712+
* ZA[T + N * esz]. Note that this means that each tile is not contiguous
713+
* in the ZA storage, because its rows are striped through the ZA array.
714+
*
715+
* Because this is so large, keep this toward the end of the reset area,
716+
* to keep the offsets into the rest of the structure smaller.
717+
*/
718+
ARMVectorReg zarray[ARM_MAX_VQ * 16];
697719
#endif
698720

699721
#if defined(CONFIG_USER_ONLY)

target/arm/machine.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,39 @@ static const VMStateDescription vmstate_sve = {
167167
VMSTATE_END_OF_LIST()
168168
}
169169
};
170+
171+
static const VMStateDescription vmstate_vreg = {
172+
.name = "vreg",
173+
.version_id = 1,
174+
.minimum_version_id = 1,
175+
.fields = (VMStateField[]) {
176+
VMSTATE_UINT64_ARRAY(d, ARMVectorReg, ARM_MAX_VQ * 2),
177+
VMSTATE_END_OF_LIST()
178+
}
179+
};
180+
181+
static bool za_needed(void *opaque)
182+
{
183+
ARMCPU *cpu = opaque;
184+
185+
/*
186+
* When ZA storage is disabled, its contents are discarded.
187+
* It will be zeroed when ZA storage is re-enabled.
188+
*/
189+
return FIELD_EX64(cpu->env.svcr, SVCR, ZA);
190+
}
191+
192+
static const VMStateDescription vmstate_za = {
193+
.name = "cpu/sme",
194+
.version_id = 1,
195+
.minimum_version_id = 1,
196+
.needed = za_needed,
197+
.fields = (VMStateField[]) {
198+
VMSTATE_STRUCT_ARRAY(env.zarray, ARMCPU, ARM_MAX_VQ * 16, 0,
199+
vmstate_vreg, ARMVectorReg),
200+
VMSTATE_END_OF_LIST()
201+
}
202+
};
170203
#endif /* AARCH64 */
171204

172205
static bool serror_needed(void *opaque)
@@ -884,6 +917,7 @@ const VMStateDescription vmstate_arm_cpu = {
884917
&vmstate_m_security,
885918
#ifdef TARGET_AARCH64
886919
&vmstate_sve,
920+
&vmstate_za,
887921
#endif
888922
&vmstate_serror,
889923
&vmstate_irq_line_state,

0 commit comments

Comments
 (0)