KVM ARM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] KVM: arm64: Avoid rewinding the PC for trapped SMCs
@ 2020-07-14  9:45 Andrew Scull
  2020-07-15 13:16 ` James Morse
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Scull @ 2020-07-14  9:45 UTC (permalink / raw)
  To: kvmarm; +Cc: maz, kernel-team

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.

Fixes: ddb3d07cfe90 ("arm64: KVM: Inject a Virtual SError if it was pending")
Signed-off-by: Andrew Scull <ascull@google.com>
---
 arch/arm64/kvm/handle_exit.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 98ab33139982..7d9e198ebdf2 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -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;
 		}
-- 
2.27.0.389.gc38d7665816-goog

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: arm64: Avoid rewinding the PC for trapped SMCs
  2020-07-14  9:45 [PATCH] KVM: arm64: Avoid rewinding the PC for trapped SMCs Andrew Scull
@ 2020-07-15 13:16 ` James Morse
  0 siblings, 0 replies; 2+ messages in thread
From: James Morse @ 2020-07-15 13:16 UTC (permalink / raw)
  To: Andrew Scull, maz; +Cc: kernel-team, kvmarm

Hi Andrew,

On 14/07/2020 10:45, Andrew Scull wrote:
> 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!

Reviewed-by: James Morse <james.morse@arm.com>


Thanks,

James


> Fixes: ddb3d07cfe90 ("arm64: KVM: Inject a Virtual SError if it was pending")
> Signed-off-by: Andrew Scull <ascull@google.com>
> ---
>  arch/arm64/kvm/handle_exit.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> index 98ab33139982..7d9e198ebdf2 100644
> --- a/arch/arm64/kvm/handle_exit.c
> +++ b/arch/arm64/kvm/handle_exit.c
> @@ -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;
>  		}
> 

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14  9:45 [PATCH] KVM: arm64: Avoid rewinding the PC for trapped SMCs Andrew Scull
2020-07-15 13:16 ` James Morse

KVM ARM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvmarm/0 kvmarm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvmarm kvmarm/ https://lore.kernel.org/kvmarm \
		kvmarm@lists.cs.columbia.edu
	public-inbox-index kvmarm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/edu.columbia.cs.lists.kvmarm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git