From patchwork Tue Jul 12 18:20:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Zmudzinski X-Patchwork-Id: 12915382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B85A1C43334 for ; Tue, 12 Jul 2022 18:21:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.365985.596514 (Exim 4.92) (envelope-from ) id 1oBKVJ-0005KZ-4U; Tue, 12 Jul 2022 18:21:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 365985.596514; Tue, 12 Jul 2022 18:21:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBKVJ-0005KS-1i; Tue, 12 Jul 2022 18:21:01 +0000 Received: by outflank-mailman (input) for mailman id 365985; Tue, 12 Jul 2022 18:20:59 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBKVH-0005KM-Ng for xen-devel@lists.xenproject.org; Tue, 12 Jul 2022 18:20:59 +0000 Received: from sonic313-20.consmr.mail.gq1.yahoo.com (sonic313-20.consmr.mail.gq1.yahoo.com [98.137.65.83]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5f206cee-020f-11ed-924f-1f966e50362f; Tue, 12 Jul 2022 20:20:57 +0200 (CEST) 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) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5f206cee-020f-11ed-924f-1f966e50362f 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+6Hnmg22NJcsMIge6F2GYYz9ndIVcmXFg1HhuGMW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XE4zLnKMY94vRMr2awllqmFtjcgqxeOP9odek hA4.2yScXvibWlywqxulO7XgjKuaACLwX2b8f5iwYiyZjHhPF68kSSbdMs_ZYEu81CEjH9SX_zYK _ly11ilPlwOp.p4MHov174fjcKRbU4bFe4n_HKEL07RO6g3SHKSMPulBl6M0bJLRUvYssct26gJG Metr3ZueWBmwPTof1NejlDcpLXA7kZFhzKHXP55up2u2RnDTh.7tkyO0hR4gh X-Sonic-MF: 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 References: <2885cdcaccffd287ef69c7509056ddf183a38a0e.1657647656.git.brchuckz.ref@aol.com> 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); }