Received: by 10.223.176.5 with SMTP id f5csp686418wra; Fri, 2 Feb 2018 04:34:31 -0800 (PST) X-Google-Smtp-Source: AH8x224vOfM1ou4Z4frV8f+y9MCRxrdlKskQ0vkcmySbaFJs0pfWUgjcj9KmjzkjVsdJuXlja7p0 X-Received: by 10.101.81.141 with SMTP id h13mr22729324pgq.241.1517574871152; Fri, 02 Feb 2018 04:34:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517574871; cv=none; d=google.com; s=arc-20160816; b=m+QqEDSmVdf2vZCoSGrIN6aO/RvZPXokt8HNKwsvLYkzSbdKmTZmpDU1R7+a4IPe/a +nZthps96ppiwCCquwT56GGeIrgHgTuyq2Vfd4l2d04cs4i7ennzEOn2EJPIeNkI9Mm7 1nQSP46VkMPiZYBpwLhFCBYnwVt7mQ0xaZydTpUcEaiKBAclV5hH/Wp8BuyrHduTwcFB 1GRxSChA53tQnpPeQH+V4TgR1KVK/i5rK+hA07AUsW2ESBilQDiWc7ePsXMV42p2Jm8F 7BXC86mpAndUDvOc2V2TiuvVS0W+Psj/SKmavttUqrBYYLfh9cDo0patu7INPAtJ96FP Wcnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=5GxAn7HASr/bTdiTBUaUvzdyb4VmilzncEbNFjKuKQg=; b=IlNXELud7jAD0bjERA4BCEXjvRTywvkWmKdBIvBtLd8AerJTXZuAYqr0vnHDaDkFco IqIps/D1FzrDRCdhTbyZv43KLvs+n7UD1/S2jvN4QaImYObp58viUpxMR6MzzcnEhLlp Yqjvk983uv/n+oX4C2TpHA+TdiwMQ/5u42EEpXqSOypLw3aNehX2k6cn71ssNbFOFeYl g48MZI1+APAAzLCo/kpeuTfIE3ujjPT8ZRiU/Ly0zNceZcj08ZhmwBRjS33u9XSvCjuo KG9lYsHFDzfNYw8yufkLimmrMqPJtXLy487AnRdOkKejKBvcL4yhkb2uvFRPXIgAX4HW ccHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VutqMGow; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si1757550pfr.39.2018.02.02.04.34.16; Fri, 02 Feb 2018 04:34:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VutqMGow; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751869AbeBBMdM (ORCPT + 99 others); Fri, 2 Feb 2018 07:33:12 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:54518 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbeBBMdH (ORCPT ); Fri, 2 Feb 2018 07:33:07 -0500 Received: by mail-wm0-f68.google.com with SMTP id i186so12243107wmi.4 for ; Fri, 02 Feb 2018 04:33:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5GxAn7HASr/bTdiTBUaUvzdyb4VmilzncEbNFjKuKQg=; b=VutqMGowe2ds6WIVBuT5t5/w9nLALpJWcgeBF6w9eJJx3YugW1ltIIKVRt664bo7Ia XII7kRFEoge++aj83/hzdAexJiRhHft97LTZe3XFLfzKA9HfG3HUeCWgyqq8r86LDvwo c4te2J6nNU2ozLWdIb0xCa8cLEsda+i3OQdng= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=5GxAn7HASr/bTdiTBUaUvzdyb4VmilzncEbNFjKuKQg=; b=Hdi67/dIEaFe6+l+qe9+cq8Af2kxs5MISvViZ+G508dm9rD3uoFab6IhPDc1ucspId Ps5LKOaZwWRpxfWwifQmpp3/LMldJ5ziRRcCL1FcuDL4lFxY0/NwTdBZP9r/nxDEBbcG Ybv6G1fDe2wT1WSTme2W9WOHKb6VABi7ep7LoQs4ZdoZbwXZRTa6GLxdxKObx8t4CD+o drES86jUHTLIQZFwUHiPDkolhRoOszlAPm1tTCRoFmmNSu1UlLowXv2rXdofqELLkwDz z9CSNugwP0ZQBjV2MdutzNgT1amrS0K+cEcV59XKaXN8M+ZockoQw0uhGsKpdmB7LK/p DQ1A== X-Gm-Message-State: AKwxytf9XugX5+GREJwBaYYPS06m9eRGvXNMlmu8JE3Dy2zsEWFZCXqY rK0wWKhlRFuCKLGjGDTeQeUinQ== X-Received: by 10.80.144.132 with SMTP id c4mr66265338eda.13.1517574785811; Fri, 02 Feb 2018 04:33:05 -0800 (PST) Received: from localhost (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id z12sm1738484edm.0.2018.02.02.04.33.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 04:33:04 -0800 (PST) Date: Fri, 2 Feb 2018 13:33:03 +0100 From: Christoffer Dall To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Catalin Marinas , Will Deacon , Peter Maydell , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux Subject: Re: [PATCH v3 03/18] arm64: KVM: Increment PC after handling an SMC trap Message-ID: <20180202123303.GF21802@cbox> References: <20180201114657.7323-1-marc.zyngier@arm.com> <20180201114657.7323-4-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180201114657.7323-4-marc.zyngier@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 01, 2018 at 11:46:42AM +0000, Marc Zyngier wrote: > When handling an SMC trap, the "preferred return address" is set > to that of the SMC, and not the next PC (which is a departure from > the behaviour of an SMC that isn't trapped). > > Increment PC in the handler, as the guest is otherwise forever > stuck... > Reviewed-by: Christoffer Dall > Cc: stable@vger.kernel.org > Fixes: acfb3b883f6d ("arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls") > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/handle_exit.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > index 520b0dad3c62..5493bbefbd0d 100644 > --- a/arch/arm64/kvm/handle_exit.c > +++ b/arch/arm64/kvm/handle_exit.c > @@ -62,7 +62,16 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) > > static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run) > { > + /* > + * "If an SMC instruction executed at Non-secure EL1 is > + * trapped to EL2 because HCR_EL2.TSC is 1, the exception is a > + * Trap exception, not a Secure Monitor Call exception [...]" > + * > + * We need to advance the PC after the trap, as it would > + * otherwise return to the same address... > + */ > vcpu_set_reg(vcpu, 0, ~0UL); > + kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); > return 1; > } > > -- > 2.14.2 >