Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp483723imw; Wed, 13 Jul 2022 02:10:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uX1+S/znB9558OTOu/EaE9FyGboLzDibJhxacuDebrOajfL6pgvFmfBP9qFz/7WQEvCJ4f X-Received: by 2002:a17:902:7406:b0:16b:dab1:12b0 with SMTP id g6-20020a170902740600b0016bdab112b0mr2218755pll.96.1657703440291; Wed, 13 Jul 2022 02:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657703440; cv=none; d=google.com; s=arc-20160816; b=hGy9PD/Dc63hMOJP7tJqpQAqDr9sIpiXZDa4sTOl9v/NNgv2hlHQUS208+Whaz/BIc 8JQbwJGT5KlIirtAMwOj+Mn67qTpLe/Jnn/QRHKDwd3zUiCGq7hMmS2WuuUM2RyXbEZi Uhrk/HsCqtfYGZ78wM62TcxfpnT2vI2rQ29kCgSTO6WXeV77Mgj45aUxqcQvBNo43Ceu DSE2t/ItHg/XIVbc2NQ7iXwMoHW7k1QZtGpgDaDGBygDchsdpqlFnZduJe1ojJnmhGbO 2qL5tsh39xRC3OSGACex6by0doGKzU9VfVTbg3ACoF4kmR1VrqknDJ+DLWWEFxM0iL4W bkXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=po3rx7P0xH4Jlb2d4rjh2HEZfPtZkC0jo6hclr/31Ic=; b=B/0WN++AKhphuHnNO06p3lAQbzpgCW7UQpTDqm+ZUQ5X08RvO/21OxU20P8/7w0acf LGH1/X4ZjQu5YjzsnRaFe6O7CAVzmqTbqKn9/U4iPiPQwP4F5taHO+f1sOgGjlT52Pr/ xu7qfEJC71ApTiywebKCKvoLWcdGuKVR5qqR7ZNoU9vhLFMv4IXeddk8oZbIv/KsPIH+ oWqGNI7sGx72HxKsLUsZnIp7L2Xv6HjxuFDTaG2+Mi1xpsIQxZtzrw3eMKjTDzx6uzJU pRv68YnwCQkbyt/+Tc6kz/MvpvYvuW/y3Cd60PzAskMHQjuLQzKBP2tuCDlzUAktfat2 FGPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netscape.net header.s=a2048 header.b=pnNhMykC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=netscape.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nt15-20020a17090b248f00b001f05f24be87si1571880pjb.86.2022.07.13.02.10.27; Wed, 13 Jul 2022 02:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@netscape.net header.s=a2048 header.b=pnNhMykC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=netscape.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234640AbiGMIvs (ORCPT + 99 others); Wed, 13 Jul 2022 04:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbiGMIvr (ORCPT ); Wed, 13 Jul 2022 04:51:47 -0400 Received: from sonic313-21.consmr.mail.gq1.yahoo.com (sonic313-21.consmr.mail.gq1.yahoo.com [98.137.65.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F244EF208 for ; Wed, 13 Jul 2022 01:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscape.net; s=a2048; t=1657702305; bh=po3rx7P0xH4Jlb2d4rjh2HEZfPtZkC0jo6hclr/31Ic=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From:Subject:Reply-To; b=pnNhMykCudIQCeG1Ivwma7FjuZI/nYsICueZD0V+SPLbZ0nHMHAnUL02mQXSkVheDTXY3llaAGpMxLh5CiTvC0plnrug3CEAQZW68uIX+zd5Dba/NsThqRpnm/n3o9UF+99jJJXFI509DXX8LFI8pDdP1rjqWNtn2qoxOzhsT82asSY+Q8frRE6bBu8LOYERHxUAFNxFnXi/wc2a/SBigLKp1aJdaEU23wD/k+V8aaQDyeR1EuFG+CkQEE+gdjiTfPdXtGW8gHJA/vp8uDnqH6m9oUbA/6sAMP2Zo8abPQ1roK4vZtBAAS+jz8UcnJjNBIjd0lHvdfOttpmWxp+wPA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657702305; bh=fGPTfMaE5NgiHToEptF5sfYGWt3cD/iaWiWa4l+tKZM=; h=X-Sonic-MF:Date:From:Subject:To:From:Subject; b=E8J+PHRrL5LyYlsRtVX+/vx08U7QWF+pyFTsTq8BaI0L6xLrFy6GRhlmnvnooz2YVl+2VrjRrZ1hsZEntcZcEm3A9jVi/UOXSdQRH9O9rjy7mlSAzqgk7SuIyNCrP5bWIJUntkH4WQdYgpZ5Kj8cSsGkh4UDigRVaD444YTVTpQsdG1iuQNGQ8vYTxTzVI7n8j2Q6KDxfKmSsw/k9CYbzJIgjbodktbsTHwoWtDS/sZrOwLb2KyCSHR82cIGp1/rOjLHfDneB8qOhG9PK6ngSgHek8sXVc6EVrC6Zq9XsC9/wTsrdvv674D5+Ng5PvV0Lrj0xRrxRpJ63CDRwG8efA== X-YMail-OSG: iJ9rad4VM1lLyKmHFAUcS8Po3ixAgb7f4Xmvk6q3hJALY0SSa0T8Q.dHr72lWpv vfb7vkE4pbC7a7JGU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ZUvCEIjSg1tOJCj6DCPVjVMjmGbvGo - X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.gq1.yahoo.com with HTTP; Wed, 13 Jul 2022 08:51:45 +0000 Received: by hermes--production-bf1-58957fb66f-hgp8q (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ee28fbef4544e32e715de306ef9fc732; Wed, 13 Jul 2022 08:51:39 +0000 (UTC) Message-ID: <3d3f0766-2e06-428b-65bb-5d9f778a2baf@netscape.net> Date: Wed, 13 Jul 2022 04:51:36 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: Chuck Zmudzinski Subject: Re: [PATCH v2] Subject: x86/PAT: Report PAT on CPUs that support PAT without MTRR To: Jan Beulich Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Dan Williams , "Kirill A. Shutemov" , Tom Lendacky , Jane Chu , Tianyu Lan , Randy Dunlap , Sean Christopherson , Juergen Gross , xen-devel@lists.xenproject.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org References: <9d5070ae4f3e956a95d3f50e24f1a93488b9ff52.1657671676.git.brchuckz.ref@aol.com> <9d5070ae4f3e956a95d3f50e24f1a93488b9ff52.1657671676.git.brchuckz@aol.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.20407 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/13/22 2:18 AM, Jan Beulich wrote: > On 13.07.2022 03:36, Chuck Zmudzinski wrote: > > v2: *Add force_pat_disabled variable to fix "nopat" on Xen PV (Jan Beulich) > > *Add the necessary code to incorporate the "nopat" fix > > *void init_cache_modes(void) -> void __init init_cache_modes(void) > > *Add Jan Beulich as Co-developer (Jan has not signed off yet) > > *Expand the commit message to include relevant parts of the commit > > message of Jan Beulich's proposed patch for this problem > > *Fix 'else if ... {' placement and indentation > > *Remove indication the backport to stable branches is only back to 5.17.y > > > > I think these changes address all the comments on the original patch > > > > I added Jan Beulich as a Co-developer because Juergen Gross asked me to > > include Jan's idea for fixing "nopat" that was missing from the first > > version of the patch. > > You've sufficiently altered this change to clearly no longer want my > S-o-b; unfortunately in fact I think you broke things: Well, I hope we can come to an agreement so I have your S-o-b. But that would probably require me to remove Juergen's R-b. > > @@ -292,7 +294,7 @@ void init_cache_modes(void) > > rdmsrl(MSR_IA32_CR_PAT, pat); > > } > > > > - if (!pat) { > > + if (!pat || pat_force_disabled) { > > By checking the new variable here ... > > > /* > > * No PAT. Emulate the PAT table that corresponds to the two > > * cache bits, PWT (Write Through) and PCD (Cache Disable). > > @@ -313,6 +315,16 @@ void init_cache_modes(void) > > */ > > pat = PAT(0, WB) | PAT(1, WT) | PAT(2, UC_MINUS) | PAT(3, UC) | > > PAT(4, WB) | PAT(5, WT) | PAT(6, UC_MINUS) | PAT(7, UC); > > ... you put in place a software view which doesn't match hardware. I > continue to think that ... > > > + } else if (!pat_bp_enabled) { > > ... the variable wants checking here instead (at which point, yes, > this comes quite close to simply being a v2 of my original patch). > > By using !pat_bp_enabled here you actually broaden where the change > would take effect. Iirc Boris had asked to narrow things (besides > voicing opposition to this approach altogether). Even without that > request I wonder whether you aren't going to far with this. > > Jan I thought about checking for the administrator's "nopat" setting where you suggest which would limit the effect of "nopat" to not reporting PAT as enabled to device drivers who query for PAT availability using pat_enabled(). The main reason I did not do that is that due to the fact that we cannot write to the PAT MSR, we cannot really disable PAT. But we come closer to respecting the wishes of the administrator by configuring the caching modes as if PAT is actually disabled by the hardware or firmware when in fact it is not. What would you propose logging as a message when we report PAT as disabled via pat_enabled()? The main reason I did not choose to check the new variable in the new 'else if' block is that I could not figure out what to tell the administrator in that case. I think we would have to log something like, "nopat is set, but we cannot disable PAT, doing our best to disable PAT by not reporting PAT as enabled via pat_enabled(), but that does not guarantee that kernel drivers and components cannot use PAT if they query for PAT support using boot_cpu_has(X86_FEATURE_PAT) instead of pat_enabled()." However, I acknowledge WC mappings would still be disabled because arch_can_pci_mmap_wc() will be false if pat_enabled() is false. Perhaps we also need to log something if we keep the check for "nopat" where I placed it. We could say something like: "nopat is set, but we cannot disable hardware/firmware PAT support, so we are emulating as if there is no PAT support which puts in place a software view that does not match hardware." No matter what, because we cannot write to PAT MSR in the Xen PV case, we probably need to log something to explain the problems associated with trying to honor the administrator's request. Also, what log level should it be. Should it be a pr_warn instead of a pr_info? I will agree to implement your approach of checking the new variable where you suggest and limiting the effect of "nopat" to not reporting PAT as enabled via pat_enabled() if there is a consensus about what we should log to the administrator in that case and if Juergen and/or Boris agrees with it. Chuck