From patchwork Fri Jun 14 03:08:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 166767 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1506093ilk; Thu, 13 Jun 2019 20:13:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTVTmpjym5nlONCp7cXNMiL5+SrHRyEPDwwvVVoUeevI/XM2N2zDtvpQAVR269MGjU7Vne X-Received: by 2002:a17:902:54d:: with SMTP id 71mr88734823plf.140.1560481992793; Thu, 13 Jun 2019 20:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560481992; cv=none; d=google.com; s=arc-20160816; b=0O9F4a2+gOACBN8ykuD+8ilbPLvDID0kkPS2JP+Q6+34qHQIy7jT/70KTqOQSydfaH pPGhUV0GVGPAhIx/srXhvyP1wDDH0ewzT3yEzIffmniILwKKP6JZabtazbmued5FDpDW 3ieJ3Y9MWo1R2FqdBZN3G4KMS6xmxSlqKA3V8gmbbm2RpJCQk3DYRSUsYrps+74/CVgy PWjhQbsOwgbzv5eo884WPm9BOx+q/T4qnVVP4c/h6B0j7fEM5K9wZQglTpuVJWVFj1h4 PQ0CXfYop7FDfsaSvaPqi8mlnP/DsPg9JjbMgibt5jUwIJiZwztRpnap7zAr64fRBPvr jQGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hP63VKEYPHg3zKNj3xMaZwjK56Qq/K++eO//dDzRjvk=; b=K06+P/rxEIA5ROauRkdNhcoyuaVmUyY0qbeeHVr9hIG/UQdeNzmKoaGD6k5ey56T52 slLTMSvZrnaivymy/rwC/tQrkZcltovlL6Mn3MF1GqqrRGAIlh/Jlk9rY8iwVjEiIeGh sPO8lExJ6+Ly3c/Rc+u4+uAIXhbssbnsp0ZN23MNmB8w0pZjc/8zZ9J+AUfmlSknZjzJ mF5KbEHFewN0YOv/h+DuCB0pQYwPOHhQ6cxdkBtVobJ7BvhFNDoagNN2l8jfkoaNQ3wf iQXZVvo9WCKNpMquy+heBPIWrKFHycbp13d+wB2Z2SDI/CoyfpqjK5zcdjLsh4U2l3eA n51g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="XKzO/FoV"; 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 e8si1073936plb.420.2019.06.13.20.13.12; Thu, 13 Jun 2019 20:13:12 -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; dkim=pass header.i=@linaro.org header.s=google header.b="XKzO/FoV"; 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 S1726442AbfFNDNM (ORCPT + 14 others); Thu, 13 Jun 2019 23:13:12 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39729 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbfFNDNM (ORCPT ); Thu, 13 Jun 2019 23:13:12 -0400 Received: by mail-pf1-f195.google.com with SMTP id j2so494033pfe.6 for ; Thu, 13 Jun 2019 20:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hP63VKEYPHg3zKNj3xMaZwjK56Qq/K++eO//dDzRjvk=; b=XKzO/FoVC0F/C4cPzxh2/w9xDeu3OZ3640Q66sWIDaYrI4StlFuJ3ZBr1yFuUuBOeD lAPWHE6wpJixcIXHSeVdX7HYeAwZ1jk4l8IId6e2YoZyHBTw1Cbhs+1ZcCD7HmWfBg9Z Mg/z8WeXnPtbWv3DcJW9vguLf6NclZdtb2PHrhx7vP4hvspjwrd/UcpBOqakQ23I8YJj wKS5TakaT13Waa8g7uoG37UWjq8U6cOWr0o3yUbZXY9T7L8MuVXzIqFMxExia6clUbSu HApz5WTgOGxo7STDNUHSQuiqTJd4DXkW5nwubO7ta7JT7OFDH/B+bGerim8MwpmMSWzp 9rRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hP63VKEYPHg3zKNj3xMaZwjK56Qq/K++eO//dDzRjvk=; b=k03OtpJM2jhqOvdgBQreux+IJvcnFYephu2AE5kjIV7Ic337jTt+AK9qGXvz+fzviU KRAnTg/ejYmjHn4R89r6vmOERl3IpMp8ZrytC+9UPCHcg5pH6xTq4u907ePlnRZUzdop dvO+pxbtyNYIuZu6kKBMpQzAJjvt8Cs6Yvg/FJojtUpn9VHKV2hSKkLuo3KnnEFlID31 JvTHSPtudMYhMCsejNrIUKQmGjNySlBKA6Z7TjZmkPpC34t1NDsdqouXlJCMRfgF8vWm 1tbI1QwcmeUn9XIymoNpnlQhsJkl/uOxXYE665Uw0T5FpWdmmqZDVp4cd5Je62uzW503 T+aA== X-Gm-Message-State: APjAAAWHIdvy63Bmp6PScQeMvxqziXOSmO8x4A2NvNnTJZUXvron4jSf G0euZLGzVEfPpZvRC1XiN13BVw== X-Received: by 2002:a63:545a:: with SMTP id e26mr33192910pgm.162.1560481991000; Thu, 13 Jun 2019 20:13:11 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id b16sm1067054pfd.12.2019.06.13.20.13.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 20:13:10 -0700 (PDT) From: Viresh Kumar To: linux-arm-kernel@lists.infradead.org, Julien Thierry Cc: Viresh Kumar , stable@vger.kernel.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com Subject: [PATCH v4.4 29/45] arm64: KVM: Increment PC after handling an SMC trap Date: Fri, 14 Jun 2019 08:38:12 +0530 Message-Id: <2798950c13d82c9e5b4c9a94afe8eeeef052283a.1560480942.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 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: Viresh Kumar --- arch/arm64/kvm/handle_exit.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 5295aef7c8f0..c43e0e100c11 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -51,7 +51,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; }