git: 8c931d6c8db2 - stable/14 - bhyve: Simplify register definitions a bit
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Jan 2024 14:19:20 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=8c931d6c8db27dcdba908dfb0b5713b852d2c1f0
commit 8c931d6c8db27dcdba908dfb0b5713b852d2c1f0
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-23 16:40:52 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-30 14:18:54 +0000
bhyve: Simplify register definitions a bit
It's awkward to have separate tables for information which is logically
connected. Merge the gdb_regset[] and gdb_regsize[] arrays and update
gdb_read_regs() to cope with the result. This makes the addition of
arm64 support a bit cleaner.
No functional change intended.
Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D43481
(cherry picked from commit 5e728af444b16f480ec0f43803ca2a7a3e6e2e48)
---
usr.sbin/bhyve/gdb.c | 89 ++++++++++++++++++++--------------------------------
1 file changed, 34 insertions(+), 55 deletions(-)
diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c
index cc05a32a5c56..1b0049c9e6ae 100644
--- a/usr.sbin/bhyve/gdb.c
+++ b/usr.sbin/bhyve/gdb.c
@@ -135,58 +135,34 @@ static struct vcpu **vcpus;
static int cur_vcpu, stopped_vcpu;
static bool gdb_active = false;
-static const int gdb_regset[] = {
- VM_REG_GUEST_RAX,
- VM_REG_GUEST_RBX,
- VM_REG_GUEST_RCX,
- VM_REG_GUEST_RDX,
- VM_REG_GUEST_RSI,
- VM_REG_GUEST_RDI,
- VM_REG_GUEST_RBP,
- VM_REG_GUEST_RSP,
- VM_REG_GUEST_R8,
- VM_REG_GUEST_R9,
- VM_REG_GUEST_R10,
- VM_REG_GUEST_R11,
- VM_REG_GUEST_R12,
- VM_REG_GUEST_R13,
- VM_REG_GUEST_R14,
- VM_REG_GUEST_R15,
- VM_REG_GUEST_RIP,
- VM_REG_GUEST_RFLAGS,
- VM_REG_GUEST_CS,
- VM_REG_GUEST_SS,
- VM_REG_GUEST_DS,
- VM_REG_GUEST_ES,
- VM_REG_GUEST_FS,
- VM_REG_GUEST_GS
-};
-
-static const int gdb_regsize[] = {
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
+static const struct gdb_reg {
+ enum vm_reg_name id;
+ int size;
+} gdb_regset[] = {
+ { .id = VM_REG_GUEST_RAX, .size = 8 },
+ { .id = VM_REG_GUEST_RBX, .size = 8 },
+ { .id = VM_REG_GUEST_RCX, .size = 8 },
+ { .id = VM_REG_GUEST_RDX, .size = 8 },
+ { .id = VM_REG_GUEST_RSI, .size = 8 },
+ { .id = VM_REG_GUEST_RDI, .size = 8 },
+ { .id = VM_REG_GUEST_RBP, .size = 8 },
+ { .id = VM_REG_GUEST_RSP, .size = 8 },
+ { .id = VM_REG_GUEST_R8, .size = 8 },
+ { .id = VM_REG_GUEST_R9, .size = 8 },
+ { .id = VM_REG_GUEST_R10, .size = 8 },
+ { .id = VM_REG_GUEST_R11, .size = 8 },
+ { .id = VM_REG_GUEST_R12, .size = 8 },
+ { .id = VM_REG_GUEST_R13, .size = 8 },
+ { .id = VM_REG_GUEST_R14, .size = 8 },
+ { .id = VM_REG_GUEST_R15, .size = 8 },
+ { .id = VM_REG_GUEST_RIP, .size = 8 },
+ { .id = VM_REG_GUEST_RFLAGS, .size = 4 },
+ { .id = VM_REG_GUEST_CS, .size = 4 },
+ { .id = VM_REG_GUEST_SS, .size = 4 },
+ { .id = VM_REG_GUEST_DS, .size = 4 },
+ { .id = VM_REG_GUEST_ES, .size = 4 },
+ { .id = VM_REG_GUEST_FS, .size = 4 },
+ { .id = VM_REG_GUEST_GS, .size = 4 },
};
#ifdef GDB_LOG
@@ -1032,15 +1008,18 @@ static void
gdb_read_regs(void)
{
uint64_t regvals[nitems(gdb_regset)];
+ int regnums[nitems(gdb_regset)];
+ for (size_t i = 0; i < nitems(gdb_regset); i++)
+ regnums[i] = gdb_regset[i].id;
if (vm_get_register_set(vcpus[cur_vcpu], nitems(gdb_regset),
- gdb_regset, regvals) == -1) {
+ regnums, regvals) == -1) {
send_error(errno);
return;
}
start_packet();
- for (size_t i = 0; i < nitems(regvals); i++)
- append_unsigned_native(regvals[i], gdb_regsize[i]);
+ for (size_t i = 0; i < nitems(gdb_regset); i++)
+ append_unsigned_native(regvals[i], gdb_regset[i].size);
finish_packet();
}