From: Mingwei Zhang <mizhang@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Mingwei Zhang <mizhang@google.com>,
David Matlack <dmatlack@google.com>
Subject: [PATCH v4 3/3] KVM: x86: Print guest pgd in kvm_nested_vmenter()
Date: Thu, 25 Aug 2022 22:57:55 +0000 [thread overview]
Message-ID: <20220825225755.907001-4-mizhang@google.com> (raw)
In-Reply-To: <20220825225755.907001-1-mizhang@google.com>
Print guest pgd in kvm_nested_vmenter() to enrich the information for
tracing. When tdp is enabled, print the value of tdp page table (EPT/NPT);
when tdp is disabled, print the value of non-nested CR3.
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Mingwei Zhang <mizhang@google.com>
---
arch/x86/kvm/svm/nested.c | 2 ++
arch/x86/kvm/trace.h | 13 +++++++++----
arch/x86/kvm/vmx/nested.c | 2 ++
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index 835c508eed8e..05b7994244c5 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -787,6 +787,8 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa,
vmcb12->control.int_ctl,
vmcb12->control.event_inj,
vmcb12->control.nested_ctl,
+ vmcb12->control.nested_cr3,
+ vmcb12->save.cr3,
KVM_ISA_SVM);
trace_kvm_nested_intercepts(vmcb12->control.intercepts[INTERCEPT_CR] & 0xffff,
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index e7f0da9474f0..b2be0348bb14 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -591,9 +591,10 @@ TRACE_EVENT(kvm_pv_eoi,
*/
TRACE_EVENT(kvm_nested_vmenter,
TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
- __u32 event_inj, bool tdp_enabled, __u32 isa),
+ __u32 event_inj, bool tdp_enabled, __u64 guest_tdp,
+ __u64 guest_cr3, __u32 isa),
TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, tdp_enabled,
- isa),
+ guest_tdp, guest_cr3, isa),
TP_STRUCT__entry(
__field( __u64, rip )
@@ -602,6 +603,7 @@ TRACE_EVENT(kvm_nested_vmenter,
__field( __u32, int_ctl )
__field( __u32, event_inj )
__field( bool, tdp_enabled )
+ __field( __u64, guest_pgd )
__field( __u32, isa )
),
@@ -612,11 +614,13 @@ TRACE_EVENT(kvm_nested_vmenter,
__entry->int_ctl = int_ctl;
__entry->event_inj = event_inj;
__entry->tdp_enabled = tdp_enabled;
+ __entry->guest_pgd = tdp_enabled ? guest_tdp : guest_cr3;
__entry->isa = isa;
),
TP_printk("rip: 0x%016llx %s: 0x%016llx nested_rip: 0x%016llx "
- "int_ctl: 0x%08x event_inj: 0x%08x nested_%s: %s",
+ "int_ctl: 0x%08x event_inj: 0x%08x nested_%s: %s, "
+ "guest_pgd: 0x%016llx",
__entry->rip,
__entry->isa == KVM_ISA_VMX ? "vmcs" : "vmcb",
__entry->vmcb,
@@ -624,7 +628,8 @@ TRACE_EVENT(kvm_nested_vmenter,
__entry->int_ctl,
__entry->event_inj,
__entry->isa == KVM_ISA_VMX ? "ept" : "npt",
- __entry->tdp_enabled ? "on" : "off")
+ __entry->tdp_enabled ? "on" : "off",
+ __entry->guest_pgd)
);
TRACE_EVENT(kvm_nested_intercepts,
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index f72fe9452391..f963e5ce0a28 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -3370,6 +3370,8 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
vmcs12->guest_intr_status,
vmcs12->vm_entry_intr_info_field,
vmcs12->secondary_vm_exec_control & SECONDARY_EXEC_ENABLE_EPT,
+ vmcs12->ept_pointer,
+ vmcs12->guest_cr3,
KVM_ISA_VMX);
kvm_service_local_tlb_flush_requests(vcpu);
--
2.37.2.672.g94769d06f0-goog
next prev parent reply other threads:[~2022-08-25 22:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 22:57 [PATCH v4 0/3] Extend KVM trace_kvm_nested_vmrun() to support VMX Mingwei Zhang
2022-08-25 22:57 ` [PATCH v4 1/3] KVM: x86: Update trace function for nested VM entry " Mingwei Zhang
2022-08-30 20:31 ` Sean Christopherson
2022-08-25 22:57 ` [PATCH v4 2/3] KVM: nVMX: Add tracepoint for nested vmenter Mingwei Zhang
2022-08-25 22:57 ` Mingwei Zhang [this message]
2022-08-30 21:29 ` [PATCH v4 3/3] KVM: x86: Print guest pgd in kvm_nested_vmenter() Sean Christopherson
2022-08-30 20:29 ` [PATCH v4 0/3] Extend KVM trace_kvm_nested_vmrun() to support VMX Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220825225755.907001-4-mizhang@google.com \
--to=mizhang@google.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®