All of lore.kernel.org
 help / color / mirror / Atom feed
* x86 setup code rewrite in C
@ 2007-07-10  2:51 H. Peter Anvin
  2007-07-10  2:51   ` H. Peter Anvin
                   ` (3 more replies)
  0 siblings, 4 replies; 72+ messages in thread
From: H. Peter Anvin @ 2007-07-10  2:51 UTC (permalink / raw)
  To: linux-kernel, linux-arch, andi, akpm

This patch set replaces the x86 setup code, which is currently all in
assembly, with a version written in C, using the ".code16gcc" feature
of binutils (which has been present since at least 2001.)

The new code is vastly easier to read, and, I hope, debug.  It should
be noted that I found a fair number of minor bugs while going through
this code, and have attempted to correct them.

In the process of doing so, it introduces several cleanups, in
particular:

- Obsoletes the hd_info field in the boot_params structure; they are
  only ever used for ST-506 (pre-IDE) drives and are pretty much
  guaranteed to be wrong on current BIOSes;
- Unifies the CPU feature bits between i386 and x86-64.  In the
  future, it should be possible to use arch/i386/boot/cpucheck.c to do
  the post-invocation CPU check currently done in
  arch/x86_64/kernel/trampoline.S, although this patch set doesn't
  introduce that change.
- boot_params is now a proper structure.

This code has been tested in -mm since early in the 2.6.22 cycle.

 arch/i386/boot/bootsect.S                     |   98 -
 arch/i386/boot/edd.S                          |  231 --
 arch/i386/boot/setup.S                        | 1075 -------------
 arch/i386/boot/video.S                        | 2043 --------------------------
 arch/i386/kernel/verify_cpu.S                 |   94 -
 arch/x86_64/boot/bootsect.S                   |   98 -
 arch/x86_64/boot/install.sh                   |    2
 arch/x86_64/boot/mtools.conf.in               |   17
 arch/x86_64/boot/setup.S                      |  826 ----------
 arch/x86_64/boot/tools/build.c                |  185 --
 b/Documentation/i386/zero-page.txt            |    1
 b/MAINTAINERS                                 |    4
 b/arch/i386/Kconfig.cpu                       |    6
 b/arch/i386/boot/Makefile                     |   46
 b/arch/i386/boot/a20.c                        |  161 ++
 b/arch/i386/boot/apm.c                        |   97 +
 b/arch/i386/boot/bitops.h                     |   45
 b/arch/i386/boot/boot.h                       |  290 +++
 b/arch/i386/boot/cmdline.c                    |   97 +
 b/arch/i386/boot/code16gcc.h                  |    9
 b/arch/i386/boot/compressed/Makefile          |    7
 b/arch/i386/boot/compressed/head.S            |    6
 b/arch/i386/boot/copy.S                       |  101 +
 b/arch/i386/boot/cpu.c                        |   69
 b/arch/i386/boot/cpucheck.c                   |  267 +++
 b/arch/i386/boot/edd.c                        |  196 ++
 b/arch/i386/boot/header.S                     |  283 +++
 b/arch/i386/boot/main.c                       |  161 ++
 b/arch/i386/boot/mca.c                        |   43
 b/arch/i386/boot/memory.c                     |   99 +
 b/arch/i386/boot/pm.c                         |  170 ++
 b/arch/i386/boot/pmjump.S                     |   54
 b/arch/i386/boot/printf.c                     |  331 ++++
 b/arch/i386/boot/setup.ld                     |   54
 b/arch/i386/boot/string.c                     |   34
 b/arch/i386/boot/tools/build.c                |  160 --
 b/arch/i386/boot/tty.c                        |  112 +
 b/arch/i386/boot/version.c                    |   23
 b/arch/i386/boot/vesa.h                       |   79 +
 b/arch/i386/boot/video-bios.c                 |  125 +
 b/arch/i386/boot/video-vesa.c                 |  284 +++
 b/arch/i386/boot/video-vga.c                  |  260 +++
 b/arch/i386/boot/video.c                      |  456 +++++
 b/arch/i386/boot/video.h                      |  145 +
 b/arch/i386/boot/voyager.c                    |   46
 b/arch/i386/kernel/cpu/Makefile               |    2
 b/arch/i386/kernel/cpu/addon_cpuid_features.c |   50
 b/arch/i386/kernel/cpu/common.c               |    2
 b/arch/i386/kernel/cpu/proc.c                 |   21
 b/arch/i386/kernel/e820.c                     |    2
 b/arch/i386/kernel/setup.c                    |   12
 b/arch/x86_64/Kconfig                         |    4
 b/arch/x86_64/boot/Makefile                   |  136 -
 b/arch/x86_64/boot/compressed/Makefile        |    9
 b/arch/x86_64/boot/compressed/head.S          |    6
 b/arch/x86_64/kernel/Makefile                 |    2
 b/arch/x86_64/kernel/setup.c                  |   21
 b/arch/x86_64/kernel/verify_cpu.S             |   22
 b/drivers/ide/legacy/hd.c                     |   73
 b/include/asm-i386/boot.h                     |    6
 b/include/asm-i386/bootparam.h                |   85 +
 b/include/asm-i386/cpufeature.h               |   26
 b/include/asm-i386/e820.h                     |   14
 b/include/asm-i386/processor.h                |    1
 b/include/asm-i386/required-features.h        |   39
 b/include/asm-i386/setup.h                    |   10
 b/include/asm-x86_64/alternative.h            |   68
 b/include/asm-x86_64/boot.h                   |   16
 b/include/asm-x86_64/bootparam.h              |    1
 b/include/asm-x86_64/cpufeature.h             |  115 -
 b/include/asm-x86_64/e820.h                   |    6
 b/include/asm-x86_64/processor.h              |    3
 b/include/asm-x86_64/required-features.h      |   46
 b/include/asm-x86_64/segment.h                |    8
 b/include/linux/edd.h                         |    4
 b/include/linux/screen_info.h                 |    9
 76 files changed, 4601 insertions(+), 5208 deletions(-)

^ permalink raw reply	[flat|nested] 72+ messages in thread
* x86 setup code rewrite in C - revised
@ 2007-07-11 19:18 H. Peter Anvin
  2007-07-11 19:18                                                             ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
  0 siblings, 1 reply; 72+ messages in thread
From: H. Peter Anvin @ 2007-07-11 19:18 UTC (permalink / raw)
  To: torvalds, andi, linux-kernel

This patch set replaces the x86 setup code, which is currently all in
assembly, with a version written in C, using the ".code16gcc" feature
of binutils (which has been present since at least 2001.)

The new code is vastly easier to read, and, I hope, debug.  It should
be noted that I found a fair number of minor bugs while going through
this code, and have attempted to correct them.

In the process of doing so, it introduces several cleanups, in
particular:

- Obsoletes the hd_info field in the boot_params structure; they are
  only ever used for ST-506 (pre-IDE) drives and are pretty much
  guaranteed to be wrong on current BIOSes;
- Unifies the CPU feature bits between i386 and x86-64.  In the
  future, it should be possible to use arch/i386/boot/cpucheck.c to do
  the post-invocation CPU check currently done in
  arch/x86_64/kernel/trampoline.S, although this patch set doesn't
  introduce that change.
- boot_params is now a proper structure.

This patchset incorporates all feedback received by 2007-07-11 12:00 PDT.

 arch/i386/boot/bootsect.S                     |   98 -
 arch/i386/boot/edd.S                          |  231 --
 arch/i386/boot/setup.S                        | 1075 -------------
 arch/i386/boot/video.S                        | 2043 --------------------------
 arch/i386/kernel/verify_cpu.S                 |   94 -
 arch/x86_64/boot/bootsect.S                   |   98 -
 arch/x86_64/boot/install.sh                   |    2 
 arch/x86_64/boot/mtools.conf.in               |   17 
 arch/x86_64/boot/setup.S                      |  826 ----------
 arch/x86_64/boot/tools/build.c                |  185 --
 b/Documentation/i386/zero-page.txt            |    1 
 b/MAINTAINERS                                 |    4 
 b/arch/i386/Kconfig.cpu                       |    6 
 b/arch/i386/boot/Makefile                     |   48 
 b/arch/i386/boot/a20.c                        |  161 ++
 b/arch/i386/boot/apm.c                        |   97 +
 b/arch/i386/boot/bitops.h                     |   45 
 b/arch/i386/boot/boot.h                       |  296 +++
 b/arch/i386/boot/cmdline.c                    |   97 +
 b/arch/i386/boot/code16gcc.h                  |   15 
 b/arch/i386/boot/compressed/Makefile          |    7 
 b/arch/i386/boot/compressed/head.S            |    6 
 b/arch/i386/boot/copy.S                       |  101 +
 b/arch/i386/boot/cpu.c                        |   69 
 b/arch/i386/boot/cpucheck.c                   |  267 +++
 b/arch/i386/boot/edd.c                        |  196 ++
 b/arch/i386/boot/header.S                     |  283 +++
 b/arch/i386/boot/main.c                       |  161 ++
 b/arch/i386/boot/mca.c                        |   43 
 b/arch/i386/boot/memory.c                     |   99 +
 b/arch/i386/boot/pm.c                         |  170 ++
 b/arch/i386/boot/pmjump.S                     |   54 
 b/arch/i386/boot/printf.c                     |  307 +++
 b/arch/i386/boot/setup.ld                     |   54 
 b/arch/i386/boot/string.c                     |   52 
 b/arch/i386/boot/tools/build.c                |  160 --
 b/arch/i386/boot/tty.c                        |  112 +
 b/arch/i386/boot/version.c                    |   23 
 b/arch/i386/boot/vesa.h                       |   79 +
 b/arch/i386/boot/video-bios.c                 |  125 +
 b/arch/i386/boot/video-vesa.c                 |  284 +++
 b/arch/i386/boot/video-vga.c                  |  260 +++
 b/arch/i386/boot/video.c                      |  456 +++++
 b/arch/i386/boot/video.h                      |  145 +
 b/arch/i386/boot/voyager.c                    |   46 
 b/arch/i386/kernel/cpu/Makefile               |    2 
 b/arch/i386/kernel/cpu/addon_cpuid_features.c |   50 
 b/arch/i386/kernel/cpu/common.c               |    2 
 b/arch/i386/kernel/cpu/proc.c                 |   21 
 b/arch/i386/kernel/e820.c                     |    2 
 b/arch/i386/kernel/setup.c                    |   12 
 b/arch/x86_64/Kconfig                         |    4 
 b/arch/x86_64/boot/Makefile                   |  136 -
 b/arch/x86_64/boot/compressed/Makefile        |    9 
 b/arch/x86_64/boot/compressed/head.S          |    6 
 b/arch/x86_64/kernel/Makefile                 |    2 
 b/arch/x86_64/kernel/setup.c                  |   21 
 b/arch/x86_64/kernel/verify_cpu.S             |   22 
 b/drivers/ide/legacy/hd.c                     |   73 
 b/include/asm-i386/boot.h                     |    6 
 b/include/asm-i386/bootparam.h                |   85 +
 b/include/asm-i386/cpufeature.h               |   26 
 b/include/asm-i386/e820.h                     |   14 
 b/include/asm-i386/processor.h                |    1 
 b/include/asm-i386/required-features.h        |   39 
 b/include/asm-i386/setup.h                    |   10 
 b/include/asm-x86_64/alternative.h            |   68 
 b/include/asm-x86_64/boot.h                   |   16 
 b/include/asm-x86_64/bootparam.h              |    1 
 b/include/asm-x86_64/cpufeature.h             |  115 -
 b/include/asm-x86_64/e820.h                   |    4 
 b/include/asm-x86_64/processor.h              |    3 
 b/include/asm-x86_64/required-features.h      |   46 
 b/include/asm-x86_64/segment.h                |    8 
 b/include/linux/edd.h                         |    4 
 b/include/linux/screen_info.h                 |    9 
 76 files changed, 4606 insertions(+), 5209 deletions(-)

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

end of thread, other threads:[~2007-07-13  9:27 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10  2:51 x86 setup code rewrite in C H. Peter Anvin
2007-07-10  2:51 ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
2007-07-10  2:51   ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 02/33] hd.c: remove BIOS/CMOS queries H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 03/33] include/asm-i386/boot.h: This is <asm/boot.h>, not <linux/boot.h> H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 04/33] Unify the CPU features vectors between i386 and x86-64 H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 05/33] Change CONFIG_X86_MINIMUM_CPU_MODEL to CONFIG_X86_MINIMUM_CPU_FAMILY H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 06/33] Clean up struct screen_info (<linux/screen_info.h>) H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 07/33] Use a new CPU feature word to cover all Intel features that are spread around H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 08/33] Define zero-page offset 0x1e4 as a scratch field, and use it H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 09/33] Make definitions for struct e820entry and struct e820map consistent H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10 11:48     ` Andi Kleen
2007-07-10  2:51   ` [x86 setup 10/33] Make struct boot_params a real structure, and remove obsolete fields H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 11/33] x86-64: add CONFIG_PHYSICAL_ALIGN for consistency with i386 H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 12/33] x86-64: add symbolic constants for the boot segment selectors H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 13/33] Header file to produce 16-bit code with gcc H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10 14:16       ` Segher Boessenkool
2007-07-10 15:21         ` Andi Kleen
2007-07-10 15:48           ` H. Peter Anvin
2007-07-10 15:53             ` H. Peter Anvin
2007-07-10 20:08             ` Segher Boessenkool
2007-07-10 20:43               ` H. Peter Anvin
2007-07-10 21:08                 ` Pawel Dziepak
2007-07-10 21:20                   ` H. Peter Anvin
2007-07-11  0:26                   ` Brian Gerst
2007-07-10 19:57           ` Segher Boessenkool
2007-07-10 20:42             ` H. Peter Anvin
2007-07-10 21:10               ` Segher Boessenkool
2007-07-10 21:40                 ` H. Peter Anvin
2007-07-10 22:06                   ` Segher Boessenkool
2007-07-10 21:43               ` Adrian Bunk
2007-07-10 21:46                 ` H. Peter Anvin
2007-07-11  0:30                 ` Brian Gerst
2007-07-10  2:51   ` [x86 setup 14/33] Top header file for new x86 setup code H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 15/33] Simple bitops for the " H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 16/33] String-handling functions " H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10 18:25       ` Jan Engelhardt
2007-07-10 18:35         ` H. Peter Anvin
2007-07-10 20:10           ` Segher Boessenkool
2007-07-10 20:44             ` H. Peter Anvin
2007-07-10 21:14               ` Segher Boessenkool
2007-07-11 12:46                 ` Andi Kleen
2007-07-10  2:51   ` [x86 setup 17/33] A20 handling code H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10 18:27       ` Jan Engelhardt
2007-07-10 18:33         ` H. Peter Anvin
2007-07-10 18:36         ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 18/33] APM probing code H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 19/33] Command-line parsing code for the new x86 setup code H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10  2:51   ` [x86 setup 20/33] Console-writing " H. Peter Anvin
2007-07-10  2:51     ` H. Peter Anvin
2007-07-10 18:35       ` Jan Engelhardt
2007-07-10 18:48         ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 21/33] Version string " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 22/33] CPU features verification " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  7:37       ` Sébastien Dugué
2007-07-10  7:37         ` Sébastien Dugué
2007-07-10  2:52   ` [x86 setup 23/33] EDD probing code " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 24/33] MCA support for " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 25/33] Memory probing support for the " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 26/33] Voyager " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 27/33] Video mode probing " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 28/33] Code for actual protected-mode entry H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 29/33] Assembly header and main routine for new x86 setup code H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 30/33] Linker script for the " H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 31/33] Use the new x86 setup code for i386 H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  7:55       ` Tilman Schmidt
2007-07-10  2:52   ` [x86 setup 32/33] Use the new x86 setup code for x86-64; unify with i386 H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  2:52   ` [x86 setup 33/33] Remove old i386 setup code H. Peter Anvin
2007-07-10  2:52     ` H. Peter Anvin
2007-07-10  4:24 ` x86 setup code rewrite in C Yinghai Lu
2007-07-10  4:39   ` H. Peter Anvin
2007-07-10  5:25 ` Jeff Garzik
2007-07-10 16:24 ` Jeremy Fitzhardinge
  -- strict thread matches above, loose matches on Subject: below --
2007-07-11 19:18 x86 setup code rewrite in C - revised H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
2007-07-11 19:18   ` [x86 setup 02/33] hd.c: remove BIOS/CMOS queries H. Peter Anvin
2007-07-11 19:18     ` [x86 setup 03/33] include/asm-i386/boot.h: This is <asm/boot.h>, not <linux/boot.h> H. Peter Anvin
2007-07-11 19:18       ` [x86 setup 04/33] Unify the CPU features vectors between i386 and x86-64 H. Peter Anvin
2007-07-11 19:18         ` [x86 setup 05/33] Change CONFIG_X86_MINIMUM_CPU_MODEL to CONFIG_X86_MINIMUM_CPU_FAMILY H. Peter Anvin
2007-07-11 19:18           ` [x86 setup 06/33] Clean up struct screen_info (<linux/screen_info.h>) H. Peter Anvin
2007-07-11 19:18             ` [x86 setup 07/33] Use a new CPU feature word to cover all Intel features that are spread around H. Peter Anvin
2007-07-11 19:18               ` [x86 setup 08/33] Define zero-page offset 0x1e4 as a scratch field, and use it H. Peter Anvin
2007-07-11 19:18                 ` [x86 setup 09/33] Make definitions for struct e820entry and struct e820map consistent H. Peter Anvin
2007-07-11 19:18                   ` [x86 setup 10/33] Make struct boot_params a real structure, and remove obsolete fields H. Peter Anvin
2007-07-11 19:18                     ` [x86 setup 11/33] x86-64: add CONFIG_PHYSICAL_ALIGN for consistency with i386 H. Peter Anvin
2007-07-11 19:18                       ` [x86 setup 12/33] x86-64: add symbolic constants for the boot segment selectors H. Peter Anvin
2007-07-11 19:18                         ` [x86 setup 13/33] Header file to produce 16-bit code with gcc H. Peter Anvin
2007-07-11 19:18                           ` [x86 setup 14/33] Top header file for new x86 setup code H. Peter Anvin
2007-07-11 19:18                             ` [x86 setup 15/33] Simple bitops for the " H. Peter Anvin
2007-07-11 19:18                               ` [x86 setup 16/33] String-handling functions " H. Peter Anvin
2007-07-11 19:18                                 ` [x86 setup 17/33] A20 handling code H. Peter Anvin
2007-07-11 19:18                                   ` [x86 setup 18/33] APM probing code H. Peter Anvin
2007-07-11 19:18                                     ` [x86 setup 19/33] Command-line parsing code for the new x86 setup code H. Peter Anvin
2007-07-11 19:18                                       ` [x86 setup 20/33] Console-writing " H. Peter Anvin
2007-07-11 19:18                                         ` [x86 setup 21/33] Version string " H. Peter Anvin
2007-07-11 19:18                                           ` [x86 setup 22/33] CPU features verification " H. Peter Anvin
2007-07-11 19:18                                             ` [x86 setup 23/33] EDD probing code " H. Peter Anvin
2007-07-11 19:18                                               ` [x86 setup 24/33] MCA support for " H. Peter Anvin
2007-07-11 19:18                                                 ` [x86 setup 25/33] Memory probing support for the " H. Peter Anvin
2007-07-11 19:18                                                   ` [x86 setup 26/33] Voyager " H. Peter Anvin
2007-07-11 19:18                                                     ` [x86 setup 27/33] Video mode probing " H. Peter Anvin
2007-07-11 19:18                                                       ` [x86 setup 28/33] Code for actual protected-mode entry H. Peter Anvin
2007-07-11 19:18                                                         ` [x86 setup 29/33] Assembly header and main routine for new x86 setup code H. Peter Anvin
2007-07-11 19:18                                                           ` [x86 setup 30/33] Linker script for the " H. Peter Anvin
2007-07-11 19:18                                                             ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
2007-07-11 19:18                                                               ` [x86 setup 31/33] Use the new x86 setup code for i386 H. Peter Anvin
2007-07-11 19:18                                                                 ` H. Peter Anvin
2007-07-13  9:27                                                                   ` Tilman Schmidt

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.