|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v7 05/50] x86/svm: Pass struct vcpu to svm_vmcb_dump()
svm_vmcb_dump() prints virt_to_maddr() of the VMCB it's passed, which
is right only while VMCBs are reached through the directmap. Pass
instead the vcpu, fish out the physical address from that, and map it
ourselves.
This prepares for moving VMCBs off the xenheap.
Assisted-by: Claude Code:claude-fable-5, Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
CC: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
Changes in v7:
- Rebase over "x86/svm: Drop 'struct' from the vmcb_struct type".
- Pass `struct vcpu` so that we can print the paddr (Jan Beulich).
- Retitle (was: "x86/svm: drop svm_vmcb_dump()'s paddr").
- Assert in svm_vmexit_handler() that its vmcb is still the vCPU's
before dumping it.
- Message: VMCBs move off the xenheap.
Changes in v5:
- Keep VCPU_svm_vmcb: svm_asm_do_resume() now uses it, since
df8d101a3854 ("x86/svm: Work around VMRUN's corruption of
VMCB.INTR_SHADOW") in staging.
- Retitle (was: "x86/svm: drop svm_vmcb_dump()'s paddr and the unused
VCPU_svm_vmcb").
Changes in v4:
- New in this version.
---
xen/arch/x86/hvm/svm/svm.c | 3 ++-
xen/arch/x86/hvm/svm/vmcb.c | 19 ++++++++++++-------
xen/arch/x86/hvm/svm/vmcb.h | 2 +-
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 6419f3011e..a846328802 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2693,7 +2693,8 @@ void asmlinkage svm_vmexit_handler(void)
if ( unlikely(exit_reason == VMEXIT_INVALID) )
{
gdprintk(XENLOG_ERR, "invalid VMCB state:\n");
- svm_vmcb_dump(__func__, vmcb);
+ ASSERT(vmcb == v->arch.hvm.svm.vmcb);
+ svm_vmcb_dump(__func__, v);
domain_crash(v->domain);
goto out;
}
diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c
index 5c893fde95..bbeee4ec67 100644
--- a/xen/arch/x86/hvm/svm/vmcb.c
+++ b/xen/arch/x86/hvm/svm/vmcb.c
@@ -268,20 +268,26 @@ static void svm_dump_sel(const char *name, const struct
segment_register *s)
name, s->sel, s->attr, s->limit, s->base);
}
-void svm_vmcb_dump(const char *from, const struct vmcb *vmcb)
+void svm_vmcb_dump(const char *from, const struct vcpu *v)
{
struct vcpu *curr = current;
+ paddr_t pa = v->arch.hvm.svm.vmcb_pa;
+ struct vmcb *vmcb = SVM_MAP_VMCB_ONE(v, v->arch.hvm.svm.vmcb, pa);
/*
* If we are dumping the VMCB currently in context, some guest state may
* still be cached in hardware. Retrieve it.
*/
- if ( vmcb == curr->arch.hvm.svm.vmcb )
+ if ( v == curr )
svm_sync_vmcb(curr, vmcb_in_sync);
printk("Dumping guest's current state at %s...\n", from);
+ /*
+ * Always print the vaddr from the vcpu struct; the local vmcb
+ * pointer variable may be a transient mapping.
+ */
printk("Size of VMCB = %zu, paddr = %"PRIpaddr", vaddr = %p\n",
- sizeof(struct vmcb), virt_to_maddr(vmcb), vmcb);
+ sizeof(struct vmcb), pa, v->arch.hvm.svm.vmcb);
printk("cr_intercepts = %#x dr_intercepts = %#x "
"exception_intercepts = %#x\n",
@@ -343,6 +349,8 @@ void svm_vmcb_dump(const char *from, const struct vmcb
*vmcb)
svm_dump_sel("LDTR", &vmcb->ldtr);
svm_dump_sel("IDTR", &vmcb->idtr);
svm_dump_sel(" TR", &vmcb->tr);
+
+ SVM_UNMAP_VMCB(v, vmcb);
}
bool svm_vmcb_isvalid(
@@ -425,7 +433,6 @@ static void cf_check vmcb_dump(unsigned char ch)
{
struct domain *d;
struct vcpu *v;
- struct vmcb *vmcb;
printk("*********** VMCB Areas **************\n");
@@ -444,9 +451,7 @@ static void cf_check vmcb_dump(unsigned char ch)
continue;
}
printk("\tVCPU %d\n", v->vcpu_id);
- vmcb = SVM_MAP_VMCB(v);
- svm_vmcb_dump("key_handler", vmcb);
- SVM_UNMAP_VMCB(v, vmcb);
+ svm_vmcb_dump("key_handler", v);
process_pending_softirqs();
}
diff --git a/xen/arch/x86/hvm/svm/vmcb.h b/xen/arch/x86/hvm/svm/vmcb.h
index 2ffb6b1b99..070a44ff6c 100644
--- a/xen/arch/x86/hvm/svm/vmcb.h
+++ b/xen/arch/x86/hvm/svm/vmcb.h
@@ -561,7 +561,7 @@ int svm_create_vmcb(struct vcpu *v);
void svm_destroy_vmcb(struct vcpu *v);
void setup_vmcb_dump(void);
-void svm_vmcb_dump(const char *from, const struct vmcb *vmcb);
+void svm_vmcb_dump(const char *from, const struct vcpu *v);
bool svm_vmcb_isvalid(const char *from, const struct vmcb *vmcb,
const struct vcpu *v, bool verbose);
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |