From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EA79C433EF for ; Tue, 7 Sep 2021 04:26:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBF5760555 for ; Tue, 7 Sep 2021 04:26:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231701AbhIGE1Y (ORCPT ); Tue, 7 Sep 2021 00:27:24 -0400 Received: from mga01.intel.com ([192.55.52.88]:58320 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbhIGE1X (ORCPT ); Tue, 7 Sep 2021 00:27:23 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10099"; a="242375432" X-IronPort-AV: E=Sophos;i="5.85,274,1624345200"; d="scan'208";a="242375432" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2021 21:26:16 -0700 X-IronPort-AV: E=Sophos;i="5.85,274,1624345200"; d="scan'208";a="605061922" Received: from xiaoyaol-mobl.ccr.corp.intel.com (HELO [10.239.13.122]) ([10.239.13.122]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2021 21:26:15 -0700 Subject: Re: [PATCH] x86/tsx: clear RTM and HLE when MSR_IA32_TSX_CTRL is not supported To: Hao Peng Cc: Borislav Petkov , tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, Pawan Gupta References: <77e8d483-4395-0017-300e-0886f75217bb@intel.com> From: Xiaoyao Li Message-ID: Date: Tue, 7 Sep 2021 12:26:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > Thanks. >> And the Patch itself makes no sense. >> >>>>> Thanks. >>>>>> -- >>>>>> Regards/Gruss, >>>>>> Boris. >>>>>> >>>>>> https://people.kernel.org/tglx/notes-about-netiquette >>>> >>