target/arm/arch_dump: Add SVE notes
PATCH v3 1/1 target/arm/arch_dump: Add SVE notes
When dumping a guest with dump-guest-memory also dump the SVE registers if they are in use.
---
v3:
- Pulled sve_bswap64 out of kvm64.c and reused it here
- Changed fpsr_offset and sve_size to only align to a 16 byte boundary from the note payload offset, not from the note head. Doing this makes it consistent with the documentation and what gcore does. Testing shows that the elf headers and gdb are still happy.
- Added blank lines between functions
include/elf.h | 2 + target/arm/arch_dump.c | 124 ++++++++++++++++++++++++++++++++++++++++- target/arm/cpu.h | 25 +++++++++ target/arm/kvm64.c | 24 -------- 4 files changed, 149 insertions(+), 26 deletions(-)
include/elf.h +2 -0
@@ -1650,6 +1650,8 @@ typedef struct elf64_shdr {#define NT_ARM_HW_BREAK 0x402/* ARM hardware breakpoint registers */ #define NT_ARM_HW_WATCH 0x403/* ARM hardware watchpoint registers */ #define NT_ARM_SYSTEM_CALL 0x404/* ARM system call number */ +#define NT_ARM_SVE 0x405/* ARM Scalable Vector Extension +registers */ /* * Physical entry point into the kernel.
target/arm/arch_dump.c +122 -2
164 lines not on this page · raw message
target/arm/cpu.h +25 -0
@@ -975,6 +975,31 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);void aarch64_sve_change_el (CPUARMState *env,int old_el,int new_el,bool el0_a64);void aarch64_add_sve_properties (Object *obj); + +/* +* SVE registers are encoded in KVM's memory in an endianness-invariant format. +* The byte at offset i from the start of the in-memory representation contains +* the bits [(7 + 8 * i) : (8 * i)] of the register value. As this means the +* lowest offsets are stored in the lowest memory addresses, then that nearly +* matches QEMU's representation, which is to use an array of host-endian +* uint64_t's, where the lower offsets are at the lower indices. To complete +* the translation we just need to byte swap the uint64_t's on big-endian hosts. +*/ +static inline uint64_t *sve_bswap64 (uint64_t *dst,uint64_t *src,int nr) +{ +#ifdef HOST_WORDS_BIGENDIAN +int i; + +for (i =0 ; i < nr; ++i) { + dst[i] =bswap64 (src[i]); + } + +return dst; +#else +return src; +#endif +} +#else static inline void aarch64_sve_narrow_vq (CPUARMState *env,unsigned vq) { } static inline void aarch64_sve_change_el(CPUARMState *env, int o,
target/arm/kvm64.c +0 -24
@@ -876,30 +876,6 @@ static int kvm_arch_put_fpsimd(CPUState *cs)return 0 ; } -/* -* SVE registers are encoded in KVM's memory in an endianness-invariant format. -* The byte at offset i from the start of the in-memory representation contains -* the bits [(7 + 8 * i) : (8 * i)] of the register value. As this means the -* lowest offsets are stored in the lowest memory addresses, then that nearly -* matches QEMU's representation, which is to use an array of host-endian -* uint64_t's, where the lower offsets are at the lower indices. To complete -* the translation we just need to byte swap the uint64_t's on big-endian hosts. -*/ -static uint64_t *sve_bswap64 (uint64_t *dst,uint64_t *src,int nr) -{ -#ifdef HOST_WORDS_BIGENDIAN -int i; - -for (i =0 ; i < nr; ++i) { - dst[i] =bswap64 (src[i]); - } - -return dst; -#else -return src; -#endif -} -/* * KVM SVE registers come in slices where ZREGs have a slice size of 2048 bits * and PREGS and the FFR have a slice size of 256 bits. However we simply hard
Signature · 1 line
2.21.0
Quoted 15 lines · Andrew Jones
When dumping a guest with dump-guest-memory also dump the SVE registers if they are in use.
Signed-off-by Andrew Jones <[email protected]>---
v3:
- Pulledsve_bswap64out ofkvm64.cand reused it here
- Changedfpsr_offsetandsve_sizeto only align to a 16 byte boundary from the note payload offset, not from the note head. Doing this makes it consistent with the documentation and what gcore does. Testing shows that the elf headers and gdb are still happy.
- Added blank lines between functions
Quoted 5 lines
include/elf.h | 2 + target/arm/arch_dump.c | 124 ++++++++++++++++++++++++++++++++++++++++- target/arm/cpu.h | 25 +++++++++ target/arm/kvm64.c | 24 -------- 4 files changed, 149 insertions(+), 26 deletions(-)
r~