Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp797021imm; Mon, 21 May 2018 14:39:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr9oQcB3PF3XxHz/gCkZLbmnY/VKCy0Bfa8PU2UjwPFQHUg2QNlIoo51h6TRYam8k0C79IA X-Received: by 2002:a62:a111:: with SMTP id b17-v6mr21639156pff.132.1526938760913; Mon, 21 May 2018 14:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526938760; cv=none; d=google.com; s=arc-20160816; b=dGP38z9j1qRb6cDHA9iCfWCefYwoMsi8OCx67DQX4QRqn8wNKOJmlBDugmSE2u3zSY SH46kZiGn91ChExqsni3kUqTT574uS6TZIW8jCi9RSp1gh4t6r3+hdkeqJwyWxt+Uyfd dctg9KnJEXiq2of8R6/ZAnzOiva9RodHjFR4UHJ05+1E5o4szEi+W1+yk4tSE5NVMPz3 hKsfjIyTktIMvAVhLaiu0t3/cHoNRPFMjzeDGKszCAMf55OF2cjrtAD9+6im7m3m8Kdj LEkKH2UL05VeUmM9HBCYIfUy9xkwkvkhQErDBxISK+tcs3mOKZWpSBES6OEKJYkS+z/7 Ts8Q== 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=rGacbnJKxVsvY6/D3TNFoXh4hood7vQ2wdKrSpDlMJg=; b=XLp6M3dglf3I/QTFAt9QxVPXkCsMNcFgbQ/a+v0c8IjEjJdVqAFF8ua7EQOP0owFnl qt124JFsliQki/NNoYws9+kVt1MrKFAXraJ1YpyvnzG6YZv00KivfOQSbdxoU4fM0XvH izcbBxLV1ZybgLETzfKuxUtwL58u9PRDswe165nzrT9OhnCGA31AVO0NJutV+ekiskIe NT6GLCY30QwdvtB0UVx2hAziIV3mpMDYRXQe6u0QYxEfAoMh9ttIrXXJfb/lfaxyxcR7 ZkJu6iae4TLK0CfuN34AZ0PsWBbZbJbJJnQbfE90baZTRgCccz8IXU0Hbu5Y6KPP2aOU s2/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=At1lOX8+; 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 b37-v6si14817313plb.377.2018.05.21.14.39.06; Mon, 21 May 2018 14:39:20 -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=At1lOX8+; 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 S1754427AbeEUVh5 (ORCPT + 99 others); Mon, 21 May 2018 17:37:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:40140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932166AbeEUVZQ (ORCPT ); Mon, 21 May 2018 17:25:16 -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 2A74620872; Mon, 21 May 2018 21:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937915; bh=Xpr03eaTHPjf9q1KpK8nceE0F8v4lFOmCp2tEEsoMDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=At1lOX8+X0L8TRPW4q50ZwRiG67gWgZ+dxfbOusnhEC3fWr12luFQ+sjxLn6Ttlsj Cyknjv3UOBNOwQPvJLw8sYybPi5slA/ENeYzI1q0qvXL9dah2ZLYHPsxIsWO4L66Jj HCSURt+ptgIViumdqGiLYAOl9SKXDDpStGE/r4lM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konrad Rzeszutek Wilk , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.16 073/110] x86/KVM/VMX: Expose SPEC_CTRL Bit(2) to the guest Date: Mon, 21 May 2018 23:12:10 +0200 Message-Id: <20180521210512.632685068@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: Konrad Rzeszutek Wilk commit da39556f66f5cfe8f9c989206974f1cb16ca5d7c upstream Expose the CPUID.7.EDX[31] bit to the guest, and also guard against various combinations of SPEC_CTRL MSR values. The handling of the MSR (to take into account the host value of SPEC_CTRL Bit(2)) is taken care of in patch: KVM/SVM/VMX/x86/spectre_v2: Support the combination of guest and host IBRS Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/vmx.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -402,7 +402,7 @@ static inline int __do_cpuid_ent(struct /* cpuid 7.0.edx*/ const u32 kvm_cpuid_7_0_edx_x86_features = - F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | + F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(RDS) | F(ARCH_CAPABILITIES); /* all calls to cpuid_count() should be made on the same cpu */ --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3276,7 +3276,8 @@ static int vmx_get_msr(struct kvm_vcpu * case MSR_IA32_SPEC_CTRL: if (!msr_info->host_initiated && !guest_cpuid_has(vcpu, X86_FEATURE_IBRS) && - !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL)) + !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) && + !guest_cpuid_has(vcpu, X86_FEATURE_RDS)) return 1; msr_info->data = to_vmx(vcpu)->spec_ctrl; @@ -3397,11 +3398,12 @@ static int vmx_set_msr(struct kvm_vcpu * case MSR_IA32_SPEC_CTRL: if (!msr_info->host_initiated && !guest_cpuid_has(vcpu, X86_FEATURE_IBRS) && - !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL)) + !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) && + !guest_cpuid_has(vcpu, X86_FEATURE_RDS)) return 1; /* The STIBP bit doesn't fault even if it's not advertised */ - if (data & ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP)) + if (data & ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_RDS)) return 1; vmx->spec_ctrl = data;