svm: debug functions
PATCH 1/1 svm: debug functions
Hi!
Attached patch adds two helpful debug functions.
Signed-off-by Christoph Egger <[email protected]>
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
# HG changeset patch
# User cegger
# Date 1271146742 -7200
svm debug methods
xen/arch/x86/hvm/svm/vmcb.c +63 -1
@@ -301,13 +301,75 @@ void svm_destroy_vmcb(struct vcpu *v) arch_svm->vmcb =NULL ; } -static void svm_dump_sel (char *name,svm_segment_register_t *s) +static void svm_dump_sel (const char *name,svm_segment_register_t *s) {printk ("%s: sel=0x%04x, attr=0x%04x, limit=0x%08x, base=0x%016llx\n" , name, s->sel, s->attr.bytes, s->limit, (unsigned long long )s->base); } +void svm_dump_regs (const char *from,struct cpu_user_regs *regs) +{ +printk ("%s: RAX = 0x%016llx RBX = 0x%016llx\n" , from, + (unsigned long long )regs->rax, (unsigned long long )regs->rbx); +printk ("%s: RCX = 0x%016llx RDX = 0x%016llx\n" , from, + (unsigned long long )regs->rcx, (unsigned long long )regs->rdx); +printk ("%s: RSI = 0x%016llx RDI = 0x%016llx\n" , from, + (unsigned long long )regs->rsi, (unsigned long long )regs->rdi); +#ifdef __x86_64__ +printk ("%s: R08 = 0x%016llx R09 = 0x%016llx\n" , from, + (unsigned long long )regs->r8, (unsigned long long )regs->r9); +printk ("%s: R10 = 0x%016llx R11 = 0x%016llx\n" , from, + (unsigned long long )regs->r10, (unsigned long long )regs->r11); +printk ("%s: R12 = 0x%016llx R13 = 0x%016llx\n" , from, + (unsigned long long )regs->r12, (unsigned long long )regs->r13); +printk ("%s: R14 = 0x%016llx R15 = 0x%016llx\n" , from, + (unsigned long long )regs->r14, (unsigned long long )regs->r15); +#endif +} + +void svm_dump_instr (const char *from,uint64_t rip) +{ +enum hvm_copy_result rc; +uint8_t instrbuf[15 ]; +size_t i, len; + + len =PAGE_SIZE - (rip & ~PAGE_MASK ); +if (len >sizeof (instrbuf)) + len =sizeof (instrbuf); + + rc =hvm_fetch_from_guest_virt (instrbuf, rip, len,0 ); + +switch (rc) { +case HVMCOPY_unhandleable: +printk ("%s: can't fetch instruction bytes from rip (unhandleable)\n" , + from); +break ; +case HVMCOPY_bad_gva_to_gfn: +printk ("%s: can't fetch instruction bytes from rip (bad_gva_to_gfn)\n" , + from); +break ; +case HVMCOPY_bad_gfn_to_mfn: +printk ("%s: can't fetch instruction bytes from rip (bad_gfn_to_mfn)\n" , + from); +break ; +case HVMCOPY_gfn_paged_out: +printk ("%s: can't fetch instruction bytes from rip (gfn_paged_out)\n" , + from); +break ; +case HVMCOPY_gfn_shared: +printk ("%s: can't fetch instruction bytes from rip (gfn_shared)\n" , + from); +break ; +case HVMCOPY_okay: +printk ("%s: instruction bytes @rip " , from); +for (i =0 ; i < len; i++) +printk ("%#2x " , instrbuf[i]); +printk ("\n" ); +break ; + } +} +void svm_dump_vmcb (const char *from,struct vmcb_struct *vmcb) {printk ("Dumping guest's current state at %s...\n" , from);
xen/include/asm-x86/hvm/svm/svm.h +2 -0
@@ -29,6 +29,8 @@#include <asm/i387.h> void svm_dump_vmcb (const char *from,struct vmcb_struct *vmcb); +void svm_dump_regs (const char *from,struct cpu_user_regs *regs); +void svm_dump_instr (const char *from,uint64_t rip);#define SVM_REG_EAX (0)#define SVM_REG_ECX (1)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
They're not actually plumbed into anything though... I think anyone can throw a bit of ad-hoc tracing together when developing a new patch set, it doesn't mean it needs checking in.
Also the functions are not svm-specific.
-- Keir
Quoted 7 lines · Christoph Egger
Hi!
Attached patch adds two helpful debug functions.
Signed-off-by Christoph Egger <[email protected]>