Add the debugfs file named 'mmu-debug', we can disable/enable mmu audit by
this file:
enable:
echo 1> debugfs/kvm/mmu-debug
disable:
echo 0> debugfs/kvm/mmu-debug
This patch not change the logic
Signed-off-by: Xiao Guangrong<xiaoguangrong@xxxxxxxxxxxxxx>
---
arch/x86/kvm/Kconfig | 6 +
arch/x86/kvm/mmu.c | 250 ++--------------------------------
arch/x86/kvm/mmu_debug.c | 329 ++++++++++++++++++++++++++++++++++++++++++++
+
+static void mmu_debug_enable(void)
+{
+ int ret;
+
+ if (mmu_debug)
+ return;
+
+ ret = register_trace_kvm_mmu_audit(kvm_mmu_audit, NULL);
+ WARN_ON(ret);
+
+ mmu_debug = true;
+}
diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86/kvm/mmutrace.h
index 3aab0f0..28a0e1f 100644
--- a/arch/x86/kvm/mmutrace.h
+++ b/arch/x86/kvm/mmutrace.h
@@ -195,6 +195,25 @@ DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_prepare_zap_page,
TP_ARGS(sp)
);
+
+TRACE_EVENT(
+ kvm_mmu_audit,
+ TP_PROTO(struct kvm_vcpu *vcpu, const char *msg),
+ TP_ARGS(vcpu, msg),
+
+ TP_STRUCT__entry(
+ __field(struct kvm_vcpu *, vcpu)
+ __field(const char *, msg)
+ ),
+
+ TP_fast_assign(
+ __entry->vcpu = vcpu;
+ __entry->msg = msg;
+ ),
+
+ TP_printk("%s", __entry->msg)