Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp547987imw; Wed, 13 Jul 2022 03:39:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vXqNHQca/5z3F3NVF4tzvCCIHhoE5UbmAPclX/U8NHP3bcPAWqibziqUvmQQFCBtLGv1CM X-Received: by 2002:a05:6402:2404:b0:437:d11f:b9c7 with SMTP id t4-20020a056402240400b00437d11fb9c7mr4062503eda.176.1657708773627; Wed, 13 Jul 2022 03:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657708773; cv=none; d=google.com; s=arc-20160816; b=jNQDnOLStgxzT8TB84w7HwXv3vlltUSwhxPgWxH9urt16IHUYa+f7D0E/eL3kvOcIw PxjAXxhpXYVEyytHiy0TJjT/ln+YndBNuzCJEKoSlWlnvaSNXknZIbyB17NpcZXuhMX3 rDlW+bqnoGxjAN3G/MKohkDFIqPDaXz/+YxiJhgkTH6IArmPX7geEwTFqHqybVKbQJgA iwDJFRSNFcUjikGbZV0VeERB1rIk8ofingU95pByNVFfofdN7xsNoy6+26jGo7oCsc/H KL9vibhfd1E8OPOAh/BYeHgIm8Sct9e4U6zXX99c4nuMilsTsYTgwexMnihMUnG/f1qS 0IyA== 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=TC1YZJRZ1HK+fEyY7YDkLkdLYwW/HtLekVLODCURuoc=; b=wwNoIBPMNC7aVeUN7+58hsvrZBDC13CTDrp8BYrj4Fki+07dSZHyqgQMEXOQSfHqyo EKme0+x7zShdcaTftcWl0h/RPY/85QZLDzRqMOBQ5vCGoG+FOAVwOKGsKGaUqeypvn3g Atdx7LBRtzHJtL/l9dK8901K74C7pvTvrnlyzLoRDhdrwkgA+pMdUz5eXrm/XrzhrHEC sb8u2jjKz06yLT4EVN973KKiaVmhlCbN3rVOVKPTpFhpuVPTbOauoLbiKU5PDXYb10n2 Hz14hBl0fVt39GJ9TTEis73DPlgyI59MZ3PWjFQuGt2amaIDiZtRf46B4+VHtiS8LMGU iFAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netscape.net header.s=a2048 header.b=CRq6hwaU; 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 b12-20020a056402278c00b00435c7624e9esi20461738ede.617.2022.07.13.03.38.59; Wed, 13 Jul 2022 03:39:33 -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=CRq6hwaU; 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 S236087AbiGMKhI (ORCPT + 99 others); Wed, 13 Jul 2022 06:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbiGMKhF (ORCPT ); Wed, 13 Jul 2022 06:37:05 -0400 Received: from sonic308-54.consmr.mail.gq1.yahoo.com (sonic308-54.consmr.mail.gq1.yahoo.com [98.137.68.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED442FD511 for ; Wed, 13 Jul 2022 03:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscape.net; s=a2048; t=1657708623; bh=TC1YZJRZ1HK+fEyY7YDkLkdLYwW/HtLekVLODCURuoc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=CRq6hwaUkxj1cqg4bN+xsmARZxQn57v3O4MbQk4T/NrjoW1rWoUKNv3VPLhbZS02xI5YT0ImAsXG+IRSlSixQyqMPDe51+zj5bi+A/bDqjryfpLwatNJcJzQDWa77ZRQf0lWYOY0SLwg7R6IS/68q/5MDdY1QzJC7ytl/AaU84n+fgN63mkDcCaF1kqYYyL5gP2qyDJ+CRwN8rWGGkHnzGlK2VdZtK0UVKMi5ZmsE7UazwyTAGLmURX/TZtXyNWd0fTIuMwvjN64Zb+gid7cFby40fw+qQ7FEBeNjYW/c0CfI7OlYUE0KA3ZYT16iJu+CZGRNSqIFk+XCr04KMMDng== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657708623; bh=1aKOJ3rqFl3/Xk516KhFG2RmtNCAOe5ux/yPgO41wBf=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=FceTnK+kUr5uVObmwGpy68/wPTIOPw+h0JrlrMPrvUKTjYqVUCwNvgIJrdwkI/fcGNqfxjhFilSQLmaPO02Rg5qtoV9ftQAFC1TdnUW0z7nkzL3aJVofMg/LDX6ROrhnsY2WRwN57W15KlU4HIJn0+Ez87QfBL+6J+RyJJUkyuAd+1VOeOnxzTx2ORSebheMhjoGw/Yuk3VgPxbXyYJ0cPaiVbKg9lGY9JSLPI8EDb307QMbIPYezl9nWXsZqiD2Lg0Hiq4V5MYwb/gxVoVyu9/sQMu3hPR1jqlOwiCkVsr0Ud+bl+chNz+UEtEahbsGpofSo6kYTeDpqi2UDoY6jA== X-YMail-OSG: Ejjps90VM1lhpOImESIgbi_Y8Kj5j50KHq3kji2wF8n.kpmmQ5ufuj2EAGBzXDA txgPZZUj4zT2vj6aL5SQplr6m6E3urlCLzOXDkgSFZcjBA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ID3Geq_EJ48cRL5g - X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Wed, 13 Jul 2022 10:37:03 +0000 Received: by hermes--production-ne1-7864dcfd54-xmlhn (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 54bb56f5686ec92203ef9b89a04e8860; Wed, 13 Jul 2022 10:37:00 +0000 (UTC) Message-ID: <775493aa-618c-676f-8aa4-d1667cf2ca78@netscape.net> Date: Wed, 13 Jul 2022 06:36:58 -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: 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> <3d3f0766-2e06-428b-65bb-5d9f778a2baf@netscape.net> 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 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