Re: Need help in understanding x86 syscall

From: Steven Rostedt
Date: Thu Aug 11 2005 - 10:52:22 EST


On Thu, 2005-08-11 at 11:28 -0400, linux-os (Dick Johnson) wrote:
> On Thu, 11 Aug 2005, Coywolf Qi Hunt wrote:
>
> > On 8/11/05, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> >> On Thu, 2005-08-11 at 10:04 -0400, linux-os (Dick Johnson) wrote:
> >>> Every interrupt software, or hardware, results in the branched
> >>> procedure being executed with the interrupts OFF. That's why
> >>> one of the first instructions in the kernel entry for a syscall
> >>> is 'sti' to turn them back on. Look at entry.S, line 182. This
> >>> occurs any time a trap occurs as well (Page 26-168, i486
> >>> Programmer's reference manual). FYI, this is helpful when
> >>> designing/debugging complex interrupt-service routines since
> >>> you can execute the interrupt with a software 'INT' instruction
> >>> (with the correct offset from the IRQ you are using). The software
> >>> doesn't 'know' where the interrupt came from, HW or SW.
> >>
> >> I'm looking at 2.6.13-rc6-git1 line 182 of entry.S and I don't see it.
> >> Must be a different kernel.
> >>
> >> According to the documentation that I was looking at, a trap in x86 does
> >> _not_ turn off interrupts.
> >>
> > ...
> >>
> >> I don't see a sti here.
> >
>
> Search for sysenter_entry. This is where the stack is switched
> to the kernel stack. Then the code falls through past the
> next label, sysenter_past_esp. The very next instruction
> after the kernel stack has been set is 'sti'. Clear as day.

I just applied the following to one of my kernels:

-- arch/i386/kernel/entry.S (revision 274)
+++ arch/i386/kernel/entry.S (working copy)
@@ -184,6 +184,7 @@
ENTRY(sysenter_entry)
movl TSS_sysenter_esp0(%esp),%esp
sysenter_past_esp:
+ ud2
sti
pushl $(__USER_DS)
pushl %ebp

And booted it. The system is up and running, so I really don't think
that the sysenter_entry is used for system calls.

Not so "Clear as day"!

-- Steve


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/