File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,19 @@ static __always_inline u64 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu)
275
275
return vcpu -> arch .fault .esr_el2 ;
276
276
}
277
277
278
+ static inline bool guest_hyp_wfx_traps_enabled (const struct kvm_vcpu * vcpu )
279
+ {
280
+ u64 esr = kvm_vcpu_get_esr (vcpu );
281
+ bool is_wfe = !!(esr & ESR_ELx_WFx_ISS_WFE );
282
+ u64 hcr_el2 = __vcpu_sys_reg (vcpu , HCR_EL2 );
283
+
284
+ if (!vcpu_has_nv (vcpu ) || vcpu_is_el2 (vcpu ))
285
+ return false;
286
+
287
+ return ((is_wfe && (hcr_el2 & HCR_TWE )) ||
288
+ (!is_wfe && (hcr_el2 & HCR_TWI )));
289
+ }
290
+
278
291
static __always_inline int kvm_vcpu_get_condition (const struct kvm_vcpu * vcpu )
279
292
{
280
293
u64 esr = kvm_vcpu_get_esr (vcpu );
Original file line number Diff line number Diff line change @@ -129,8 +129,12 @@ static int kvm_handle_fpasimd(struct kvm_vcpu *vcpu)
129
129
static int kvm_handle_wfx (struct kvm_vcpu * vcpu )
130
130
{
131
131
u64 esr = kvm_vcpu_get_esr (vcpu );
132
+ bool is_wfe = !!(esr & ESR_ELx_WFx_ISS_WFE );
132
133
133
- if (esr & ESR_ELx_WFx_ISS_WFE ) {
134
+ if (guest_hyp_wfx_traps_enabled (vcpu ))
135
+ return kvm_inject_nested_sync (vcpu , kvm_vcpu_get_esr (vcpu ));
136
+
137
+ if (is_wfe ) {
134
138
trace_kvm_wfx_arm64 (* vcpu_pc (vcpu ), true);
135
139
vcpu -> stat .wfe_exit_stat ++ ;
136
140
} else {
You can’t perform that action at this time.
0 commit comments