Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp792542imm; Mon, 21 May 2018 14:33:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrpaIPxXoQxDT8H0um84ZjTUa4YPnNEuUvgzSG2Ah194MFSBbm90OWVJ57HRAU1WhJJRdRt X-Received: by 2002:a65:5144:: with SMTP id g4-v6mr4374789pgq.445.1526938409988; Mon, 21 May 2018 14:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526938409; cv=none; d=google.com; s=arc-20160816; b=XAXngejeAm4z8iY/vdRhssEf2VKf+jY7Gslccr2LNXyi7vO7ro4vTT8eHBVc6yEE5C m9C+IFSSpurSbOzIYAgLAQJkSd66sYrAE7CkKrs8P1m//gpwVNzcXGR6FuNschvV0Qve TwYE8Bzt4IfOgfaGTUl4RIzFmqCXG+9tc/666KO3MyEzgu8DVY0y42WTMqoqnDpTZSM9 XjjJU6RiMKiQiFISREIcZSMZFBENDmMW78y+Zx/JuzNignQdyOsQm0iZKcFjQXOae0O2 sI1GfzKrqA1l/051QlyWCxCaBJFm+0birs2VMdLYNcDrLV0XuSel0uX4IDa6ah3vSSMg 7Vjg== 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:dkim-signature :arc-authentication-results; bh=i+OTPdjxIx40Hw8/rkycCcXFhZ4CL9/v9vTD8Gl/zEI=; b=0BwhUybS+2+O4i5bhDl+dWBvFeNqsGrVuIdgZ+iuqgMAn+fHhR8LUwXbq8nsQj+UIY Tl1Mqipqh5stB3qJewLHgmHoN8bmyZAqwrxZoAY4JlAcwn2gbg2QOytWtUc/I7F3K8vF fHaAzbm8t1Ivmwz3xT7t3GBNoiUSeoBGlS2ppj9172V41Z7GkAEf+l7mwafAXtSBteWF lRctXbzHQgn7HG97U7WjCH3vXFpiCZdtvKdmw7iyH9sJrjToIJCTAkMdepHe74wusb9X dwKwtgrroMQlTCBcLLqs37l2xf966A+r2raEyJTpJbO1XMOMK59nyksoP11LEeiu7LdC BSrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jhMxocmY; 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 d9-v6si15148987pls.334.2018.05.21.14.33.15; Mon, 21 May 2018 14:33:29 -0700 (PDT) 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=jhMxocmY; 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 S932549AbeEUV01 (ORCPT + 99 others); Mon, 21 May 2018 17:26:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:41096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932536AbeEUV0S (ORCPT ); Mon, 21 May 2018 17:26:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 1335E20871; Mon, 21 May 2018 21:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937977; bh=7E16b8g6J+4LWoTGvYwLRUFTMFxbAcSMzTu6DBzR2jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhMxocmYxR36jB4sIr+rNjRxa6uXP11+djwA0AuRiunKhVWvIvgPiPt/9Mikh2X5n Xdofrs1Ox7TdE4lvDtZ+qYgBu1XZCbCNWeTy7FYmWM9SmL/aot6O+0GoW9mMkiKIDi pRX2fa9ea6w3DkMYOTRRI/U0HYZU3m+0M2ByROl8= 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 Subject: [PATCH 4.16 094/110] KVM: SVM: Move spec control call after restore of GS Date: Mon, 21 May 2018 23:12:31 +0200 Message-Id: <20180521210514.147497996@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.16-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: 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 @@ -5495,6 +5495,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 @@ -5515,18 +5527,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();