x86/setup for v2.6.31
Subsystems (3)
Linus,
Please pull the latest x86-setup-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-setup-for-linus
These are the BIOS-call sandboxing patches. This has the chance to fix a couple of long-lived Linux boot problems on various weird boxes that were too finetuned to the Windows BIOS call environment.
Thanks,
Ingo
------------------>
H. Peter Anvin (7):
x86, setup: "glove box" BIOS calls -- infrastructure x86, setup: "glove box" BIOS interrupts in the core boot code x86, setup: "glove box" BIOS interrupts in the APM code x86, setup: "glove box" BIOS interrupts in the EDD code x86, setup: "glove box" BIOS interrupts in the MCA code x86, setup: "glove box" BIOS interrupts in the video code x86, setup: fix comment in the "glove box" code
arch/x86/boot/Makefile | 5 +- arch/x86/boot/a20.c | 9 ++- arch/x86/boot/apm.c | 76 ++++++---------- arch/x86/boot/bioscall.S | 82 ++++++++++++++++++ arch/x86/boot/boot.h | 48 +++++++++++ arch/x86/boot/edd.c | 71 +++++++--------- arch/x86/boot/header.S | 2 +- arch/x86/boot/main.c | 39 +++++---- arch/x86/boot/mca.c | 27 +++--- arch/x86/boot/memory.c | 79 +++++++++--------- arch/x86/boot/regs.c | 29 ++++++ arch/x86/boot/setup.ld | 6 ++ arch/x86/boot/tty.c | 52 ++++++----- arch/x86/boot/video-bios.c | 27 +++--- arch/x86/boot/video-vesa.c | 137 +++++++++++++----------------- arch/x86/boot/video-vga.c | 95 +++++++++++++-------- arch/x86/boot/video.c | 42 ++++----- arch/x86/boot/video.h | 14 --- arch/x86/kernel/acpi/realmode/Makefile | 2 +- arch/x86/kernel/acpi/realmode/bioscall.S | 1 + arch/x86/kernel/acpi/realmode/regs.c | 1 + 21 files changed, 489 insertions(+), 355 deletions(-) create mode 100644 arch/x86/boot/bioscall.S create mode 100644 arch/x86/boot/regs.c create mode 100644 arch/x86/kernel/acpi/realmode/bioscall.S create mode 100644 arch/x86/kernel/acpi/realmode/regs.c
arch/x86/boot/Makefile +3 -2
@@ -26,9 +26,10 @@ targets := vmlinux.bin setup.bin setup.elf bzImage targets += fdimage fdimage144 fdimage288 image.iso mtools.conf subdir- := compressed -setup-y += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o +setup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpucheck.o edd.o setup-y += header.o main.o mca.o memory.o pm.o pmjump.o -setup-y += printf.o string.o tty.o video.o video-mode.o version.o +setup-y += printf.o regs.o string.o tty.o video.o video-mode.o +setup-y += version.o setup-$(CONFIG_X86_APM_BOOT) += apm.o # The link order of the video-*.o modules can matter. In particular,
arch/x86/boot/a20.c +6 -3
@@ -2,7 +2,7 @@* * Copyright (C) 1991, 1992 Linus Torvalds * Copyright 2007-2008 rPath, Inc. - All Rights Reserved -* Copyright 2009 Intel Corporation +* Copyright 2009 Intel Corporation; author H. Peter Anvin * * This file is part of the Linux kernel, and is made available under * the terms of the GNU General Public License version 2.
@@ -90,8 +90,11 @@ static int a20_test_long(void)static void enable_a20_bios (void ) { - asmvolatile ("pushfl; int $0x15; popfl" - : :"a" ((u16 )0x2401 )); +struct biosregs ireg; + +initregs (&ireg); + ireg.ax =0x2401 ; +intcall (0x15 , &ireg,NULL ); }static void enable_a20_kbc (void )
arch/x86/boot/apm.c +29 -47
110 lines not on this page · raw message
arch/x86/boot/bioscall.S new file +82 -0
82 lines not on this page · raw message
arch/x86/boot/boot.h +48 -0
72 lines not on this page · raw message
arch/x86/boot/edd.c +31 -40
110 lines not on this page · raw message
arch/x86/boot/header.S +1 -1
@@ -221,7 +221,7 @@ setup_data: .quad 0 # 64-bit physical pointer to # End of setup header ##################################################### - .section ".inittext", "ax" + .section ".entrytext", "ax" start_of_setup: #ifdef SAFE_RESET_DISK_CONTROLLER # Reset the disk controller.
arch/x86/boot/main.c +21 -18
@@ -2,6 +2,7 @@* * Copyright (C) 1991, 1992 Linus Torvalds * Copyright 2007 rPath, Inc. - All Rights Reserved +* Copyright 2009 Intel Corporation; author H. Peter Anvin * * This file is part of the Linux kernel, and is made available under * the terms of the GNU General Public License version 2.
@@ -61,11 +62,10 @@ static void copy_boot_params(void)*/ static void keyboard_set_repeat (void ) { -u16 ax =0x0305 ; -u16 bx =0 ; - asmvolatile ("int $0x16" - :"+a" (ax),"+b" (bx) - : :"ecx" ,"edx" ,"esi" ,"edi" ); +struct biosregs ireg; +initregs (&ireg); + ireg.ax =0x0305 ; +intcall (0x16 , &ireg,NULL ); }/*
@@ -73,18 +73,22 @@ static void keyboard_set_repeat(void)*/ static void query_ist (void ) { +struct biosregs ireg, oreg; +/* Some older BIOSes apparently crash on this call, so filter it from machines too old to have SpeedStep at all. */ if (cpu.level <6 )return ; - asm("int $0x15" - :"=a" (boot_params.ist_info.signature), -"=b" (boot_params.ist_info.command), -"=c" (boot_params.ist_info.event), -"=d" (boot_params.ist_info.perf_level) - :"a" (0x0000e980 ),/* IST Support */ -"d" (0x47534943 ));/* Request value */ +initregs (&ireg); + ireg.ax =0xe980 ;/* IST Support */ + ireg.edx =0x47534943 ;/* Request value */ +intcall (0x15 , &ireg, &oreg); + + boot_params.ist_info.signature = oreg.eax; + boot_params.ist_info.command = oreg.ebx; + boot_params.ist_info.event = oreg.ecx; + boot_params.ist_info.perf_level = oreg.edx; }/*
@@ -93,13 +97,12 @@ static void query_ist(void)static void set_bios_mode (void ) {#ifdef CONFIG_X86_64 -u32 eax, ebx; +struct biosregs ireg; - eax =0xec00 ; - ebx =2 ; - asmvolatile ("int $0x15" - :"+a" (eax),"+b" (ebx) - : :"ecx" ,"edx" ,"esi" ,"edi" ); +initregs (&ireg); + ireg.ax =0xec00 ; + ireg.bx =2 ; +intcall (0x15 , &ireg,NULL );#endif }
arch/x86/boot/mca.c +12 -15
@@ -2,6 +2,7 @@* * Copyright (C) 1991, 1992 Linus Torvalds * Copyright 2007 rPath, Inc. - All Rights Reserved +* Copyright 2009 Intel Corporation; author H. Peter Anvin * * This file is part of the Linux kernel, and is made available under * the terms of the GNU General Public License version 2.
@@ -16,26 +17,22 @@int query_mca (void ) { -u8 err; -u16 es, bx, len; - - asm("pushw %%es ; " -"int $0x15 ; " -"setc %0 ; " -"movw %%es, %1 ; " -"popw %%es" - :"=acd" (err),"=acdSD" (es),"=b" (bx) - :"a" (0xc000 )); - -if (err) +struct biosregs ireg, oreg; +u16 len; + +initregs (&ireg); + ireg.ah =0xc0 ; +intcall (0x15 , &ireg, &oreg); + +if (oreg.eflags &X86_EFLAGS_CF )return -1 ;/* No MCA present */ -set_fs (es); - len =rdfs16 (bx); +set_fs (oreg.es); + len =rdfs16 (oreg.bx);if (len >sizeof (boot_params.sys_desc_table)) len =sizeof (boot_params.sys_desc_table); -copy_from_fs (&boot_params.sys_desc_table, bx, len); +copy_from_fs (&boot_params.sys_desc_table, oreg.bx, len);return 0 ; }
arch/x86/boot/memory.c +39 -40
133 lines not on this page · raw message
arch/x86/boot/regs.c new file +29 -0
@@ -0,0 +1,29 @@ +/* ----------------------------------------------------------------------- +* +* Copyright 2009 Intel Corporation; author H. Peter Anvin +* +* This file is part of the Linux kernel, and is made available under +* the terms of the GNU General Public License version 2 or (at your +* option) any later version; incorporated herein by reference. +* +* ----------------------------------------------------------------------- */ + +/* +* Simple helper function for initializing a register set. +* +* Note that this sets EFLAGS_CF in the input register set; this +* makes it easier to catch functions which do nothing but don't +* explicitly set CF. +*/ + +#include "boot.h" + +void initregs (struct biosregs *reg) +{ +memset (reg,0 ,sizeof *reg); + reg->eflags |=X86_EFLAGS_CF ; + reg->ds =ds (); + reg->es =ds (); + reg->fs =fs (); + reg->gs =gs (); +}
arch/x86/boot/setup.ld +6 -0
@@ -15,8 +15,11 @@ SECTIONS . = 497; .header : { *(.header) } + .entrytext : { *(.entrytext) } .inittext : { *(.inittext) } .initdata : { *(.initdata) } + __end_init = .; + .text : { *(.text) } .text32 : { *(.text32) }
@@ -52,4 +55,7 @@ SECTIONS . = ASSERT(_end <= 0x8000, "Setup too big!"); . = ASSERT(hdr == 0x1f1, "The setup header has the wrong offset!"); + /* Necessary for the very-old-loader check to work... */ + . = ASSERT(__end_init <= 5*512, "init sections too big!"); + }
arch/x86/boot/tty.c +28 -24
91 lines not on this page · raw message
arch/x86/boot/video-bios.c +13 -14
@@ -2,6 +2,7 @@* * Copyright (C) 1991, 1992 Linus Torvalds * Copyright 2007 rPath, Inc. - All Rights Reserved +* Copyright 2009 Intel Corporation; author H. Peter Anvin * * This file is part of the Linux kernel, and is made available under * the terms of the GNU General Public License version 2.
@@ -29,21 +30,21 @@ static int bios_set_mode(struct mode_info *mi)static int set_bios_mode (u8 mode) { -u16 ax; +struct biosregs ireg, oreg;u8 new_mode; - ax = mode;/* AH=0x00 Set Video Mode */ - asm volatile(INT10 - : "+a" (ax) - : : "ebx", "ecx", "edx", "esi", "edi"); +initregs (&ireg); + ireg.al = mode;/* AH=0x00 Set Video Mode */ +intcall (0x10 , &ireg,NULL ); - ax =0x0f00 ;/* Get Current Video Mode */ - asm volatile(INT10 - : "+a" (ax) - : : "ebx", "ecx", "edx", "esi", "edi"); + + ireg.ah =0x0f ;/* Get Current Video Mode */ +intcall (0x10 , &ireg, &oreg); do_restore =1 ;/* Assume video contents were lost */ - new_mode = ax &0x7f ;/* Not all BIOSes are clean with the top bit */ + +/* Not all BIOSes are clean with the top bit */ + new_mode = ireg.al &0x7f ;if (new_mode == mode)return 0 ;/* Mode change OK */
@@ -53,10 +54,8 @@ static int set_bios_mode(u8 mode)/* Mode setting failed, but we didn't end up where we started. That's bad. Try to revert to the original video mode. */ - ax = boot_params.screen_info.orig_video_mode; - asm volatile(INT10 - : "+a" (ax) - : : "ebx", "ecx", "edx", "esi", "edi"); + ireg.ax = boot_params.screen_info.orig_video_mode; + intcall(0x10, &ireg, NULL); }#endif return -1 ;
arch/x86/boot/video-vesa.c +60 -77
224 lines not on this page · raw message
arch/x86/boot/video-vga.c +59 -36
182 lines not on this page · raw message
arch/x86/boot/video.c +19 -23
77 lines not on this page · raw message
arch/x86/boot/video.h +0 -14
@@ -112,20 +112,6 @@ extern int force_x, force_y; /* Don't query the BIOS for cols/rows */extern int do_restore;/* Restore screen contents */ extern int graphic_mode;/* Graphics mode with linear frame buffer */ -/* -* int $0x10 is notorious for touching registers it shouldn't. -* gcc doesn't like %ebp being clobbered, so define it as a push/pop -* sequence here. -* -* A number of systems, including the original PC can clobber %bp in -* certain circumstances, like when scrolling. There exists at least -* one Trident video card which could clobber DS under a set of -* circumstances that we are unlikely to encounter (scrolling when -* using an extended graphics mode of more than 800x600 pixels), but -* it's cheap insurance to deal with that here. -*/ -#define INT10 "pushl %%ebp; pushw %%ds; int $0x10; popw %%ds; popl %%ebp" -/* Accessing VGA indexed registers */ static inline u8 in_idx (u16 port,u8 index) {
arch/x86/kernel/acpi/realmode/Makefile +1 -1
@@ -9,7 +9,7 @@ always := wakeup.bin targets := wakeup.elf wakeup.lds -wakeup-y += wakeup.o wakemain.o video-mode.o copy.o +wakeup-y += wakeup.o wakemain.o video-mode.o copy.o bioscall.o regs.o # The link order of the video-*.o modules can matter. In particular, # video-vga.o *must* be listed first, followed by video-vesa.o.
arch/x86/kernel/acpi/realmode/bioscall.S new file +1 -0
@@ -0,0 +1 @@ +#include "../../../boot/bioscall.S"
arch/x86/kernel/acpi/realmode/regs.c new file +1 -0
@@ -0,0 +1 @@ +#include "../../../boot/regs.c"