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: 10241803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D23E602DC for ; Mon, 26 Feb 2018 09:47:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEF1B2896A for ; Mon, 26 Feb 2018 09:47:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E33672996F; Mon, 26 Feb 2018 09:47:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 861942896A for ; Mon, 26 Feb 2018 09:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Rtn5QsDf0//otJ9XpvdPqi2MAUhGl25IWlyphEZtNnM=; b=o5OUnA6XNJgGbO aEHvNGJRZSbcSt2lhZ1RztkDVK89YkBIXhNU1rDEiXZCM88hB1pd86bSQbsL5y6Q5L7w3I0xbmi1v RSdsU+WbmZvW63UJvQU0Q6zB2Dg3Rqt3OBB47U5T5hmVWJBaqck2GtoBW7b/lIu6AuAMwpAarbyvU hN7xqwOkPunegHh1aqFRhzWZoW1RLmUhGBYicA++S/zIX47Fw/Opw+qg8jvh3ZWOUKd3OCxjLYQEV fj4tuEfjnx0XE9bKL++N8qtqDxlQLecVhCOonHvPm5tPPJrlUAEREClprNoFI+ERpIDCzVFgEDjp1 CfLZvfjkVrJCHzha1PAw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqFNf-0003ku-2l; Mon, 26 Feb 2018 09:47:35 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqFI6-0007sG-BX for linux-arm-kernel@bombadil.infradead.org; Mon, 26 Feb 2018 09:41:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=ICM98YOtjrCSYD0nqFuS4Deo1 HyRrm+udnNx1FvHm4JX6X5ZXHu7NTpuVrmy+9mMJd4VBs4gg5N2Jc+f1yKlM5iFsajvZJo4x6ph0w m04NSHvobm8uX/B4IsThGWzqn4ePQH8L3dNUn4j02d2MgD0jjmg95umWwbq/XhoOOGdKQtjuYZQUq E4TJoLz4dtLCrK38qGxyoYSR8MIgnoquYr6PsHSVZuB2C0Opfe+ev/hMJ1/p92BFYCE4sAT0UveW9 pzXJJS2/4eCo0RXl7bRZ60PAQd9hUkl2qcK1hpt4m15E4/9blnI8lB9QSZFVSbavz8he8llPSgumI zxECdk8hQ==; Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqE5g-0003Xf-GV for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2018 08:24:57 +0000 Received: by mail-pg0-x243.google.com with SMTP id i14so998890pgv.3 for ; Mon, 26 Feb 2018 00:24:45 -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=grnwll3MesB1iyLG3UwFFmgOhs0oMyeJV1iMseuQ9ntD1QET1luMK00UAqgUwjTXjr ZTgPZsylu7PuTmeuI6mnJqiPuHSw53ZCdnCm7WeCwl2TroaSZddmLvXNM9yhaghaUYOi X3o6eRgVsGnv1Y9/GnVz7toea4Iqr0SVKQcE0nWQ2ObnWcGM4EEYJEGAIl6bzOxODi/d e/5FPb6goNik64E1sZhoKQ1RbBFoJ2Dbqe4LNEA73HGQft441056wZ3WXeCwolICWlSq Z36SwUYJrMrY1jX4w5jKutD5TAFO9MeZPvm+u2Y66VitPG+c+WrUIJCU3nf/jF+5+GCU bElQ== X-Gm-Message-State: APf1xPDj/avLruDR7S3UIQTk+VT+FIJHxd3/IaoZIh8B0/tlZTg3R2iy 1S4wdytcR3OZc+/Q5lVNSBM4PA== X-Google-Smtp-Source: AH8x224sXf07/1UaovxeoGYvKB4N4ak2vjiwygI8UCwWpZ58MGgB9BdV/E0oV8AEgRnphKGvX23Haw== 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?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_032456_589112_F6BD47C6 X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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; }