Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4636074imw; Tue, 12 Jul 2022 11:25:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sy7ehvwK8C/lZPbQZzlm4FObhDER9fkgcuFbJ7l6dGL2ziFIE6FrZWskwUW7cmKsuEU8TZ X-Received: by 2002:a05:6402:26ca:b0:43a:c743:7c with SMTP id x10-20020a05640226ca00b0043ac743007cmr21875490edd.227.1657650301915; Tue, 12 Jul 2022 11:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657650301; cv=none; d=google.com; s=arc-20160816; b=ndqC6joCwUNEHg/1UI2G4H13AcVv1O+it6Qa/lcnwsFeqc+0dHNq8jUI5zOeJnF8y1 CjxmViUIgA6fTKaGvmRf9pxDKi4zzTDrINhfOETmFTcO91QIeHBgoCcMWzLfu/N33NJ/ fSny6rQzrpzZB0HSWYsSUVJe93m8EToB/zt6vQLREmUI8MGd6ywiGgvB702FNBM4L83X YFIGEd/UU2gb8Mkx2hNT1NoRRH9LtsdRvAAcPavLApvY+G5sgtv1dtuT40uGi/8n7deY sp3mG6Au8LPa6072qxzOTFZguzlEolI7vUWKs76U6cC1sGHuq2t792cHGy7tCOimSp/o +lIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=CKwnEohSEzLCt0euoMPaexML+KON7/bDHVVi6FBe4pI=; b=RbvaeARUkoOApRLSnC6MRxQT3DK8YbSGszBiIN+GVCid9073v2+x+z7q3WkwiaDDzh AcOWFbDVHaIjq/lZ0m5GS0yPtA8X1m2mO+Iy4aasyxsFLzyjLDphhSAWD6sOsEKUrq1E vKi5dhtYLjNVq2QwpT3n7MzSySCHcKc+67X3KhpATaIkYZS8cd78I+4gfxkiIN5T7EVy amTVibx/kEb5bj8OtGcQsVdWs+eYArHJ4ja2InAOGlmEaINHpEw0IQPk2bBMB6WGe2aE kfGEYlN/oCf6zMqnVb4s1z7NsLdv4T8Zcg8IfkDC6tyjZTMJNMr5KZ1eUF9uGXNnsQNT +fGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=j1UCI128; 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=aol.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc42-20020a1709071c2a00b0072b53e95011si1935213ejc.265.2022.07.12.11.24.34; Tue, 12 Jul 2022 11:25:01 -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=@aol.com header.s=a2048 header.b=j1UCI128; 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=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233064AbiGLSU7 (ORCPT + 99 others); Tue, 12 Jul 2022 14:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231731AbiGLSU5 (ORCPT ); Tue, 12 Jul 2022 14:20:57 -0400 Received: from sonic313-20.consmr.mail.gq1.yahoo.com (sonic313-20.consmr.mail.gq1.yahoo.com [98.137.65.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9837C1757 for ; Tue, 12 Jul 2022 11:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1657650055; bh=CKwnEohSEzLCt0euoMPaexML+KON7/bDHVVi6FBe4pI=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=j1UCI128UC/XdFVIk8BLV40tyhM2thxOLZH7jtvTEo/A8IUpSPaP461IU1bcGCYaneClzexEZECahX9lGBNFlFtATxmGtC1JimPj8U11JSg7iCl7fJma81s4m5R6SViYqBTJVxCJo7iTBRgRCcUSZRBrPTAu8HUNQCFyYu5uvJGh8M5fb9wtvCpchF1Hn2G1IbM6wUJNdMDEr162EbzVnwNTtWl9tKcPjyV06px5uY4jCL4yI5GAlMpnVnJkvBcy1SOibG8/IWQ/+aZgthwfC2VYWy1XT690LtufKYDuoCza4551OKny8fyIgNnFYsgETQtj5u4j+XzZ1lIJmePNfQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657650055; bh=dwvF5IXFxheLGtHJwEBV8hj410W9zZhbiJkuKyvC/7E=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=JpDTgTFsAq45depS6oNm5+uGftDdlQ1MAnIOPRJfPCpTOaL70KC6u3qrb6vAOgnyF2g6HQLieKKj2mkRh4eXrecDBi5vhH4xsst2m+nGBPCZjVvgtFuLgr58krI5AaDKGpbmMbmNvaSzt93NusCylNGdLe0JU1V4x7U+6Hnmg22NJcsMIge6F2GYYz9ndIVcmXFg1HhuGMWs2O0C5efYu26JVpIQ9f02gZJarqnm7wgSLXtCPXeduftahmTxc6YwSh9br954TO/HSjm5CsNW8zrexLYBkt2HJFgxT6sKrTi7tc6lvTJNSFMcUA6TLJZwRXxa3V6f9FQ0JyGb728c/A== X-YMail-OSG: 4PXjc.QVM1mipgaiULtM_pFdsG.GKyXFDyGWQ6WZpiXOqchOGYZe3LVFRAJJ5Au M7WSoPI0ftFeNZOaO.qOL2WZrudPyJTWhvrJ8FQNAaMkRh6IDe.htE1abegSF2MneaqOLulPvP7K xK7A_y1KDO0Yz3UeMcQAp_E3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jEQW5A3in8VA33d1pwDv6daDVth 7PIgiAYyaD4A_ETwvByhGp2FiUHMvTe4sX.L975Yvs4MuGHFDIQ8CO6bn8OnkVSOEHE6aeE42mlp FGDQIcmsENOMWIucS4Frt29Li.0E2WbEAIF3AddWAQX2xUYsBOg59vHsO4FG5lxXQ3iiug6s0jSC u2uXIdZd5v9d2mEw7RC134lk0hSfhoNRl3KgHcOLQG2XPoNqluGVz3VScNg0I7sqZAFd49OhIG29 3QBIlJLNt0wk.hvJDjO2OenTHdWzQZCgVlHdKRvTCUbzF.t6sVr3SWBzsdHpzrloeRbUsD9Dni4l rJRmL1GSYxgKjzpqNpJALMAU1Pl_.iVjRB6e5zJlW7x9zY3TOdvNuZ6D3JHAnq6uNLHh8ay4zODl .WwFq5AEVOj6lJnFjtd6DU1MjGGfc6GLH.S2RVdde7I9B0sI.Waj42QasW_qfQsba2UgX5YP8uaW gFWATVUB6DM1v7GYv4tS8vc9M9lMLQSSKm1QP3bNRqD0N_7vUaXMNHhjHr0ztUcBxenm3vL9XAM9 J0_NVBt3uYWKZv.5e1TxFxFZBTiqSWRcIgSOxvDmPTZHSxdm41PcTJLsb2QUCqQRksy2WyXl0xI1 mDP0rlgb2z2BkJ225w9RSf0fOyVT9JmLGQ9JMPzJrn6G02z7Vx2MdGmNVSzFPKKp2XVtQYWHnyWF vkBg.etAfGynfqY8gFj_cGJ5vBw9aV1WeIzL_v2XE4zLnKMY94vRMr2awllqmFtjcgqxeOP9odek hA4.2yScXvibWlywqxulO7XgjKuaACLwX2b8f5iwYiyZjHhPF68kSSbdMs_ZYEu81CEjH9SX_zYK _ly11ilPlwOp.p4MHov174fjcKRbU4bFe4n_HKEL07RO6g3SHKSMPulBl6M0bJLRUvYssct26gJG Metr3ZueWBmwPTof1NejlDcpLXA7kZFhzKHXP55up2u2RnDTh.7tkyO0hR4gh X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.gq1.yahoo.com with HTTP; Tue, 12 Jul 2022 18:20:55 +0000 Received: by hermes--production-bf1-58957fb66f-p6kcj (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID b90d8ba9e0f4f18b61bda02035f72ec5; Tue, 12 Jul 2022 18:20:53 +0000 (UTC) From: Chuck Zmudzinski To: linux-kernel@vger.kernel.org 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 , Brijesh Singh , Jane Chu , Tianyu Lan , Randy Dunlap , Sean Christopherson , Jan Beulich , Juergen Gross , xen-devel@lists.xenproject.org, stable@vger.kernel.org Subject: [PATCH] x86/PAT: Report PAT on CPUs that support PAT without MTRR Date: Tue, 12 Jul 2022 14:20:37 -0400 Message-Id: <2885cdcaccffd287ef69c7509056ddf183a38a0e.1657647656.git.brchuckz@aol.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit References: <2885cdcaccffd287ef69c7509056ddf183a38a0e.1657647656.git.brchuckz.ref@aol.com> 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,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 The commit 99c13b8c8896d7bcb92753bf ("x86/mm/pat: Don't report PAT on CPUs that don't support it") incorrectly failed to account for the case in init_cache_modes() when CPUs do support PAT and falsely reported PAT to be disabled when in fact PAT is enabled. In some environments, notably in Xen PV domains, MTRR is disabled but PAT is still enabled, and that is the case that the aforementioned commit failed to account for. As an unfortunate consequnce, the pat_enabled() function currently does not correctly report that PAT is enabled in such environments. The fix is implemented in init_cache_modes() by setting pat_bp_enabled to true in init_cache_modes() for the case that commit 99c13b8c8896d7bcb92753bf ("x86/mm/pat: Don't report PAT on CPUs that don't support it") failed to account for. This patch fixes a regression that some users are experiencing with Linux as a Xen Dom0 driving particular Intel graphics devices by correctly reporting to the Intel i915 driver that PAT is enabled where previously it was falsely reporting that PAT is disabled. Fixes: 99c13b8c8896d7bcb92753bf ("x86/mm/pat: Don't report PAT on CPUs that don't support it") Cc: stable@vger.kernel.org Signed-off-by: Chuck Zmudzinski --- Reminder: This patch is a regression fix that is needed on stable versions 5.17 and later. arch/x86/mm/pat/memtype.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index d5ef64ddd35e..0f2417bd1b40 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -315,6 +315,18 @@ void init_cache_modes(void) PAT(4, WB) | PAT(5, WT) | PAT(6, UC_MINUS) | PAT(7, UC); } + else if (!pat_bp_enabled) { + /* + * In some environments, specifically Xen PV, PAT + * initialization is skipped because MTRRs are disabled even + * though PAT is available. In such environments, set PAT to + * enabled to correctly indicate to callers of pat_enabled() + * that CPU support for PAT is available. + */ + pat_bp_enabled = true; + pr_info("x86/PAT: PAT enabled by init_cache_modes\n"); + } + __init_cache_modes(pat); } -- 2.36.1