Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36017 )
Change subject: x86 gdb: Extend GDB stub with MSR read and write commands ......................................................................
x86 gdb: Extend GDB stub with MSR read and write commands
Add commands to read and write MSRs on x86.
NOT FOR MERGE!!!
Change-Id: I4addf44305dbcfb06c7573dc30541038356f2c33 Signed-off-by: Werner Zeh werner.zeh@siemens.com --- M src/arch/x86/exception.c 1 file changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/17/36017/1
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index c2783d5..7d10c3e 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -22,6 +22,7 @@ #include <stdint.h> #include <string.h> #include <arch/io.h> +#include <cpu/x86/msr.h>
#if CONFIG(GDB_STUB)
@@ -417,6 +418,7 @@ while (1) { unsigned long addr, length, val; char *ptr; + msr_t msr; out_buffer[0] = '\0'; out_buffer[1] = '\0'; if (!get_packet(in_buffer)) @@ -428,6 +430,37 @@ out_buffer[2] = hexchars[signo & 0xf]; out_buffer[3] = '\0'; break; + case 'e': + /* eAA..AA: Read MSR given by AA..AA. */ + ptr = &in_buffer[1]; + if (parse_ulong(&ptr, &addr) && + (*(ptr++) == ':')) { + char *out_buf_ptr = out_buffer; + + msr = rdmsr(addr); + copy_to_hex(out_buf_ptr, (void *)&(msr.hi), 4); + out_buf_ptr += (4 << 1); + copy_to_hex(out_buf_ptr, (void *)&(msr.lo), 4); + } else + memcpy(out_buffer, "E05", 4); + break; + case 'E': + /* EAA..AA,HHHH,LLLL: Write MSR given by AA..AA. */ + /* Put HHHH into high portion of the 64 bit */ + /* and LLLL into the low portion. */ + ptr = &in_buffer[1]; + if (parse_ulong(&ptr, &addr) && + (*(ptr++) == ',') && + parse_ulong(&ptr, (unsigned long *) &msr.hi) && + (*(ptr++) == ',') && + parse_ulong(&ptr, (unsigned long *) &msr.lo) && + (*(ptr++) == ':')) { + wrmsr(addr, msr); + memcpy(out_buffer, "OK", 3); + } else + memcpy(out_buffer, "E06", 4); + break; + case 'g': /* return the value of the CPU registers */ copy_to_hex(out_buffer, &gdb_stub_registers, sizeof(gdb_stub_registers));