H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_VM86_H |
| 2 | #define _ASM_X86_VM86_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
Cyrill Gorcunov | 9831bfb | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 4 | |
Vegard Nossum | 6330a30 | 2008-05-28 09:46:19 +0200 | [diff] [blame] | 5 | #include <asm/ptrace.h> |
David Howells | af170c5 | 2012-12-14 22:37:13 +0000 | [diff] [blame] | 6 | #include <uapi/asm/vm86.h> |
Cyrill Gorcunov | 9831bfb | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | /* |
| 9 | * This is the (kernel) stack-layout when we have done a "SAVE_ALL" from vm86 |
| 10 | * mode - the main change is that the old segment descriptors aren't |
| 11 | * useful any more and are forced to be zero by the kernel (and the |
| 12 | * hardware when a trap occurs), and the real segment descriptors are |
| 13 | * at the end of the structure. Look at ptrace.h to see the "normal" |
| 14 | * setup. For user space layout see 'struct vm86_regs' above. |
| 15 | */ |
| 16 | |
| 17 | struct kernel_vm86_regs { |
| 18 | /* |
| 19 | * normal regs, with special meaning for the segment descriptors.. |
| 20 | */ |
Jeremy Fitzhardinge | 49d26b6 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 21 | struct pt_regs pt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | /* |
| 23 | * these are specific to v86 mode: |
| 24 | */ |
| 25 | unsigned short es, __esh; |
| 26 | unsigned short ds, __dsh; |
| 27 | unsigned short fs, __fsh; |
| 28 | unsigned short gs, __gsh; |
| 29 | }; |
| 30 | |
| 31 | struct kernel_vm86_struct { |
| 32 | struct kernel_vm86_regs regs; |
| 33 | /* |
| 34 | * the below part remains on the kernel stack while we are in VM86 mode. |
| 35 | * 'tss.esp0' then contains the address of VM86_TSS_ESP0 below, and when we |
| 36 | * get forced back from VM86, the CPU and "SAVE_ALL" will restore the above |
| 37 | * 'struct kernel_vm86_regs' with the then actual values. |
| 38 | * Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct' |
| 39 | * in kernelspace, hence we need not reget the data from userspace. |
| 40 | */ |
| 41 | #define VM86_TSS_ESP0 flags |
| 42 | unsigned long flags; |
| 43 | unsigned long screen_bitmap; |
| 44 | unsigned long cpu_type; |
| 45 | struct revectored_struct int_revectored; |
| 46 | struct revectored_struct int21_revectored; |
| 47 | struct vm86plus_info_struct vm86plus; |
| 48 | struct pt_regs *regs32; /* here we save the pointer to the old regs */ |
| 49 | /* |
| 50 | * The below is not part of the structure, but the stack layout continues |
| 51 | * this way. In front of 'return-eip' may be some data, depending on |
| 52 | * compilation, so we don't rely on this and save the pointer to 'oldregs' |
| 53 | * in 'regs32' above. |
| 54 | * However, with GCC-2.7.2 and the current CFLAGS you see exactly this: |
| 55 | |
| 56 | long return-eip; from call to vm86() |
| 57 | struct pt_regs oldregs; user space registers as saved by syscall |
| 58 | */ |
| 59 | }; |
| 60 | |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 61 | #ifdef CONFIG_VM86 |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | void handle_vm86_fault(struct kernel_vm86_regs *, long); |
| 64 | int handle_vm86_trap(struct kernel_vm86_regs *, long, int); |
Harvey Harrison | e04f99c | 2008-02-04 16:48:04 +0100 | [diff] [blame] | 65 | struct pt_regs *save_v86_state(struct kernel_vm86_regs *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 67 | struct task_struct; |
| 68 | void release_vm86_irqs(struct task_struct *); |
| 69 | |
| 70 | #else |
| 71 | |
| 72 | #define handle_vm86_fault(a, b) |
| 73 | #define release_vm86_irqs(a) |
| 74 | |
Joe Perches | 9e8a935 | 2008-03-23 01:03:58 -0700 | [diff] [blame] | 75 | static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) |
| 76 | { |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | #endif /* CONFIG_VM86 */ |
| 81 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 82 | #endif /* _ASM_X86_VM86_H */ |