2003-11-04 07:08:23

by Zwane Mwaikambo

[permalink] [raw]
Subject: [PATCH][2.6] Dont use cpu_has_pse for WP test branch

It appears that not all processors which support PSE have the PSE bit set,
possibly we should be checking with PSE36 too. But instead i've opted to
simply check for 586+

Celeron (Mendocino): fpu vme de tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 mmx fxsr

Opteron 240: fpu vme de tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat
pse36 clflush mmx fxsr sse sse2 syscall mmxext lm 3dnowext 3dnow

Index: linux-2.6.0-test9/arch/i386/mm/init.c
===================================================================
RCS file: /build/cvsroot/linux-2.6.0-test9/arch/i386/mm/init.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 init.c
--- linux-2.6.0-test9/arch/i386/mm/init.c 27 Oct 2003 07:12:18 -0000 1.1.1.1
+++ linux-2.6.0-test9/arch/i386/mm/init.c 4 Nov 2003 06:58:30 -0000
@@ -388,8 +388,7 @@ void __init paging_init(void)

void __init test_wp_bit(void)
{
- if (cpu_has_pse) {
- /* Ok, all PSE-capable CPUs are definitely handling the WP bit right. */
+ if (boot_cpu_data.x86_model >= 5) {
boot_cpu_data.wp_works_ok = 1;
return;
}


2003-11-04 09:34:35

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: [PATCH][2.6] Dont use cpu_has_pse for WP test branch

On Tue, 4 Nov 2003, Zwane Mwaikambo wrote:

> It appears that not all processors which support PSE have the PSE bit set,
> possibly we should be checking with PSE36 too. But instead i've opted to
> simply check for 586+
>
> Celeron (Mendocino): fpu vme de tsc msr pae mce cx8 apic sep mtrr pge mca
> cmov pat pse36 mmx fxsr
>
> Opteron 240: fpu vme de tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat
> pse36 clflush mmx fxsr sse sse2 syscall mmxext lm 3dnowext 3dnow

Please ignore this patch, turns out CONFIG_DEBUG_PAGEALLOC disables the
PSE bit in early_cpu_init.

2003-11-04 16:13:38

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH][2.6] Dont use cpu_has_pse for WP test branch


On Tue, 4 Nov 2003, Zwane Mwaikambo wrote:
>
> It appears that not all processors which support PSE have the PSE bit set,
> possibly we should be checking with PSE36 too. But instead i've opted to
> simply check for 586+

Why?

The reason we test the PSE bit is not that we think it's a good indicator
of "new enough". It's because if the PSE bit is set, we will use 4MB
pages, and the code below that actually _tests_ whether WP works or not
won't work.

So it doesn't _matter_ that

> Celeron (Mendocino): fpu vme de tsc msr pae mce cx8 apic sep mtrr pge mca
> cmov pat pse36 mmx fxsr
>
> Opteron 240: fpu vme de tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat
> pse36 clflush mmx fxsr sse sse2 syscall mmxext lm 3dnowext 3dnow

do not have PSE, they'll just end up testing dynamically if it works or
not.

In fact, these days we could remove the test entirely: the only reason it
exists is because traditionally we didn't have the "fixmap" helpers, so we
used the page in lowest kernel memory for testing (which did not exist if
we had PSE, since with PSE the kernel wouldn't use individual pages to map
itself).

Linus

2003-11-04 16:37:07

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: [PATCH][2.6] Dont use cpu_has_pse for WP test branch

On Tue, 4 Nov 2003, Linus Torvalds wrote:

> Why?
>
> The reason we test the PSE bit is not that we think it's a good indicator
> of "new enough". It's because if the PSE bit is set, we will use 4MB
> pages, and the code below that actually _tests_ whether WP works or not
> won't work.

Agreed, i also retracted the patch due to the reasons behind cpu_has_pse
not working was because of CONFIG_DEBUG_PAGEALLOC.

> In fact, these days we could remove the test entirely: the only reason it
> exists is because traditionally we didn't have the "fixmap" helpers, so we
> used the page in lowest kernel memory for testing (which did not exist if
> we had PSE, since with PSE the kernel wouldn't use individual pages to map
> itself).

Wasn't the test unconditional in 2.4? How about the following then?

Index: linux-2.6.0-test9-mm1/arch/i386/mm/init.c
===================================================================
RCS file: /build/cvsroot/linux-2.6.0-test9-mm1/arch/i386/mm/init.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 init.c
--- linux-2.6.0-test9-mm1/arch/i386/mm/init.c 30 Oct 2003 11:22:42 -0000 1.1.1.1
+++ linux-2.6.0-test9-mm1/arch/i386/mm/init.c 4 Nov 2003 16:34:45 -0000
@@ -390,12 +390,6 @@ void __init paging_init(void)

void __init test_wp_bit(void)
{
- if (cpu_has_pse) {
- /* Ok, all PSE-capable CPUs are definitely handling the WP bit right. */
- boot_cpu_data.wp_works_ok = 1;
- return;
- }
-
printk("Checking if this processor honours the WP bit even in supervisor mode... ");

/* Any page-aligned address will do, the test is non-destructive */