File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,16 @@ struct kvm_vcpu_arch {
286
286
} sta ;
287
287
};
288
288
289
+ /*
290
+ * Returns true if a Performance Monitoring Interrupt (PMI), a.k.a. perf event,
291
+ * arrived in guest context. For riscv, any event that arrives while a vCPU is
292
+ * loaded is considered to be "in guest".
293
+ */
294
+ static inline bool kvm_arch_pmi_in_guest (struct kvm_vcpu * vcpu )
295
+ {
296
+ return IS_ENABLED (CONFIG_GUEST_PERF_EVENTS ) && !!vcpu ;
297
+ }
298
+
289
299
static inline void kvm_arch_sync_events (struct kvm * kvm ) {}
290
300
291
301
#define KVM_RISCV_GSTAGE_TLB_MIN_ORDER 12
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ config KVM
32
32
select KVM_XFER_TO_GUEST_WORK
33
33
select KVM_GENERIC_MMU_NOTIFIER
34
34
select SCHED_INFO
35
+ select GUEST_PERF_EVENTS if PERF_EVENTS
35
36
help
36
37
Support hosting virtualized guest machines.
37
38
Original file line number Diff line number Diff line change @@ -51,6 +51,12 @@ void kvm_arch_disable_virtualization_cpu(void)
51
51
csr_write (CSR_HIDELEG , 0 );
52
52
}
53
53
54
+ static void kvm_riscv_teardown (void )
55
+ {
56
+ kvm_riscv_aia_exit ();
57
+ kvm_unregister_perf_callbacks ();
58
+ }
59
+
54
60
static int __init riscv_kvm_init (void )
55
61
{
56
62
int rc ;
@@ -105,9 +111,11 @@ static int __init riscv_kvm_init(void)
105
111
kvm_info ("AIA available with %d guest external interrupts\n" ,
106
112
kvm_riscv_aia_nr_hgei );
107
113
114
+ kvm_register_perf_callbacks (NULL );
115
+
108
116
rc = kvm_init (sizeof (struct kvm_vcpu ), 0 , THIS_MODULE );
109
117
if (rc ) {
110
- kvm_riscv_aia_exit ();
118
+ kvm_riscv_teardown ();
111
119
return rc ;
112
120
}
113
121
@@ -117,7 +125,7 @@ module_init(riscv_kvm_init);
117
125
118
126
static void __exit riscv_kvm_exit (void )
119
127
{
120
- kvm_riscv_aia_exit ();
128
+ kvm_riscv_teardown ();
121
129
122
130
kvm_exit ();
123
131
}
Original file line number Diff line number Diff line change @@ -226,6 +226,13 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
226
226
return (vcpu -> arch .guest_context .sstatus & SR_SPP ) ? true : false;
227
227
}
228
228
229
+ #ifdef CONFIG_GUEST_PERF_EVENTS
230
+ unsigned long kvm_arch_vcpu_get_ip (struct kvm_vcpu * vcpu )
231
+ {
232
+ return vcpu -> arch .guest_context .sepc ;
233
+ }
234
+ #endif
235
+
229
236
vm_fault_t kvm_arch_vcpu_fault (struct kvm_vcpu * vcpu , struct vm_fault * vmf )
230
237
{
231
238
return VM_FAULT_SIGBUS ;
You can’t perform that action at this time.
0 commit comments