KVM: arm64: Avoid rewinding the PC for trapped SMCs
PATCH 1/1 KVM: arm64: Avoid rewinding the PC for trapped SMCs
When handling a guest's SError that was identified in __guest_exit, it is injected back into the guest at the instruction that caused the switch into hyp. A trapped SMC does not advance the PC so no adjustment needs to be made to the PC.
--- arch/arm64/kvm/handle_exit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arm64/kvm/handle_exit.c +2 -3
@@ -244,12 +244,11 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,u8 esr_ec =ESR_ELx_EC (kvm_vcpu_get_esr (vcpu));/* -* HVC/SMC already have an adjusted PC, which we need +* HVC already has an adjusted PC, which we need * to correct in order to return to after having * injected the SError. */ -if (esr_ec == ESR_ELx_EC_HVC32 || esr_ec == ESR_ELx_EC_HVC64 || - esr_ec == ESR_ELx_EC_SMC32 || esr_ec == ESR_ELx_EC_SMC64) { +if (esr_ec == ESR_ELx_EC_HVC32 || esr_ec == ESR_ELx_EC_HVC64) {u32 adj =kvm_vcpu_trap_il_is32bit (vcpu) ?4 :2 ; *vcpu_pc (vcpu) -= adj; }
Signature · 6 lines
2.27.0.389.gc38d7665816-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Hi Andrew,
Quoted 4 lines · Andrew Scull
When handling a guest's SError that was identified in
__guest_exit, it is injected back into the guest at the instruction that caused the switch into hyp. A trapped SMC does not advance the PC so no adjustment needs to be made to the PC.
Oops!
Thanks,
James
Quoted 16 lines
Fixes ddb3d07cfe90 ("arm64: KVM: Inject a Virtual SError if it was pending")Signed-off-by Andrew Scull <[email protected]>--- arch/arm64/kvm/handle_exit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)arch/arm64/kvm/handle_exit.c +0
-1@@ -244,12 +244,11 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,u8 esr_ec =ESR_ELx_EC (kvm_vcpu_get_esr (vcpu));/* -* HVC/SMC already have an adjusted PC, which we need
arch/arm64/kvm/handle_exit.c int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, · line 254
Quoted 10 lines
arch/arm64/kvm/handle_exit.c +2
-2+* HVC already has an adjusted PC, which we need * to correct in order to return to after having * injected the SError. */ -if (esr_ec == ESR_ELx_EC_HVC32 || esr_ec == ESR_ELx_EC_HVC64 || - esr_ec == ESR_ELx_EC_SMC32 || esr_ec == ESR_ELx_EC_SMC64) { +if (esr_ec == ESR_ELx_EC_HVC32 || esr_ec == ESR_ELx_EC_HVC64) {u32 adj =kvm_vcpu_trap_il_is32bit (vcpu) ?4 :2 ; *vcpu_pc (vcpu) -= adj; }
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm