From patchwork Fri Mar 9 09:07:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10270157 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 6A4CC60236 for ; Fri, 9 Mar 2018 09:17:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 694F128754 for ; Fri, 9 Mar 2018 09:17:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E25B2876B; Fri, 9 Mar 2018 09:17:43 +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 C59C928754 for ; Fri, 9 Mar 2018 09:17:42 +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=D9EBFK6uzhkaZ17vFnch506VlAzn5MbAWAQaAYvKQV8=; b=gNKTlzJeFxHWwLJ3cqAaPSspJ4 ExB69KYoobLI6grjRDXdqGVPftrSohok73cF+ZawmUec/8kl0g9rJUfbh0LZYdhj4Pc5Eg7hDQT3h WUw9tu2agy3k6Hc6mYViuWUhElk4QuS3vyG7LYz93OSnXVorOpDEP1btStRhcZsrNy5qgXTCbCAEr KEuDz/TpovQMEuP50tBfCcC9HRf3JTuIs9fGYZy8KcRo4cttemJmtEQ+dzEDGwwD9LTWYvmeuqGJw gQYeipCdBNhriegzLYR5TPGZ32+mpVThixwk/I/aSHM6/qz+7KUq/ueMOclCLo37Ynsjm0V4kkxOt 4Ph5NKIQ==; 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 1euE9e-0002k4-83; Fri, 09 Mar 2018 09:17:34 +0000 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euE34-0005bD-1x for linux-arm-kernel@lists.infradead.org; Fri, 09 Mar 2018 09:12:20 +0000 Received: by mail-pg0-x241.google.com with SMTP id r26so3324019pgv.13 for ; Fri, 09 Mar 2018 01:10:35 -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=Tq4hPDXUAswFY+BzhgeuJo8JpPQc0VI5qWituqvYsfw=; b=eLZxvXArN+S5O58urZiQujArZu3zlI/6AlUfWGkeATYvK/qc5oELiLVwLeRgIWdZKl VWZxHRfNtMkA7ezp3Tfw9uxUf9ml7E4PByMBVBG9vIeNXF6TN8Wh/IQ48BcBPmMO69Mm RaSfW5QHKMtIne2SuO3PSffrrnujezp/Iqkag= 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=Tq4hPDXUAswFY+BzhgeuJo8JpPQc0VI5qWituqvYsfw=; b=SjyVWree8I1fxFpmH3lq7i+SyTBts57YFDhLmBUzUBdDPAHP4V2pe2XOgM0cdK6G89 z4YAYBDkTski+9p3Hyl3EjbeFMqr1WwPuwpopmu06ag34NAo1N8eEKxpGtOMBsoKFK3E U6McxQ1VWmUdZeyDHsG1HKNO2a2T97viFTK2NBV7fp5gs1ISdGNF3Scni+NnJD+wYunF N8gCwEvZoXa07VWH4v8jUFlkQRqcWaWAzDydW/wI1pJbz8dDuqVz0E1NksFLp8KD7acB APzA74Enf/qhsig6sEGtO/l21cg7Z7vXWDFfMHADolo/Jpj6lLBnigCOmmmINAmnRm19 F6Zw== X-Gm-Message-State: AElRT7HFVY1HZ+yPBzwp/2Ib1TVyuq6jjBzkvMJY5Q7YLJ/dXHT7Hw4B C5cyy7+qkLknPVfxzDF6CP6b8YOzTf4= X-Google-Smtp-Source: AG47ELuDk5BYgxNkvUI7QBvbqTgnR3C2/Rf5zX1j8FqcTFg89FBToV1qhCMGRTc/V8lG3xLhL4aURA== X-Received: by 10.99.113.94 with SMTP id b30mr333107pgn.196.1520586635283; Fri, 09 Mar 2018 01:10:35 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id c7sm1961752pfg.36.2018.03.09.01.10.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 01:10:34 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , broonie@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 22/39] arm64: KVM: Increment PC after handling an SMC trap Date: Fri, 9 Mar 2018 17:07:05 +0800 Message-Id: <20180309090722.26279-23-alex.shi@linaro.org> X-Mailer: git-send-email 2.16.2.440.gc6284da In-Reply-To: <20180309090722.26279-1-alex.shi@linaro.org> References: <20180309090722.26279-1-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_011047_150090_68122259 X-CRM114-Status: GOOD ( 13.50 ) 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 , stable@vger.kernel.org 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 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; }