Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1037901imw; Wed, 13 Jul 2022 12:34:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vIrGjfmP/qWu6/wkb2Xb0KVBuxjaIuSJJaHPEmSUAwVD7Nw/4lRAqEhd/S3oiAgO5a78l8 X-Received: by 2002:a63:4558:0:b0:411:442a:b740 with SMTP id u24-20020a634558000000b00411442ab740mr4109086pgk.540.1657740895251; Wed, 13 Jul 2022 12:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657740895; cv=none; d=google.com; s=arc-20160816; b=BMp6QfdBbSKd0u9dVsM7IOxu/+KdBYWpcwv/1ecqzIkTwTS+jfKP6MeUB8ftCro6zN l7esmWMDkdAr38t4/wQ40w9Unny/zk2LSLajwjf8bhhVnvdMBt5qepJiXMqlxfhklUXq 7RcgH+SdSiQ+/MH2ogeJOnRfYk+BZ6svZRb+ZHxZS5wWKnhVlCOgdMKe0sbs9DOYAbG3 YLhHJmnP+WdX4vXshovHj9ZIuIwkqhea6UcVUYKNGZK/Mez2+FcGqaaEUHBtxiXDoscb qacDaq03DVDOhAx4gqUOheNC0+hUvYI3TslrFmiJRQeUFsPDpHjY/3G2ceRoICJP//Z7 EgLw== 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=lrtn2id1/w6rDvkb7r86M1MSgYYCSarhdbpXFUxCFVo=; b=YUSzLylRjG/tSc2EdIpGYl2/UzvLiEV4QfuqYto1+MIyGsqyg/9D3YaYm8UiPHRJXI 46x7S08iuRFhTKHI/7bUdqQCC/xyvIPJli15mR5PoAn/oP2ihqOdjHODv51MNqe9828R DO+wWP5LYPfZCvIMjHXN0/ZpCuOB/sUSj1aTNbd6pas4rhhL2SaD+O+95wK2t/rF2Ugo O8voO2nhUcBYa8CqNkI4uL7meLKnZXimV+dZvsNkZ2QbIqnUssNQqunjHiKhTmOojPgz ulvx/bRomeLNReQhnqi80mUUckwbUyXliysofMRjt5YSLXKVMM8Ec+6ljgdcJQ+Cf+Xp CEPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netscape.net header.s=a2048 header.b=B84svUEC; 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 k10-20020a170902d58a00b0016c15d2564csi16985991plh.25.2022.07.13.12.34.42; Wed, 13 Jul 2022 12:34:55 -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=B84svUEC; 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 S236359AbiGMTHz (ORCPT + 99 others); Wed, 13 Jul 2022 15:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbiGMTHx (ORCPT ); Wed, 13 Jul 2022 15:07:53 -0400 Received: from sonic309-21.consmr.mail.gq1.yahoo.com (sonic309-21.consmr.mail.gq1.yahoo.com [98.137.65.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567362CDEA for ; Wed, 13 Jul 2022 12:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscape.net; s=a2048; t=1657739271; bh=lrtn2id1/w6rDvkb7r86M1MSgYYCSarhdbpXFUxCFVo=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From:Subject:Reply-To; b=B84svUECHrKyJj/S/IA0R8B6lzJRrmGR6EjjpwPre6q4FnLUCuFWxAtYl0QfyVHyIuxkXCqQOyFh6hsXj72Wk8JBJk3m2RTXCJElviQNFA3ulDFaBWg7Ao7PGijwTpRfKtWyHj0HT/FPOq7FG4bZRIzn6uGWpOG78VEr6iIUJP6nd8vslvQINGoin87C5RKWpEdOCYPbkdeOLX2Xm9/oKdguMR3gohWdVcDQ/kshLij0URNJEZQ72feeP2efpGeDcIUFj+ZlpjnOVxYOj+sOTOFrvNq1kfkjDKjliTl6YlGnnKILFOmoTqnzMxbIddJAJO8032CJs7C6YmurCvJvSg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657739271; bh=gginz7UTVTgsk/g8Xk92Vk/h7wc2Tv65ymmhLjLTC1X=; h=X-Sonic-MF:Date:From:Subject:To:From:Subject; b=SG+GnJHKUuULT/10FXE8IbELqySkPBhK8iFZ3W73AbOJo+iITG6ge9uydl6ZejYBJm5INzzhh1nnkoAdNwKZiFtCc9GPU3a5WuMlCURYMMjBncMP/2aivjIqAbVvGI0PclkKRSvFIRsDvLGyq6ctVG8tbCviLZgMBIlQf7lpyP2B5uUGkno+GBrFgWgwvwJYPqfVjWhlkJvahJTeI2/uW/cie4pSWpzKHm/eFUo8j2nx7QET2lvcRdD37sgwPesL/CF+5bpctMwWCIy5iDkNypJ/Cpe2u7v0dRDqL0nXTruwlBwJKY+i4KZcNbRNfGPX3DiKO1KyEFY8IjHjmwUv0A== X-YMail-OSG: qTQWnokVM1lfWDhV4gNNqh7DX7aoOaA1up.GlrFFYo.ojAmpcQqaUbXwWXAPITa jNtkZMD.YGcpXxR32NhmVokKMcZFO4ZPbxASOKqpHO4dVXiO4uD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0JHS5h6I4qvf TEQ-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.gq1.yahoo.com with HTTP; Wed, 13 Jul 2022 19:07:51 +0000 Received: by hermes--production-bf1-58957fb66f-h8ftj (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 65a156af75367857ded6d2cf2b081491; Wed, 13 Jul 2022 19:07:48 +0000 (UTC) Message-ID: <56a304ad-606f-6d33-bd2b-8c614fcdb666@netscape.net> Date: Wed, 13 Jul 2022 15:07:47 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; 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: 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> 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, 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 7/13/2022 6:36 AM, Chuck Zmudzinski wrote: > >> 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). > > The question is, whether "nopat" needs to be translated to > pat_enabled() returning "false". When I started working on a re-factoring effort of the logic surrounding pat_enabled(), I noticed there are five different reasons in the current code for setting pat_disabled to true, which IMO is what should be a redundant variable that should always be equal !pat_enabled() and !pat_bp_enabled, but that unfortunately is not the case. The five reasons for setting pat_disabled to true are given as message strings: 1. "MTRRs disabled, skipping PAT initialization too." 2. "PAT support disabled because CONFIG_MTRR is disabled in the kernel." 3. "PAT support disabled via boot option." 4. "PAT not supported by the CPU." 5. "PAT support disabled by the firmware." The only effect of setting pat_disabled to true is to inhibit the execution of pat_init(), but it does not inhibit the execution of init_cache_modes(), which is for handling all these cases when pat_init() was skipped. The Xen case is one of those cases, so in the Xen case, pat_disabled will be true yet the only way to fix the current regression and the five-year-old commit is by setting pat_bp_enabled to true so pat_enabled() will return true. So to fix the five-year-old commit, we must have pat_enabled() != pat_disabled Something is wrong with this logic, that is why I wanted to precede my fix with some re-factoring that will change some variable and function names and modify some comments before trying to fix the five-year-old commit, so that we will never have a situation when pat_enabled() != pat_disabled. Chuck