Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp220013imw; Wed, 13 Jul 2022 23:43:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1txioC/pb8xqdEdFtiJNe3gdHNyduF7lOhu2OSRJoStgqdyg187LLwhArNxOwxGf1Yyk0Z0 X-Received: by 2002:a17:90b:1c12:b0:1f0:2836:7799 with SMTP id oc18-20020a17090b1c1200b001f028367799mr14897837pjb.139.1657781019072; Wed, 13 Jul 2022 23:43:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657781019; cv=pass; d=google.com; s=arc-20160816; b=s5d0vGO+J5uxRu4a3ny5+7lA5t9CDz4Maj3qH8mSz/wZ8sBOyc6/U4xGYECnfava7H CRE9nmZgBOiEVEQxM9HOad5xfhbDkVTLuxmX6xATDufGamv+zpmZWpRBQtCXKaPlWkPX pxruODtM59Uc/yvhMqZQ/K6HXkksua49NjLz5ZPHRMn6ntJaJ6yhABlib5dFoghPtUq4 4GYjO8E9qJJqxNtQWRBWEgOovUOw+hrmIhS1zfR6+svXlWa6K8jDv6FkNsDB62nbA003 FnRXLm50QXOSRPMhexcbu5x1sa6AEzXHzNTrw6hNh1eRhpDUhsEqqc0WZwgNqXGPXGaF ZXyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=oFcPL/umJ+5KuC79w/CHfNJulm3P2EJlDY+FDAewpq0=; b=TjXFLOqj+5xl4fqDVDiaOVmNuCy7hO/zRWNhzSSyXHNfycd3vayYg8RiR+7Y3eByQO TXGeWPX6Vu9+MICGwn5086j9/8lYoUqThd//AzOLvvuovVBZ61wlwR4X8izHJcuJ8KQx GdYU23XVqznx5zDoANLXQ1I8vp/x/uweSFvhpk4f7ENeHX5oeriNRb1JuUauJb3LEjYU bXzkjYoulZaW+8jZ032/1z+P1meXUIXnGuJ5qnxkIhOp5nxsqmNbjGxIYhG9h2ke1zhZ 5l7al6BC0TrJbFCBwFO3cBulfyCM7rRaSLP9g+vwOzSPWHdWL09lXtiR4cjVFMcQ3Py7 GvLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=e1zpRprI; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i189-20020a639dc6000000b0041604920dc3si834352pgd.840.2022.07.13.23.43.26; Wed, 13 Jul 2022 23:43:39 -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=@suse.com header.s=selector1 header.b=e1zpRprI; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbiGNG2s (ORCPT + 99 others); Thu, 14 Jul 2022 02:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbiGNG2q (ORCPT ); Thu, 14 Jul 2022 02:28:46 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2065.outbound.protection.outlook.com [40.107.22.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA1CF641B; Wed, 13 Jul 2022 23:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QqTqMTAFVOS6hELOasuAtCMQchggV2oG+GQ3DA59npH9S3NWZABjJULmcLN03J0VbyFCbFrEs6ywmFPfYTrYNfBvdWhGCEv4xDrk3JHviqSzIYYuvXbbBIOghWIjggqILRASOE6wh8BGcqa2PCfhP1vOgsCzbkz+Cr4nlmS7XAuCiaeVTdxqHsBfL/WQG6uszaj1RcSSgx+36NjgmAC0anPZzss8ttKq5NYW3SYQLqcwaXF1Hl+3OnmEOBtypzBMPSrKjrYDx2aQ9PCTOTC9tvmPbYszL4KwRy6h8GGrEfVGdjoyV9vOc9NccTNtwlkmw4fdoglztKd/hiV59gAAIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oFcPL/umJ+5KuC79w/CHfNJulm3P2EJlDY+FDAewpq0=; b=dxsPRA72J3RfPqWljx0tqjPV2SnmQteChvkV+9aMGI3Iq9EpSXhibRuXbZyI47QB4bL2gq3+lk3Wbt53eqF+FIoEvuqn3NbqQkb3JXEBMP1L5uyWmyhUNigguIJNjCLKzdVyDNQlIC4QghSPpCiTJs+mpS3GS1tObZUrVtPc3FmceqT+ml/cRLzALW5HB6paFq4801kLV0j5xr5RGNm1724jxPg5jg8Ft+BuItUOCsTcO4/0yYNwKjH3vu8vvQCOK04nI+8TErktnLgIy551kfbyc/YxGDWrdxWD3RrwoEZL/x5KYHinM7j3Ze7gWowBhPv0cknmYO/6GeMphhL3dw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oFcPL/umJ+5KuC79w/CHfNJulm3P2EJlDY+FDAewpq0=; b=e1zpRprIVfpu1tHbrNsGB4l26KcpRtYbmgWcPeRnUV69vWNrc0TG2xd2uTRmwsHXAYyvnjG0XVFd4oj4NaOtSFzx5bPoVOYZ5J5Sdzo23iXHu8jjYfNpr9/GLujW7wJzMWN8+ORa0vPatAczdW/SWGl1kFZ/84S10/VbTTDBXrOvYuvcnCjiNTR6OG6j4Eg3ZUQZRWbxzNjcKGIgzLOBB5E0GWsIKMbYjgO8zvYm7g+YXk3EznjYvOKDxel86DZFBi2yGyj/TXRyu9DnpF5bDkRC0wL2ATf2xlE1dq+svzTr+NYTYXDF5ccqBKD0ubk6v8t4RZ1vPcUf+htKk9RU0g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8886.eurprd04.prod.outlook.com (2603:10a6:10:2e1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26; Thu, 14 Jul 2022 06:28:41 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::60ad:4d78:a28a:7df4]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::60ad:4d78:a28a:7df4%4]) with mapi id 15.20.5438.014; Thu, 14 Jul 2022 06:28:41 +0000 Message-ID: <76b421cd-7a91-ebac-6f48-8a00eaf3c6f5@suse.com> Date: Thu, 14 Jul 2022 08:28:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; 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 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 , xen-devel@lists.xenproject.org, Chuck Zmudzinski , linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <9d5070ae4f3e956a95d3f50e24f1a93488b9ff52.1657671676.git.brchuckz.ref@aol.com> <9d5070ae4f3e956a95d3f50e24f1a93488b9ff52.1657671676.git.brchuckz@aol.com> From: Jan Beulich In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM6P192CA0040.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::17) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 890d6b25-ecc9-4cfc-1720-08da656217f1 X-MS-TrafficTypeDiagnostic: DU2PR04MB8886:EE_ X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xsijC1C5/aUsdXTY9sq5FG0lG4MSm/AnyXkF/LQslEiba4ExCq/GuZdGF4vUyo00eT5eFsbVpm4ZVKcfN+E21Aj+SR7pLqAk+nKFZ/M/li4tpiKWnQ2fMFL/tPdhKEtDJ+YtaIJ2LEMF6EbKEIHUHl3Awoi8eCBL2awkLDOpU5GaFEDP1WTeJUBrC9rJeUrg76AQD7bKja+g2M4oTHdDSjJoeTKu6hcJ6W7veO/8z3S7/r/6fQVGnCDP4shdKPiW8nPDJcabMqp4IHs/1VXd9VxPgfxixFjQureMx8/TXZWAiQipOX7JifibNPi+HcVLAS7sjnXSOLruROiOjYklKA0b25g6mXfdWztlEKpFOftur721LJ2klV62aZEPWQHqwrv5RWwfCtxWDnuHJbGahQidS1HVM4EmgWt8+dNDhWtaUbcKRAVlESD8fix1JzLBUUV7tsAp9D5DLILw1l5qAtSSCKI2Vf7ldAbxamuMvHhMLtzAzvze/igG8kUf4/ZgskN2NwioHob2NTDXK3M5aGuI2nxLmrlW7JhJN9upLE190UCq8xC9nJLBV6zQIKED2tPxHNItB99ZL+6o7qRIzGWhGffI/7bIhlIOQib9Pl5pXhnOTbWEFmVPd1hFPwgBYJIzyul8CAVEFwKCrbVzRAWzdDOAK9rvv8oeo6QZBuXkpgxvCUBwp7mMjhd7Jmsezaih1ucMJZKWsYHY79WNf8whV+MyCzWMFIdlBMK/9HhztKtxOZm4S66adgzMGIbYrM4SdByyyI/wdpGf+vXzG/IUicvZg5jvO2LOnDb/8vi5UQVwTMt14j8+eU3nItxEedpd4hKCiKsOC/bLsVuRRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(366004)(396003)(376002)(39860400002)(346002)(136003)(66476007)(6512007)(478600001)(41300700001)(8936002)(6862004)(2906002)(6666004)(6506007)(6486002)(86362001)(53546011)(8676002)(7416002)(26005)(2616005)(38100700002)(36756003)(186003)(66946007)(31696002)(54906003)(66556008)(4326008)(316002)(37006003)(31686004)(6636002)(83380400001)(5660300002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eWk2QjhDUzhTa0VOa2craVdWbGRyU29Kb3R4em9WVzF2Y1E2cnFCYTlteHNu?= =?utf-8?B?Q0VYUXRsVktTeGhYZmtyWV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MGloczhSUUtHUG1HT3NqbnFUemxBU3VPaXJVYm5MRUJyNFpHNFVUZitN?= =?utf-8?B?VThKRll5bVA4cnp3RWp2WHhHdW5nSTJJcVRCbGE2cWdFYlEvWklzTnErNWJn?= =?utf-8?B?aWlxaSt4cDM1cEM3S0VoeHdLRSsrb2xITWJLa25Oa01wK0VvZEZCYm1ud0hS?= =?utf-8?B?V1pEMjlkdDJ6ZDBuWWM0N1Y5djdZa3F1ZmFlbGhEK3lTSmJBb0kva0VENjla?= =?utf-8?Q?1OfHrm4/BrJi2eCBAzceTDWXT?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 890d6b25-ecc9-4cfc-1720-08da656217f1 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2022 06:28:41.1254 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: h0f4nX/qECLf+7es3I6k417KQ63N3bJPznCqljoopr5NSkP6kPu79/8H+6vl5zgAX0asfyRqrn37OSr0EUrvLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8886 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 14.07.2022 07:40, Juergen Gross wrote: > On 13.07.22 03:36, Chuck Zmudzinski wrote: >> @@ -292,7 +294,7 @@ void init_cache_modes(void) >> rdmsrl(MSR_IA32_CR_PAT, pat); >> } >> >> - if (!pat) { >> + if (!pat || pat_force_disabled) { > > Can we just remove this modification and ... > >> /* >> * 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); >> + } else if (!pat_bp_enabled) { > > ... use > > + } else if (!pat_bp_enabled && !pat_force_disabled) { > > here? > > This will result in the desired outcome in all cases IMO: If PAT wasn't > disabled via "nopat" and the PAT MSR has a non-zero value (from BIOS or > Hypervisor) and PAT has been disabled implicitly (e.g. due to lack of > MTRR), then PAT will be set to "enabled" again. Just to mention it explicitly: If the value _read_ from the MSR is zero, we're hosed anyway, as then we can only express a single memory type (UC) in all PTEs. The zero case we mean to deal with is when reading the MSR wasn't valid to try. Jan