[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 4 5 5 extra-y := head.o init_task.o vmlinux.lds 6 6 7 - obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \ 7 + obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ 8 8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ 9 9 pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ 10 10 quirks.o i8237.o ··· 34 34 obj-$(CONFIG_HPET_TIMER) += time_hpet.o 35 35 obj-$(CONFIG_EFI) += efi.o efi_stub.o 36 36 obj-$(CONFIG_DOUBLEFAULT) += doublefault.o 37 + obj-$(CONFIG_VM86) += vm86.o 37 38 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 38 39 39 40 EXTRA_AFLAGS := -traditional
+2
arch/i386/kernel/entry.S
··· 323 323 324 324 ALIGN 325 325 work_notifysig_v86: 326 + #ifdef CONFIG_VM86 326 327 pushl %ecx # save ti_flags for do_notify_resume 327 328 call save_v86_state # %eax contains pt_regs pointer 328 329 popl %ecx ··· 331 330 xorl %edx, %edx 332 331 call do_notify_resume 333 332 jmp resume_userspace 333 + #endif 334 334 335 335 # perform syscall exit tracing 336 336 ALIGN
+1
arch/i386/kernel/process.c
··· 48 48 #include <asm/processor.h> 49 49 #include <asm/i387.h> 50 50 #include <asm/desc.h> 51 + #include <asm/vm86.h> 51 52 #ifdef CONFIG_MATH_EMULATION 52 53 #include <asm/math_emu.h> 53 54 #endif
-2
include/asm-i386/irq.h
··· 21 21 return ((irq == 2) ? 9 : irq); 22 22 } 23 23 24 - extern void release_vm86_irqs(struct task_struct *); 25 - 26 24 #ifdef CONFIG_X86_LOCAL_APIC 27 25 # define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ 28 26 #endif
+20
include/asm-i386/vm86.h
··· 16 16 #define IF_MASK 0x00000200 17 17 #define IOPL_MASK 0x00003000 18 18 #define NT_MASK 0x00004000 19 + #ifdef CONFIG_VM86 19 20 #define VM_MASK 0x00020000 21 + #else 22 + #define VM_MASK 0 /* ignored */ 23 + #endif 20 24 #define AC_MASK 0x00040000 21 25 #define VIF_MASK 0x00080000 /* virtual interrupt flag */ 22 26 #define VIP_MASK 0x00100000 /* virtual interrupt pending */ ··· 204 200 */ 205 201 }; 206 202 203 + #ifdef CONFIG_VM86 204 + 207 205 void handle_vm86_fault(struct kernel_vm86_regs *, long); 208 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 */ 209 221 210 222 #endif /* __KERNEL__ */ 211 223
+10
init/Kconfig
··· 237 237 help 238 238 This enables the legacy 16-bit UID syscall wrappers. 239 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 + 240 250 config CC_OPTIMIZE_FOR_SIZE 241 251 bool "Optimize for size (Look out for broken compilers!)" 242 252 default y
+2
kernel/sys_ni.c
··· 102 102 cond_syscall(sys_setresuid16); 103 103 cond_syscall(sys_setreuid16); 104 104 cond_syscall(sys_setuid16); 105 + cond_syscall(sys_vm86old); 106 + cond_syscall(sys_vm86); 105 107 106 108 /* arch-specific weak syscall entries */ 107 109 cond_syscall(sys_pciconfig_read);