Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2002193imu; Fri, 14 Dec 2018 04:19:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/XzF8GOIP2dpvwuo/7sq+yDWpToXUsh8NAzeaadbec+8n70dtJTBqy3/ofXUEHL3YSAZitV X-Received: by 2002:a63:2744:: with SMTP id n65mr2501251pgn.65.1544789982806; Fri, 14 Dec 2018 04:19:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789982; cv=none; d=google.com; s=arc-20160816; b=X4J9B3LeiHqLYzXRJiQSfrajSTUEVHTIhEECfeEtLq2HFDycbslgk1/GcySqvNhSDt cmN4h6H+Qiq5Zp4PfciGg8wwAKsPXrcUgQYtwfywH46iWetM0Cf9U7ZTFi7od1pu2p+Z dNp2Vm4x/PP6CGG0mr+/0w8SgC8VdyS/rNBPmt7wmxP/QEolH5PStABAnM+NuTn3m1/W zI1ResSZHf3xYJn/SphGcmVrAb7GmHITkAe/CmmiaCcRWYX9AWQR1gYm6GxBc42Pqptr RzbjOjeNmcvzt4XPM56etHb6N8DYwW1Spx0Iwj3dMNYirrqC0xCyg7/pk/ZJr7UGNj7g S3xg== 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=CpgR7WWoEMSoxOHPu6BoUF31ebfW+8U8xYhioRF3hDY=; b=fxIlCKzOzod8gI1yyxYm79QW1QhS63U2OWfF6rpwciRITeJOl3saO4HIcX+WPDjUF/ 1xFv28td+Cy5SjweCP8Jt8vnqg2VfmIV+16pFG0sCeNhhL4H9evT13joWi3pjjaf0Kau lXrVcC02jf6iK5rZn/XDYcU9C3+BFCjquJbfvQLL9o7CTlHTZYseZ+MZtdH4pxbJLQwi zuA9NDMMmBoUe3bBUv0jsivOcBEjyQVrRaK56qUiHmGErKVGjV9+yvtozc4k8J+bGCox Scxv6Mxc/atgIl9u8OdGfpcx5Ticq1Nn5Y+SGH6go5waFbtdx24DlRfsUDbVopHaaKeX 4Y5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jlNOcnZL; 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 d39si555770pla.278.2018.12.14.04.19.27; Fri, 14 Dec 2018 04:19:42 -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=jlNOcnZL; 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 S1732729AbeLNMSj (ORCPT + 99 others); Fri, 14 Dec 2018 07:18:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:36494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730605AbeLNMQT (ORCPT ); Fri, 14 Dec 2018 07:16:19 -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 CF5272133F; Fri, 14 Dec 2018 12:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789778; bh=8WAvJQX9jGcjF2U83WaTNd0zgluNShbDeW8S3zBpWXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jlNOcnZLrVJt+iem2sH4xZt7iRZ5ir+s51c5Gl+24/tPVkhnj/73T/XFjHX7DvxuV +Yp9F5/h9KJfKpUJdXyHF5F2KYzYgc6xQY9tpRpLq8CaYNM2r42uoa93MhlJqro2fS j6pARU7dI+8rSHdCAFC1BFLHUL6IAjl20TR3zfuY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konrad Rzeszutek Wilk , Thomas Gleixner , Borislav Petkov , Ingo Molnar , Ben Hutchings Subject: [PATCH 4.4 56/88] x86/bugs, KVM: Support the combination of guest and host IBRS Date: Fri, 14 Dec 2018 13:00:30 +0100 Message-Id: <20181214115707.135880362@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: Konrad Rzeszutek Wilk commit 5cf687548705412da47c9cec342fd952d71ed3d5 upstream. A guest may modify the SPEC_CTRL MSR from the value used by the kernel. Since the kernel doesn't use IBRS, this means a value of zero is what is needed in the host. But the 336996-Speculative-Execution-Side-Channel-Mitigations.pdf refers to the other bits as reserved so the kernel should respect the boot time SPEC_CTRL value and use that. This allows to deal with future extensions to the SPEC_CTRL interface if any at all. Note: This uses wrmsrl() instead of native_wrmsl(). I does not make any difference as paravirt will over-write the callq *0xfff.. with the wrmsrl assembler code. Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Thomas Gleixner Reviewed-by: Borislav Petkov Reviewed-by: Ingo Molnar [bwh: Backported to 4.4: This was partly applied before; apply just the missing bits] Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm.c | 6 ++---- arch/x86/kvm/vmx.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3904,8 +3904,7 @@ static void svm_vcpu_run(struct kvm_vcpu * is no need to worry about the conditional branch over the wrmsr * being speculatively taken. */ - if (svm->spec_ctrl) - native_wrmsrl(MSR_IA32_SPEC_CTRL, svm->spec_ctrl); + x86_spec_ctrl_set_guest(svm->spec_ctrl); asm volatile ( "push %%" _ASM_BP "; \n\t" @@ -4017,8 +4016,7 @@ static void svm_vcpu_run(struct kvm_vcpu if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)) svm->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL); - if (svm->spec_ctrl) - native_wrmsrl(MSR_IA32_SPEC_CTRL, 0); + x86_spec_ctrl_restore_host(svm->spec_ctrl); /* Eliminate branch target predictions from guest mode */ vmexit_fill_RSB(); --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8658,8 +8658,7 @@ static void __noclone vmx_vcpu_run(struc * is no need to worry about the conditional branch over the wrmsr * being speculatively taken. */ - if (vmx->spec_ctrl) - native_wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); + x86_spec_ctrl_set_guest(vmx->spec_ctrl); vmx->__launched = vmx->loaded_vmcs->launched; asm( @@ -8797,8 +8796,7 @@ static void __noclone vmx_vcpu_run(struc if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)) vmx->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL); - if (vmx->spec_ctrl) - native_wrmsrl(MSR_IA32_SPEC_CTRL, 0); + x86_spec_ctrl_restore_host(vmx->spec_ctrl); /* Eliminate branch target predictions from guest mode */ vmexit_fill_RSB();