Skip to contentSkip to conversation

fix brown paperbag bug in pentium-m-support.patch

PATCH New Adrian Bunk 1 participant 4 messages Jan 25, 2004

lore
Share & tools
lore
#0 lore raw

cover fix brown paperbag bug in pentium-m-support.patch

Hi Andrew,

there's a brown paperbag bug in pentium-m-support.patch.

The first patch fixes this issue, thw other two patches are rediffs of amd-elan-is-a-different-subarch and better-i386-cpu-selection.

Please revert the patches in the following direction:

i386-default-to-n.patch
cpu-options-default-to-y.patch
better-i386-cpu-selection.patch
add-config-for-mregparm-3-ng-fixes.patch
add-config-for-mregparm-3-ng.patch
amd-elan-is-a-different-subarch.patch
pentium-m-support.patch

Then apply in the following direction:

[1/3] Pentium M: fix brown paperbag bug [2/3] AMD Elan patch: rediffed add-config-for-mregparm-3-ng.patch add-config-for-mregparm-3-ng-fixes.patch [3/3] CPU patch rediffed, includes the contents of:
- better-i386-cpu-selection.patch
- cpu-options-default-to-y.patch
- i386-default-to-n.patch

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#1 lore raw

PATCH 1/3 Pentium M: fix brown paperbag bug

I said in the description that MPENTIUMM gets a bigger X86_L1_CACHE_SHIFT, but I only gave it X86_L1_CACHE_SHIFT=5 .

Where's a brown paperbag?

add Pentium M and Pentium-4 M options:

- add MPENTIUMM (equivalent to PENTIUMIII except for a bigger X86_L1_CACHE_SHIFT)

- document that MPENTIUM4 is the right choice for a Pentium-4 M

diffstat output:

 arch/i386/Kconfig         |   28 +++++++++++++++++-----------
 arch/i386/Makefile        |    1 +
 include/asm-i386/module.h |    2 ++
 3 files changed, 20 insertions(+), 11 deletions(-)
arch/i386/Makefile renamed from arch/i386/Makefile~pentium-m-support +1 -0
diff -puN arch/i386/Makefile~pentium-m-support arch/i386/Makefile
@@ -34,6 +34,7 @@ cflags-$(CONFIG_M586MMX)	+= $(call check
 cflags-$(CONFIG_M686)		+= -march=i686
 cflags-$(CONFIG_MPENTIUMII)	+= $(call check_gcc,-march=pentium2,-march=i686)
 cflags-$(CONFIG_MPENTIUMIII)	+= $(call check_gcc,-march=pentium3,-march=i686)
+cflags-$(CONFIG_MPENTIUMM)	+= $(call check_gcc,-march=pentium3,-march=i686)
 cflags-$(CONFIG_MPENTIUM4)	+= $(call check_gcc,-march=pentium4,-march=i686)
 cflags-$(CONFIG_MK6)		+= $(call check_gcc,-march=k6,-march=i586)
 # Please note, that patches that add -march=athlon-xp and friends are pointless.
include/asm-i386/module.h renamed from include/asm-i386/module.h~pentium-m-support +2 -0
diff -puN include/asm-i386/module.h~pentium-m-support include/asm-i386/module.h
@@ -26,6 +26,8 @@ struct mod_arch_specific
 #define MODULE_PROC_FAMILY "PENTIUMII "
 #elif defined CONFIG_MPENTIUMIII
 #define MODULE_PROC_FAMILY "PENTIUMIII "
+#elif defined CONFIG_MPENTIUMM
+#define MODULE_PROC_FAMILY "PENTIUMM "
 #elif defined CONFIG_MPENTIUM4
 #define MODULE_PROC_FAMILY "PENTIUM4 "
 #elif defined CONFIG_MK6
arch/i386/Kconfig renamed from arch/i386/Kconfig.old +17 -11
@@ -222,14 +222,20 @@
 	  extended prefetch instructions in addition to the Pentium II
 	  extensions.
 
+config MPENTIUMM
+	bool "Pentium M"
+	help
+	  Select this for Intel Pentium M (not Pentium-4 M)
+	  notebook chips.
+
 config MPENTIUM4
-	bool "Pentium-4/Celeron(P4-based)/Xeon"
+	bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/Xeon"
 	help
-	  Select this for Intel Pentium 4 chips.  This includes both
-	  the Pentium 4 and P4-based Celeron chips.  This option
-	  enables compile flags optimized for the chip, uses the
-	  correct cache shift, and applies any applicable Pentium III
-	  optimizations.
+	  Select this for Intel Pentium 4 chips.  This includes the
+	  Pentium 4, P4-based Celeron and Xeon, and Pentium-4 M
+	  (not Pentium M) chips.  This option enables compile flags
+	  optimized for the chip, uses the correct cache shift, and
+	  applies any applicable Pentium III optimizations.
 
 config MK6
 	bool "K6/K6-II/K6-III"
@@ -330,7 +336,7 @@
 	default "7" if MPENTIUM4 || X86_GENERIC
 	default "4" if MELAN || M486 || M386
 	default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2
-	default "6" if MK7 || MK8
+	default "6" if MK7 || MK8 || MPENTIUMM
 
 config RWSEM_GENERIC_SPINLOCK
 	bool
@@ -379,17 +385,17 @@
 
 config X86_GOOD_APIC
 	bool
-	depends on MK7 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8
+	depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8
 	default y
 
 config X86_INTEL_USERCOPY
 	bool
-	depends on MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7
+	depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7
 	default y
 
 config X86_USE_PPRO_CHECKSUM
 	bool
-	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2
+	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2
 	default y
 
 config X86_USE_3DNOW
@@ -571,7 +577,7 @@
 
 config X86_TSC
 	bool
-	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ
+	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ
 	default y
 
 config X86_MCE
#2 lore raw

PATCH 2/3 AMD Elan patch: rediffed

In reply to Adrian Bunk

From: Adrian Bunk <[email protected]>

- AMD Elan is a different subarch, you can't configure a kernel that runs on both the AMD Elan and other i386 CPUs

- added optimizing CFLAGS for the AMD Elan

diffstat output:

 arch/i386/Kconfig                    |   20 +++++++++++++++-----
 arch/i386/Makefile                   |    3 +++
 arch/i386/boot/setup.S               |    2 +-
 arch/i386/kernel/cpu/cpufreq/Kconfig |    2 +-
 include/asm-i386/module.h            |    2 +-
 include/asm-i386/timex.h             |    2 +-
 6 files changed, 22 insertions(+), 9 deletions(-)
arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S~amd-elan-is-a-different-subarch +1 -1
diff -puN arch/i386/boot/setup.S~amd-elan-is-a-different-subarch arch/i386/boot/setup.S
@@ -755,7 +755,7 @@ end_move_self:					# now we are at the r
 # AMD Elan bug fix by Robert Schwebel.
 #
 
-#if defined(CONFIG_MELAN)
+#if defined(CONFIG_X86_ELAN)
 	movb $0x02, %al			# alternate A20 gate
 	outb %al, $0x92			# this works on SC410/SC520
 a20_elan_wait:
arch/i386/kernel/cpu/cpufreq/Kconfig renamed from arch/i386/kernel/cpu/cpufreq/Kconfig~amd-elan-is-a-different-subarch +1 -1
diff -puN arch/i386/kernel/cpu/cpufreq/Kconfig~amd-elan-is-a-different-subarch arch/i386/kernel/cpu/cpufreq/Kconfig
@@ -54,7 +54,7 @@ config X86_ACPI_CPUFREQ_PROC_INTF
 
 config ELAN_CPUFREQ
 	tristate "AMD Elan"
-	depends on CPU_FREQ_TABLE && MELAN
+	depends on CPU_FREQ_TABLE && X86_ELAN
 	---help---
 	  This adds the CPUFreq driver for AMD Elan SC400 and SC410
 	  processors.
arch/i386/Makefile renamed from arch/i386/Makefile~amd-elan-is-a-different-subarch +3 -0
diff -puN arch/i386/Makefile~amd-elan-is-a-different-subarch arch/i386/Makefile
@@ -48,6 +48,9 @@ cflags-$(CONFIG_MWINCHIP3D)	+= $(call ch
 cflags-$(CONFIG_MCYRIXIII)	+= $(call check_gcc,-march=c3,-march=i486) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
 cflags-$(CONFIG_MVIAC3_2)	+= $(call check_gcc,-march=c3-2,-march=i686)
 
+# AMD Elan support
+cflags-$(CONFIG_X86_ELAN)	+= -march=i486
+
 CFLAGS += $(cflags-y)
 
 # Default subarch .c files
include/asm-i386/timex.h renamed from include/asm-i386/timex.h~amd-elan-is-a-different-subarch +1 -1
diff -puN include/asm-i386/timex.h~amd-elan-is-a-different-subarch include/asm-i386/timex.h
@@ -12,7 +12,7 @@
 #ifdef CONFIG_X86_PC9800
    extern int CLOCK_TICK_RATE;
 #else
-#ifdef CONFIG_MELAN
+#ifdef CONFIG_X86_ELAN
 #  define CLOCK_TICK_RATE 1189200 /* AMD Elan has different frequency! */
 #else
 #  define CLOCK_TICK_RATE 1193182 /* Underlying HZ */

_

arch/i386/Kconfig renamed from arch/i386/Kconfig.old +15 -5
@@ -43,6 +43,15 @@
 	help
 	  Choose this option if your computer is a standard PC or compatible.
 
+config X86_ELAN
+	bool "AMD Elan"
+	help
+	  Select this for an AMD Elan processor.
+
+	  Do not use this option for K6/Athlon/Opteron processors!
+
+	  If unsure, choose "PC-compatible" instead.
+
 config X86_VOYAGER
 	bool "Voyager (NCR)"
 	help
@@ -130,6 +139,8 @@
 	default y
 	depends on SMP && X86_ES7000 && MPENTIUMIII
 
+if !X86_ELAN
+
 choice
 	prompt "Processor family"
 	default M686
@@ -258,9 +269,6 @@
 	  use of some extended instructions, and passes appropriate optimization
 	  flags to GCC.
 
-config MELAN
-	bool "Elan"
-
 config MCRUSOE
 	bool "Crusoe"
 	help
@@ -318,6 +326,8 @@
 	  when it has moderate overhead. This is intended for generic 
 	  distributions kernels.
 
+endif
+
 #
 # Define implied options from the CPU selection here
 #
@@ -334,7 +344,7 @@
 config X86_L1_CACHE_SHIFT
 	int
 	default "7" if MPENTIUM4 || X86_GENERIC
-	default "4" if MELAN || M486 || M386
+	default "4" if X86_ELAN || M486 || M386
 	default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2
 	default "6" if MK7 || MK8 || MPENTIUMM
 
@@ -380,7 +390,7 @@
 
 config X86_ALIGNMENT_16
 	bool
-	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2
+	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2
 	default y
 
 config X86_GOOD_APIC
include/asm-i386/module.h renamed from include/asm-i386/module.h.old +1 -1
@@ -36,7 +36,7 @@
 #define MODULE_PROC_FAMILY "K7 "
 #elif defined CONFIG_MK8
 #define MODULE_PROC_FAMILY "K8 "
-#elif defined CONFIG_MELAN
+#elif defined CONFIG_X86_ELAN
 #define MODULE_PROC_FAMILY "ELAN "
 #elif defined CONFIG_MCRUSOE
 #define MODULE_PROC_FAMILY "CRUSOE "
#3 lore raw

PATCH 3/3 CPU patch rediffed

In reply to Adrian Bunk

This patch changes the way the CPUs are selected from the current "select a reasonable setting that supports all your CPUs, and for further optimizations for more than one CPU type you might also want to enable X86_GENERIC" to "select all CPUs your kernel should support" which is a better understandable semantics for users (= people configuring a kernel).

As a side effect, further optimizations are possible based on this patch, but they are _not_ included.

Changes:

- changed the i386 CPU selection from a choice to single options for every cpu
- X86_GENERIC is no longer required
- renamed the M* variables to CPU_*, this is needed to ask the users upgrading from older kernels instead of silently changing the semantics
- X86_GOOD_APIC -> X86_BAD_APIC
- help text changes/updates

TODO:
- module versioning

The main effect is that this patch makes it easier for people who configure kernels that should work on different CPU types. A user (= person compiling his own kernel) does no longer need any deeper knowledge when e.g. configuring a kernel that should run on both an Athlon and a Pentium 4 - he simply selects all CPUs he wants to support in his kernel.

As a side effect, this patch allows further optimizations based on the fact that e.g. a kernel for an i386 no longer needs to support an Athlon which can be used to omit support for non-selected CPUs. For exampler there is no need to include arch/i386/kernel/cpu/amd.c in your kernel if the kernel should only run on a 386; I made two such example patches that are _way_ too ugly for merging but show that this CPU selection scheme makes some more space savings possible

diffstat output:

 arch/i386/Kconfig                    |  269 ++++++++++++---------------
 arch/i386/Makefile                   |   57 +++--
 arch/i386/lib/mmx.c                  |    2 
 arch/i386/mach-voyager/voyager_smp.c |    6 
 arch/x86_64/Kconfig                  |    4 
 drivers/serial/8250.h                |    2 
 include/asm-i386/apic.h              |    4 
 include/asm-i386/bugs.h              |    7 
 include/asm-i386/module.h            |    2 
 include/asm-i386/processor.h         |    4 
 include/asm-x86_64/apic.h            |    2 
 11 files changed, 178 insertions(+), 181 deletions(-)
arch/i386/lib/mmx.c renamed from arch/i386/lib/mmx.c~better-i386-cpu-selection +1 -1
diff -puN arch/i386/lib/mmx.c~better-i386-cpu-selection arch/i386/lib/mmx.c
@@ -121,7 +121,7 @@ void *_mmx_memcpy(void *to, const void *
 	return p;
 }
 
-#ifdef CONFIG_MK7
+#ifdef CONFIG_CPU_ONLY_K7
 
 /*
  *	The K7 has streaming cache bypass load/store. The Cyrix III, K6 and
arch/i386/mach-voyager/voyager_smp.c renamed from arch/i386/mach-voyager/voyager_smp.c~better-i386-cpu-selection +3 -3
diff -puN arch/i386/mach-voyager/voyager_smp.c~better-i386-cpu-selection arch/i386/mach-voyager/voyager_smp.c
@@ -553,7 +553,7 @@ do_boot_cpu(__u8 cpu)
 
 	/* For the 486, we can't use the 4Mb page table trick, so
 	 * must map a region of memory */
-#ifdef CONFIG_M486
+#ifdef CONFIG_CPU_486
 	int i;
 	unsigned long *page_table_copies = (unsigned long *)
 		__get_free_page(GFP_KERNEL);
@@ -612,7 +612,7 @@ do_boot_cpu(__u8 cpu)
 	/* set the original swapper_pg_dir[0] to map 0 to 4Mb transparently
 	 * (so that the booting CPU can find start_32 */
 	orig_swapper_pg_dir0 = swapper_pg_dir[0];
-#ifdef CONFIG_M486
+#ifdef CONFIG_CPU_486
 	if(page_table_copies == NULL)
 		panic("No free memory for 486 page tables\n");
 	for(i = 0; i < PAGE_SIZE/sizeof(unsigned long); i++)
@@ -669,7 +669,7 @@ do_boot_cpu(__u8 cpu)
 	/* reset the page table */
 	swapper_pg_dir[0] = orig_swapper_pg_dir0;
 	local_flush_tlb();
-#ifdef CONFIG_M486
+#ifdef CONFIG_CPU_486
 	free_page((unsigned long)page_table_copies);
 #endif
 	  
arch/i386/Makefile renamed from arch/i386/Makefile~better-i386-cpu-selection +37 -20

67 lines not on this page · raw message

arch/x86_64/Kconfig renamed from arch/x86_64/Kconfig~better-i386-cpu-selection +0 -4
diff -puN arch/x86_64/Kconfig~better-i386-cpu-selection arch/x86_64/Kconfig
@@ -111,10 +111,6 @@ config X86_TSC
 	bool
 	default y
 
-config X86_GOOD_APIC
-	bool
-	default y
-
 config X86_MSR
 	tristate "/dev/cpu/*/msr - Model-specific register support"
 	help
drivers/serial/8250.h renamed from drivers/serial/8250.h~better-i386-cpu-selection +1 -1
diff -puN drivers/serial/8250.h~better-i386-cpu-selection drivers/serial/8250.h
@@ -44,7 +44,7 @@ struct old_serial_port {
 
 #undef SERIAL_DEBUG_PCI
 
-#if defined(__i386__) && (defined(CONFIG_M386) || defined(CONFIG_M486))
+#if defined(__i386__) && (defined(CONFIG_CPU_386) || defined(CONFIG_CPU_486))
 #define SERIAL_INLINE
 #endif
   
include/asm-i386/apic.h renamed from include/asm-i386/apic.h~better-i386-cpu-selection +2 -2
diff -puN include/asm-i386/apic.h~better-i386-cpu-selection include/asm-i386/apic.h
@@ -41,7 +41,7 @@ static __inline__ void apic_wait_icr_idl
 	do { } while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY );
 }
 
-#ifdef CONFIG_X86_GOOD_APIC
+#ifndef CONFIG_X86_BAD_APIC
 # define FORCE_READ_AROUND_WRITE 0
 # define apic_read_around(x)
 # define apic_write_around(x,y) apic_write((x),(y))
@@ -56,7 +56,7 @@ static inline void ack_APIC_irq(void)
 	/*
 	 * ack_APIC_irq() actually gets compiled as a single instruction:
 	 * - a single rmw on Pentium/82489DX
-	 * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
+	 * - a single write on P6+ cores (!CONFIG_X86_BAD_APIC)
 	 * ... yummie.
 	 */
 
include/asm-i386/bugs.h renamed from include/asm-i386/bugs.h~better-i386-cpu-selection +3 -4
diff -puN include/asm-i386/bugs.h~better-i386-cpu-selection include/asm-i386/bugs.h
@@ -165,9 +165,8 @@ static void __init check_popad(void)
  * - In order to run on anything without a TSC, we need to be
  *   compiled for a i486.
  * - In order to support the local APIC on a buggy Pentium machine,
- *   we need to be compiled with CONFIG_X86_GOOD_APIC disabled,
- *   which happens implicitly if compiled for a Pentium or lower
- *   (unless an advanced selection of CPU features is used) as an
+ *   we need to be compiled with CONFIG_X86_BAD_APIC enabled,
+ *   which happens implicitly if compiled for a Pentium as an
  *   otherwise config implies a properly working local APIC without
  *   the need to do extra reads from the APIC.
 */
@@ -198,7 +197,7 @@ static void __init check_config(void)
  * integrated APIC (see 11AP erratum in "Pentium Processor
  * Specification Update").
  */
-#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_GOOD_APIC)
+#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_BAD_APIC)
 	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL
 	    && cpu_has_apic
 	    && boot_cpu_data.x86 == 5

diff -puN include/asm-i386/module.h~better-i386-cpu-selection include/asm-i386/module.h

include/asm-i386/processor.h renamed from include/asm-i386/processor.h~better-i386-cpu-selection +2 -2
diff -puN include/asm-i386/processor.h~better-i386-cpu-selection include/asm-i386/processor.h
@@ -568,7 +568,7 @@ static inline void rep_nop(void)
 #define K7_NOP7        ".byte 0x8D,0x04,0x05,0,0,0,0\n"
 #define K7_NOP8        K7_NOP7 ASM_NOP1
 
-#ifdef CONFIG_MK8
+#ifdef CONFIG_CPU_ONLY_K8
 #define ASM_NOP1 K8_NOP1
 #define ASM_NOP2 K8_NOP2
 #define ASM_NOP3 K8_NOP3
@@ -577,7 +577,7 @@ static inline void rep_nop(void)
 #define ASM_NOP6 K8_NOP6
 #define ASM_NOP7 K8_NOP7
 #define ASM_NOP8 K8_NOP8
-#elif defined(CONFIG_MK7)
+#elif defined(CONFIG_CPU_ONLY_K7)
 #define ASM_NOP1 K7_NOP1
 #define ASM_NOP2 K7_NOP2
 #define ASM_NOP3 K7_NOP3
include/asm-x86_64/apic.h renamed from include/asm-x86_64/apic.h~better-i386-cpu-selection +1 -1
diff -puN include/asm-x86_64/apic.h~better-i386-cpu-selection include/asm-x86_64/apic.h
@@ -52,7 +52,7 @@ static inline void ack_APIC_irq(void)
 	/*
 	 * ack_APIC_irq() actually gets compiled as a single instruction:
 	 * - a single rmw on Pentium/82489DX
-	 * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
+	 * - a single write on P6+ cores (!CONFIG_X86_BAD_APIC)
 	 * ... yummie.
 	 */
 

_

include/asm-i386/module.h renamed from include/asm-i386/module.h~pentium-m-support +1 -1
@@ -49,7 +51,7 @@ struct mod_arch_specific
 #elif CONFIG_MVIAC3_2
 #define MODULE_PROC_FAMILY "VIAC3-2 "
 #else
-#error unknown processor family
+#define MODULE_PROC_FAMILY "this needs to be fixed"
 #endif
 
 #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
arch/i386/Kconfig renamed from arch/i386/Kconfig.old +127 -142

419 lines not on this page · raw message