safe_hlt() & NMIs
Quoted 5 lines · On Tue, 14 Dec 2004 at 15:00:56 -0800 (PST) Linus Torvalds wrote:
Checking for kernel CS also requires checking that it's not vm86 mode, btw. So that's not just a "
regs->xcs&0xffff==__KERNEL_CS" either.But something like
Quoted 8 lines
static inline int kernel_mode(struct pt_regs *regs) { return !((regs->eflags & VM_MASK) | (regs->xcs & 3)); }should DTRT.
Can you pls double-check my thinking, and test?
There is already a user_mode() macro in asm-i386/ptrace.h but it's slow.
x86_64's macro is ugly but at least there's no logical-or in it.
Your i386 code is better, so how about applying this patch (boots/runs/is faster
on my tests):
Signed-off-by Chuck Ebbert <[email protected]>
include/asm-i386/ptrace.h 2004-12-17 16:59:39.956099664 -0500 renamed from include/asm-i386/ptrace.h 2004-10-19 15:28:18.000000000 -0400 +5 -1
@@ -55,7 +55,11 @@ struct pt_regs { #define PTRACE_SET_THREAD_AREA 26 #ifdef __KERNEL__ -#define user_mode(regs) ((VM_MASK & (regs)->eflags) || (3 & (regs)->xcs)) +static inline int kernel_mode(struct pt_regs *regs) +{ + return !((3 & (regs)->xcs) | (VM_MASK & (regs)->eflags)); +} +#define user_mode(regs) (!kernel_mode(regs)) #define instruction_pointer(regs) ((regs)->eip) #if defined(CONFIG_SMP) && defined(CONFIG_FRAME_POINTER) extern unsigned long profile_pc(struct pt_regs *regs);
--
Please take it as a sign of my infinite respect for you, that I insist on you doing all the work.
-- Rusty Russell