All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Mikulas Patocka <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mpatocka@redhat.com, linux-kernel@vger.kernel.org,
	peterz@infradead.org, mcgrof@suse.com, tglx@linutronix.de,
	dvlasenk@redhat.com, jpoimboe@redhat.com, toshi.kani@hp.com,
	luto@kernel.org, akpm@linux-foundation.org, brgerst@gmail.com,
	bp@alien8.de, torvalds@linux-foundation.org, hpa@zytor.com,
	mingo@kernel.org
Subject: [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT
Date: Wed, 24 May 2017 03:21:11 -0700	[thread overview]
Message-ID: <tip-cbed27cdf0e3f7ea3b2259e86b9e34df02be3fe4@git.kernel.org> (raw)
In-Reply-To: <alpine.LRH.2.02.1704181501450.26399@file01.intranet.prod.int.rdu2.redhat.com>

Commit-ID:  cbed27cdf0e3f7ea3b2259e86b9e34df02be3fe4
Gitweb:     http://git.kernel.org/tip/cbed27cdf0e3f7ea3b2259e86b9e34df02be3fe4
Author:     Mikulas Patocka <mpatocka@redhat.com>
AuthorDate: Tue, 18 Apr 2017 15:07:11 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 24 May 2017 10:17:23 +0200

x86/PAT: Fix Xorg regression on CPUs that don't support PAT

In the file arch/x86/mm/pat.c, there's a '__pat_enabled' variable. The
variable is set to 1 by default and the function pat_init() sets
__pat_enabled to 0 if the CPU doesn't support PAT.

However, on AMD K6-3 CPUs, the processor initialization code never calls
pat_init() and so __pat_enabled stays 1 and the function pat_enabled()
returns true, even though the K6-3 CPU doesn't support PAT.

The result of this bug is that a kernel warning is produced when attempting to
start the Xserver and the Xserver doesn't start (fork() returns ENOMEM).
Another symptom of this bug is that the framebuffer driver doesn't set the
K6-3 MTRR registers:

  x86/PAT: Xorg:3891 map pfn expected mapping type uncached-minus for [mem 0xe4000000-0xe5ffffff], got write-combining
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 3891 at arch/x86/mm/pat.c:1020 untrack_pfn+0x5c/0x9f
  ...
  x86/PAT: Xorg:3891 map pfn expected mapping type uncached-minus for [mem 0xe4000000-0xe5ffffff], got write-combining

To fix the bug change pat_enabled() so that it returns true only if PAT
initialization was actually done.

Also, I changed boot_cpu_has(X86_FEATURE_PAT) to
this_cpu_has(X86_FEATURE_PAT) in pat_ap_init(), so that we check the PAT
feature on the processor that is being initialized.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: stable@vger.kernel.org # v4.2+
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1704181501450.26399@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/pat.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 9b78685..83a59a6 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -65,9 +65,11 @@ static int __init nopat(char *str)
 }
 early_param("nopat", nopat);
 
+static bool __read_mostly __pat_initialized = false;
+
 bool pat_enabled(void)
 {
-	return !!__pat_enabled;
+	return __pat_initialized;
 }
 EXPORT_SYMBOL_GPL(pat_enabled);
 
@@ -225,13 +227,14 @@ static void pat_bsp_init(u64 pat)
 	}
 
 	wrmsrl(MSR_IA32_CR_PAT, pat);
+	__pat_initialized = true;
 
 	__init_cache_modes(pat);
 }
 
 static void pat_ap_init(u64 pat)
 {
-	if (!boot_cpu_has(X86_FEATURE_PAT)) {
+	if (!this_cpu_has(X86_FEATURE_PAT)) {
 		/*
 		 * If this happens we are on a secondary CPU, but switched to
 		 * PAT on the boot CPU. We have no way to undo PAT.
@@ -306,7 +309,7 @@ void pat_init(void)
 	u64 pat;
 	struct cpuinfo_x86 *c = &boot_cpu_data;
 
-	if (!pat_enabled()) {
+	if (!__pat_enabled) {
 		init_cache_modes();
 		return;
 	}

  parent reply	other threads:[~2017-05-24 10:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 19:07 [PATCH] X86: don't report PAT on CPUs that don't support it Mikulas Patocka
2017-04-18 19:28 ` H. Peter Anvin
2017-04-18 20:47   ` Mikulas Patocka
2017-05-14 22:07     ` Mikulas Patocka
2017-05-16 13:57 ` H. Peter Anvin
2017-05-16 15:49   ` Mikulas Patocka
2017-05-18  7:17     ` Ingo Molnar
2017-05-24 10:21 ` tip-bot for Mikulas Patocka [this message]
2017-05-28 18:18   ` [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT Bernhard Held
2017-05-28 18:43     ` Andy Lutomirski
2017-05-29 22:50       ` Mikulas Patocka
2017-05-30 17:14         ` Dominik Brodowski
2017-05-30 17:59           ` Mikulas Patocka
2017-05-30 18:47             ` Dominik Brodowski
2017-05-30 19:30             ` Bernhard Held
2017-05-31  9:39             ` Junichi Nomura
2017-06-06 22:49       ` [PATCH v2] X86: don't report PAT on CPUs that don't support it Mikulas Patocka
2017-06-06 22:51         ` Andy Lutomirski
2017-06-06 23:21           ` Mikulas Patocka
2017-06-13 15:54             ` Andy Lutomirski
2017-06-14 20:24               ` Mikulas Patocka
2017-06-07 19:54         ` Bernhard Held
2017-07-03  5:05         ` Mikulas Patocka
2017-07-04 13:41           ` Thomas Gleixner
2017-07-04 13:48             ` Thomas Gleixner
2017-07-04 23:04             ` [PATCH v3] " Mikulas Patocka
2017-07-05  7:03               ` [tip:x86/urgent] x86/mm/pat: Don't " tip-bot for Mikulas Patocka
2017-05-31  0:53 [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT Doug Smythies
2017-06-01  7:49 ` Ian W MORRISON
2017-06-01 14:48   ` Ian W MORRISON
2017-06-02  6:32 Ian W MORRISON

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-cbed27cdf0e3f7ea3b2259e86b9e34df02be3fe4@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mcgrof@suse.com \
    --cc=mingo@kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=toshi.kani@hp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.