x86: vm86 cleanups
Subsystems (4)
PATCH v4 1/1 x86: vm86 cleanups
The goal of this set of patches is to change vm86 support to return to userspace with the normal exit paths instead of leaving data on the kernel stack and jumping directly into the exit asm routines. This fixes issues like ptrace and syscall auditing not working with vm86, and makes possible cleanups in the syscall exit work code.
Changes from v3:
- Removed patches already accepted
- Renamed some fields per Ingo
- Added patches to allow disabling hardware IRQ support and to fix includes
- Added helper macro for free_vm86 (Note: could not use inline function due to header issues)
Changes from v2:
- Use gs slot of regs32 (present but unused in lazy mode)
- Add access_ok() checks before get_user_try/put_user_try
Changes from v1:
- Added first two patches
- Changed userspace access to copy each field explicitly instead of relying on the same order of members in the structure.
PATCH 1/8 x86/vm86: Move vm86 fields out of thread_struct
Allocate a separate structure for the vm86 fields.
--- arch/x86/include/asm/processor.h | 11 +++------- arch/x86/include/asm/vm86.h | 19 ++++++++++++++++- arch/x86/kernel/process.c | 3 +++ arch/x86/kernel/vm86_32.c | 46 +++++++++++++++++++++++----------------- arch/x86/mm/fault.c | 4 ++-- 5 files changed, 53 insertions(+), 30 deletions(-)
arch/x86/include/asm/processor.h +3 -8
@@ -6,8 +6,8 @@/* Forward declaration, a strange C thing */ struct task_struct ;struct mm_struct ; +struct vm86 ; -#include <asm/vm86.h> #include <asm/math_emu.h> #include <asm/segment.h> #include <asm/types.h>
@@ -400,13 +400,9 @@ struct thread_struct {unsigned long cr2;unsigned long trap_nr;unsigned long error_code; -#ifdef CONFIG_X86_32 +#ifdef CONFIG_VM86 /* Virtual 86 mode info */ -struct vm86plus_struct __user *vm86_info; -unsigned long screen_bitmap; -unsigned long v86flags; -unsigned long v86mask; -unsigned long saved_sp0; +struct vm86 *vm86;#endif /* IO permissions: */ unsigned long *io_bitmap_ptr;
@@ -710,7 +706,6 @@ static inline void spin_lock_prefetch(const void *x)#define INIT_THREAD { \ .sp0 = TOP_OF_INIT_STACK, \ - .vm86_info = NULL, \ .sysenter_cs = __KERNEL_CS, \ .io_bitmap_ptr = NULL, \ }
arch/x86/include/asm/vm86.h +18 -1
@@ -1,7 +1,6 @@#ifndef _ASM_X86_VM86_H#define _ASM_X86_VM86_H -#include <asm/ptrace.h> #include <uapi/asm/vm86.h>
@@ -58,6 +57,14 @@ struct kernel_vm86_struct {*/ }; +struct vm86 { +struct vm86plus_struct __user *vm86_info; +unsigned long screen_bitmap; +unsigned long v86flags; +unsigned long v86mask; +unsigned long saved_sp0; +}; +#ifdef CONFIG_VM86 void handle_vm86_fault (struct kernel_vm86_regs *,long );
@@ -67,6 +74,14 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *);struct task_struct ;void release_vm86_irqs (struct task_struct *); +#define free_vm86 (t) do { \ + struct thread_struct *__t = (t); \ + if (__t->vm86 != NULL) { \ + kfree(__t->vm86); \ + __t->vm86 = NULL; \ + } \ +} while (0) +#else #define handle_vm86_fault (a, b)
@@ -77,6 +92,8 @@ static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c)return 0 ; } +#define free_vm86 (t) do { } while(0) +#endif /* CONFIG_VM86 */ #endif /* _ASM_X86_VM86_H */
arch/x86/kernel/process.c +3 -0
@@ -29,6 +29,7 @@#include <asm/debugreg.h> #include <asm/nmi.h> #include <asm/tlbflush.h> +#include <asm/vm86.h> /* * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -110,6 +111,8 @@ void exit_thread(void)kfree (bp); } +free_vm86 (t); +fpu__drop (fpu); }
arch/x86/kernel/vm86_32.c +27 -19
143 lines not on this page · raw message
arch/x86/mm/fault.c +2 -2
@@ -315,12 +315,12 @@ check_v8086_mode(struct pt_regs *regs, unsigned long address, {unsigned long bit; -if (!v8086_mode (regs)) +if (!v8086_mode (regs) || !tsk->thread.vm86)return ; bit = (address -0xA0000 ) >>PAGE_SHIFT ;if (bit <32 ) - tsk->thread.screen_bitmap |=1 << bit; + tsk->thread.vm86->screen_bitmap |=1 << bit; }static bool low_pfn (unsigned long pfn)
Signature · 1 line
2.4.3
Re: [PATCH 1/8] x86/vm86: Move vm86 fields out of thread_struct
Quoted 1 line · Brian Gerst
Allocate a separate structure for the vm86 fields.
tip-bot for Brian Gerst
merge bot[tip:x86/asm] x86/vm86: Move vm86 fields out of 'thread_struct'
In reply to Brian Gerstx86/vm86: Move vm86 fields out of 'thread_struct'
Commit-ID: 9fda6a0681e070b496235b132bc70ceb80300211 Gitweb: http://git.kernel.org/tip/9fda6a0681e070b496235b132bc70ceb80300211 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:16 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:07 +0200
x86/vm86: Move vm86 fields out of 'thread_struct'
Allocate a separate structure for the vm86 fields.
--- arch/x86/include/asm/processor.h | 11 +++------- arch/x86/include/asm/vm86.h | 19 ++++++++++++++++- arch/x86/kernel/process.c | 3 +++ arch/x86/kernel/vm86_32.c | 46 +++++++++++++++++++++++----------------- arch/x86/mm/fault.c | 6 ++++-- 5 files changed, 55 insertions(+), 30 deletions(-)
arch/x86/include/asm/processor.h +3 -8
@@ -6,8 +6,8 @@/* Forward declaration, a strange C thing */ struct task_struct ;struct mm_struct ; +struct vm86 ; -#include <asm/vm86.h> #include <asm/math_emu.h> #include <asm/segment.h> #include <asm/types.h>
@@ -400,13 +400,9 @@ struct thread_struct {unsigned long cr2;unsigned long trap_nr;unsigned long error_code; -#ifdef CONFIG_X86_32 +#ifdef CONFIG_VM86 /* Virtual 86 mode info */ -struct vm86plus_struct __user *vm86_info; -unsigned long screen_bitmap; -unsigned long v86flags; -unsigned long v86mask; -unsigned long saved_sp0; +struct vm86 *vm86;#endif /* IO permissions: */ unsigned long *io_bitmap_ptr;
@@ -718,7 +714,6 @@ static inline void spin_lock_prefetch(const void *x)#define INIT_THREAD { \ .sp0 = TOP_OF_INIT_STACK, \ - .vm86_info = NULL, \ .sysenter_cs = __KERNEL_CS, \ .io_bitmap_ptr = NULL, \ }
arch/x86/include/asm/vm86.h +18 -1
@@ -1,7 +1,6 @@#ifndef _ASM_X86_VM86_H#define _ASM_X86_VM86_H -#include <asm/ptrace.h> #include <uapi/asm/vm86.h>
@@ -58,6 +57,14 @@ struct kernel_vm86_struct {*/ }; +struct vm86 { +struct vm86plus_struct __user *vm86_info; +unsigned long screen_bitmap; +unsigned long v86flags; +unsigned long v86mask; +unsigned long saved_sp0; +}; +#ifdef CONFIG_VM86 void handle_vm86_fault (struct kernel_vm86_regs *,long );
@@ -67,6 +74,14 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *);struct task_struct ;void release_vm86_irqs (struct task_struct *); +#define free_vm86 (t) do { \ + struct thread_struct *__t = (t); \ + if (__t->vm86 != NULL) { \ + kfree(__t->vm86); \ + __t->vm86 = NULL; \ + } \ +} while (0) +#else #define handle_vm86_fault (a, b)
@@ -77,6 +92,8 @@ static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c)return 0 ; } +#define free_vm86 (t) do { } while(0) +#endif /* CONFIG_VM86 */ #endif /* _ASM_X86_VM86_H */
arch/x86/kernel/process.c +3 -0
@@ -29,6 +29,7 @@#include <asm/debugreg.h> #include <asm/nmi.h> #include <asm/tlbflush.h> +#include <asm/vm86.h> /* * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -110,6 +111,8 @@ void exit_thread(void)kfree (bp); } +free_vm86 (t); +fpu__drop (fpu); }
arch/x86/kernel/vm86_32.c +27 -19
143 lines not on this page · raw message
arch/x86/mm/fault.c +4 -2
@@ -301,14 +301,16 @@ static inline void check_v8086_mode(struct pt_regs *regs, unsigned long address, struct task_struct *tsk) { +#ifdef CONFIG_VM86 unsigned long bit; -if (!v8086_mode (regs)) +if (!v8086_mode (regs) || !tsk->thread.vm86)return ; bit = (address -0xA0000 ) >>PAGE_SHIFT ;if (bit <32 ) - tsk->thread.screen_bitmap |=1 << bit; + tsk->thread.vm86->screen_bitmap |=1 << bit; +#endif }static bool low_pfn (unsigned long pfn)
PATCH 2/8 x86/vm86: Move fields from kernel_vm86_struct
In reply to Brian GerstMove the non-regs fields to the off-stack data.
--- arch/x86/include/asm/vm86.h | 16 ++++++++-------- arch/x86/kernel/vm86_32.c | 42 ++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 28 deletions(-)
arch/x86/include/asm/vm86.h +8 -8
@@ -37,13 +37,7 @@ struct kernel_vm86_struct {* Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct' * in kernelspace, hence we need not reget the data from userspace. */ -#define VM86_TSS_ESP0 flags -unsigned long flags; -unsigned long screen_bitmap; -unsigned long cpu_type; -struct revectored_struct int_revectored; -struct revectored_struct int21_revectored; -struct vm86plus_info_struct vm86plus; +#define VM86_TSS_ESP0 regs32struct pt_regs *regs32;/* here we save the pointer to the old regs */ /* * The below is not part of the structure, but the stack layout continues
@@ -59,10 +53,16 @@ struct kernel_vm86_struct {struct vm86 {struct vm86plus_struct __user *vm86_info; -unsigned long screen_bitmap;unsigned long v86flags;unsigned long v86mask;unsigned long saved_sp0; + +unsigned long flags; +unsigned long screen_bitmap; +unsigned long cpu_type; +struct revectored_struct int_revectored; +struct revectored_struct int21_revectored; +struct vm86plus_info_struct vm86plus; };#ifdef CONFIG_VM86
arch/x86/kernel/vm86_32.c +22 -20
115 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH 2/8] x86/vm86: Move fields from kernel_vm86_struct
Quoted 1 line · Brian Gerst
Move the non-regs fields to the off-stack data.
Although I admit I haven't carefully reviewed the mindless conversion part of the patch.
tip-bot for Brian Gerst
merge bot[tip:x86/asm] x86/vm86: Move fields from ' struct kernel_vm86_struct' to 'struct vm86'
In reply to Brian Gerstx86/vm86: Move fields from 'struct kernel_vm86_struct' to 'struct vm86'
Commit-ID: d4ce0f26c790af8e829d3fad0a6787f40f98e24f Gitweb: http://git.kernel.org/tip/d4ce0f26c790af8e829d3fad0a6787f40f98e24f Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:17 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:08 +0200
x86/vm86: Move fields from 'struct kernel_vm86_struct' to 'struct vm86'
Move the non-regs fields to the off-stack data.
--- arch/x86/include/asm/vm86.h | 16 ++++++++-------- arch/x86/kernel/vm86_32.c | 42 ++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 28 deletions(-)
arch/x86/include/asm/vm86.h +8 -8
@@ -37,13 +37,7 @@ struct kernel_vm86_struct {* Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct' * in kernelspace, hence we need not reget the data from userspace. */ -#define VM86_TSS_ESP0 flags -unsigned long flags; -unsigned long screen_bitmap; -unsigned long cpu_type; -struct revectored_struct int_revectored; -struct revectored_struct int21_revectored; -struct vm86plus_info_struct vm86plus; +#define VM86_TSS_ESP0 regs32struct pt_regs *regs32;/* here we save the pointer to the old regs */ /* * The below is not part of the structure, but the stack layout continues
@@ -59,10 +53,16 @@ struct kernel_vm86_struct {struct vm86 {struct vm86plus_struct __user *vm86_info; -unsigned long screen_bitmap;unsigned long v86flags;unsigned long v86mask;unsigned long saved_sp0; + +unsigned long flags; +unsigned long screen_bitmap; +unsigned long cpu_type; +struct revectored_struct int_revectored; +struct revectored_struct int21_revectored; +struct vm86plus_info_struct vm86plus; };#ifdef CONFIG_VM86
arch/x86/kernel/vm86_32.c +22 -20
115 lines not on this page · raw message
PATCH 3/8 x86/vm86: Eliminate kernel_vm86_struct
In reply to Brian GerstNow there is no vm86-specific data left on the kernel stack while in userspace, except for the 32-bit regs.
--- arch/x86/include/asm/vm86.h | 25 +----------- arch/x86/kernel/vm86_32.c | 95 +++++++++++++++++++-------------------------- 2 files changed, 42 insertions(+), 78 deletions(-)
arch/x86/include/asm/vm86.h +1 -24
@@ -27,32 +27,9 @@ struct kernel_vm86_regs {unsigned short gs, __gsh; }; -struct kernel_vm86_struct { -struct kernel_vm86_regs regs; -/* -* the below part remains on the kernel stack while we are in VM86 mode. -* 'tss.esp0' then contains the address of VM86_TSS_ESP0 below, and when we -* get forced back from VM86, the CPU and "SAVE_ALL" will restore the above -* 'struct kernel_vm86_regs' with the then actual values. -* Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct' -* in kernelspace, hence we need not reget the data from userspace. -*/ -#define VM86_TSS_ESP0 regs32 -struct pt_regs *regs32;/* here we save the pointer to the old regs */ -/* -* The below is not part of the structure, but the stack layout continues -* this way. In front of 'return-eip' may be some data, depending on -* compilation, so we don't rely on this and save the pointer to 'oldregs' -* in 'regs32' above. -* However, with GCC-2.7.2 and the current CFLAGS you see exactly this: - -long return-eip; from call to vm86() -struct pt_regs oldregs; user space registers as saved by syscall -*/ -}; -struct vm86 {struct vm86plus_struct __user *vm86_info; +struct pt_regs *regs32;unsigned long v86flags;unsigned long v86mask;unsigned long saved_sp0;
arch/x86/kernel/vm86_32.c +41 -54
187 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH 3/8] x86/vm86: Eliminate kernel_vm86_struct
Quoted 2 lines · Brian Gerst
Now there is no vm86-specific data left on the kernel stack while in userspace, except for the 32-bit regs.
This is *so* much better.
tip-bot for Brian Gerst
merge bot[tip:x86/asm] x86/vm86: Eliminate 'struct kernel_vm86_struct'
In reply to Brian Gerstx86/vm86: Eliminate 'struct kernel_vm86_struct'
Commit-ID: 90c6085a248f8f964588617f51329688bcc9f2bc Gitweb: http://git.kernel.org/tip/90c6085a248f8f964588617f51329688bcc9f2bc Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:18 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:08 +0200
x86/vm86: Eliminate 'struct kernel_vm86_struct'
Now there is no vm86-specific data left on the kernel stack while in userspace, except for the 32-bit regs.
--- arch/x86/include/asm/vm86.h | 25 +----------- arch/x86/kernel/vm86_32.c | 95 +++++++++++++++++++-------------------------- 2 files changed, 42 insertions(+), 78 deletions(-)
arch/x86/include/asm/vm86.h +1 -24
@@ -27,32 +27,9 @@ struct kernel_vm86_regs {unsigned short gs, __gsh; }; -struct kernel_vm86_struct { -struct kernel_vm86_regs regs; -/* -* the below part remains on the kernel stack while we are in VM86 mode. -* 'tss.esp0' then contains the address of VM86_TSS_ESP0 below, and when we -* get forced back from VM86, the CPU and "SAVE_ALL" will restore the above -* 'struct kernel_vm86_regs' with the then actual values. -* Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct' -* in kernelspace, hence we need not reget the data from userspace. -*/ -#define VM86_TSS_ESP0 regs32 -struct pt_regs *regs32;/* here we save the pointer to the old regs */ -/* -* The below is not part of the structure, but the stack layout continues -* this way. In front of 'return-eip' may be some data, depending on -* compilation, so we don't rely on this and save the pointer to 'oldregs' -* in 'regs32' above. -* However, with GCC-2.7.2 and the current CFLAGS you see exactly this: - -long return-eip; from call to vm86() -struct pt_regs oldregs; user space registers as saved by syscall -*/ -}; -struct vm86 {struct vm86plus_struct __user *vm86_info; +struct pt_regs *regs32;unsigned long v86flags;unsigned long v86mask;unsigned long saved_sp0;
arch/x86/kernel/vm86_32.c +41 -54
187 lines not on this page · raw message
PATCH 4/8 x86/vm86: Use the normal pt_regs area for vm86
In reply to Brian GerstChange to use the normal pt_regs area to enter and exit vm86 mode. This is done by increasing the padding at the top of the stack to make room for the extra vm86 segment slots in the IRET frame. It then saves the 32-bit regs in the off-stack vm86 data, and copies in the vm86 regs. Exiting back to 32-bit mode does the reverse. This allows removing the hacks to jump directly into the exit asm code due to having to change the stack pointer. Returning normally from the vm86 syscall and the exception handlers allows things like ptrace and auditing to work properly.
--- arch/x86/entry/entry_32.S | 24 +------- arch/x86/include/asm/thread_info.h | 11 ++-- arch/x86/include/asm/vm86.h | 6 +- arch/x86/kernel/signal.c | 3 + arch/x86/kernel/vm86_32.c | 110 +++++++++++++++---------------------- 5 files changed, 60 insertions(+), 94 deletions(-)
arch/x86/entry/entry_32.S +1 -23
@@ -525,34 +525,12 @@ work_resched: work_notifysig: # deal with pending signals and # notify-resume requests -#ifdef CONFIG_VM86 - testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) - movl %esp, %eax - jnz work_notifysig_v86 # returning to kernel-space or - # vm86-space -1: -#else - movl %esp, %eax -#endif TRACE_IRQS_ON ENABLE_INTERRUPTS(CLBR_NONE) - movb PT_CS(%esp), %bl - andb $SEGMENT_RPL_MASK, %bl - cmpb $USER_RPL, %bl - jb resume_kernel + movl %esp, %eax xorl %edx, %edx call do_notify_resume jmp resume_userspace - -#ifdef CONFIG_VM86 - ALIGN -work_notifysig_v86: - pushl %ecx # save ti_flags for do_notify_resume - call save_v86_state # %eax contains pt_regs pointer - popl %ecx - movl %eax, %esp - jmp 1b -#endif END(work_pending) # perform syscall exit tracing
arch/x86/include/asm/thread_info.h +7 -4
@@ -27,14 +27,17 @@* Without this offset, that can result in a page fault. (We are * careful that, in this case, the value we read doesn't matter.) * -* In vm86 mode, the hardware frame is much longer still, but we neither -* access the extra members from NMI context, nor do we write such a -* frame at sp0 at all. +* In vm86 mode, the hardware frame is much longer still, so add 16 +* bytes to make room for the real-mode segments. * * x86_64 has a fixed-length stack frame. */ #ifdef CONFIG_X86_32 -# define TOP_OF_KERNEL_STACK_PADDING 8 +# ifdef CONFIG_VM86 +# define TOP_OF_KERNEL_STACK_PADDING 16 +# else +# define TOP_OF_KERNEL_STACK_PADDING 8 +# endif #else # define TOP_OF_KERNEL_STACK_PADDING 0#endif
arch/x86/include/asm/vm86.h +4 -2
@@ -29,7 +29,7 @@ struct kernel_vm86_regs {struct vm86 {struct vm86plus_struct __user *vm86_info; -struct pt_regs *regs32; +struct pt_regs regs32;unsigned long v86flags;unsigned long v86mask;unsigned long saved_sp0;
@@ -46,7 +46,7 @@ struct vm86 {void handle_vm86_fault (struct kernel_vm86_regs *,long );int handle_vm86_trap (struct kernel_vm86_regs *,long ,int ); -struct pt_regs *save_v86_state (struct kernel_vm86_regs *); +void save_v86_state (struct kernel_vm86_regs *,int );struct task_struct ;void release_vm86_irqs (struct task_struct *);
@@ -69,6 +69,8 @@ static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) return 0; } +static inline void save_v86_state (struct kernel_vm86_regs *,int ) { } +#define free_vm86 (t) do { } while(0)#endif /* CONFIG_VM86 */
arch/x86/kernel/signal.c +3 -0
@@ -635,6 +635,9 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)bool stepping, failed;struct fpu *fpu = ¤t->thread.fpu; +if (v8086_mode (regs)) +save_v86_state ((struct kernel_vm86_regs *) regs,VM86_SIGNAL ); +/* Are we from a system call? */ if (syscall_get_nr (current, regs) >=0 ) {/* If so, check system call restarting.. */
arch/x86/kernel/vm86_32.c +45 -65
237 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 8 lines · Brian Gerst
Change to use the normal
pt_regsarea to enter and exit vm86 mode. This is done by increasing the padding at the top of the stack to make room for the extra vm86 segment slots in the IRET frame. It then saves the 32-bit regs in the off-stack vm86 data, and copies in the vm86 regs. Exiting back to 32-bit mode does the reverse. This allows removing the hacks to jump directly into the exit asm code due to having to change the stack pointer. Returning normally from the vm86 syscall and the exception handlers allows things like ptrace and auditing to work properly.
With caveats below:
arch/x86/entry/entry_32.S work_resched: · line 542
Quoted 4 lines
arch/x86/entry/entry_32.S +0
-4- movb PT_CS(%esp), %bl - andb $SEGMENT_RPL_MASK, %bl - cmpb $USER_RPL, %bl - jb resume_kernel
I agree with this hunk, and I have the same hunk in my tree. However, it has nothing to do with vm86 and, on the off chance that this hunk is wrong, I think it should be bisect-friendly.
If you want to preserve my bit of archeology, you could include:
in this series and stick your patch on top. (Or, Ingo, if you want to apply just that one patch from my pile and merge this on top, you'd get exactly the same result.)
arch/x86/include/asm/thread_info.h line 31
Quoted 11 lines
arch/x86/include/asm/thread_info.h +2
-3@@ -27,14 +27,17 @@* Without this offset, that can result in a page fault. (We are * careful that, in this case, the value we read doesn't matter.) * -* In vm86 mode, the hardware frame is much longer still, but we neither -* access the extra members from NMI context, nor do we write such a -* frame at sp0 at all. +* In vm86 mode, the hardware frame is much longer still, so add 16 +* bytes to make room for the real-mode segments.
I've now read this comment a few times, and I think it could be better. How about:
In vm86 mode, the hardware frame is extended by 4 bytes for each of ds, es, fs and gs. To allow room for those extra slots while still keeping pt_regs in its normal location on entries from vm86 mode, we need at least 16 bytes of padding. In the vm86 case, we don't need to worry about the SYSENTER + NMI issue: we disallow SYSENTER from vm86 mode, so we don't need to worry about an NMI trying to read above the top of the vm86 hardware frame.
--Andy
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 14 lines · Andy Lutomirski
Quoted 8 lines · Brian Gerst
Change to use the normal
pt_regsarea to enter and exit vm86 mode. This is done by increasing the padding at the top of the stack to make room for the extra vm86 segment slots in the IRET frame. It then saves the 32-bit regs in the off-stack vm86 data, and copies in the vm86 regs. Exiting back to 32-bit mode does the reverse. This allows removing the hacks to jump directly into the exit asm code due to having to change the stack pointer. Returning normally from the vm86 syscall and the exception handlers allows things like ptrace and auditing to work properly.With caveats below:
Acked-by Andy Lutomirski <[email protected]>
Quoted 8 lines
arch/x86/entry/entry_32.S work_resched: · line 542
Quoted 4 lines
arch/x86/entry/entry_32.S +0
-4- movb PT_CS(%esp), %bl - andb $SEGMENT_RPL_MASK, %bl - cmpb $USER_RPL, %bl - jb resume_kernelI agree with this hunk, and I have the same hunk in my tree. However, it has nothing to do with vm86 and, on the off chance that this hunk is wrong, I think it should be bisect-friendly.
I think it was causing signal handling to fail, but I can't remember exactly. If I kept the code it would have needed to add a test for the VM flag. But I came to the same conclusion you did, that it was unneeded.
Quoted 7 lines
If you want to preserve my bit of archeology, you could include:
in this series and stick your patch on top. (Or, Ingo, if you want to apply just that one patch from my pile and merge this on top, you'd get exactly the same result.)
I'd be OK with that.
Quoted 15 lines
arch/x86/include/asm/thread_info.h line 31
Quoted 11 lines
arch/x86/include/asm/thread_info.h +2
-3@@ -27,14 +27,17 @@* Without this offset, that can result in a page fault. (We are * careful that, in this case, the value we read doesn't matter.) * -* In vm86 mode, the hardware frame is much longer still, but we neither -* access the extra members from NMI context, nor do we write such a -* frame at sp0 at all. +* In vm86 mode, the hardware frame is much longer still, so add 16 +* bytes to make room for the real-mode segments. I've now read this comment a few times, and I think it could be better. How about:
Quoted 7 lines
In vm86 mode, the hardware frame is extended by 4 bytes for each of ds, es, fs and gs. To allow room for those extra slots while still keeping
pt_regsin its normal location on entries from vm86 mode, we need at least 16 bytes of padding. In the vm86 case, we don't need to worry about the SYSENTER + NMI issue: we disallow SYSENTER from vm86 mode, so we don't need to worry about an NMI trying to read above the top of the vm86 hardware frame.
That looks good.
--
Brian Gerst
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 3 lines · Brian Gerst
I think it was causing signal handling to fail, but I can't remember exactly.
Ugh.
If that hunk made a difference, then there is something wrong with your patch-series. So please double-check.
Linus
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 11 lines · Linus Torvalds
Quoted 3 lines · Brian Gerst
I think it was causing signal handling to fail, but I can't remember exactly.
Ugh.
If that hunk made a difference, then there is something wrong with your patch-series. So please double-check.
Linus
I think I remember now what the issue was. Since entering vm86 mode uses force_iret(), the work_pending code path was being taken. I had to move the call to save_v86_state out of here to handle_signal(), otherwise it would just restore the 32-bit regs and exit the syscall without ever entering vm86 mode. But that meant that the test for kernel CS was seeing the vm86 regs instead of 32-bit regs, and was failing because it didn't account for the VM bit (if the real-mode CS looked like RPL 0). A fault would get stuck in a loop because it couldn't exit to the signal handling code.
--
Brian Gerst
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 10 lines · Brian Gerst
I think I remember now what the issue was. Since entering vm86 mode uses
force_iret(), thework_pendingcode path was being taken. I had to move the call tosave_v86_stateout of here tohandle_signal(), otherwise it would just restore the 32-bit regs and exit the syscall without ever entering vm86 mode. But that meant that the test for kernel CS was seeing the vm86 regs instead of 32-bit regs, and was failing because it didn't account for the VM bit (if the real-mode CS looked like RPL 0). A fault would get stuck in a loop because it couldn't exit to the signal handling code.
Hmm. I think we'd want a big comment about that code then, and how it is only used for user-space (including vm86 mode).
Linus
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 12 lines · Linus Torvalds
Quoted 10 lines · Brian Gerst
I think I remember now what the issue was. Since entering vm86 mode uses
force_iret(), thework_pendingcode path was being taken. I had to move the call tosave_v86_stateout of here tohandle_signal(), otherwise it would just restore the 32-bit regs and exit the syscall without ever entering vm86 mode. But that meant that the test for kernel CS was seeing the vm86 regs instead of 32-bit regs, and was failing because it didn't account for the VM bit (if the real-mode CS looked like RPL 0). A fault would get stuck in a loop because it couldn't exit to the signal handling code.
Quoted 2 lines
Hmm. I think we'd want a big comment about that code then, and how it is only used for user-space (including vm86 mode).
I think that a very tiny comment might be sufficient, because I'm planning to resubmit my patch series that removes all the work_xyz asm entirely as soon as Brian's patches land in -tip :) I've just been waiting for v86 mode to GTFO of the asm loop so the rest could be done in C. I had a small patch to deal with vm86, but Brian's is much better, so I decided to hold off.
--Andy
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
In reply to Brian Gerstarch/x86/include/asm/vm86.h static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) · line 73
Quoted 5 lines · Brian Gerst
arch/x86/include/asm/vm86.h +2
-0+static inline void save_v86_state (struct kernel_vm86_regs *,int ) { } +
So this is not a valid inline function and the patches were clearly not built with !VM86 such as 64-bit defconfig:
In file included from arch/x86/kernel/signal.c:34:0:
./arch/x86/include/asm/vm86.h: In function ‘save_v86_state’:
./arch/x86/include/asm/vm86.h:70:42: error: parameter name omitted
static inline void save_v86_state(struct kernel_vm86_regs *, int) { }
./arch/x86/include/asm/vm86.h:70:42: error: parameter name omitted
I fixed this up.
Thanks,
Ingo
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 12 lines · Ingo Molnar
arch/x86/include/asm/vm86.h
Quoted 5 lines · Brian Gerst
arch/x86/include/asm/vm86.h +2
-0+static inline void save_v86_state (struct kernel_vm86_regs *,int ) { } +So this is not a valid inline function and the patches were clearly not built with !VM86 such as 64-bit defconfig:
Quoted 7 lines
In file included from
arch/x86/kernel/signal.c:34:0:
./arch/x86/include/asm/vm86.h: In function ‘save_v86_state’:
./arch/x86/include/asm/vm86.h:70:42: error: parameter name omitted
static inline voidsave_v86_state(struct kernel_vm86_regs *, int){ }
./arch/x86/include/asm/vm86.h:70:42: error: parameter name omittedI fixed this up.
Another build fix was needed for:
arch/x86/mm/fault.c: In function ‘check_v8086_mode’:
arch/x86/mm/fault.c:319:39: error: ‘struct thread_struct’ has no member named ‘vm86’
that's on 32-bit defconfig.
Thanks,
Ingo
============>
arch/x86/mm/fault.c +2 -0
@@ -302,6 +302,7 @@ static inline void check_v8086_mode(struct pt_regs *regs, unsigned long address, struct task_struct *tsk) { +#ifdef CONFIG_VM86 unsigned long bit;if (!v8086_mode (regs) || !tsk->thread.vm86)
@@ -310,6 +311,7 @@ check_v8086_mode(struct pt_regs *regs, unsigned long address, bit = (address -0xA0000 ) >>PAGE_SHIFT ;if (bit <32 ) tsk->thread.vm86->screen_bitmap |=1 << bit; +#endif }static bool low_pfn (unsigned long pfn)
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 9 lines · Ingo Molnar
Quoted 2 lines
I fixed this up.
Another build fix was needed for:
arch/x86/mm/fault.c: In function ‘check_v8086_mode’:
arch/x86/mm/fault.c:319:39: error: ‘struct thread_struct’ has no member named ‘vm86’that's on 32-bit defconfig.
A third one occurs in:
drivers/scsi/dpt_i2o.c:1933:7: error: ‘CPU_386’ undeclared (first use in this function) drivers/scsi/dpt_i2o.c:1936:7: error: ‘CPU_486’ undeclared (first use in this function) drivers/scsi/dpt_i2o.c:1939:7: error: ‘CPU_586’ undeclared (first use in this function)
due to the include file changes.
I fixed this up too.
Thanks,
Ingo
Re: [PATCH 4/8] x86/vm86: Use the normal pt_regs area for vm86
Quoted 19 lines · Ingo Molnar
Quoted 9 lines · Ingo Molnar
Quoted 2 lines
I fixed this up.
Another build fix was needed for:
arch/x86/mm/fault.c: In function ‘check_v8086_mode’:
arch/x86/mm/fault.c:319:39: error: ‘struct thread_struct’ has no member named ‘vm86’that's on 32-bit defconfig.
A third one occurs in:
drivers/scsi/dpt_i2o.c:1933:7: error: ‘CPU_386’ undeclared (first use in this function)drivers/scsi/dpt_i2o.c:1936:7: error: ‘CPU_486’ undeclared (first use in this function)drivers/scsi/dpt_i2o.c:1939:7: error: ‘CPU_586’ undeclared (first use in this function)
Quoted 7 lines
due to the include file changes.
I fixed this up too.
Thanks,
Ingo
I'll admit that I forgot to test the 64-bit build, but the SCSI driver... WTF is it doing with the cpu type?
--
Brian Gerst
tip-bot for Brian Gerst
merge bot[tip:x86/asm] x86/vm86: Use the normal pt_regs area for vm86
In reply to Brian Gerstx86/vm86: Use the normal pt_regs area for vm86
Commit-ID: 5ed92a8ab71f8865ba07811429c988c72299b315 Gitweb: http://git.kernel.org/tip/5ed92a8ab71f8865ba07811429c988c72299b315 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:19 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:09 +0200
x86/vm86: Use the normal pt_regs area for vm86
Change to use the normal pt_regs area to enter and exit vm86 mode. This is done by increasing the padding at the top of the stack to make room for the extra vm86 segment slots in the IRET frame. It then saves the 32-bit regs in the off-stack vm86 data, and copies in the vm86 regs. Exiting back to 32-bit mode does the reverse. This allows removing the hacks to jump directly into the exit asm code due to having to change the stack pointer. Returning normally from the vm86 syscall and the exception handlers allows things like ptrace and auditing to work properly.
--- arch/x86/entry/entry_32.S | 24 +------- arch/x86/include/asm/thread_info.h | 11 ++-- arch/x86/include/asm/vm86.h | 6 +- arch/x86/kernel/signal.c | 3 + arch/x86/kernel/vm86_32.c | 110 +++++++++++++++---------------------- 5 files changed, 60 insertions(+), 94 deletions(-)
arch/x86/entry/entry_32.S +1 -23
@@ -525,34 +525,12 @@ work_resched: work_notifysig: # deal with pending signals and # notify-resume requests -#ifdef CONFIG_VM86 - testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) - movl %esp, %eax - jnz work_notifysig_v86 # returning to kernel-space or - # vm86-space -1: -#else - movl %esp, %eax -#endif TRACE_IRQS_ON ENABLE_INTERRUPTS(CLBR_NONE) - movb PT_CS(%esp), %bl - andb $SEGMENT_RPL_MASK, %bl - cmpb $USER_RPL, %bl - jb resume_kernel + movl %esp, %eax xorl %edx, %edx call do_notify_resume jmp resume_userspace - -#ifdef CONFIG_VM86 - ALIGN -work_notifysig_v86: - pushl %ecx # save ti_flags for do_notify_resume - call save_v86_state # %eax contains pt_regs pointer - popl %ecx - movl %eax, %esp - jmp 1b -#endif END(work_pending) # perform syscall exit tracing
arch/x86/include/asm/thread_info.h +7 -4
@@ -27,14 +27,17 @@* Without this offset, that can result in a page fault. (We are * careful that, in this case, the value we read doesn't matter.) * -* In vm86 mode, the hardware frame is much longer still, but we neither -* access the extra members from NMI context, nor do we write such a -* frame at sp0 at all. +* In vm86 mode, the hardware frame is much longer still, so add 16 +* bytes to make room for the real-mode segments. * * x86_64 has a fixed-length stack frame. */ #ifdef CONFIG_X86_32 -# define TOP_OF_KERNEL_STACK_PADDING 8 +# ifdef CONFIG_VM86 +# define TOP_OF_KERNEL_STACK_PADDING 16 +# else +# define TOP_OF_KERNEL_STACK_PADDING 8 +# endif #else # define TOP_OF_KERNEL_STACK_PADDING 0#endif
arch/x86/include/asm/vm86.h +4 -2
@@ -29,7 +29,7 @@ struct kernel_vm86_regs {struct vm86 {struct vm86plus_struct __user *vm86_info; -struct pt_regs *regs32; +struct pt_regs regs32;unsigned long v86flags;unsigned long v86mask;unsigned long saved_sp0;
@@ -46,7 +46,7 @@ struct vm86 {void handle_vm86_fault (struct kernel_vm86_regs *,long );int handle_vm86_trap (struct kernel_vm86_regs *,long ,int ); -struct pt_regs *save_v86_state (struct kernel_vm86_regs *); +void save_v86_state (struct kernel_vm86_regs *,int );struct task_struct ;void release_vm86_irqs (struct task_struct *);
@@ -69,6 +69,8 @@ static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) return 0; } +static inline void save_v86_state (struct kernel_vm86_regs *a,int b) { } +#define free_vm86 (t) do { } while(0)#endif /* CONFIG_VM86 */
arch/x86/kernel/signal.c +3 -0
@@ -635,6 +635,9 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)bool stepping, failed;struct fpu *fpu = ¤t->thread.fpu; +if (v8086_mode (regs)) +save_v86_state ((struct kernel_vm86_regs *) regs,VM86_SIGNAL ); +/* Are we from a system call? */ if (syscall_get_nr (current, regs) >=0 ) {/* If so, check system call restarting.. */
arch/x86/kernel/vm86_32.c +45 -65
237 lines not on this page · raw message
PATCH 5/8 x86/vm86: Add a separate config option for hardware IRQ handling
In reply to Brian GerstAllow disabling hardware interrupt support for vm86.
--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/irq_vectors.h | 10 ---------- arch/x86/include/asm/vm86.h | 20 ++++++++++++++++++-- arch/x86/kernel/vm86_32.c | 12 ++++++++++-- 4 files changed, 36 insertions(+), 14 deletions(-)
arch/x86/Kconfig +8 -0
@@ -1067,6 +1067,14 @@ config VM86 bool default X86_LEGACY_VM86 +config VM86_INTERRUPTS + bool "Enable VM86 interrupt support" + default y + depends on VM86 + ---help--- + This option allows VM86 programs to request interrupts for + real mode hardware drivers. + config X86_16BIT bool "Enable support for 16-bit segments" if EXPERT default y
arch/x86/include/asm/irq_vectors.h +0 -10
@@ -117,16 +117,6 @@#define FPU_IRQ 13 -#define FIRST_VM86_IRQ 3 -#define LAST_VM86_IRQ 15 - -#ifndef __ASSEMBLY__ -static inline int invalid_vm86_irq (int irq) -{ -return irq <FIRST_VM86_IRQ || irq >LAST_VM86_IRQ ; -} -#endif -/* * Size the maximum number of interrupts. *
arch/x86/include/asm/vm86.h +18 -2
@@ -49,7 +49,6 @@ int handle_vm86_trap(struct kernel_vm86_regs *, long, int);void save_v86_state (struct kernel_vm86_regs *,int );struct task_struct ; -void release_vm86_irqs (struct task_struct *);#define free_vm86 (t) do { \ struct thread_struct *__t = (t); \
@@ -62,7 +61,6 @@ void release_vm86_irqs(struct task_struct *);#else #define handle_vm86_fault (a, b) -#define release_vm86_irqs (a)static inline int handle_vm86_trap (struct kernel_vm86_regs *a,long b,int c) {
@@ -75,4 +73,22 @@ static inline void save_v86_state(struct kernel_vm86_regs *, int) { }#endif /* CONFIG_VM86 */ +#ifdef CONFIG_VM86_INTERRUPTS + +#define FIRST_VM86_IRQ 3 +#define LAST_VM86_IRQ 15 + +static inline int invalid_vm86_irq (int irq) +{ +return irq <FIRST_VM86_IRQ || irq >LAST_VM86_IRQ ; +} + +void release_vm86_irqs (struct task_struct *); + +#else /* CONFIG_VM86_INTERRUPTS */ + +static inline void release_vm86_irqs (struct task_struct *tsk) { } + +#endif /* CONFIG_VM86_INTERRUPTS */ +#endif /* _ASM_X86_VM86_H */
arch/x86/kernel/vm86_32.c +10 -2
@@ -189,8 +189,15 @@ out: } - +#ifdef CONFIG_VM86_INTERRUPTS static int do_vm86_irq_handling (int subfunction,int irqnumber); +#else +static inline int do_vm86_irq_handling (int subfunction,int irqnumber) +{ +return -EINVAL ; +} +#endif +static long do_sys_vm86 (struct vm86plus_struct __user *v86,bool plus); SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
@@ -713,6 +720,7 @@ simulate_sigsegv:save_v86_state (regs,VM86_UNKNOWN ); } +#ifdef CONFIG_VM86_INTERRUPTS /* ---------------- vm86 special IRQ passing stuff ----------------- */ #define VM86_IRQNAME "vm86irq"
@@ -828,4 +836,4 @@ static int do_vm86_irq_handling(int subfunction, int irqnumber) }return -EINVAL ; } - +#endif
Signature · 1 line
2.4.3
Re: [PATCH 5/8] x86/vm86: Add a separate config option for hardware IRQ handling
Quoted 15 lines · Brian Gerst
Allow disabling hardware interrupt support for vm86.
Signed-off-by Brian Gerst <[email protected]>--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/irq_vectors.h | 10 ---------- arch/x86/include/asm/vm86.h | 20 ++++++++++++++++++-- arch/x86/kernel/vm86_32.c | 12 ++++++++++-- 4 files changed, 36 insertions(+), 14 deletions(-)arch/x86/Kconfig +0
-0
arch/x86/Kconfig config VM86 · line 1076
Quoted 10 lines
arch/x86/Kconfig +7
-0@@ -1067,6 +1067,14 @@ config VM86 bool default X86_LEGACY_VM86 +config VM86_INTERRUPTS + bool "Enable VM86 interrupt support" + default y + depends on VM86 + ---help--- + This option allows VM86 programs to request interrupts for + real mode hardware drivers.
So I'm wondering what the justification for this is. People can disable vm86 already via CONFIG_X86_LEGACY_VM86. The extra config just uglifies the code unnecessarily.
Thanks,
Ingo
Re: [PATCH 5/8] x86/vm86: Add a separate config option for hardware IRQ handling
Quoted 33 lines · Ingo Molnar
Quoted 15 lines · Brian Gerst
Allow disabling hardware interrupt support for vm86.
Signed-off-by Brian Gerst <[email protected]>--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/irq_vectors.h | 10 ---------- arch/x86/include/asm/vm86.h | 20 ++++++++++++++++++-- arch/x86/kernel/vm86_32.c | 12 ++++++++++-- 4 files changed, 36 insertions(+), 14 deletions(-)arch/x86/Kconfig +0
-0arch/x86/Kconfig config VM86 · line 1076
Quoted 10 lines
arch/x86/Kconfig +7
-0@@ -1067,6 +1067,14 @@ config VM86 bool default X86_LEGACY_VM86 +config VM86_INTERRUPTS + bool "Enable VM86 interrupt support" + default y + depends on VM86 + ---help--- + This option allows VM86 programs to request interrupts for + real mode hardware drivers.So I'm wondering what the justification for this is. People can disable vm86 already via
CONFIG_X86_LEGACY_VM86. The extra config just uglifies the code unnecessarily.
Quoted 3 lines
Thanks,
Ingo
Disabling even less-used code that could have system stability impact. We've discouraged user-mode drivers for a very long time. Ironically, other than being configured through the vm86 syscall, there isn't really anything vm86-specific about it. All it does is register an IRQ handler that sends a signal to the task.
--
Brian Gerst
Re: [PATCH 5/8] x86/vm86: Add a separate config option for hardware IRQ handling
Quoted 36 lines · Brian Gerst
Quoted 35 lines · Ingo Molnar
Quoted 15 lines · Brian Gerst
Allow disabling hardware interrupt support for vm86.
Signed-off-by Brian Gerst <[email protected]>--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/irq_vectors.h | 10 ---------- arch/x86/include/asm/vm86.h | 20 ++++++++++++++++++-- arch/x86/kernel/vm86_32.c | 12 ++++++++++-- 4 files changed, 36 insertions(+), 14 deletions(-)arch/x86/Kconfig +0
-0arch/x86/Kconfig config VM86 · line 1076
Quoted 10 lines
arch/x86/Kconfig +7
-0@@ -1067,6 +1067,14 @@ config VM86 bool default X86_LEGACY_VM86 +config VM86_INTERRUPTS + bool "Enable VM86 interrupt support" + default y + depends on VM86 + ---help--- + This option allows VM86 programs to request interrupts for + real mode hardware drivers.So I'm wondering what the justification for this is. People can disable vm86 already via
CONFIG_X86_LEGACY_VM86. The extra config just uglifies the code unnecessarily.Thanks,
Quoted 7 lines
Quoted 1 line
Ingo
Disabling even less-used code that could have system stability impact. We've discouraged user-mode drivers for a very long time. Ironically, other than being configured through the vm86 syscall, there isn't really anything vm86-specific about it. All it does is register an IRQ handler that sends a signal to the task.
So is this actually used by anything? Could we get away with disabling it, just to see whether anything cares?
Thanks,
Ingo
Re: [PATCH 5/8] x86/vm86: Add a separate config option for hardware IRQ handling
Quoted 41 lines · Ingo Molnar
Quoted 38 lines · Brian Gerst
Quoted 36 lines · Ingo Molnar
Quoted 15 lines · Brian Gerst
Allow disabling hardware interrupt support for vm86.
Signed-off-by Brian Gerst <[email protected]>--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/irq_vectors.h | 10 ---------- arch/x86/include/asm/vm86.h | 20 ++++++++++++++++++-- arch/x86/kernel/vm86_32.c | 12 ++++++++++-- 4 files changed, 36 insertions(+), 14 deletions(-)arch/x86/Kconfig +0
-0arch/x86/Kconfig config VM86 · line 1076
Quoted 10 lines
arch/x86/Kconfig +7
-0@@ -1067,6 +1067,14 @@ config VM86 bool default X86_LEGACY_VM86 +config VM86_INTERRUPTS + bool "Enable VM86 interrupt support" + default y + depends on VM86 + ---help--- + This option allows VM86 programs to request interrupts for + real mode hardware drivers.So I'm wondering what the justification for this is. People can disable vm86 already via
CONFIG_X86_LEGACY_VM86. The extra config just uglifies the code unnecessarily.Thanks,
Ingo
Quoted 8 lines
Quoted 5 lines
Disabling even less-used code that could have system stability impact. We've discouraged user-mode drivers for a very long time. Ironically, other than being configured through the vm86 syscall, there isn't really anything vm86-specific about it. All it does is register an IRQ handler that sends a signal to the task.
So is this actually used by anything? Could we get away with disabling it, just to see whether anything cares?
My best guess would be some very old X11 drivers that needed interrupts to run the Video BIOS code.
--
Brian Gerst
Re: [PATCH 5/8] x86/vm86: Add a separate config option for hardware IRQ handling
Quoted 11 lines · Brian Gerst
Quoted 8 lines
Quoted 5 lines
Disabling even less-used code that could have system stability impact. We've discouraged user-mode drivers for a very long time. Ironically, other than being configured through the vm86 syscall, there isn't really anything vm86-specific about it. All it does is register an IRQ handler that sends a signal to the task.
So is this actually used by anything? Could we get away with disabling it, just to see whether anything cares?
My best guess would be some very old X11 drivers that needed interrupts to run the Video BIOS code.
So let's keep it - but not complicate it with another layer of disabling logic. People that rely on legacies will enable vm86 as a single block - they won't necessarily know how deeply they rely on it.
What _would_ be useful is to have a 3-mode vm86 sysctl:
1: enabled
0: disabled
-1: disabled permanently (one-shot disabling after bootup)
That way a distro can permanently disable vm86 for a particular bootup by setting it to -1 in /etc/sysctl.conf.
The kernel should default that setting to '0'.
Thanks,
Ingo
tip-bot for Ingo Molnar
merge bot[tip:x86/asm] x86/vm86: Move the vm86 IRQ definitions to vm86.h
In reply to Brian Gerstx86/vm86: Move the vm86 IRQ definitions to vm86.h
Commit-ID: af3e565a8542c4be699a0403b88fd6c691f5914f Gitweb: http://git.kernel.org/tip/af3e565a8542c4be699a0403b88fd6c691f5914f Author: Ingo Molnar <[email protected]> AuthorDate: Fri, 31 Jul 2015 10:59:20 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:10 +0200
x86/vm86: Move the vm86 IRQ definitions to vm86.h
Move vm86 specific definitions from irq_vectors.h to vm86.h.
Based on patch from Brian Gerst.
Originally-from: Brian Gerst <[email protected]>
--- arch/x86/include/asm/irq_vectors.h | 10 ---------- arch/x86/include/asm/vm86.h | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-)
arch/x86/include/asm/irq_vectors.h +0 -10
@@ -117,16 +117,6 @@#define FPU_IRQ 13 -#define FIRST_VM86_IRQ 3 -#define LAST_VM86_IRQ 15 - -#ifndef __ASSEMBLY__ -static inline int invalid_vm86_irq (int irq) -{ -return irq <FIRST_VM86_IRQ || irq >LAST_VM86_IRQ ; -} -#endif -/* * Size the maximum number of interrupts. *
arch/x86/include/asm/vm86.h +14 -1
@@ -49,7 +49,6 @@ int handle_vm86_trap(struct kernel_vm86_regs *, long, int);void save_v86_state (struct kernel_vm86_regs *,int );struct task_struct ; -void release_vm86_irqs (struct task_struct *);#define free_vm86 (t) do { \ struct thread_struct *__t = (t); \
@@ -59,6 +58,20 @@ void release_vm86_irqs(struct task_struct *); } \ }while (0 ) +/* +* Support for VM86 programs to request interrupts for +* real mode hardware drivers: + */ +#define FIRST_VM86_IRQ 3 +#define LAST_VM86_IRQ 15 + +static inline int invalid_vm86_irq (int irq) +{ +return irq <FIRST_VM86_IRQ || irq >LAST_VM86_IRQ ; +} + +void release_vm86_irqs (struct task_struct *); +#else #define handle_vm86_fault (a, b)
PATCH 6/8 x86/vm86: Clean up vm86.h includes
In reply to Brian Gerstvm86.h was being implicitly included in alot of places via processor.h, which in turn got it from math_emu.h. Break that chain and explicitly include vm86.h in all files that need it. Also remove unused vm86 field from math_emu_info.
--- arch/x86/include/asm/math_emu.h | 6 +----- arch/x86/include/asm/syscalls.h | 1 + arch/x86/kernel/process_32.c | 1 + arch/x86/kernel/signal.c | 1 + arch/x86/kernel/traps.c | 1 + arch/x86/kernel/vm86_32.c | 1 + arch/x86/math-emu/get_address.c | 1 + arch/x86/mm/fault.c | 1 + 8 files changed, 8 insertions(+), 5 deletions(-)
arch/x86/include/asm/math_emu.h +1 -5
@@ -2,7 +2,6 @@#define _ASM_X86_MATH_EMU_H#include <asm/ptrace.h> -#include <asm/vm86.h> /* This structure matches the layout of the data saved to the stack following a device-not-present interrupt, part of it saved
@@ -10,9 +9,6 @@*/ struct math_emu_info {long ___orig_eip; -union { -struct pt_regs *regs; -struct kernel_vm86_regs *vm86; - }; +struct pt_regs *regs; };#endif /* _ASM_X86_MATH_EMU_H */
arch/x86/include/asm/syscalls.h +1 -0
@@ -37,6 +37,7 @@ asmlinkage long sys_get_thread_area(struct user_desc __user *);asmlinkage unsigned long sys_sigreturn (void );/* kernel/vm86_32.c */ +struct vm86_struct ;asmlinkage long sys_vm86old (struct vm86_struct __user *);asmlinkage long sys_vm86 (unsigned long ,unsigned long );
arch/x86/kernel/process_32.c +1 -0
@@ -53,6 +53,7 @@#include <asm/syscalls.h> #include <asm/debugreg.h> #include <asm/switch_to.h> +#include <asm/vm86.h> asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
arch/x86/kernel/signal.c +1 -0
@@ -31,6 +31,7 @@#include <asm/vdso.h> #include <asm/mce.h> #include <asm/sighandling.h> +#include <asm/vm86.h> #ifdef CONFIG_X86_64 #include <asm/proto.h>
arch/x86/kernel/traps.c +1 -0
@@ -62,6 +62,7 @@#include <asm/fpu/xstate.h> #include <asm/trace/mpx.h> #include <asm/mpx.h> +#include <asm/vm86.h> #ifdef CONFIG_X86_64 #include <asm/x86_init.h>
arch/x86/kernel/vm86_32.c +1 -0
@@ -51,6 +51,7 @@#include <asm/tlbflush.h> #include <asm/irq.h> #include <asm/traps.h> +#include <asm/vm86.h> /* * Known problems:
arch/x86/math-emu/get_address.c +1 -0
@@ -21,6 +21,7 @@#include <asm/uaccess.h> #include <asm/desc.h> +#include <asm/vm86.h> #include "fpu_system.h" #include "exception.h"
arch/x86/mm/fault.c +1 -0
@@ -21,6 +21,7 @@#include <asm/kmemcheck.h> /* kmemcheck_*(), ... */ #include <asm/fixmap.h> /* VSYSCALL_ADDR */ #include <asm/vsyscall.h> /* emulate_vsyscall */ +#include <asm/vm86.h> /* struct vm86 */ #define CREATE_TRACE_POINTS #include <asm/trace/exceptions.h>
Signature · 1 line
2.4.3
tip-bot for Brian Gerst
merge bot[tip:x86/asm] x86/vm86: Clean up vm86.h includes
x86/vm86: Clean up vm86.h includes
Commit-ID: ba3e127ec105e790eeec4034d9769e018e4a1b54 Gitweb: http://git.kernel.org/tip/ba3e127ec105e790eeec4034d9769e018e4a1b54 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:21 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:10 +0200
x86/vm86: Clean up vm86.h includes
vm86.h was being implicitly included in alot of places via processor.h, which in turn got it from math_emu.h. Break that chain and explicitly include vm86.h in all files that need it. Also remove unused vm86 field from math_emu_info.
--- arch/x86/include/asm/math_emu.h | 6 +----- arch/x86/include/asm/syscalls.h | 1 + arch/x86/kernel/process_32.c | 1 + arch/x86/kernel/signal.c | 1 + arch/x86/kernel/traps.c | 1 + arch/x86/kernel/vm86_32.c | 1 + arch/x86/math-emu/get_address.c | 1 + arch/x86/mm/fault.c | 1 + drivers/scsi/dpt_i2o.c | 3 +++ 9 files changed, 11 insertions(+), 5 deletions(-)
arch/x86/include/asm/math_emu.h +1 -5
@@ -2,7 +2,6 @@#define _ASM_X86_MATH_EMU_H#include <asm/ptrace.h> -#include <asm/vm86.h> /* This structure matches the layout of the data saved to the stack following a device-not-present interrupt, part of it saved
@@ -10,9 +9,6 @@*/ struct math_emu_info {long ___orig_eip; -union { -struct pt_regs *regs; -struct kernel_vm86_regs *vm86; - }; +struct pt_regs *regs; };#endif /* _ASM_X86_MATH_EMU_H */
arch/x86/include/asm/syscalls.h +1 -0
@@ -37,6 +37,7 @@ asmlinkage long sys_get_thread_area(struct user_desc __user *);asmlinkage unsigned long sys_sigreturn (void );/* kernel/vm86_32.c */ +struct vm86_struct ;asmlinkage long sys_vm86old (struct vm86_struct __user *);asmlinkage long sys_vm86 (unsigned long ,unsigned long );
arch/x86/kernel/process_32.c +1 -0
@@ -53,6 +53,7 @@#include <asm/syscalls.h> #include <asm/debugreg.h> #include <asm/switch_to.h> +#include <asm/vm86.h> asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
arch/x86/kernel/signal.c +1 -0
@@ -31,6 +31,7 @@#include <asm/vdso.h> #include <asm/mce.h> #include <asm/sighandling.h> +#include <asm/vm86.h> #ifdef CONFIG_X86_64 #include <asm/proto.h>
arch/x86/kernel/traps.c +1 -0
@@ -62,6 +62,7 @@#include <asm/fpu/xstate.h> #include <asm/trace/mpx.h> #include <asm/mpx.h> +#include <asm/vm86.h> #ifdef CONFIG_X86_64 #include <asm/x86_init.h>
arch/x86/kernel/vm86_32.c +1 -0
@@ -51,6 +51,7 @@#include <asm/tlbflush.h> #include <asm/irq.h> #include <asm/traps.h> +#include <asm/vm86.h> /* * Known problems:
arch/x86/math-emu/get_address.c +1 -0
@@ -21,6 +21,7 @@#include <asm/uaccess.h> #include <asm/desc.h> +#include <asm/vm86.h> #include "fpu_system.h" #include "exception.h"
arch/x86/mm/fault.c +1 -0
@@ -20,6 +20,7 @@#include <asm/kmemcheck.h> /* kmemcheck_*(), ... */ #include <asm/fixmap.h> /* VSYSCALL_ADDR */ #include <asm/vsyscall.h> /* emulate_vsyscall */ +#include <asm/vm86.h> /* struct vm86 */ #define CREATE_TRACE_POINTS #include <asm/trace/exceptions.h>
drivers/scsi/dpt_i2o.c +3 -0
@@ -1924,6 +1924,9 @@ static void adpt_alpha_info(sysInfo_S* si)#endif #if defined __i386__ + +#include <uapi/asm/vm86.h> +static void adpt_i386_info (sysInfo_S * si) {// This is all the info we need for now
Re: [tip:x86/asm] x86/vm86: Clean up vm86.h includes
Quoted 32 lines · tip-bot for Brian Gerst
Commit-ID: ba3e127ec105e790eeec4034d9769e018e4a1b54 Gitweb: http://git.kernel.org/tip/ba3e127ec105e790eeec4034d9769e018e4a1b54 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:21 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:10 +0200x86/vm86: Clean up
vm86.hincludes
vm86.hwas being implicitly included in alot of places viaprocessor.h, which in turn got it frommath_emu.h. Break that chain and explicitly includevm86.hin all files that need it. Also remove unused vm86 field frommath_emu_info.Signed-off-by Brian Gerst <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Borislav Petkov <[email protected]>Cc Denys Vlasenko <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>[ Fixed build failure. ]Signed-off-by Ingo Molnar <[email protected]>drivers/scsi/dpt_i2o.c +0
-0
drivers/scsi/dpt_i2o.c static void adpt_alpha_info(sysInfo_S* si) · line 1932
Quoted 9 lines
drivers/scsi/dpt_i2o.c +3
-0@@ -1924,6 +1924,9 @@ static void adpt_alpha_info(sysInfo_S* si)#endif #if defined __i386__ + +#include <uapi/asm/vm86.h> +static void adpt_i386_info (sysInfo_S * si) {// This is all the info we need for now
It would have been better to just remove the the CPU_* defines from this driver. boot_cpu_data.x86 is simply the family ID from CPUID, and nowhere else uses defines like this.
--
Brian Gerst
Re: [tip:x86/asm] x86/vm86: Clean up vm86.h includes
Quoted 36 lines · Brian Gerst
Quoted 34 lines · tip-bot for Brian Gerst
Commit-ID: ba3e127ec105e790eeec4034d9769e018e4a1b54 Gitweb: http://git.kernel.org/tip/ba3e127ec105e790eeec4034d9769e018e4a1b54 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:21 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:10 +0200x86/vm86: Clean up
vm86.hincludes
vm86.hwas being implicitly included in alot of places viaprocessor.h, which in turn got it frommath_emu.h. Break that chain and explicitly includevm86.hin all files that need it. Also remove unused vm86 field frommath_emu_info.Signed-off-by Brian Gerst <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Borislav Petkov <[email protected]>Cc Denys Vlasenko <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>[ Fixed build failure. ]Signed-off-by Ingo Molnar <[email protected]>drivers/scsi/dpt_i2o.c +0
-0@@ -1924,6 +1924,9 @@ static void adpt_alpha_info(sysInfo_S* si)#endif
Quoted 11 lines
drivers/scsi/dpt_i2o.c static void adpt_alpha_info(sysInfo_S* si) · line 1932
Quoted 7 lines
drivers/scsi/dpt_i2o.c +3
-0#if defined __i386__ + +#include <uapi/asm/vm86.h> +static void adpt_i386_info (sysInfo_S * si) {// This is all the info we need for now It would have been better to just remove the the CPU_* defines from this driver. boot_cpu_data.x86 is simply the family ID from CPUID, and nowhere else uses defines like this.
Please send a followup patch for that.
Thanks,
Ingo
PATCH 7/8 x86/vm86: Rename vm86->vm86_info to user_vm86
In reply to Brian GerstMake it clearer that this is the pointer to the userspace vm86 state area.
--- arch/x86/include/asm/vm86.h | 2 +- arch/x86/kernel/vm86_32.c | 70 +++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 35 deletions(-)
arch/x86/include/asm/vm86.h +1 -1
@@ -28,7 +28,7 @@ struct kernel_vm86_regs { };struct vm86 { -struct vm86plus_struct __user *vm86_info; +struct vm86plus_struct __user *user_vm86;struct pt_regs regs32;unsigned long v86flags;unsigned long v86mask;
arch/x86/kernel/vm86_32.c +36 -34
132 lines not on this page · raw message
Signature · 1 line
2.4.3
tip-bot for Brian Gerst
merge bot[tip:x86/asm] x86/vm86: Rename vm86->vm86_info to user_vm86
x86/vm86: Rename vm86->vm86_info to user_vm86
Commit-ID: 1342635638cba9b7c8eac776da5e54390d14d313 Gitweb: http://git.kernel.org/tip/1342635638cba9b7c8eac776da5e54390d14d313 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:22 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:11 +0200
x86/vm86: Rename vm86->vm86_info to user_vm86
Make it clearer that this is the pointer to the userspace vm86 state area.
--- arch/x86/include/asm/vm86.h | 2 +- arch/x86/kernel/vm86_32.c | 70 +++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 35 deletions(-)
arch/x86/include/asm/vm86.h +1 -1
@@ -28,7 +28,7 @@ struct kernel_vm86_regs { };struct vm86 { -struct vm86plus_struct __user *vm86_info; +struct vm86plus_struct __user *user_vm86;struct pt_regs regs32;unsigned long v86flags;unsigned long v86mask;
arch/x86/kernel/vm86_32.c +36 -34
132 lines not on this page · raw message
PATCH 8/8 x86/vm86: Rename vm86->v86flags and v86mask
In reply to Brian GerstRename v86flags to veflags, and v86mask to veflags_mask.
--- arch/x86/include/asm/vm86.h | 4 ++-- arch/x86/kernel/vm86_32.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-)
arch/x86/include/asm/vm86.h +2 -2
@@ -30,8 +30,8 @@ struct kernel_vm86_regs {struct vm86 {struct vm86plus_struct __user *user_vm86;struct pt_regs regs32; -unsigned long v86flags; -unsigned long v86mask; +unsigned long veflags; +unsigned long veflags_mask;unsigned long saved_sp0;unsigned long flags;
arch/x86/kernel/vm86_32.c +10 -10
@@ -80,8 +80,8 @@/* * virtual flags (16 and 32-bit versions) */ -#define VFLAGS (*(unsigned short *)&(current->thread.vm86->v86flags)) -#define VEFLAGS (current->thread.vm86->v86flags) +#define VFLAGS (*(unsigned short *)&(current->thread.vm86->veflags)) +#define VEFLAGS (current->thread.vm86->veflags)#define set_flags (X , new, mask) \ ((X) = ((X) & ~(mask)) | ((new) & (mask)))
@@ -108,7 +108,7 @@ void save_v86_state(struct kernel_vm86_regs *regs, int retval)pr_alert ("no user_vm86: BAD\n" );do_exit (SIGSEGV ); } -set_flags (regs->pt.flags,VEFLAGS ,X86_EFLAGS_VIF | vm86->v86mask); +set_flags (regs->pt.flags,VEFLAGS ,X86_EFLAGS_VIF | vm86->veflags_mask); user = vm86->user_vm86; if (!access_ok(VERIFY_WRITE, user, vm86->vm86plus.is_vm86pus ?
@@ -315,16 +315,16 @@ static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool plus)switch (vm86->cpu_type) {case CPU_286 : - vm86->v86mask =0 ; + vm86->veflags_mask =0 ;break ;case CPU_386 : - vm86->v86mask =X86_EFLAGS_NT |X86_EFLAGS_IOPL ; + vm86->veflags_mask =X86_EFLAGS_NT |X86_EFLAGS_IOPL ;break ;case CPU_486 : - vm86->v86mask =X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ; + vm86->veflags_mask =X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ;break ;default : - vm86->v86mask =X86_EFLAGS_ID |X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ; + vm86->veflags_mask =X86_EFLAGS_ID |X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ;break ; }
@@ -384,7 +384,7 @@ static inline void clear_AC(struct kernel_vm86_regs *regs)static inline void set_vflags_long (unsigned long flags,struct kernel_vm86_regs *regs) { -set_flags (VEFLAGS , flags, current->thread.vm86->v86mask); +set_flags (VEFLAGS , flags, current->thread.vm86->veflags_mask);set_flags (regs->pt.flags, flags,SAFE_MASK );if (flags &X86_EFLAGS_IF )set_IF (regs);
@@ -394,7 +394,7 @@ static inline void set_vflags_long(unsigned long flags, struct kernel_vm86_regsstatic inline void set_vflags_short (unsigned short flags,struct kernel_vm86_regs *regs) { -set_flags (VFLAGS , flags, current->thread.vm86->v86mask); +set_flags (VFLAGS , flags, current->thread.vm86->veflags_mask);set_flags (regs->pt.flags, flags,SAFE_MASK );if (flags &X86_EFLAGS_IF )set_IF (regs);
@@ -409,7 +409,7 @@ static inline unsigned long get_vflags(struct kernel_vm86_regs *regs)if (VEFLAGS &X86_EFLAGS_VIF ) flags |=X86_EFLAGS_IF ; flags |=X86_EFLAGS_IOPL ; -return flags | (VEFLAGS & current->thread.vm86->v86mask); +return flags | (VEFLAGS & current->thread.vm86->veflags_mask); }static inline int is_revectored (int nr,struct revectored_struct *bitmap)
Signature · 1 line
2.4.3
tip-bot for Brian Gerst
merge bot[tip:x86/asm] x86/vm86: Rename vm86->v86flags and v86mask
x86/vm86: Rename vm86->v86flags and v86mask
Commit-ID: decd275e62d5eef4b947fab89652fa6afdadf2f2 Gitweb: http://git.kernel.org/tip/decd275e62d5eef4b947fab89652fa6afdadf2f2 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 29 Jul 2015 01:41:23 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 31 Jul 2015 13:31:11 +0200
x86/vm86: Rename vm86->v86flags and v86mask
Rename v86flags to veflags, and v86mask to veflags_mask.
--- arch/x86/include/asm/vm86.h | 4 ++-- arch/x86/kernel/vm86_32.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-)
arch/x86/include/asm/vm86.h +2 -2
@@ -30,8 +30,8 @@ struct kernel_vm86_regs {struct vm86 {struct vm86plus_struct __user *user_vm86;struct pt_regs regs32; -unsigned long v86flags; -unsigned long v86mask; +unsigned long veflags; +unsigned long veflags_mask;unsigned long saved_sp0;unsigned long flags;
arch/x86/kernel/vm86_32.c +10 -10
@@ -80,8 +80,8 @@/* * virtual flags (16 and 32-bit versions) */ -#define VFLAGS (*(unsigned short *)&(current->thread.vm86->v86flags)) -#define VEFLAGS (current->thread.vm86->v86flags) +#define VFLAGS (*(unsigned short *)&(current->thread.vm86->veflags)) +#define VEFLAGS (current->thread.vm86->veflags)#define set_flags (X , new, mask) \ ((X) = ((X) & ~(mask)) | ((new) & (mask)))
@@ -108,7 +108,7 @@ void save_v86_state(struct kernel_vm86_regs *regs, int retval)pr_alert ("no user_vm86: BAD\n" );do_exit (SIGSEGV ); } -set_flags (regs->pt.flags,VEFLAGS ,X86_EFLAGS_VIF | vm86->v86mask); +set_flags (regs->pt.flags,VEFLAGS ,X86_EFLAGS_VIF | vm86->veflags_mask); user = vm86->user_vm86; if (!access_ok(VERIFY_WRITE, user, vm86->vm86plus.is_vm86pus ?
@@ -308,16 +308,16 @@ static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool plus)switch (vm86->cpu_type) {case CPU_286 : - vm86->v86mask =0 ; + vm86->veflags_mask =0 ;break ;case CPU_386 : - vm86->v86mask =X86_EFLAGS_NT |X86_EFLAGS_IOPL ; + vm86->veflags_mask =X86_EFLAGS_NT |X86_EFLAGS_IOPL ;break ;case CPU_486 : - vm86->v86mask =X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ; + vm86->veflags_mask =X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ;break ;default : - vm86->v86mask =X86_EFLAGS_ID |X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ; + vm86->veflags_mask =X86_EFLAGS_ID |X86_EFLAGS_AC |X86_EFLAGS_NT |X86_EFLAGS_IOPL ;break ; }
@@ -377,7 +377,7 @@ static inline void clear_AC(struct kernel_vm86_regs *regs)static inline void set_vflags_long (unsigned long flags,struct kernel_vm86_regs *regs) { -set_flags (VEFLAGS , flags, current->thread.vm86->v86mask); +set_flags (VEFLAGS , flags, current->thread.vm86->veflags_mask);set_flags (regs->pt.flags, flags,SAFE_MASK );if (flags &X86_EFLAGS_IF )set_IF (regs);
@@ -387,7 +387,7 @@ static inline void set_vflags_long(unsigned long flags, struct kernel_vm86_regsstatic inline void set_vflags_short (unsigned short flags,struct kernel_vm86_regs *regs) { -set_flags (VFLAGS , flags, current->thread.vm86->v86mask); +set_flags (VFLAGS , flags, current->thread.vm86->veflags_mask);set_flags (regs->pt.flags, flags,SAFE_MASK );if (flags &X86_EFLAGS_IF )set_IF (regs);
@@ -402,7 +402,7 @@ static inline unsigned long get_vflags(struct kernel_vm86_regs *regs)if (VEFLAGS &X86_EFLAGS_VIF ) flags |=X86_EFLAGS_IF ; flags |=X86_EFLAGS_IOPL ; -return flags | (VEFLAGS & current->thread.vm86->v86mask); +return flags | (VEFLAGS & current->thread.vm86->veflags_mask); }static inline int is_revectored (int nr,struct revectored_struct *bitmap)