Martin Schmidt has uploaded this change for review.

View Change

src/arch/x86: Fix register accesses for x86_64 debugging

Code that interacts with GDB was accessing the eip and eflags filed in
the eregs struct.
Because those registers are rip and rflags in x86_64, compilation would fail
with x86_64 + debugging enabled.

Fix compilation by accessing the fields with a macro
which expends to the corresponding x86_64 or x86 registers.

Signed-off-by: Martin Schmidt <martin.schmidt@epita.fr>
Change-Id: I07183fe84d083e79ccfda19df82e87c374aed84a
---
M src/arch/x86/exception.c
M src/arch/x86/include/arch/registers.h
2 files changed, 12 insertions(+), 7 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/32/45032/1
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c
index f10c7bf..07e2314 100644
--- a/src/arch/x86/exception.c
+++ b/src/arch/x86/exception.c
@@ -380,9 +380,9 @@
#if CONFIG(GDB_STUB)
int signo;
memcpy(gdb_stub_registers, info, 8*sizeof(uint32_t));
- gdb_stub_registers[PC] = info->eip;
+ gdb_stub_registers[PC] = info->X86_ARCH_IP_REGISTER;
gdb_stub_registers[CS] = info->cs;
- gdb_stub_registers[PS] = info->eflags;
+ gdb_stub_registers[PS] = info->X86_ARCH_FLAGS_REGISTER;
signo = GDB_UNKNOWN;
if (info->vector < ARRAY_SIZE(exception_to_signal))
signo = exception_to_signal[info->vector];
@@ -416,9 +416,9 @@
copy_from_hex(&gdb_stub_registers, in_buffer + 1,
sizeof(gdb_stub_registers));
memcpy(info, gdb_stub_registers, 8*sizeof(uint32_t));
- info->eip = gdb_stub_registers[PC];
+ info->X86_ARCH_IP_REGISTER = gdb_stub_registers[PC];
info->cs = gdb_stub_registers[CS];
- info->eflags = gdb_stub_registers[PS];
+ info->X86_ARCH_FLAGS_REGISTER = gdb_stub_registers[PS];
memcpy(out_buffer, "OK", 3);
break;
case 'm':
@@ -452,13 +452,13 @@
*/
ptr = &in_buffer[1];
if (parse_ulong(&ptr, &addr))
- info->eip = addr;
+ info->X86_ARCH_IP_REGISTER = addr;

/* Clear the trace bit */
- info->eflags &= ~(1 << 8);
+ info->X86_ARCH_FLAGS_REGISTER &= ~(1 << 8);
/* Set the trace bit if we are single stepping */
if (in_buffer[0] == 's')
- info->eflags |= (1 << 8);
+ info->X86_ARCH_FLAGS_REGISTER |= (1 << 8);
return;
case 'D':
memcpy(out_buffer, "OK", 3);
diff --git a/src/arch/x86/include/arch/registers.h b/src/arch/x86/include/arch/registers.h
index 5f8f9be..ec3b71a 100644
--- a/src/arch/x86/include/arch/registers.h
+++ b/src/arch/x86/include/arch/registers.h
@@ -67,6 +67,8 @@
QUAD_DOWNTO16(sp);
uint64_t ss;
};
+#define X86_ARCH_IP_REGISTER rip
+#define X86_ARCH_FLAGS_REGISTER rflags
#else
struct eregs {
LONG_DOWNTO8(a);
@@ -83,7 +85,10 @@
uint32_t cs;
uint32_t eflags;
};
+#define X86_ARCH_IP_REGISTER eip
+#define X86_ARCH_FLAGS_REGISTER eflags
#endif
+
#endif // !ASSEMBLER

#if CONFIG(COMPILER_LLVM_CLANG)

To view, visit change 45032. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I07183fe84d083e79ccfda19df82e87c374aed84a
Gerrit-Change-Number: 45032
Gerrit-PatchSet: 1
Gerrit-Owner: Martin Schmidt
Gerrit-MessageType: newchange