Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-11-04 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 12:08 PM, Andy Lutomirski wrote: > The int_ret_from_sys_call and syscall tracing code disagrees with > the sysret path as to the value of RCX. > > The Intel SDM, the AMD APM, and my laptop all agree that sysret > returns with RCX == RIP. The syscall tracing code does not

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-11-04 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 12:08 PM, Andy Lutomirski l...@amacapital.net wrote: The int_ret_from_sys_call and syscall tracing code disagrees with the sysret path as to the value of RCX. The Intel SDM, the AMD APM, and my laptop all agree that sysret returns with RCX == RIP. The syscall tracing

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-30 Thread Andy Lutomirski
On Sat, Jun 28, 2014 at 10:07 AM, Pavel Machek wrote: > On Thu 2014-06-26 13:47:32, Andy Lutomirski wrote: >> On Thu, Jun 26, 2014 at 1:12 PM, H. Peter Anvin wrote: >> > The real question is if we care that sysret and iter don't match. On 32 >> > bits the situation is even more complex. >> >>

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-30 Thread Andy Lutomirski
On Sat, Jun 28, 2014 at 10:07 AM, Pavel Machek pa...@ucw.cz wrote: On Thu 2014-06-26 13:47:32, Andy Lutomirski wrote: On Thu, Jun 26, 2014 at 1:12 PM, H. Peter Anvin h...@zytor.com wrote: The real question is if we care that sysret and iter don't match. On 32 bits the situation is even

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-28 Thread Pavel Machek
On Thu 2014-06-26 13:47:32, Andy Lutomirski wrote: > On Thu, Jun 26, 2014 at 1:12 PM, H. Peter Anvin wrote: > > The real question is if we care that sysret and iter don't match. On 32 > > bits the situation is even more complex. > > At least for 64 bits, iret vs sysret is purely a kernel

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-28 Thread Pavel Machek
On Thu 2014-06-26 13:47:32, Andy Lutomirski wrote: On Thu, Jun 26, 2014 at 1:12 PM, H. Peter Anvin h...@zytor.com wrote: The real question is if we care that sysret and iter don't match. On 32 bits the situation is even more complex. At least for 64 bits, iret vs sysret is purely a

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 1:12 PM, H. Peter Anvin wrote: > The real question is if we care that sysret and iter don't match. On 32 bits > the situation is even more complex. At least for 64 bits, iret vs sysret is purely a kernel implementation detail (except where a tracer modifies things that

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread H. Peter Anvin
The real question is if we care that sysret and iter don't match. On 32 bits the situation is even more complex. On June 26, 2014 1:00:22 PM PDT, Andy Lutomirski wrote: >On Thu, Jun 26, 2014 at 12:59 PM, Andy Lutomirski >wrote: >> On Thu, Jun 26, 2014 at 12:56 PM, Andi Kleen >wrote:

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 12:59 PM, Andy Lutomirski wrote: > On Thu, Jun 26, 2014 at 12:56 PM, Andi Kleen wrote: >>> show RCX == RIP even under strace. >> >> If you think it's really worth the extra instruction? > > Hard to say. That extra instruction only happens on slow paths, so I > suspect

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 12:56 PM, Andi Kleen wrote: >> show RCX == RIP even under strace. > > If you think it's really worth the extra instruction? Hard to say. That extra instruction only happens on slow paths, so I suspect the slowdown is negligible. On the other hand, having syscall show a

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andi Kleen
> show RCX == RIP even under strace. If you think it's really worth the extra instruction? It's not wrong, but it's not clear if it's useful. -Andi > > Signed-off-by: Andy Lutomirski > --- > arch/x86/kernel/entry_64.S | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git

[PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
The int_ret_from_sys_call and syscall tracing code disagrees with the sysret path as to the value of RCX. The Intel SDM, the AMD APM, and my laptop all agree that sysret returns with RCX == RIP. The syscall tracing code does not respect this property. For example, this program: int main() {

[PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
The int_ret_from_sys_call and syscall tracing code disagrees with the sysret path as to the value of RCX. The Intel SDM, the AMD APM, and my laptop all agree that sysret returns with RCX == RIP. The syscall tracing code does not respect this property. For example, this program: int main() {

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andi Kleen
show RCX == RIP even under strace. If you think it's really worth the extra instruction? It's not wrong, but it's not clear if it's useful. -Andi Signed-off-by: Andy Lutomirski l...@amacapital.net --- arch/x86/kernel/entry_64.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 12:56 PM, Andi Kleen a...@firstfloor.org wrote: show RCX == RIP even under strace. If you think it's really worth the extra instruction? Hard to say. That extra instruction only happens on slow paths, so I suspect the slowdown is negligible. On the other hand, having

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 12:59 PM, Andy Lutomirski l...@amacapital.net wrote: On Thu, Jun 26, 2014 at 12:56 PM, Andi Kleen a...@firstfloor.org wrote: show RCX == RIP even under strace. If you think it's really worth the extra instruction? Hard to say. That extra instruction only happens on

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread H. Peter Anvin
The real question is if we care that sysret and iter don't match. On 32 bits the situation is even more complex. On June 26, 2014 1:00:22 PM PDT, Andy Lutomirski l...@amacapital.net wrote: On Thu, Jun 26, 2014 at 12:59 PM, Andy Lutomirski l...@amacapital.net wrote: On Thu, Jun 26, 2014 at

Re: [PATCH] x86_64,entry: Fix RCX for traced syscalls

2014-06-26 Thread Andy Lutomirski
On Thu, Jun 26, 2014 at 1:12 PM, H. Peter Anvin h...@zytor.com wrote: The real question is if we care that sysret and iter don't match. On 32 bits the situation is even more complex. At least for 64 bits, iret vs sysret is purely a kernel implementation detail (except where a tracer modifies