Skip to contentSkip to conversation

target/arm/arch_dump: Add SVE notes

PATCH Applied Andrew Jones 3 participants 4 messages Jan 20, 2020 – Jan 23, 2020

lore
Share & tools
lore
#0 lore raw

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.

---
 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
index 3501e0c8d03a..a7c357af74ca 100644
@@ -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
index 40f2c45e17e3..c1aedbeac0db 100644
@@ -980,6 +980,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
index 876184b8fe4d..e2da756e65ed 100644
@@ -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.1
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Message-id: [email protected]
Type: series
Subject: [PATCH REPOST v3] target/arm/arch_dump: Add SVE notes

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
3df154f target/arm/arch_dump: Add SVE notes

=== OUTPUT BEGIN ===
ERROR: code indent should never use tabs
#22: FILE: include/elf.h:1653:
+#define NT_ARM_SVE^I0x405^I^I/* ARM Scalable Vector Extension$

WARNING: Block comments use a leading /* on a separate line #22: FILE: include/elf.h:1653:
+#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension

ERROR: code indent should never use tabs
#23: FILE: include/elf.h:1654:
+^I^I^I^I^I registers */$

WARNING: Block comments use * on subsequent lines
#23: FILE: include/elf.h:1654:
+#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension
+ registers */

WARNING: Block comments use a trailing */ on a separate line #23: FILE: include/elf.h:1654:
+ registers */

total: 2 errors, 3 warnings, 233 lines checked

Commit 3df154fd119b (target/arm/arch_dump: Add SVE notes) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
In reply to Andrew Jones
Quoted 4 lines · Andrew Jones

When dumping a guest with dump-guest-memory also dump the SVE registers if they are in use.

Quoted 9 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(-)

Applied to target-arm.next, thanks (I fixed up the checkpatch nits).

-- PMM

#3 lore raw
Quoted 16 lines · Peter Maydell
Quoted 4 lines · Andrew Jones

When dumping a guest with dump-guest-memory also dump the SVE registers if they are in use.

Quoted 9 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(-)
Quoted 3 lines

Applied to target-arm.next, thanks (I fixed up the checkpatch nits).

You mean the ones in include/elf.h? I had left those on purpose in order to exactly match the glibc elf.h. I just checked QEMU's elf.h, though, and see other changes were reformatted. Next time I'll do the same.

Thanks,
drew