Re: Calling syscalls from x86-64 kernel results in a crash on Opteron machines

Stephen Hemminger
2004-09-13T16:48:45Z

On Mon, 13 Sep 2004 18:17:36 +0200
Andrea Arcangeli <andrea@novell.com> wrote:

> Hi Constantine,
>
> On Mon, Sep 13, 2004 at 06:05:52PM +0300, Constantine Gavrilov wrote:
> > And BTW, kernel-space applications have their own place even if the
> > concept seems foreign to you.
>
> I avoided to do like i386 that inefficiently calls int 0x80 when you can
> call sys_read/sys_write etc.. by hand.
>
> the syscall is only meaningful if you're not in kernel space. Once
> you're in kernel space if you ever try to invoke a syscall again (either
> via int 0x80, syscall, sysenter, call gate, whatever) then you're just
> going slower than you should for no good reason.
>
> The only point of calling int 0x80 and friends is to change mode from
> user space to kernel space, and you're in kernel space already so you
> should just call sys_read/sys_write etc.. by hand which will not waste
> precious cycles and it'll be a lot simpler too.
>
> Note also that int 0x80 will bring you into the 32bit emulation layer,
> the only 64bit entry point is reacheable only via syscall.
>
> Hope this helps.

Actually, the fact that system calls work in kernel space I would consider
a BUG. The int 0x80 handler should oops or at least kill the offending
thread for security and robustness reasons.

--
Stephen Hemminger mailto:shemminger@osdl.org
Open Source Development Lab http://developer.osdl.org/shemminger