2012-02-10 15:56:45

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Compat 32-bit syscall entry from 64-bit task!?

On 02/09/2012 11:42 PM, Indan Zupancic wrote:>
> Patch implementing this below. It uses bit 3 for task mode and bit 5
> for syscall mode. Those bits are only valid if VIF is set. It increases
> the kernel size by around 50 bytes, 6 for a 32-bit kernel.
>
> Any objections?

#include <stdnak.h>

-hpa


2012-02-10 22:42:48

by Indan Zupancic

[permalink] [raw]
Subject: Re: Compat 32-bit syscall entry from 64-bit task!?

On Fri, February 10, 2012 16:53, H. Peter Anvin wrote:
> On 02/09/2012 11:42 PM, Indan Zupancic wrote:>
>> Patch implementing this below. It uses bit 3 for task mode and bit 5
>> for syscall mode. Those bits are only valid if VIF is set. It increases
>> the kernel size by around 50 bytes, 6 for a 32-bit kernel.
>>
>> Any objections?
>
> #include <stdnak.h>

Could you please elaborate? Is it just the stealing of eflags bits that
irks you or are there technical problems too?

I understand some people would prefer a new regset, but that would force
everyone to use PTRACE_GETREGSET instead of whatever they are using now.
The problem with that is that not all archs support PTRACE_GETREGSET, so
the user space ptrace code needs to use different ptrace calls depending
on the architecture for no good reason. If PEEK_USER works then it's less
of a problem, then it's one extra ptrace call compared to the eflag way
if PTRACE_GETREGS is used. If this new info is exposed with a special
regset instead of being appended to normal regs then one extra ptrace
call per system call event needs to be done. You can as well add special
x86 ptrace requests then.

Or is the main advantage of using a regset that it shows up in coredumps?
That would merit the extra effort at least.

Stealing eflags bits may be ugly like hell, but it's very simple for both
the kernel and user space to implement.

I think everyone agrees that this kind of info needs to be exposed somehow.
In the end I don't care how it is done, as long as the info is easily
available.

Greetings,

Indan

2012-02-10 23:00:05

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Compat 32-bit syscall entry from 64-bit task!?

On 02/10/2012 02:42 PM, Indan Zupancic wrote:
>> #include <stdnak.h>
>
> Could you please elaborate? Is it just the stealing of eflags bits that
> irks you or are there technical problems too?

Yes, I will not accept that unless it gets ok'd by the architecture
people, which may take a long time.

> I understand some people would prefer a new regset, but that would force
> everyone to use PTRACE_GETREGSET instead of whatever they are using now.
> The problem with that is that not all archs support PTRACE_GETREGSET, so
> the user space ptrace code needs to use different ptrace calls depending
> on the architecture for no good reason. If PEEK_USER works then it's less
> of a problem, then it's one extra ptrace call compared to the eflag way
> if PTRACE_GETREGS is used. If this new info is exposed with a special
> regset instead of being appended to normal regs then one extra ptrace
> call per system call event needs to be done. You can as well add special
> x86 ptrace requests then.

Seriously... if you're mucking with registers on this level, youan
architecture dependency is not a big deal, and perhaps it's a good sign
that the laggard architectures need to catch up. If multiple ptrace
requests is a problem, then perhaps this is a good sign that we need a
single way to get multiple regsets in a single request?

> Or is the main advantage of using a regset that it shows up in coredumps?
> That would merit the extra effort at least.

That is another plus, which is significant, too. The final advantage is
expandability.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

2012-02-12 12:08:19

by Indan Zupancic

[permalink] [raw]
Subject: Re: Compat 32-bit syscall entry from 64-bit task!?

On Fri, February 10, 2012 23:56, H. Peter Anvin wrote:
> On 02/10/2012 02:42 PM, Indan Zupancic wrote:
>>> #include <stdnak.h>
>>
>> Could you please elaborate? Is it just the stealing of eflags bits that
>> irks you or are there technical problems too?
>
> Yes, I will not accept that unless it gets ok'd by the architecture
> people, which may take a long time.

The kernel x86 people or the Intel CPU people?

With the latest patch it doesn't matter what bits Intel decides to use in
the future, any clashes can always be handled unambiguously.

>> I understand some people would prefer a new regset, but that would force
>> everyone to use PTRACE_GETREGSET instead of whatever they are using now.
>> The problem with that is that not all archs support PTRACE_GETREGSET, so
>> the user space ptrace code needs to use different ptrace calls depending
>> on the architecture for no good reason. If PEEK_USER works then it's less
>> of a problem, then it's one extra ptrace call compared to the eflag way
>> if PTRACE_GETREGS is used. If this new info is exposed with a special
>> regset instead of being appended to normal regs then one extra ptrace
>> call per system call event needs to be done. You can as well add special
>> x86 ptrace requests then.
>
> Seriously... if you're mucking with registers on this level, youan
> architecture dependency is not a big deal, and perhaps it's a good sign
> that the laggard architectures need to catch up. If multiple ptrace
> requests is a problem, then perhaps this is a good sign that we need a
> single way to get multiple regsets in a single request?

Well, if we're forcing people to use a different API then we can as well
overhaul the whole ptrace thing to have a decent interface instead of all
this mucking around with waitpid() and whatnot.

That is the main advantage of the stealing eflags bits approach, it's mostly
API independent. That it puts the info close to the data where it is used is
a bonus.

>> Or is the main advantage of using a regset that it shows up in coredumps?
>> That would merit the extra effort at least.
>
> That is another plus, which is significant, too. The final advantage is
> expandability.

I just realized that if coredumping uses ptrace's code the eflags will
show up too. As for expandability, there are a few more bits left...
But more seriously, what other highly x86 specific flags are needed?
Other than maybe the syscall entry instruction, which I'm not convinced
of, I can't think of anything.

Greetings,

Indan