Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1999731imu; Fri, 14 Dec 2018 04:17:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ul09qtkGf3WHC785IphGdixXSvXdG8vbf+ThQ4qz00+QQFLNLiEVrniqT/IhJGfs32A3qr X-Received: by 2002:a62:53c5:: with SMTP id h188mr2598471pfb.190.1544789855980; Fri, 14 Dec 2018 04:17:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789855; cv=none; d=google.com; s=arc-20160816; b=Ql0lS/l/VC+OhtH6qJChNDUlS0yFkxla0gpMHW87bZJNFes0v4t19O47seAJncYKTJ gJQtIAMR5r8oPRPxeekFCW3uwQ6obSo9MB2X7GpOj8fPEwUy3/dYEddr/UYmp6MzLwBU flslErMzlWKTLYQuJBnKhCM+R91Yi+cLAuEkIiXoW9Y014wXzodyE+VzFGLVHrTDy8GA ROUNfZzRJB7IfXndNnKl2C+LqBHojRjEEmfNkVsL3FUZB5Dgy6Zpf5RvKSpvobKtvRgY SVUM+JGXqk+tKF5wPBfbwjvl3V24FPIN1QD1Elb//ySze5FPMlm6P39QDFbWFUrXbh/D 69xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9YXPmhWjmbixNKadoxUkFuEnYCrNSYY0x3Pb737ypUQ=; b=Z3ZHANqTJV1u5Eo7JzgDEmo7TqiSCRNhjxRETSLArlZVlxuKUonZapXWMUrVbARQr1 I1hp0ReZEke6rbvBAnv0gkuJNW3nJ3utRNLxRX1khOdX12gHjlGlve6+OdszD68vvY5s NkzrlS1DftYBcSYbcNo+gIbNiyAsaPH53H06dm4K7r3eIiiDQZuolR7lFmGR1ZdGBF0y PtgmII27w8UoNLmkNb1RFdY1bCFLF2y6JPTIjoIDXsur8V8DHvYJ572CMvJ7SuPYxwTy 7nL76wn8/DvCAldow6dpD+mHq5JlHRwflrS+xUouCNOyPipl2Vi99q+Tb62O82/zTdNo p7cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wQ6hwG0w; 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 d4si2241706pls.348.2018.12.14.04.17.21; Fri, 14 Dec 2018 04:17:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wQ6hwG0w; 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 S1732779AbeLNMQg (ORCPT + 99 others); Fri, 14 Dec 2018 07:16:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:36796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732264AbeLNMQe (ORCPT ); Fri, 14 Dec 2018 07:16:34 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E185214AE; Fri, 14 Dec 2018 12:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789793; bh=JMn3SSFj0g8NHb+MFh7WUwRpo0MvSNUGV1q8RiDG0zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wQ6hwG0wgqMKpB0XNpslLnJGNgov8+AlBuS9FJGqmE3xYIW+0NS7itERAIvDt/mmB McovjY6qVrXsplwC1Pn6QE68BR6ET9A2B3hrtYdqCTL/qYesSJwPJSDHBbIs4A0CKk JHdLmsWiEN2phUpIauwruZdAUynlCb6NOuAiLT8s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Konrad Rzeszutek Wilk , Paolo Bonzini , David Woodhouse , Ben Hutchings Subject: [PATCH 4.4 58/88] KVM: SVM: Move spec control call after restore of GS Date: Fri, 14 Dec 2018 13:00:32 +0100 Message-Id: <20181214115707.259654951@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit 15e6c22fd8e5a42c5ed6d487b7c9fe44c2517765 upstream. svm_vcpu_run() invokes x86_spec_ctrl_restore_host() after VMEXIT, but before the host GS is restored. x86_spec_ctrl_restore_host() uses 'current' to determine the host SSBD state of the thread. 'current' is GS based, but host GS is not yet restored and the access causes a triple fault. Move the call after the host GS restore. Fixes: 885f82bfbc6f x86/process: Allow runtime control of Speculative Store Bypass Signed-off-by: Thomas Gleixner Reviewed-by: Borislav Petkov Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Paolo Bonzini Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3998,6 +3998,18 @@ static void svm_vcpu_run(struct kvm_vcpu #endif ); + /* Eliminate branch target predictions from guest mode */ + vmexit_fill_RSB(); + +#ifdef CONFIG_X86_64 + wrmsrl(MSR_GS_BASE, svm->host.gs_base); +#else + loadsegment(fs, svm->host.fs); +#ifndef CONFIG_X86_32_LAZY_GS + loadsegment(gs, svm->host.gs); +#endif +#endif + /* * We do not use IBRS in the kernel. If this vCPU has used the * SPEC_CTRL MSR it may have left it on; save the value and @@ -4018,18 +4030,6 @@ static void svm_vcpu_run(struct kvm_vcpu x86_spec_ctrl_restore_host(svm->spec_ctrl); - /* Eliminate branch target predictions from guest mode */ - vmexit_fill_RSB(); - -#ifdef CONFIG_X86_64 - wrmsrl(MSR_GS_BASE, svm->host.gs_base); -#else - loadsegment(fs, svm->host.fs); -#ifndef CONFIG_X86_32_LAZY_GS - loadsegment(gs, svm->host.gs); -#endif -#endif - reload_tss(vcpu); local_irq_disable();