[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SY4P282MB108456E39C664F79EC0292249DCFA@SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM>
Date: Sun, 8 Oct 2023 22:56:10 +0800
From: Tianyi Liu <i.pear@...look.com>
To: seanjc@...gle.com, pbonzini@...hat.com, peterz@...radead.org,
mingo@...hat.com, acme@...nel.org
Cc: linux-arm-kernel@...ts.infradead.org, kvmarm@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
kvm@...r.kernel.org, x86@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
namhyung@...nel.org, irogers@...gle.com, adrian.hunter@...el.com,
Tianyi Liu <i.pear@...look.com>
Subject: [PATCH v2 3/5] KVM: implement new perf interfaces
This patch provides two KVM implementations for the following new perf
interfaces, just redirecting them to the arch-specific implementations:
- get_frame_pointer: Return the frame pointer of the running vm.
- read_virt: Read data from a virtual address of the running vm.
Signed-off-by: Tianyi Liu <i.pear@...look.com>
---
virt/kvm/kvm_main.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 486800a70..6fd6ee6c0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -6018,6 +6018,9 @@ static unsigned int kvm_guest_state(void)
if (!kvm_arch_vcpu_in_kernel(vcpu))
state |= PERF_GUEST_USER;
+ if (kvm_arch_vcpu_is_64bit(vcpu))
+ state |= PERF_GUEST_64BIT;
+
return state;
}
@@ -6032,9 +6035,31 @@ static unsigned long kvm_guest_get_ip(void)
return kvm_arch_vcpu_get_ip(vcpu);
}
+static unsigned long kvm_guest_get_frame_pointer(void)
+{
+ struct kvm_vcpu *vcpu = kvm_get_running_vcpu();
+
+ if (WARN_ON_ONCE(!kvm_arch_pmi_in_guest(vcpu)))
+ return 0;
+
+ return kvm_arch_vcpu_get_frame_pointer(vcpu);
+}
+
+static bool kvm_guest_read_virt(void *addr, void *dest, unsigned int length)
+{
+ struct kvm_vcpu *vcpu = kvm_get_running_vcpu();
+
+ if (WARN_ON_ONCE(!kvm_arch_pmi_in_guest(vcpu)))
+ return false;
+
+ return kvm_arch_vcpu_read_virt(vcpu, addr, dest, length);
+}
+
static struct perf_guest_info_callbacks kvm_guest_cbs = {
.state = kvm_guest_state,
.get_ip = kvm_guest_get_ip,
+ .get_frame_pointer = kvm_guest_get_frame_pointer,
+ .read_virt = kvm_guest_read_virt,
.handle_intel_pt_intr = NULL,
};
--
2.42.0
Powered by blists - more mailing lists