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: 10994201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4062313AD for ; Fri, 14 Jun 2019 03:22:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 309092018E for ; Fri, 14 Jun 2019 03:22:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24E6227DA4; Fri, 14 Jun 2019 03:22:47 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 B860C27D4A for ; Fri, 14 Jun 2019 03:22:46 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=uf0MNUftKdFblmffXT7BOT8WQ4naGuI/DAstHa3QItY=; b=DqhzT2iySlKoGJ LRFmUch4KNOTg10KYUVbtZFnZWsPjb+FyHXIPFI3MUV6qhKscrzHOSkm4eJE40u/fY+aXUebWvuGR DOrXEYYVu3WECn3LlQDjFBJuKXuaxjECkxrrwa61mklNQNqbe4GxNYgKF8gPR5m1SQDpZHvo+oBw9 GaWmiDuT9ssicd6ZfsZTC5Ke2EL2WrFQy3NcXmvrsjj8DC92FpAVcLXh2EFYIi7fEYEfSu1pZMGcD gTdZ9mnZ+D5kizgD2k9DvK4t1CI146XT+EKBI3F9GIZ7mVuj3Um0VI6pJEkIgoNANoxPyZeFe4fx8 k/0Z6aQgjcIcBKSJ6oOw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbcnV-0002sD-B4; Fri, 14 Jun 2019 03:22:37 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hbceO-0000q0-Bl for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2019 03:13:16 +0000 Received: by mail-pg1-x541.google.com with SMTP id p10so690188pgn.1 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=eWScJHdpwE0XRm+DNe3rBpAcZzzn+KiUZY+d/UT7rGdCKJGST8v7eamGR/b5bnJMP8 bnCOymqWq5BuYvPXnSEJfJDRSSTgTI68F64Ky1J9xy/58MQ83epeYLtg8H4Ys6RCJHqU b/zerPWfxaafAzdvwa+28WYq4/aIWhtubBQbVxSsnHenSlxLyY3YYNXBhLVSQLPk4oyI xltTTY2z3+2eJ3PFyqPfa24Hn8BsSucKjs8us0RIBCBq3tL1Fd0xudHMzzR8gzzHjp/x sVKR5MFGP1+u3uJSc+0L3aTzdDcfdjs8hXiQjvH+88I7imoO9MOtw+QZRhSKiMPE7qOF HIJw== X-Gm-Message-State: APjAAAVkv1Iqb9a3Mo4lMsQ+CXLtFELN6dyXfsqIPbbFND+FmerqcwXc ZrRUFh8J1Cclf1MsFXHDduMG9Gv9gXE= X-Google-Smtp-Source: APXvYqz3iGB3sFLe1ujAa4CWxg87VdsLELINdehSRwwhAyr0qsSp+adC3/BhKcW2M+2In5oYCgZjeg== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190613_201312_506102_8715F18A X-CRM114-Status: GOOD ( 11.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marc Zyngier , Viresh Kumar , Will Deacon , stable@vger.kernel.org, mark.brown@arm.com, Catalin Marinas , Russell King 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 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(+) 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; }