All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT
@ 2017-06-02  6:32 Ian W MORRISON
  0 siblings, 0 replies; 13+ messages in thread
From: Ian W MORRISON @ 2017-06-02  6:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Bernhard Held, Mikulas Patocka, Andy Lutomirski, Ingo Molnar,
	chris, Doug Smythies

On 2 June 2017 at 00:48, Ian W MORRISON <ianwmorrison@gmail.com> wrote:
> On 6/1/17 5:49 PM, Ian W MORRISON wrote:
>> On 31 May 2017 at 10:53, Doug Smythies <dsmythies@telus.net> wrote:
>>> Note Before:
>>> I might not have the address list correct, as I have re-created this
>>> e-mail from the web page archive, having found the thread after bisecting the
>>> kernel.
>>>
>>> On 2017.05.29 18:50:57 -0400 (EDT) Mikulas Patocka wrote:
>>>> On Sun, 28 May 2017, Andy Lutomirski wrote:
>>>>> On Sun, May 28, 2017 at 11:18 AM, Bernhard Held <berny156@gmx.de> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> this patch breaks the boot of my kernel. The last message is "Booting
>>>>>> the kernel.".
>>>
>>> It breaks my kernel boot also, and I know of at least two others with
>>> the same, or similar, problem as of kernel 4.12-rc3.
>>>
>>
>> Just to add that I cannot boot v4.12-rc3 kernel with any Intel Atom
>> (BYT and CHT) Intel Compute Sticks. Adding 'earlyprintk=efi' confirms
>> kernel panic with
>> [ 0.000000] Kernel panic - not syncing: x86/PAT: PAT enabled, but not
>> supported by secondary CPU
>>
>>
>> <snip>
>>
>
> Confirmed that following patch fixes boot of v4.12-rc3 for Intel Atom Compute Sticks:
>
> [PATCH] Fix X86_FEATURE_PAT regression bug
>

<snip>

And for the sake of completeness, the revert patch
(https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/urgent)
also fixes the boot of v4.12-rc3 for Intel Atom Compute Sticks (as
expected and now tested - yay).

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT
@ 2017-05-31  0:53 Doug Smythies
  2017-06-01  7:49 ` Ian W MORRISON
  0 siblings, 1 reply; 13+ messages in thread
From: Doug Smythies @ 2017-05-31  0:53 UTC (permalink / raw)
  To: 'Bernhard Held', 'Mikulas Patocka',
	'Andy Lutomirski', 'Ingo Molnar'
  Cc: linux-kernel, Doug Smythies

Note Before:
I might not have the address list correct, as I have re-created this
e-mail from the web page archive, having found the thread after bisecting the
kernel.

On 2017.05.29 18:50:57 -0400 (EDT) Mikulas Patocka wrote:
> On Sun, 28 May 2017, Andy Lutomirski wrote:
>> On Sun, May 28, 2017 at 11:18 AM, Bernhard Held <berny156@gmx.de> wrote:
>>> Hi,
>>>
>>> this patch breaks the boot of my kernel. The last message is "Booting
>>> the kernel.".

It breaks my kernel boot also, and I know of at least two others with
the same, or similar, problem as of kernel 4.12-rc3.

>>> My setup might be unusual: I'm running a Xenon E5450 (LGA 771) in a
>>> Gigbayte G33-DS3R board (LGA 775). The BIOS is patched with the
>>> microcode of the E5450 and recognizes the CPU.

I do not think my test server setup is unusual.
I use Ubuntu 16.04.2 server edition as my distro, and
steal Ubuntu kernel configurations for compiling.
My processor is an older model i7
(Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz)

> Hi
>
> Please do the following three tests and test if the kernel boots.
>
> 1. use the PAT patch and revert the change to the function pat_enabled()
> - i.e. change it to the original:
> bool pat_enabled(void)
> {
>	return !!__pat_enabled;
> }

Test 1 result: fail

>
> 2. use the PAT patch and revert the change to the function pat_ap_init
> - i.e. change it to the original:
> static void pat_ap_init(u64 pat)
> {
>	if (!boot_cpu_has(X86_FEATURE_PAT)) {

Test 2 result: pass

> 3. use the full PAT patch and apply the below patch on the top of it.
>

Test 3 result: fail

>> I think this patch is bogus.  pat_enabled() sure looks like it's
>> supposed to return true if PAT is *enabled*, and these days PAT is
>> "enabled" even if there's no HW PAT support.  Even if the patch were
>> somehow correct, it should have been split up into two patches, one to
>> change pat_enabled() and one to use this_cpu_has().
>> 
>> Ingo, I'd suggest reverting the patch, cc-ing stable on the revert so
>> -stable knows not to backport it, and starting over with the fix.
>> From very brief inspection, the right fix is to make sure that
>> pat_init(), or at least init_cache_modes(), gets called on the
>>
> pat_init() needs to be called with cache disabled - and the cache disable 
> code (functions prepare_set() and post_set()) exists in 
> arch/x86/kernel/cpu/mtrr/generic.c - it may not be compiled if CONFIG_MTRR 
> is not set.
>
> Though, it is possible to call init_cache_modes() - see the patch below. 
> init_cache_modes() does nothing if it is called multiple times.
>
>> affected CPUs.
>> 
>> As a future cleanup, I think that pat_enabled() could be deleted
>> outright and, if needed, replaced by functions like have_memtype_wc()
>> or similar.  (Do we already have helpers like that?)  Toshi, am I
>> right?
>> 
>> --Andy

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH] X86: don't report PAT on CPUs that don't support it
@ 2017-04-18 19:07 Mikulas Patocka
  2017-05-24 10:21 ` [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT tip-bot for Mikulas Patocka
  0 siblings, 1 reply; 13+ messages in thread
From: Mikulas Patocka @ 2017-04-18 19:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin; +Cc: x86, linux-kernel

In the file arch/x86/mm/pat.c, there's a variable __pat_enabled. 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 CPU, 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 this warning is produced when attemting 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.

This patch changes 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.

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
Modules linked in: blowfish_generic blowfish_common cbc dm_crypt dm_loop msr configfs cpufreq_userspace cpufreq_powersave cpufreq_ondemand cpufreq_conservative ext4 crc16 jbd2 mbcache hpfs nls_cp852 msdos fat matroxfb_base matroxfb_g450 matroxfb_accel cfbfillrect cfbimgblt cfbcopyarea matroxfb_DAC1064 g450_pll matroxfb_misc floppy snd_usb_audio snd_hwdep snd_usbmidi_lib snd_seq_midi snd_seq_midi_event snd_rawmidi snd_pcm snd_seq snd_seq_device snd_timer hid_generic snd usbhid hid soundcore powernow_k6 pcspkr evdev e1000 ehci_pci uhci_hcd ehci_hcd usbcore usb_common dm_mod pata_it821x unix
CPU: 0 PID: 3891 Comm: Xorg Not tainted 4.11.0-rc6-test+ #35
Hardware name: System Manufacturer Product Name/VA-503A, BIOS 4.51 PG 08/02/00
Call Trace:
 ? __warn+0xab/0xc0
 ? untrack_pfn+0x5c/0x9f
 ? warn_slowpath_null+0xf/0x13
 ? untrack_pfn+0x5c/0x9f
 ? unmap_single_vma+0x43/0x66
 ? unmap_vmas+0x24/0x30
 ? exit_mmap+0x3c/0xa5
 ? __mmput+0xf/0x76
 ? copy_process.part.76+0xb43/0x1129
 ? _do_fork+0x96/0x177
 ? do_int80_syscall_32+0x3e/0x4c
 ? entry_INT80_32+0x2a/0x2a
---[ end trace 8726f9d9fa90d702 ]---
x86/PAT: Xorg:3891 map pfn expected mapping type uncached-minus for [mem 0xe4000000-0xe5ffffff], got write-combining

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org	# v4.2+

---
 arch/x86/mm/pat.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: linux-2.6/arch/x86/mm/pat.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/pat.c
+++ linux-2.6/arch/x86/mm/pat.c
@@ -64,9 +64,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);
 
@@ -224,13 +226,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.
@@ -305,7 +308,7 @@ void pat_init(void)
 	u64 pat;
 	struct cpuinfo_x86 *c = &boot_cpu_data;
 
-	if (!pat_enabled()) {
+	if (!__pat_enabled) {
 		init_cache_modes();
 		return;
 	}

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-06-02  6:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02  6:32 [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT Ian W MORRISON
  -- strict thread matches above, loose matches on Subject: below --
2017-05-31  0:53 Doug Smythies
2017-06-01  7:49 ` Ian W MORRISON
2017-06-01 14:48   ` Ian W MORRISON
2017-04-18 19:07 [PATCH] X86: don't report PAT on CPUs that don't support it Mikulas Patocka
2017-05-24 10:21 ` [tip:x86/urgent] x86/PAT: Fix Xorg regression on CPUs that don't support PAT tip-bot for Mikulas Patocka
2017-05-28 18:18   ` 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

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.