From patchwork Thu Mar 1 12:54:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10251397 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 E0C8D602B5 for ; Thu, 1 Mar 2018 13:29:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF9852018F for ; Thu, 1 Mar 2018 13:29:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C44DE201B1; Thu, 1 Mar 2018 13:29:49 +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 492292018F for ; Thu, 1 Mar 2018 13:29:49 +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:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Rtn5QsDf0//otJ9XpvdPqi2MAUhGl25IWlyphEZtNnM=; b=IG3fXL5ITVVGqw+os4uPm39IMZ YMQ5Q6BMeHqb/6L3AlAal08kntNjuvEp3sfWNb1I8P6nCXyu3JvA+w2vtwMPp0n44Qvpk/NVKLi10 MxaEYikFa83gscLBeGpNUR1XKMpIgLQ9mqZcVfmr/1RmGEnGb6kMUL6UWx0X5h9ECI5h/JDtHXExB lgeBHQXVtS8Xz1ssI+CZWBoJgJCd+dO6v0hAqOwNgM9/dyfjNrZ/YeO8xlLJxtLFqGe52gUYC1rlp h/XtoEkAeXkynDcpwx1b9WnLXQf1HOPsEOPFrktwMXUGSMRD8T/7/mjEmkoX7FiBgcSJYhNUF1ZXd x4j4kkCg==; 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 1erOHB-0001uc-Gk; Thu, 01 Mar 2018 13:29:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erO0R-0005Ub-QQ for linux-arm-kernel@bombadil.infradead.org; Thu, 01 Mar 2018 13:12:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To: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=fjZg2cg202rt5L2RQbntFZdbK bdcsYoPRshXSNdbXmOP0/1vPXlnY2JoinnKxp+V1WHA8sl6bcCb46OJs4W6kRU+SIrz5pH/KtCn8l uJKEcwQ4suzpkW2KudRonkmqiRuWQwEheGMWmYD4tfKcAR9v4LqGYXgFSKRUfdWYmCWzrw4qSNx4u b8VA1DUPdP87o7vR1U64gy65DDcS3WJkTC/Hq6nH1W77V0Dop/07MTDCsG7ZQtGXkB0Ri4sdWTe+N gzE+bSKu1IrBcTM6MTKP3XuCaGbzY9TPx6JuGMWlDMrroLSshTkooclHzZhnHsDKMaQlKJh1wpx8Y bxKzpXi2A==; Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erNoB-0005AP-Nn for linux-arm-kernel@lists.infradead.org; Thu, 01 Mar 2018 12:59:41 +0000 Received: by mail-pf0-x242.google.com with SMTP id f80so2401193pfa.8 for ; Thu, 01 Mar 2018 04:59:29 -0800 (PST) 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; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=KX26itFa6TWDAtd8NB+rYrugNbEWlF+pHs/zXVAPusKcpCZ1Yu/dj9IDJ0aaYxZZe9 cbh5KbeIX3EMOicPzUJD+vVsN8abRaPgSgXf8EH34CGpffQ5XmnVOWCzgqITfqvMGc8N wMMw5oF1PWtUflxwo4lMbqjXw14s/8YtGrJkQ= 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; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=rDd2blUPPZV1CpppRK4TYz3/+G4qQZDTZx7FPkvxUfKGuxTvcd9Ib+U2x/vThc+lAX Nk2MeBq1JvHs7gpn7fxGq31cwf5cPAtL+ZA59zLSYmaScDvS/xKZp2/piIZCbVv8fxZR kJrcntKSR8zLcJX6ItBxdf/7ORYHTIjZsnGe7+/nEo5J30DcZU1RpL39MbrlaQSUYA13 o5Q0DDAZBnGD8u+txKG3NZCF1PUJfUfQQH5PRfxVV+a6u1TBwmRlZSHfP8eMSKULy/0w szCMv+CXaUZycOd938QP1fsm1MBFCSltCPZMULlQTxLQHyhR+6WUc9u2aFKhvTZu/nJW cgzQ== X-Gm-Message-State: APf1xPBEr0594smQ9PTg2E+0/4b6UVF1bCOQvMTAggmCcPRScvvhbKlK dkC/iXRFK+RCj1eJn/1lgPF8xQ== X-Google-Smtp-Source: AG47ELtD/baaMEgHc/wvhiwz4X0UBIZz2P2IRUFr9lAdDcIq1pdr5XeqYlJlK9TbxfXFiquPRg2LEA== X-Received: by 10.99.117.24 with SMTP id q24mr1474368pgc.53.1519909168143; Thu, 01 Mar 2018 04:59:28 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.04.59.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 04:59:27 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 30/45] arm64: KVM: Increment PC after handling an SMC trap Date: Thu, 1 Mar 2018 20:54:07 +0800 Message-Id: <1519908862-11425-31-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180301_125939_762773_82561853 X-CRM114-Status: GOOD ( 16.33 ) 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: , Cc: Alex Shi 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; }