public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RBP save and restore on x86-64 system calls
@ 2006-08-28 17:37 Hanson, Jonathan M
  2006-08-28 19:16 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: Hanson, Jonathan M @ 2006-08-28 17:37 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

	This may not be a kernel question per se but I was hoping someone on
this list might be able to shed some light into where RBP is saved to on an
x86-64 system when a non-tracing system call is made.
	An ioctl() triggers my kernel module and I need to have a way to
reliably retrieve what RBP was immediately before the system call. RBP is
not saved on the process' stack on kernel entry. The code in entry.S says
that it's up to the C code (which I'm taking to mean glibc) to deal with
these non-saved registers. I have a statically compiled application and I
can't see the glibc code doing anything to save or restore RBP in the
assembly. It has to be saved somewhere or these would be all kinds of
problems after control returned to the user application from the system
call.
	Please reply directly to me as well as the list as I'm not a current
subscriber. Thanks for your time.


[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 11348 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: RBP save and restore on x86-64 system calls
  2006-08-28 17:37 RBP save and restore on x86-64 system calls Hanson, Jonathan M
@ 2006-08-28 19:16 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2006-08-28 19:16 UTC (permalink / raw)
  To: Hanson, Jonathan M; +Cc: linux-kernel

"Hanson, Jonathan M" <jonathan.m.hanson@intel.com> writes:

> 	This may not be a kernel question per se but I was hoping someone on
> this list might be able to shed some light into where RBP is saved to on an
> x86-64 system when a non-tracing system call is made.

It might not be saved at all. The entry code relies on the C ABI
of the kernel code to save it somewhere or just not clobber it.

> 	An ioctl() triggers my kernel module and I need to have a way to
> reliably retrieve what RBP was immediately before the system call. RBP is
> not saved on the process' stack on kernel entry. The code in entry.S says
> that it's up to the C code (which I'm taking to mean glibc)

No, it's the kernel C code. RBP isn't callee clobbered register
so it's not saved.

What you can do is to use the new dwarf2 unwinder that will be in 2.6.18.
It can figure out all the register contents for you if you unwind until
it hits user space. This will require a kernel built with CONFIG_STACK_UNWIND.

There are also still some quirks with it, but for ioctls it should
work.

-Andi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-28 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-28 17:37 RBP save and restore on x86-64 system calls Hanson, Jonathan M
2006-08-28 19:16 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox