[PATCH] Make vm86 support optional

This adds an option to remove vm86 support under CONFIG_EMBEDDED. Saves
about 5k.

This version eliminates most of the #ifdefs of the previous version and
instead uses function stubs in vm86.h. Also, release_vm86_irqs is moved
from asm-i386/irq.h to a more appropriate home in vm86.h so that the stubs
can live together.

$ size vmlinux-baseline vmlinux-novm86
text data bss dec hex filename
2920821 523232 190652 3634705 377611 vmlinux-baseline
2916268 523100 190492 3629860 376324 vmlinux-novm86

Signed-off-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Matt Mackall and committed by
Linus Torvalds
64ca9004 708e9a79

+37 -3
+2 -1
arch/i386/kernel/Makefile
··· 4 5 extra-y := head.o init_task.o vmlinux.lds 6 7 - obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \ 8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ 9 pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ 10 quirks.o i8237.o ··· 34 obj-$(CONFIG_HPET_TIMER) += time_hpet.o 35 obj-$(CONFIG_EFI) += efi.o efi_stub.o 36 obj-$(CONFIG_DOUBLEFAULT) += doublefault.o 37 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 38 39 EXTRA_AFLAGS := -traditional
··· 4 5 extra-y := head.o init_task.o vmlinux.lds 6 7 + obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ 8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ 9 pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ 10 quirks.o i8237.o ··· 34 obj-$(CONFIG_HPET_TIMER) += time_hpet.o 35 obj-$(CONFIG_EFI) += efi.o efi_stub.o 36 obj-$(CONFIG_DOUBLEFAULT) += doublefault.o 37 + obj-$(CONFIG_VM86) += vm86.o 38 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 39 40 EXTRA_AFLAGS := -traditional
+2
arch/i386/kernel/entry.S
··· 323 324 ALIGN 325 work_notifysig_v86: 326 pushl %ecx # save ti_flags for do_notify_resume 327 call save_v86_state # %eax contains pt_regs pointer 328 popl %ecx ··· 331 xorl %edx, %edx 332 call do_notify_resume 333 jmp resume_userspace 334 335 # perform syscall exit tracing 336 ALIGN
··· 323 324 ALIGN 325 work_notifysig_v86: 326 + #ifdef CONFIG_VM86 327 pushl %ecx # save ti_flags for do_notify_resume 328 call save_v86_state # %eax contains pt_regs pointer 329 popl %ecx ··· 330 xorl %edx, %edx 331 call do_notify_resume 332 jmp resume_userspace 333 + #endif 334 335 # perform syscall exit tracing 336 ALIGN
+1
arch/i386/kernel/process.c
··· 48 #include <asm/processor.h> 49 #include <asm/i387.h> 50 #include <asm/desc.h> 51 #ifdef CONFIG_MATH_EMULATION 52 #include <asm/math_emu.h> 53 #endif
··· 48 #include <asm/processor.h> 49 #include <asm/i387.h> 50 #include <asm/desc.h> 51 + #include <asm/vm86.h> 52 #ifdef CONFIG_MATH_EMULATION 53 #include <asm/math_emu.h> 54 #endif
-2
include/asm-i386/irq.h
··· 21 return ((irq == 2) ? 9 : irq); 22 } 23 24 - extern void release_vm86_irqs(struct task_struct *); 25 - 26 #ifdef CONFIG_X86_LOCAL_APIC 27 # define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ 28 #endif
··· 21 return ((irq == 2) ? 9 : irq); 22 } 23 24 #ifdef CONFIG_X86_LOCAL_APIC 25 # define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ 26 #endif
+20
include/asm-i386/vm86.h
··· 16 #define IF_MASK 0x00000200 17 #define IOPL_MASK 0x00003000 18 #define NT_MASK 0x00004000 19 #define VM_MASK 0x00020000 20 #define AC_MASK 0x00040000 21 #define VIF_MASK 0x00080000 /* virtual interrupt flag */ 22 #define VIP_MASK 0x00100000 /* virtual interrupt pending */ ··· 204 */ 205 }; 206 207 void handle_vm86_fault(struct kernel_vm86_regs *, long); 208 int handle_vm86_trap(struct kernel_vm86_regs *, long, int); 209 210 #endif /* __KERNEL__ */ 211
··· 16 #define IF_MASK 0x00000200 17 #define IOPL_MASK 0x00003000 18 #define NT_MASK 0x00004000 19 + #ifdef CONFIG_VM86 20 #define VM_MASK 0x00020000 21 + #else 22 + #define VM_MASK 0 /* ignored */ 23 + #endif 24 #define AC_MASK 0x00040000 25 #define VIF_MASK 0x00080000 /* virtual interrupt flag */ 26 #define VIP_MASK 0x00100000 /* virtual interrupt pending */ ··· 200 */ 201 }; 202 203 + #ifdef CONFIG_VM86 204 + 205 void handle_vm86_fault(struct kernel_vm86_regs *, long); 206 int handle_vm86_trap(struct kernel_vm86_regs *, long, int); 207 + 208 + struct task_struct; 209 + void release_vm86_irqs(struct task_struct *); 210 + 211 + #else 212 + 213 + #define handle_vm86_fault(a, b) 214 + #define release_vm86_irqs(a) 215 + 216 + static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) { 217 + return 0; 218 + } 219 + 220 + #endif /* CONFIG_VM86 */ 221 222 #endif /* __KERNEL__ */ 223
+10
init/Kconfig
··· 237 help 238 This enables the legacy 16-bit UID syscall wrappers. 239 240 config CC_OPTIMIZE_FOR_SIZE 241 bool "Optimize for size (Look out for broken compilers!)" 242 default y
··· 237 help 238 This enables the legacy 16-bit UID syscall wrappers. 239 240 + config VM86 241 + depends X86 242 + default y 243 + bool "Enable VM86 support" if EMBEDDED 244 + help 245 + This option is required by programs like DOSEMU to run 16-bit legacy 246 + code on X86 processors. It also may be needed by software like 247 + XFree86 to initialize some video cards via BIOS. Disabling this 248 + option saves about 6k. 249 + 250 config CC_OPTIMIZE_FOR_SIZE 251 bool "Optimize for size (Look out for broken compilers!)" 252 default y
+2
kernel/sys_ni.c
··· 102 cond_syscall(sys_setresuid16); 103 cond_syscall(sys_setreuid16); 104 cond_syscall(sys_setuid16); 105 106 /* arch-specific weak syscall entries */ 107 cond_syscall(sys_pciconfig_read);
··· 102 cond_syscall(sys_setresuid16); 103 cond_syscall(sys_setreuid16); 104 cond_syscall(sys_setuid16); 105 + cond_syscall(sys_vm86old); 106 + cond_syscall(sys_vm86); 107 108 /* arch-specific weak syscall entries */ 109 cond_syscall(sys_pciconfig_read);