Received: by 10.223.185.116 with SMTP id b49csp2239139wrg; Thu, 15 Feb 2018 08:34:47 -0800 (PST) X-Google-Smtp-Source: AH8x225LR/n4uq6Ff/TEpWTMGfTEmyy+buUFKzuGkWJpU1egyDA3kfJYYA0Roxp9aWr8cq6gbN7T X-Received: by 2002:a17:902:64d0:: with SMTP id y16-v6mr3051531pli.258.1518712487364; Thu, 15 Feb 2018 08:34:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518712487; cv=none; d=google.com; s=arc-20160816; b=reGHU2hTLYRGqwit05mymevy0QqDctdiy9oXLiLz5KJPMINdiFopi2SoQAxwgPIeXO GfKfbwaAhEexC1KSHAVph6lTsE/w3MPFMv23Y73BxlNIuqHRdYP5EfH8jBicz2S2KM3b c2fhV/VssH+JTBZcWDZIMURbC7Be7EU19gGlGzbHX58okv0hrxGf7hHrvqTnsJbdi812 Per2+nqVvrFoVaRIYEH7v997qlnUcIueAGTd2AG6Jn01NXrDM5XvYVlG1OGAC2Zv+uqb v7tzhmHM7CZSoapXCya0ihzOvqpgmkYlaGSArDXHm0jjam+LAnC1NhuiNJxqrf7C67QY KC4Q== 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=MN2RVRc1yznBaYRI6mXOifpxnFHTmTPlyAnMpGtXUmY=; b=PmwFShbgVQmgT/6x3fmkBTrQbdbij6XWM2Dc1ATfRe6zcSs7GmT3uolUs064ZFveUF YeXpsoiYSYyr8GUvUKO4YGsIhSuUV0fOH1bHtjNX+/bDhsxGXQm3d+tCcqPNgHgmIGRD ONUR3iK2Lzp0ydDJYv90GZeLZq0y6OQLyFDtncvwIkOIqRGCb/xv5jBmMw3pDbGynD5w /9lgapQb2WOUMG5mKJEDgzXSK68Dpb5LHkQ0eUIQCIz0jn7YJWhhmIED4e5GFG+0a1+M IZD0IKsbOJ8nkP39nd5WkbAdoLKDtMY5JZ7LKFwd53tdgbN9eR6nbB28JVEFngbI3HWd cfxw== 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 h8si436692pgf.418.2018.02.15.08.34.33; Thu, 15 Feb 2018 08:34:47 -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 S1424058AbeBOPlz (ORCPT + 99 others); Thu, 15 Feb 2018 10:41:55 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:32820 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424041AbeBOPlu (ORCPT ); Thu, 15 Feb 2018 10:41:50 -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 D1996F04; Thu, 15 Feb 2018 15:41:49 +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.15 072/202] [Variant 2/Spectre-v2] arm64: KVM: Increment PC after handling an SMC trap Date: Thu, 15 Feb 2018 16:16:12 +0100 Message-Id: <20180215151717.252169465@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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: 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 @@ -54,7 +54,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; }