From patchwork Mon Feb 26 08:20:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 129582 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3357724lja; Mon, 26 Feb 2018 00:24:51 -0800 (PST) X-Google-Smtp-Source: AH8x227A011GKtUFwpIRDL4E95W8LqF+oxAx0QjBE1s2dYl+hiv94DGpQbxPGC6dIAzB4Y9PCNuM X-Received: by 10.99.120.201 with SMTP id t192mr7811123pgc.39.1519633491326; Mon, 26 Feb 2018 00:24:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633491; cv=none; d=google.com; s=arc-20160816; b=vFz/qY9i4pvCL+fq1UVHpGco+7+IwvLWzX1vlYbOpVBfZRsbtKbLXt1ha1WvVrO9GU S1IsQpcGtJu8b9tTCGKXDr7Vv4BOOjoV90EC82QWsq0mcBNPIWebp8ZBKDHt9li248td cq+wkw9IbDswr2YWj5kxGEsw8h4d5E8ccOstiFDpa9EnCfk/aI/41Oxfu2tRMC9BoOfk rBVVlS42BSkLsSOZ4CkCZf9FBkzFvk6dOIKTOylkCybrMizyiPo2tmEmLDVYQHQzBHOg iePxngoUx5yZJW5HMDZv2rcg+hMRQ5zNvMnOL4NlpwDENnWzpKxzVyxM/vn/OvL/Mycv Ltyg== 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:to:from:dkim-signature:arc-authentication-results; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=VxvZVjLLoiNCOJctFwihiTZdlaOV6uBf+0Ts3XkyYTPHnxN9nEK646yjC62K5Lp/FQ Z8/pAOKOYoFEXIBFCumLLCVaScpnJYj7vKn29qcnrg8RuTS2y3k7xm85YCowVValGYGV JjhIaqPCnttHWe+l854iLxOju3BRrPL/1LwPyNlVlG3sHnUhkQrCIpWNxKbcldqPS3Ii DksuPU+6bAilFexn8Jhlur3Dn+PsPMTxZfW1pSjEx8wHz3xOAm1PCN8ZqLTFSckj/lIO ggaMgyydxisixXt/+OqBK82RegDrR9EhH8PLX/PjqGxcehMmx1V9Hij2xyWuPhw4DFo0 inYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aJOtU3Bb; 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; 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 1-v6si6389538plp.678.2018.02.26.00.24.50; Mon, 26 Feb 2018 00:24:51 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=aJOtU3Bb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752433AbeBZIYs (ORCPT + 10 others); Mon, 26 Feb 2018 03:24:48 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:39892 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbeBZIYn (ORCPT ); Mon, 26 Feb 2018 03:24:43 -0500 Received: by mail-pg0-f67.google.com with SMTP id w17so5909567pgv.6 for ; Mon, 26 Feb 2018 00:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=aJOtU3BbNimU/2ivLtPtjHbi4kjfA18KzNfLloYw4Q3hTZ1P/nyrFFdoe2RaFJ0yNF MdjSu08eySO3EW1vYNOzrRndv6SeEddJWe2AJ7y1/1vb6nXbxJlesLdRWkyFmdB2lNBZ nCwEwHEQ99xu4KOJq6VQKGWXTk6FtFMwzXSS0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=l34Y42/PTB0ArvcFTibTAgONiWCvVLIGT092Cy+YaDw4URJu1Ry2xZzroqZBFwlpw4 UtHTAOoJf6PqF7LR0sKnOEB8wwMhsxIKuOKM3wWmwhObctsAl/qkb/S5h8eagrZqa9dk oaFA3k0aC8vpNTTWsZ5RwOKEksCQTuRYH8I3IP9Ix3tpJn00Rjx1clelDgra6HVoywIO dfwcRI8ocUhDf/LDJO9ctL35ZuSOQaCu1u4rGYXIEWalmdg+S3OtI8MHUu6IXGr+eu/u sh17nY4I8cmkk69B5oq8lJs9yNxuAgBQMf+mxSNm6SBb/0XbzNHvWjsaLmyiiYFnyWx/ GFmA== X-Gm-Message-State: APf1xPA0GIkkL96QAzl1PqBrSFz9uWD+mOvJ3wlIJ06pXz9l9YQTysC1 xqeQo7xus65qFMt94lVXnFbY7A== X-Received: by 10.99.145.194 with SMTP id l185mr7597844pge.394.1519633483193; Mon, 26 Feb 2018 00:24:43 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.24.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:24:42 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Christoffer Dall , kvm@vger.kernel.org (open list:KERNEL VIRTUAL MACHINE (KVM)), linux-arm-kernel@lists.infradead.org (moderated list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)), kvmarm@lists.cs.columbia.edu (open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 30/52] arm64: KVM: Increment PC after handling an SMC trap Date: Mon, 26 Feb 2018 16:20:04 +0800 Message-Id: <1519633227-29832-31-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit f5115e8869e1 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: Will Deacon Signed-off-by: Alex Shi --- arch/arm64/kvm/handle_exit.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.7.4 diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 2e6e9e9..5b56b09 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; }