From: Chuck Ebbert <76306.1226@compuserve.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Andi Kleen <ak@suse.de>, Andrew Morton <akpm@osdl.org>
Subject: Re: [patch, 2.6.10-rc3] safe_hlt() & NMIs
Date: Fri, 17 Dec 2004 18:35:38 -0500 [thread overview]
Message-ID: <200412171837_MC3-1-9129-C5D@compuserve.com> (raw)
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
>
> 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 <76306.1226@compuserve.com>
--- linux-2.6.9.1/include/asm-i386/ptrace.h 2004-10-19 15:28:18.000000000 -0400
+++ linux-2.6.9.2/include/asm-i386/ptrace.h 2004-12-17 16:59:39.956099664 -0500
@@ -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
next reply other threads:[~2004-12-17 23:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-17 23:35 Chuck Ebbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-12-11 3:29 RCU question George Anzinger
2004-12-11 14:52 ` Zwane Mwaikambo
2004-12-11 16:32 ` Manfred Spraul
2004-12-11 16:52 ` George Anzinger
2004-12-12 2:53 ` Zwane Mwaikambo
2004-12-12 8:59 ` Manfred Spraul
2004-12-12 9:37 ` Andrea Arcangeli
2004-12-12 10:22 ` Manfred Spraul
2004-12-12 12:15 ` Andrea Arcangeli
2004-12-14 21:40 ` Lee Revell
2004-12-14 22:23 ` [patch, 2.6.10-rc3] safe_hlt() & NMIs Ingo Molnar
2004-12-14 22:47 ` Ingo Molnar
2004-12-14 23:09 ` Linus Torvalds
2004-12-15 8:52 ` Ingo Molnar
2004-12-15 15:44 ` Linus Torvalds
2004-12-15 16:35 ` Ingo Molnar
2004-12-16 0:37 ` Alan Cox
2004-12-16 1:58 ` Linus Torvalds
2004-12-16 14:51 ` Ingo Molnar
2004-12-16 15:08 ` Maciej W. Rozycki
2004-12-16 15:11 ` Ingo Molnar
2004-12-16 15:42 ` Maciej W. Rozycki
2004-12-16 15:54 ` Linus Torvalds
2004-12-16 2:10 ` Zwane Mwaikambo
2004-12-16 13:26 ` Alan Cox
2004-12-14 23:41 ` Andrea Arcangeli
2004-12-14 23:00 ` Linus Torvalds
2004-12-15 5:04 ` Andi Kleen
2004-12-15 6:27 ` Avi Kivity
2004-12-15 8:51 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200412171837_MC3-1-9129-C5D@compuserve.com \
--to=76306.1226@compuserve.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.