Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp818034ybl; Wed, 11 Dec 2019 07:59:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwde+EkuG2wUudVeiNibNHf0XGqOdZKNvupaY1VCw5RpLwUGogXzqnBCHZ5jvBjEncBTlfZ X-Received: by 2002:a05:6830:1d4c:: with SMTP id p12mr2908678oth.198.1576079990336; Wed, 11 Dec 2019 07:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079990; cv=none; d=google.com; s=arc-20160816; b=Lz4dzKyPiriYmb4s1uTAnbdI9SWk6IyOaJgXa8TnXUMWNoXgU4Aozmm1dSoV25nxxu zn7jcoweCAxrS3lUJQqeb4hmhC2cSwImRBB9PDM4Fipd2FdNZZDioUn1RvsNRvmm5bN1 UfBEet2CFL9+P++2ChkExdaHDpcQrK2Ncjm0sr3/k0aQ5Zr9n3PB7OGh3vkjK6pcO9ew RW4CvmlYkDkgjoCUJg+XEg/GV7JF55nmcU73xrSfOxwNtXhvPYLbzIRwLrcNrgW+B6Cq 2zcTri+EFlnDccyzxaHPRK7e6WXeGyo+8Z2feHDFZlG0FEh/AAkUfXamjjm3kZhqdtwI 7UBg== 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=uYJV+nFR+oJCDjQCoV1aBgkhc5vQRWO++vylU0HZVyg=; b=s5M3eD431X/J0mN/Wm1YKzXRy5pvMNQrr9/JgC4gVrftrs5qGGjJArKQYvDXixG+8i K95cnU7FS1CEL9QfvgedJvwq337hRLWtB6/tDk4pPXlMkEeHMVMjj5C/y2cxDdbpLnCR mB70+CXbhvRTA0UYE775fWKaC5HNIFmlJ06ZaAFPeBkDb6d6BY1uQi95nx32gDdP6vVH Y42y2qySNfNovarQ6mPYGOGvV4ArxMQds54pkfssznjcNES9gghTfSjzg9rlhyRZl2CF Hh0/FCQgKfBnMUVdhsKpCK2t63IhSzJbLxBR11M+ogEWSaJOQ7bJ58jgXUziY69jo+UK sv1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Rs2w0sJx; 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 b10si1416870otp.124.2019.12.11.07.59.37; Wed, 11 Dec 2019 07:59:50 -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=Rs2w0sJx; 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 S1731812AbfLKP6S (ORCPT + 99 others); Wed, 11 Dec 2019 10:58:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:40154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731645AbfLKPOh (ORCPT ); Wed, 11 Dec 2019 10:14:37 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 0CDF32467D; Wed, 11 Dec 2019 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077276; bh=auBK3F1O3f85KTx3LabQwNo/1FXPbHtftbxFbtbk8kw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rs2w0sJxXLCy0bKstB81l80+JlymEqXAFuLsEa0bd/bU/Q2oSlBOH2FEtrZQ2nVDt 0DIcq+193GPxNeJq+k7RL0yyStM1tdj9UVF8+h25ONiTF7O2ma0sEnCMfS/tyqvjI5 iDAaIiq47XbPx+LvhGUPdHPHIR/eNQJuR6dmqwYM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Paolo Bonzini Subject: [PATCH 5.3 082/105] KVM: x86: fix presentation of TSX feature in ARCH_CAPABILITIES Date: Wed, 11 Dec 2019 16:06:11 +0100 Message-Id: <20191211150258.359509325@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Paolo Bonzini commit cbbaa2727aa3ae9e0a844803da7cef7fd3b94f2b upstream. KVM does not implement MSR_IA32_TSX_CTRL, so it must not be presented to the guests. It is also confusing to have !ARCH_CAP_TSX_CTRL_MSR && !RTM && ARCH_CAP_TAA_NO: lack of MSR_IA32_TSX_CTRL suggests TSX was not hidden (it actually was), yet the value says that TSX is not vulnerable to microarchitectural data sampling. Fix both. Cc: stable@vger.kernel.org Tested-by: Jim Mattson Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1292,12 +1292,18 @@ static u64 kvm_get_arch_capabilities(voi * If TSX is disabled on the system, guests are also mitigated against * TAA and clear CPU buffer mitigation is not required for guests. */ - if (boot_cpu_has_bug(X86_BUG_TAA) && boot_cpu_has(X86_FEATURE_RTM) && - (data & ARCH_CAP_TSX_CTRL_MSR)) + if (!boot_cpu_has(X86_FEATURE_RTM)) + data &= ~ARCH_CAP_TAA_NO; + else if (!boot_cpu_has_bug(X86_BUG_TAA)) + data |= ARCH_CAP_TAA_NO; + else if (data & ARCH_CAP_TSX_CTRL_MSR) data &= ~ARCH_CAP_MDS_NO; + /* KVM does not emulate MSR_IA32_TSX_CTRL. */ + data &= ~ARCH_CAP_TSX_CTRL_MSR; return data; } +EXPORT_SYMBOL_GPL(kvm_get_arch_capabilities); static int kvm_get_msr_feature(struct kvm_msr_entry *msr) {