Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp3407470pxb; Mon, 6 Sep 2021 21:29:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmC/1oS5Gt/ZlOog8PMPBB8QVPLm7J60l4QZxnXCOLP1kSzoCa/kq9fiZnfHkrJqvNgKGz X-Received: by 2002:a6b:7f42:: with SMTP id m2mr12677333ioq.86.1630988950366; Mon, 06 Sep 2021 21:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630988950; cv=none; d=google.com; s=arc-20160816; b=SxUNjUfaqPxkFTrHXnhAxpLTdidOLV8WQbdky4thhTYYyGwLqg1OQIQ20qxYL5qQNu huOo967ZXJ5GmnTLXzhXH6oGj8CPgRAmY610hEaq/ESFZ2Vb+ULruGs7OnEzKIZCbysD 2xAg4SLwUZaMPBWpnsq6BPIWshAsL+i0G5C5PAa/LI4cPRK7n1E8QFp85lPatWTK5o0C uz3EyDi3crQp7+7awd26RxrpphPbWHAmtS5IKFpEnrH+COhhyMheKM6w1J74QNu63vSE rVhVHZEjlGPJ6hexK/uPcq6V+taYI0dhbfY+71MO8OEznhNkYuDYHDG0CHmrBdBap0fj 6Jxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=+a3hrcD8mqnTuaCCRsgegANce9Fu7v7Zmvefz7sCgUQ=; b=k0a11cT0N1uBcgCo3GUkGzMhM6qdJs3M8/RcejMV4ocWsGvJ3Hc0gM5BEzIiSHzEtF mLAH+QfNGKBMj8BMunW6WfKYvTIS/2QNL60in3PwON4s/yjTmUXPd4aKabOd39bdVTKO RTuPGSVBAco/cc70RXrX//Fi0HgzxRkPf1nzJqzcKEZgGMBdz0uJo3kOG7R2lDNsHQcL LPs7X+AoiJt2WOrcnFglqJjxEtkiV+Gp8AzmnL5S7sp3WR8mGS/i1BZ4FBrkAD5Q+7fm iGAjCySRIMZH9ScdMMRCi4XYeaYhsgnJQpZ1/426jaOA6S/gRSugqo6yQDhzxeGQ5K0K srCQ== 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 c14si8537192ild.77.2021.09.06.21.28.59; Mon, 06 Sep 2021 21:29:10 -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 S231200AbhIGE1Y (ORCPT + 99 others); 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 >>>> >>