Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1090872imw; Wed, 13 Jul 2022 13:35:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v7T1CIfbB4A6qYVVD1ItAPN5OaKLWN8tOwoc/+4AFBQ85Iyk+usVMciwKHt+hqjFznzUV+ X-Received: by 2002:a17:907:2ce9:b0:72b:30e5:f1bc with SMTP id hz9-20020a1709072ce900b0072b30e5f1bcmr5296101ejc.127.1657744504525; Wed, 13 Jul 2022 13:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657744504; cv=none; d=google.com; s=arc-20160816; b=npNAcFKjGhn6/MtrdcSfiK5YP2pC2qFrf3GylzL+RbjRVG531YWsFAxbAvVLPg/WMA CflAgzyYTZkgiPqjdLrcFBH8FmxMkv1eeIgSkcgbu87jRqRXWaY/2N9jz3RrnrPHZvDC YVaGBproFFGuG4MgjbUDUsq3RIIxw4jC/oB3i/O41QjXDPHOvNsZJIFvnL4Azndn0ZUt rXOeNZEZOmKzszJHWBRqNYLnA8vr2m7mc9lKqie/h9leU55lVod5nqciNvsfbBBGwCus f6gZPsixw8H2Y9sb/muJfVxAZIAG5HFmstiB3exRBKMM+D8BVQcxqY8L0TK/kKtlDOxe 8xjg== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=gvegsbKA0Ugq9G0OL2YHhHKrmsIiT+j/cAd/AQ6k6Xs=; b=IoJlChf/eVSXLwMp55cn9UHmXhifeaB9tc2M+oENXwO33iXry6jbB42T5px+t24QJv kqTgTkOnZw8AZ7qZquKQNMfdCIuNn1sTucxqbQLYshxuRuWLkDQoqs0wWGTC8N6wwFGC v/JomULrHWaBAmh35VlumiWfvYq0NJRU20PIEg0AnRLH3mMAiD+XbQuu2uHwlzmWF0LO 8NLIH3e2favvNbLqZtZ14Ti42QeRkQJtZCzO2CxCJ6OvQyrrC2VK4zeUx3Vp0u+YintS /oM/5I6AtQ6g1te112eJkg+W974iiIp4QpKp6+PDQ97uZhGC5yGGn1ebbaevqkWXYsZD t3ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netscape.net header.s=a2048 header.b="MZQFw9/J"; 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 hq28-20020a1709073f1c00b00726f11c4c8esi17959353ejc.669.2022.07.13.13.34.36; Wed, 13 Jul 2022 13:35:04 -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="MZQFw9/J"; 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 S236927AbiGMTiY (ORCPT + 99 others); Wed, 13 Jul 2022 15:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236763AbiGMTiW (ORCPT ); Wed, 13 Jul 2022 15:38:22 -0400 Received: from sonic306-20.consmr.mail.gq1.yahoo.com (sonic306-20.consmr.mail.gq1.yahoo.com [98.137.68.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3A222B1AA for ; Wed, 13 Jul 2022 12:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscape.net; s=a2048; t=1657741101; bh=gvegsbKA0Ugq9G0OL2YHhHKrmsIiT+j/cAd/AQ6k6Xs=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From:Subject:Reply-To; b=MZQFw9/JPmpuroD8LpVy2xa3dQDRMBFdA1RTqyTtfXGmJdjhwswFVzyIiTtrjeVLke4h9R6vpbhZrwclrfloBGOp2L+wHCFozHHxshm96MpC8KnvxjrbCxDHjQlpRIUpJr3OANhsOqTkaEeDDjVqPyjjcXAeyvNV5NU3tZXVKTLiEK/0j7m1/p13hezk70gaMuusWCA4JRaa2p0Jzse6r7VoUMRvivNOpBOcUWfv/kgTPfpCaZHSyerdo5KS/z7T6qpy9go7S/K1gkEUopfNCmdCWHS4IDEM6Mgm4KYZ0+hLIe52QXhqSu9Uw1QPPkIk8YBYeUMNc2FU2q5el6C0KQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657741101; bh=gZ+FnmKOj2zVRAIddN3HlDPLO1hF3KTuu1g/XWWOSUs=; h=X-Sonic-MF:Date:Subject:From:To:From:Subject; b=a2pkxJoMqAMjHRNepy+Lww/IxC/RE0FTJRCwDDn/wY4E0LE8qCmiLkebT84SXNo+TlgHg11MluHHmltYfW7+EFlikPZ0urlzkyhtpPIYnT6NBiEKkEIrkJ5o2w4NJKVADJI7/18sg/UjKFESFH+RP6AYTYe1iExKtTUIDxtME5cTWF1ITBkUd+qnpyaT8NMqsZHgdMNbLrpBrJDldNKFgg9Zzpn0s/q6EMtoxgdHUy+mvasB13AiPzduJ9m04jq7bK/mbIgapg9+LTqtVnZf/Vhl5Gjt/5aLDz9bMDVv/+DDIUctfWPI3NckNk1ChAZ+i9BgzS9+VYZuS4pRfNSbeg== X-YMail-OSG: 6luG7AYVM1ncjX7nkCvm9bLVe10whawpCglcbiYMUxQ2vlNaWqmz.Z9bEDOn_49 iRTUpxQz7K2qvaNS2J2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GGRgwwRynI4OedIYZj95bLfbVasiHgZ WNt2WUQ-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.gq1.yahoo.com with HTTP; Wed, 13 Jul 2022 19:38:21 +0000 Received: by hermes--production-bf1-58957fb66f-p6kcj (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 564882263554cd3ca01f52971e669fd2; Wed, 13 Jul 2022 19:38:17 +0000 (UTC) Message-ID: <9c97d8b4-ae1d-efd0-8414-91a50d22cf12@netscape.net> Date: Wed, 13 Jul 2022 15:38:16 -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 From: Chuck Zmudzinski 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> <56a304ad-606f-6d33-bd2b-8c614fcdb666@netscape.net> <4e74aae6-7d8c-15ed-c571-b797239374cb@netscape.net> In-Reply-To: <4e74aae6-7d8c-15ed-c571-b797239374cb@netscape.net> 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 3:22 PM, Chuck Zmudzinski wrote: > On 7/13/2022 3:07 PM, Chuck Zmudzinski wrote: > > 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 > Sorry, I meant to say, > > To fix the five-year-old commit, we must have > > pat_enabled() != !pat_disabled or pat_enabled() == pat_disabled, > > and there is something wrong with that logic. > > Chuck So to summarize, I think this means that to be comfortable fixing the five-year-old commit and the current regression by artificially setting pat_bp_enabled and pat_enabled() to true, something which both my patch and Jan's patch does, we need to come to a new understanding of what the static boolean variable pat_disabled in arch/x86/mm/pat/memtype.c in the code really means. The fact is, we have a regression and the only fix we can find is to try to make pat_enabled() == pat_disabled I need to stop thinking about this for a while. It is time for those who have authority to fix this regression to make some comments about how they think this should be fixed. Chuck