Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1196604imw; Wed, 13 Jul 2022 15:38:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tlCm+8Qa7Z2CEDAjcnUA35bdxf3pSJhK8KYzAnm9/tqP1LnBoXseACwEC2HbM1EcNrUYXo X-Received: by 2002:a17:90b:1807:b0:1f0:5875:9751 with SMTP id lw7-20020a17090b180700b001f058759751mr6298460pjb.25.1657751886017; Wed, 13 Jul 2022 15:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657751886; cv=none; d=google.com; s=arc-20160816; b=tTW8kyIetYS1oF0HZ25nLoh9KXRTpxZ4YL92Y6h1YZDdGUU8dQrNz2VI+QA/hhQQ9l Mt3Nom7BuWhZuVAF8nUNILZwnu5oTZ+QRt62NmG5ihlUErFrkaMgExQdD0wudmqvFZGV oXx3mHLm5j4IyB/YSI/SBezK7Thmx19/STjVEcHluepKoLhv1SMX6Y6oSvRLr7UhH9Jo SpJ0j/PCOcxZ4QyawNLzpuX3YAx5ekQIL7CAt9aTkXPi2iR6Oalitc6ragJQkBOngeDt vS2XhqaGnumQFHUFRi1394Raflx31Cjn9aceuXTui5cWXIpaAYLbIpNuHCvL7ZIgr2Rs BASQ== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=sW1ejgoubTLnwSxkyhbV7vGRBPUmBbNSxg5+MIbDhoU=; b=WkdZIShfF7SPwMmBg1bcWwxM2eCQCgZFY2QvS/QSUOEkTCNAzifXy600cOL+fXCFf2 0/YPVZOpYrNm0mATPC7X/2JtVkGrxEaU7yop1VGJmvLZmMdxKLp+Bq9O9zqetuct414v /cpsN5eA8Imht+baNuQelJDXjJoNjLQOP74VcO//i7WBcPR3dNb8us+OWRUkXPQIjqoH PIdsR2Qu6IX89Ft6zQuPW6t8152o/EGZi6wZNUcwvLaMU0ujfe7TTODxKZE42WH1QOuc GQV9s8Ke/knan4DYkpCjPTdH2GJqlFUAHaUJ1TUnBZ4kXlmZD2cxuSLSP9re5GMbC1/i 4lpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netscape.net header.s=a2048 header.b=mGODDA3b; 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 u6-20020a656706000000b0040c37758b54si17317982pgf.114.2022.07.13.15.37.50; Wed, 13 Jul 2022 15:38:06 -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=mGODDA3b; 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 S237354AbiGMWXX (ORCPT + 99 others); Wed, 13 Jul 2022 18:23:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237380AbiGMWXU (ORCPT ); Wed, 13 Jul 2022 18:23:20 -0400 Received: from sonic310-22.consmr.mail.gq1.yahoo.com (sonic310-22.consmr.mail.gq1.yahoo.com [98.137.69.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2804C634 for ; Wed, 13 Jul 2022 15:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscape.net; s=a2048; t=1657750996; bh=sW1ejgoubTLnwSxkyhbV7vGRBPUmBbNSxg5+MIbDhoU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=mGODDA3bNe4GC1bDfrENgyLUL+UWOcwZnVlh5I04dnkev0wlbHWTRzyk4XL4AAUlA2UYTgh9Oggbze+72E0HoGpJ2jHKzxDod7kMhgbLK8gGjAyyY9ewn6+8nwlj7UpJVj51eylBEUyXhDi4WJuxjGX6pQBkT68RLPhbqdeR7p1y81JSIv5fN3Ga9/n/M47VGXIZJSSZPTBGwNiy5aUkIIvVhGY5lznn3Mdhu9vInTcJDv+sunq+4D4RgEW075qOwNBTJNm02KSh3GFx6QCfSmjDW3XyfhNBYnQWSfkr+8SCi0xqbwjae+5xGrMhkNvunTFIY/Qv7SgHpYssO8Z0Dw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657750996; bh=7QbdE5+wXOXbTyIVA500cevfWolfwJKHWLEvx120ZfS=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=dC1VtJsQfJzJ850whGnEk4H6TprSmJfBW59oAgmhz1Y/zE/tbIdMyb0YN9H8dMVL38UN38YU2uzBbyFud8PosDH04TXekr+b6a2L+jZTF6OBjUR0oeQC7o+rmS8rLcsoD3t2o9tpRZ8ijvwA6qw2+JS2FZfspaKWt60nT4fDm0ixNxhiObCKPAqmlVtcYI0XBRZMod34jlHLoZ+lCHqld2jtB10jlqjKD5nI4XOoRE/NsVLIshXxyWWHClxrE2KHUxusToH+5KLzTkjy4VUOofIM+CIv7RSJ9shP9jQVW+mLS7j1ifCP5ht3pgtsYYdZ7rqCgRVW5IQY/vme+AYxQw== X-YMail-OSG: KNOgYQUVM1n2RjKzOe7Hc1pLGEFWIMp2pM7hEiX_E99y_3H6Q3_Ny4uz32kSH3G hYHDfrTumNu5krn0d0Fh_rjTsebyvOa5fOEpnbk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T3fqtu02Nio7WE6bDrLwawBVerJQpq17UXYKWk0aGgJ8sLpU5 .3wucbPo2gePrjqggTm81q4fKD5OJGqyQPIdcLu2vY.TUcbdiMZr5DtnchB8wKvHOMWu25z2qMCm uy49ap2TTcGi0S5_T3QRVcMAZQBoMGFTwfKhpFBDE2V8NvUDyvkycoWAJaEvHctTPWUxrb5_6fI4 B6KIZeVrDz5kEFE_wCNEGar3h4O_FoaI42F1BKx3EdDR34QbniohkM2rqIScVTtX2zDTys1eRpJT 4py_LSSkkDHeigxNszvcAXMeoc90swpjvK6xBt7J.2TQefFDZjU36bP5X.lanG2zRwNq4oL9U4y2 q4kl8gnn11lep29qjae6PKS8HZDDTWSgtRTAHKnwQjqne8EKS_QK618jEFMft5Yqa_uLxHnhTT0J 5Qfeh4gYDIfaY2ryfL3pct5LMe2JX7lm_RjQEuW73gcrRutrkDgjHImYB5PXOBklK2.vLCak88xW i_DmMR74KfbrfSJGB1oQTsmjPQ.L5RPCuTZf_WMbaCJLEZsF8yAUDer7XsaeMm7K5yKhodluLlYm 8JGP_n47da4ZP8zGW6fSoOmgR.XtM4P_uK1QIP3wkgbGb23.3R_l.WVAMStNpP3mQam8PAwfMEnF pXUE4uSqhezLU4uFO_eMmy4HAQI_zuPitQnShyssJ25uqEJNBQWLi_NwbyrDSIUsktJ9qpHtff1b stGhWoejsiviIhPk6.RhqTlDkwIG5fUzC4L7H7XMYoXzjV5HUg90VcXFXXPzUBm3OXfaeTd9CXfw d4fY9UDl0Qof1Go6qBuOW1yvJ0AXTyfz4HONjwm_lrghkEiWYj8awLvg- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.gq1.yahoo.com with HTTP; Wed, 13 Jul 2022 22:23:16 +0000 Received: by hermes--production-bf1-58957fb66f-88chf (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 89c21ab9e0ecbc439802f7109841f4ef; Wed, 13 Jul 2022 22:12:39 +0000 (UTC) Message-ID: Date: Wed, 13 Jul 2022 18:12:36 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2] Subject: x86/PAT: Report PAT on CPUs that support PAT without MTRR Content-Language: en-US To: Juergen Gross , Jan Beulich Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Dan Williams , Tom Lendacky , Jane Chu , Tianyu Lan , Randy Dunlap , Sean Christopherson , xen-devel@lists.xenproject.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" References: <9d5070ae4f3e956a95d3f50e24f1a93488b9ff52.1657671676.git.brchuckz.ref@aol.com> <9d5070ae4f3e956a95d3f50e24f1a93488b9ff52.1657671676.git.brchuckz@aol.com> <3d3f0766-2e06-428b-65bb-5d9f778a2baf@netscape.net> <775493aa-618c-676f-8aa4-d1667cf2ca78@netscape.net> <1d06203b-97ff-e7eb-28ae-4cdbc7569218@suse.com> From: Chuck Zmudzinski 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, 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/2022 9:45 AM, Juergen Gross wrote: > On 13.07.22 15:34, Jan Beulich wrote: > > On 13.07.2022 13:10, Chuck Zmudzinski wrote: > >> On 7/13/2022 6:36 AM, Chuck Zmudzinski wrote: > >>> On 7/13/2022 5:09 AM, Jan Beulich wrote: > >>>> On 13.07.2022 10:51, Chuck Zmudzinski wrote: > >>>>> 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'm afraid I'm the wrong one to answer logging questions. As you > >>>> can see from my original patch, I didn't add any new logging (and > >>>> no addition was requested in the comments that I have got). I also > >>>> don't think "nopat" has ever meant "disable PAT", as the feature > >>>> is either there or not. Instead I think it was always seen as > >>>> "disable fiddling with PAT", which by implication means using > >>>> whatever is there (if the feature / MSR itself is available). > >>> > >>> IIRC, I do think I mentioned in the comments on your patch that > >>> it would be preferable to mention in the commit message that > >>> your patch would change the current behavior of "nopat" on > >>> Xen. The question is, how much do we want to change the > >>> current behavior of "nopat" on Xen. I think if we have to change > >>> the current behavior of "nopat" on Xen and if we are going > >>> to propagate that change to all current stable branches all > >>> the way back to 4.9.y,, we better make a lot of noise about > >>> what we are doing here. > >>> > >>> Chuck > >> > >> And in addition, if we are going to backport this patch to > >> all current stable branches, we better have a really, really, > >> good reason for changing the behavior of "nopat" on Xen. > >> > >> Does such a reason exist? > > > > Well, the simple reason is: It doesn't work the same way under Xen > > and non-Xen (in turn because, before my patch or whatever equivalent > > work, things don't work properly anyway, PAT-wise). Yet it definitely > > ought to behave the same everywhere, imo. > > There is Documentation/x86/pat.rst which rather clearly states, how > "nopat" is meant to work. It should not change the contents of the > PAT MSR and keep it just as it was set at boot time (the doc talks > about the "BIOS" setting of the MSR, and I guess in the Xen case > the hypervisor is kind of acting as the BIOS). If that is the true meaning of "nopat", then the pat_enabled() test we currently have in the i915 driver is the wrong test for the capability of the CPU to use the fast WC type pages for video frames access because it is possible for pat_enabled() to be false and "nopat" set with its official meaning, and still have a CPU with WC cache mode capability. If we accept pat_enabled() as implied WC cache mode support, why not also accept (!pat_enabled && boot_cpu_has(X86_FEATURE_HYPERVISOR)) also as implied WC cache mode support? That is what Jan's patch effectively does. He just possibly places his patch in the wrong portion of the Linux tree to be consistent with the official meaning of "nopat" and pat_enabled(). We could implement Jan's fix instead in the i915 driver instead if we need to be consistent with the official meaning of "nopat" and pat_enabled(). I could make that a v3 of my patch - and try the i915 maintainers instead of the x86 maintainers to provide the fix. But before I do that, can someone on this list of 20 recipients tell me why none of you have fixed this nasty regression? I am new to trying to contribute to Linux and the whole experience is frustrating when all you get is stonewalling from the official maintainers. So why not just someone step up and do this fix? In the meantime, Juergen can start working on cleaning up the x86/PAT code so it can provide the i915 driver with a test not for PAT, but for the WC page caching mode support that works in all supported environments, including Xen. Currently there is no such test available. Juergen proposed one but it failed to accurately test for WC cache mode capability on my Xen workstation. Until the x86 subsystem developers can provide the rest of Linux with an accurate test for the WC caching mode, we have to settle for less than a pure and perfect solution if we are serious about following Linus' regression rule and accept a quick fix to a nasty regression while we wait for a better solution that will hopefully come later. Chuck