Skip to content

Commit 22f5c20

Browse files
tlendackysean-jc
authored andcommitted
KVM: SVM: Dump guest register state in dump_vmcb()
Guest register state can be useful when debugging, include it as part of dump_vmcb(). Signed-off-by: Tom Lendacky <[email protected]> Acked-by: Borislav Petkov (AMD) <[email protected]> Tested-by: Kim Phillips <[email protected]> Link: https://lore.kernel.org/r/a4131a10c082a93610cac12b35dca90292e50f50.1742477213.git.thomas.lendacky@amd.com Signed-off-by: Sean Christopherson <[email protected]>
1 parent 962e2b6 commit 22f5c20

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,6 +3522,59 @@ static void dump_vmcb(struct kvm_vcpu *vcpu)
35223522
"excp_from:", save->last_excp_from,
35233523
"excp_to:", save->last_excp_to);
35243524

3525+
if (sev_es_guest(vcpu->kvm)) {
3526+
struct sev_es_save_area *vmsa = (struct sev_es_save_area *)save;
3527+
3528+
pr_err("%-15s %016llx\n",
3529+
"sev_features", vmsa->sev_features);
3530+
3531+
pr_err("%-15s %016llx %-13s %016llx\n",
3532+
"rax:", vmsa->rax, "rbx:", vmsa->rbx);
3533+
pr_err("%-15s %016llx %-13s %016llx\n",
3534+
"rcx:", vmsa->rcx, "rdx:", vmsa->rdx);
3535+
pr_err("%-15s %016llx %-13s %016llx\n",
3536+
"rsi:", vmsa->rsi, "rdi:", vmsa->rdi);
3537+
pr_err("%-15s %016llx %-13s %016llx\n",
3538+
"rbp:", vmsa->rbp, "rsp:", vmsa->rsp);
3539+
pr_err("%-15s %016llx %-13s %016llx\n",
3540+
"r8:", vmsa->r8, "r9:", vmsa->r9);
3541+
pr_err("%-15s %016llx %-13s %016llx\n",
3542+
"r10:", vmsa->r10, "r11:", vmsa->r11);
3543+
pr_err("%-15s %016llx %-13s %016llx\n",
3544+
"r12:", vmsa->r12, "r13:", vmsa->r13);
3545+
pr_err("%-15s %016llx %-13s %016llx\n",
3546+
"r14:", vmsa->r14, "r15:", vmsa->r15);
3547+
pr_err("%-15s %016llx %-13s %016llx\n",
3548+
"xcr0:", vmsa->xcr0, "xss:", vmsa->xss);
3549+
} else {
3550+
pr_err("%-15s %016llx %-13s %016lx\n",
3551+
"rax:", save->rax, "rbx:",
3552+
vcpu->arch.regs[VCPU_REGS_RBX]);
3553+
pr_err("%-15s %016lx %-13s %016lx\n",
3554+
"rcx:", vcpu->arch.regs[VCPU_REGS_RCX],
3555+
"rdx:", vcpu->arch.regs[VCPU_REGS_RDX]);
3556+
pr_err("%-15s %016lx %-13s %016lx\n",
3557+
"rsi:", vcpu->arch.regs[VCPU_REGS_RSI],
3558+
"rdi:", vcpu->arch.regs[VCPU_REGS_RDI]);
3559+
pr_err("%-15s %016lx %-13s %016llx\n",
3560+
"rbp:", vcpu->arch.regs[VCPU_REGS_RBP],
3561+
"rsp:", save->rsp);
3562+
#ifdef CONFIG_X86_64
3563+
pr_err("%-15s %016lx %-13s %016lx\n",
3564+
"r8:", vcpu->arch.regs[VCPU_REGS_R8],
3565+
"r9:", vcpu->arch.regs[VCPU_REGS_R9]);
3566+
pr_err("%-15s %016lx %-13s %016lx\n",
3567+
"r10:", vcpu->arch.regs[VCPU_REGS_R10],
3568+
"r11:", vcpu->arch.regs[VCPU_REGS_R11]);
3569+
pr_err("%-15s %016lx %-13s %016lx\n",
3570+
"r12:", vcpu->arch.regs[VCPU_REGS_R12],
3571+
"r13:", vcpu->arch.regs[VCPU_REGS_R13]);
3572+
pr_err("%-15s %016lx %-13s %016lx\n",
3573+
"r14:", vcpu->arch.regs[VCPU_REGS_R14],
3574+
"r15:", vcpu->arch.regs[VCPU_REGS_R15]);
3575+
#endif
3576+
}
3577+
35253578
no_vmsa:
35263579
if (sev_es_guest(vcpu->kvm))
35273580
sev_free_decrypted_vmsa(vcpu, save);

0 commit comments

Comments
 (0)