Received: by 10.223.185.116 with SMTP id b49csp2307592wrg; Thu, 15 Feb 2018 09:35:10 -0800 (PST) X-Google-Smtp-Source: AH8x226uB3xxPpU1PYwW6ggSKkaoIGmav1OewLnRGbBtb5Otq8sQDFnRTiGUC7TFZol8DYsvzkxG X-Received: by 10.99.114.86 with SMTP id c22mr2787136pgn.41.1518716109963; Thu, 15 Feb 2018 09:35:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518716109; cv=none; d=google.com; s=arc-20160816; b=tOo0MdS9LKi4qXlWeyjjftppcEbQemMVXzaEidh6sUvcXkbLI7gX1LIJQRhVz+X9LX nSn+VoPWjhI8oD78Tga5XfwJrhKG+M7zK/mmPmjYWVuKLKpmjGnxT1BilnxkroYUqPnQ U1/Vvy6n37u6MFBaIKQTkOGA+GWgKbven6GfmC+9zEZKyOWPd9gFb8j4IJZgw90dF5H8 iMhjn7kk9kTZAWWEtjyKQQimrVMSZ7QUJB1yJHgw92sQ0666GB/JwAUwo5ZCG6zoJKcc P9SKfrBKUYOkzQlYUdTSN8NYdrVQ58vuWloaKjCsKd3wEGweuFauKlFQm9BSE4xjympI Md+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=MLuSWgNkzEAAecbdA3Q4FNOagRxkZgB2ej67ChhpyKo=; b=vK/le0UfRhV0WpDkRzW4LCahOG/MJ0UnziSDXX70TgAMXsSG4y6v2GhvyzMWYpzXxd AUvcYuzXgtUmSvWfP2HubAkDsS7OrLlJ+9+1hFTjqCfvMVEA7Z22XyodXueIgAo18NDY S0usBqDyBkimL/Gztv0CXWJtwFMskNDA1klQ9Y9AGV0ursuJDjrKVjlRfGqz842uI+wu FpXn5gXIq5srJhsz59Y/7lag4XE+FFvmA2JlqJQV7pEQLaXfbEQMHQgOkdJc19c++R/k dCZHQ+2SELgB89WeXeHZUaAPLDkEbsjgjVkCnys/eNB35UE3lEEfkFc171SXt76ZlGV6 Lv4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22si10879pfd.22.2018.02.15.09.34.55; Thu, 15 Feb 2018 09:35:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164798AbeBOPdK (ORCPT + 99 others); Thu, 15 Feb 2018 10:33:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56636 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164787AbeBOPdH (ORCPT ); Thu, 15 Feb 2018 10:33:07 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 81904F97; Thu, 15 Feb 2018 15:33:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoffer Dall , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Will Deacon Subject: [PATCH 4.14 079/195] [Variant 2/Spectre-v2] arm64: KVM: Increment PC after handling an SMC trap Date: Thu, 15 Feb 2018 16:16:10 +0100 Message-Id: <20180215151709.640731876@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/handle_exit.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- 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 *v 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; }