Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp8131pxb; Tue, 7 Sep 2021 16:07:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2JHMZUpL0Guyf8PNLCai9mxdwMQ60zdtICUxfkDCXVMNT8aOPCarAPCfzqDG4fgFIC3mB X-Received: by 2002:a92:903:: with SMTP id y3mr459764ilg.29.1631056031200; Tue, 07 Sep 2021 16:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631056031; cv=none; d=google.com; s=arc-20160816; b=HbgWq1BVpt5RLQlQJCFvW0bML8tF+8z8U0NUu9QBZLR73pSMoPt8382hRwDtgIfWhT PTeBDPxMn8EKzSQEtrknUilcmGiUkrRK1N1xtUbxRfGFGyfOeyTtxBKfURt4SyAXoG/b Vt2Rs2wHGwVyL5wLifq98U0xmGMFRJaXIkxsPqkcBJqhErBhKxnVBzxeVdiOIIkAZr19 JiGJRhFnLo1BWHfAjPq6TK4YXhWj3etQg5oK2p8StFGkI2hEHPruBbYRFkT3s2AsQTet +0jp3F7uefH4KxOLrVaDiDGOmw2jQCy+Jt/LMcR/HS4Y7mtPit6mr6PpXOTv5iC8XsXQ dYiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ip+ByQfJzgYdIhoMPVnmE+ShWl7+Ttl/bMqJPZtKHkw=; b=UGYh9i7TUZZafB2iiD1rg2Ys1w4EkmDHMzytfZmFMzWX+MI25G7vP4dxih588WjQMb aKHjVWuI2fko/S0CjANEFymlpxXq7Kj9ZiFVka+RTPKyVDvYLaBSNWxI+QrwpKb+pLe9 vmF++aegm8JVseL0Y0JgMHbFNUKs2Ymc4iltm4kDZ4qtrFQlKM+D8Xu+obMbjuEIasCM wnv5qEd5cU9YJ9Rh7LGYnKOVDHKv1z9ewOCOMYUmg+fP5juWRccJa9TDhTyLeHY129en JNh82HlEQr0Ad4iaEB/bAdFHn6iJWHuGnA1N1c97GxMpO/cdAentyc4ZcJ9/kQew1D4V /jYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w31si264072jal.61.2021.09.07.16.06.48; Tue, 07 Sep 2021 16:07:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347336AbhIGXHO (ORCPT + 99 others); Tue, 7 Sep 2021 19:07:14 -0400 Received: from mga18.intel.com ([134.134.136.126]:43977 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240690AbhIGXHO (ORCPT ); Tue, 7 Sep 2021 19:07:14 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10100"; a="207450693" X-IronPort-AV: E=Sophos;i="5.85,276,1624345200"; d="scan'208";a="207450693" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 16:06:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,276,1624345200"; d="scan'208";a="430402285" Received: from gupta-dev2.jf.intel.com (HELO gupta-dev2.localdomain) ([10.54.74.119]) by orsmga006.jf.intel.com with ESMTP; 07 Sep 2021 16:06:07 -0700 Date: Tue, 7 Sep 2021 16:07:38 -0700 From: Pawan Gupta To: Hao Peng Cc: Xiaoyao Li , Borislav Petkov , tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/tsx: clear RTM and HLE when MSR_IA32_TSX_CTRL is not supported Message-ID: <20210907230738.j6j32zvyfpr37qw6@gupta-dev2.localdomain> References: <77e8d483-4395-0017-300e-0886f75217bb@intel.com> <20210907053816.qldtcxkxxv7hkzgv@gupta-dev2.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07.09.2021 14:56, Hao Peng wrote: >On Tue, Sep 7, 2021 at 1:36 PM Pawan Gupta > wrote: >> >> On 07.09.2021 12:39, Hao Peng wrote: >> >On Tue, Sep 7, 2021 at 12:26 PM Xiaoyao Li wrote: >> >> >> >> On 9/7/2021 11:40 AM, Hao Peng wrote: >> >> > On Tue, Sep 7, 2021 at 10:56 AM Xiaoyao Li wrote: >> >> >> >> >> >> On 9/7/2021 10:35 AM, Hao Peng wrote: >> >> >>> On Tue, Sep 7, 2021 at 10:08 AM Xiaoyao Li wrote: >> >> >>>> >> >> >>>> On 9/7/2021 9:47 AM, Hao Peng wrote: >> >> >>>>> On Mon, Sep 6, 2021 at 5:30 PM Borislav Petkov wrote: >> >> >>>>>> >> >> >>>>>> On Mon, Sep 06, 2021 at 10:46:05AM +0800, Hao Peng wrote: >> >> >>>>>>> If hypervisor does not support MSR_IA32_TSX_CTRL, but guest supports >> >> >>>>>>> RTM and HLE features, it will affect TAA mitigation. >> >> >>>>>>> >> >> >>>>>>> Signed-off-by: Peng Hao >> >> >>>>>>> --- >> >> >>>>>>> arch/x86/kernel/cpu/tsx.c | 7 +++++++ >> >> >>>>>>> 1 file changed, 7 insertions(+) >> >> >>>>>>> >> >> >>>>>>> diff --git a/arch/x86/kernel/cpu/tsx.c b/arch/x86/kernel/cpu/tsx.c >> >> >>>>>>> index 9c7a5f049292..5e852c14fef2 100644 >> >> >>>>>>> --- a/arch/x86/kernel/cpu/tsx.c >> >> >>>>>>> +++ b/arch/x86/kernel/cpu/tsx.c >> >> >>>>>>> @@ -122,6 +122,13 @@ void __init tsx_init(void) >> >> >>>>>>> >> >> >>>>>>> if (!tsx_ctrl_is_supported()) { >> >> >>>>>>> tsx_ctrl_state = TSX_CTRL_NOT_SUPPORTED; >> >> >>>>>>> + >> >> >>>>>>> + /* If hypervisor does not support MSR_IA32_TSX_CTRL emulation, >> >> >>>>>>> + * but guest supports RTM and HLE features, it will affect TAA >> >> >>>>>>> + * (tsx_async_abort)mitigation. >> >> >>>>>>> + */ >> >> >>>>>>> + setup_clear_cpu_cap(X86_FEATURE_RTM); >> >> >>>>>>> + setup_clear_cpu_cap(X86_FEATURE_HLE); >> >> >>>> >> >> >>>> anyway, IMHO, we shouldn't do anything here for TAA. It should be in >> >> >>>> taa_select_mitigation() >> >> >>>> >> >> >>>>>>> return; >> >> >>>>>>> } >> >> >>>>>> >> >> >>>>>> How does that even happen - the hypervisor does not support the MSR but >> >> >>>>>> "guest supports" TSX features?! >> >> >>>>>> >> >> >>>>>> I guess the guest is detecting it wrong. >> >> >>>>>> >> >> >>>>>> What hypervisor, what guest, how do I reproduce? >> >> >>>>>> >> >> >>>>> hypervisor is kvm, guest is linux too. >> >> >>>>>> Please give full details. >> >> >>>>>> >> >> >>>>> The host I used is kernel-5.4, and guest is kernel-5.13. >> >> >>>>> MSR_IA32_TSX_CTRL is exposed >> >> >>>>> to guest and guest to support RTM and HLE features, no direct >> >> >>>>> dependence. at the qemu I >> >> >>>>> started guest with -cpu host-model. >> >> >>>>> I have viewed the code of kernel-5.4, and MSR_IA32_TSX_CTRL is not >> >> >>>>> exposed to guest. >> >> >>>> >> >> >>>> Does guest see TAA_NO bit? >> >> >>>> >> >> >>> Guest can't see taa_no, which requires updating qemu to solve. But I think >> >> >>> there is a compatibility process here. >> >> >> >> >> >> Anyway, there should be some existing code in kernel already to handle >> >> >> the case that CPUID reports TRM while MSR_IA32_CORE_CAPABILITIES doesn't >> >> >> report MSR_TSX_CTRL nor TAA_NO. >> >> >> >> >> > Can you point out which patches ? At present, guest is kernel-5.13 >> >> > still has this problem. >> >> >> >> What's the output of 'cat >> >> /sys/devices/system/cpu/vulnerabilities/tsx_async_abort' on your guest? >> >> >> >Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown. >> >> This suggests that the microcode is old. Can you please share the output >> of below cmds on host and guest: >> >> $ grep . /sys/devices/system/cpu/vulnerabilities/* >host : not affected >guest: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host >state unknown. This would mean TAA_NO is not being exported to guest. Most likely qemu needs to be patched for the CPU configuration you are using. Thanks, Pawan