From patchwork Thu Apr 12 11:11:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 133222 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1572220ljb; Thu, 12 Apr 2018 04:13:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/z7zarfNvn8R4kzCrH1YsWB3mlh2VsspeKxyie1WrRdK+Qq3KxYY+ReZzmpngKyBkwgzun X-Received: by 10.99.119.133 with SMTP id s127mr344183pgc.441.1523531598211; Thu, 12 Apr 2018 04:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531598; cv=none; d=google.com; s=arc-20160816; b=QleUuvFhmb+vGdKEGf7ufI+GmhyHURjwEgzFVnJm2iFjY+WNx6pOSkaSAoO4dbqHVP 7Srw+eChAsule9QPt6GCOsoo22g7erCrXoXjuE7F7hqI58gy3wlNEdP8f1rn2TDXfFXn 0naUejfi2cybGOCO/rjkjgIMae5gzCEoeUCvXiOkeKTgnB02yBPRK54bD+vlDOPQ0iLx Q7hx/u/2daJyrGUiM30SLqK7XX6CkRAnCnNbTCzh7LZ9L5mO/lSjA4gJRc663wWpHLB9 Tc8q7wpzc8Nf+tuyy7oD918Z8aSgfAb2PYTljtlJulxb3YdEJWwa1CSYQ4v6vvdqn305 d/BQ== 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=lwC2gIe8VYeW5/QTi8ot6bYHaQjIoakpw2UV74ESkMg=; b=J607pCJyRXdAyx28NqYr6WmBbPmjZqY7lxdeYKgCLS2P+qhrVB6kFJbHVusZzzVk2F 3u+7WI9gmIAPhbyY43q2mxeqIZQqdSlX1ioCDF7jXriEpOozK6oO/POi2Ex1cysb2YP9 hLLV+EzvoG0xfU+hZ+RWFew7cot5oLpA6R+e+FKT94MfDroA67SRE3miei55BTJL+q8w zv6pamxcWjmuUuTF/5HFob63LhTWA1q42nBP5a8ZnlqL93fqfCFh6B8nbOzQpgZe3EkG NUnkfuxFDWwkmUHAKCC+8H4ax38B+lYuut/vBX4oMNPeZdo3tK/ZaEj8mpHTEeQK2Sz8 wBLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 bg3-v6si3001807plb.118.2018.04.12.04.13.17; Thu, 12 Apr 2018 04:13:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752919AbeDLLNR (ORCPT + 11 others); Thu, 12 Apr 2018 07:13:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59556 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752125AbeDLLNR (ORCPT ); Thu, 12 Apr 2018 07:13:17 -0400 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 CD66E1596; Thu, 12 Apr 2018 04:13:16 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2ED6F3F24A; Thu, 12 Apr 2018 04:13:15 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, ghackmann@google.com, shankerd@codeaurora.org Subject: [PATCH v4.9.y 27/42] arm64: KVM: Increment PC after handling an SMC trap Date: Thu, 12 Apr 2018 12:11:23 +0100 Message-Id: <20180412111138.40990-28-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180412111138.40990-1-mark.rutland@arm.com> References: <20180412111138.40990-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit f5115e8869e1dfafac0e414b4f1664f3a84a4683 upstream. 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 Signed-off-by: Catalin Marinas Signed-off-by: Mark Rutland [v4.9 backport] --- arch/arm64/kvm/handle_exit.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.11.0 diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 2e6e9e99977b..5b56b09d317b 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -53,7 +53,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; }