Received: by 10.223.176.5 with SMTP id f5csp949195wra; Tue, 6 Feb 2018 09:58:39 -0800 (PST) X-Google-Smtp-Source: AH8x2241JnhHl1JvWp163DdbWwsnB7VmAePdT4YvTFxd1O9O6X7rvUCxAeN8iSlxTIAh/HG81TZe X-Received: by 10.101.82.141 with SMTP id y13mr2588691pgp.179.1517939919719; Tue, 06 Feb 2018 09:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517939919; cv=none; d=google.com; s=arc-20160816; b=XDjimjiNBrg6bmr0v7KQ+Ls6V0hIEpFxD+5UrVhmOt4459/YSnLQgOu+Z7VExRbk3S M3XXfD1t8q/TdvJD03zfTzjHWwVfEUYPpIJl7zYP2CsXV7yAfIiMihPYLS29e/0q8aGy h3H3iHP4SGoAWJPVax52V81VPbMTe8GVSYONO2a2bFck3tW6dtC8uRhW7jcr5ucHopG7 g6AGLyDMpI5mTc4BTr7E0E82smvlKSDkaKtAdcIH01lbVHTe0pKupv+wLeOAjrE4U4tH gQszRY55N1kbuM0AQkoOOaPoXaioqUj7ZU5+6d33F7Ia6H4feZe5VfZyf2K+oZmohS3w oPEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=0azkzcQ2k2qGbNlWhST4xlCoRSe7J9dakQIfND4mQbw=; b=xa1hrIdQ5XkwYple8FVYTAFOHbmN6iXNIM8NavmxS4ohqxFeRSaUiEYE/42v7pBakU YAhQsp8AKe2DjUBZvzGCsIHPV/OnTj+BlyPOhAewlWuhUvd0XnKeqyvAl8w0uLO5FfE9 41l6TS3LvmqKv/gCuagfYw87GNiYH8qsOypkki/JguiinWUCuz4QxSy06WH/n4SMfvj5 mNn5BjAC3iyeh5kUsWKZVUJqS8r1UEJD5pEk+BC3sBmEZCH37N4wjuB8gDenPyEWmLvv sUFTiAJ7qUsaBxyc4Koqeu5GsIGaDPTqf3YEx7dn1wOmV1ppiOGU/Op1pGncOACzfzBJ AoeQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17-v6si1869740plp.44.2018.02.06.09.58.26; Tue, 06 Feb 2018 09:58:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752839AbeBFR5Y (ORCPT + 99 others); Tue, 6 Feb 2018 12:57:24 -0500 Received: from foss.arm.com ([217.140.101.70]:40984 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752710AbeBFR4z (ORCPT ); Tue, 6 Feb 2018 12:56:55 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 686D2164F; Tue, 6 Feb 2018 09:56:55 -0800 (PST) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.207.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB4C13F25C; Tue, 6 Feb 2018 09:56:52 -0800 (PST) From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux Subject: [PATCH v4 03/17] arm64: KVM: Increment PC after handling an SMC trap Date: Tue, 6 Feb 2018 17:56:07 +0000 Message-Id: <20180206175621.929-4-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180206175621.929-1-marc.zyngier@arm.com> References: <20180206175621.929-1-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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... Cc: stable@vger.kernel.org Fixes: acfb3b883f6d ("arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls") Reviewed-by: Christoffer Dall Tested-by: Ard Biesheuvel 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