lkml.org 
[lkml]   [2023]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 3/5] KVM: implement new perf callback interfaces
Date
This patch provides two KVM implementations for the following two new perf
interfaces, just redirecting them to the arch-specific implementations:

- get_unwind_info
- read_virt

Signed-off-by: Tianyi Liu <i.pear@outlook.com>
---
virt/kvm/kvm_main.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 486800a7024b..c47b6c0f8e94 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -6032,9 +6032,31 @@ static unsigned long kvm_guest_get_ip(void)
return kvm_arch_vcpu_get_ip(vcpu);
}

+static bool kvm_guest_get_unwind_info(struct perf_kvm_guest_unwind_info *info)
+{
+ struct kvm_vcpu *vcpu = kvm_get_running_vcpu();
+
+ if (WARN_ON_ONCE(!kvm_arch_pmi_in_guest(vcpu)))
+ return false;
+
+ return kvm_arch_vcpu_get_unwind_info(vcpu, info);
+}
+
+static bool kvm_guest_read_virt(unsigned long 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_unwind_info = kvm_guest_get_unwind_info,
+ .read_virt = kvm_guest_read_virt,
.handle_intel_pt_intr = NULL,
};

--
2.34.1
\
 
 \ /
  Last update: 2023-12-10 09:16    [W:0.165 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site