[systemd-devel] [PATCH] Fix broken syscall(__NR_fanotify_mark... on 32bit mips.

David Daney ddaney at caviumnetworks.com
Wed Apr 20 15:20:32 PDT 2011


On 04/20/2011 12:55 PM, Lennart Poettering wrote:
> On Wed, 20.04.11 11:43, David Daney (ddaney at caviumnetworks.com) wrote:
>
>>
>> On 04/20/2011 11:34 AM, Lennart Poettering wrote:
>>> On Wed, 20.04.11 11:19, David Daney (ddaney at caviumnetworks.com) wrote:
>>>
>>>>
>>>> On 04/20/2011 11:09 AM, Lennart Poettering wrote:
>>>>> On Wed, 20.04.11 10:36, David Daney (ddaney at caviumnetworks.com) wrote:
>>>>>
>>>>>> You would have to do something like this (untested):
>>>>>>
>>>>>> int foo_fanotify_mark(int fanotify_fd, unsigned int flags, u64 mask,
>>>>>> int dfd, const char  __user * pathname)
>>>>>> {
>>>>>> 	u32 mask_low = (u32)mask;
>>>>>> 	u32 mask_high = (u32)(mask>>    32);
>>>>>>
>>>>>> 	return syscall(4337, fanotify_fd, flags, mask_low, mask_high, dfd,
>>>>>> pathname);
>>>>>>
>>>>>> }
>>>>>>
>>>>>> The order of mask_low, mask_high in the syscall argument list
>>>>>> depends on the endianness.  Figuring out the correct order is left
>>>>>> as an exercise for the reader.
>>>>>
>>>>> That's basically the same patch as this one, right?
>>>>>
>>>>> http://lists.freedesktop.org/archives/systemd-devel/attachments/20110420/be2d393b/attachment.obj
>>>>>
>>>>
>>>> It looks like it might do the same thing.  Someone should try it on
>>>> an o32 MIPS userland running on a mips64 kernel.
>>>>
>>>> I think the behavior of the union thing is undefined, but should
>>>> work on GCC.
>>>
>>> Hmm, but unions is the official C99 way to do these things, isn't it?
>>> Instead of doing casts here and there which create aliasing probs?
>>>
>>> Any comment whether this will break non-MIPS 32bit archs, like x86?
>>
>> It would break the MIPS n32 ABI userspace.
>>
>> On MIPS n32 we are still __LP64__, but 64-bit values are passed in a
>> single register.
>>
>> I expect that the experimental x86_64 x32 ABI would suffer the same way.
>>
>> So the change would have to be gated by ABI rather than __LP64__
>
> Hmm, OK. Do you happen to know which predefined userspace macro we
> should check against for the o32 ABI?
>
> There seems to be __mips__, but that probably covers both ABIs?

How about (untested):

#if defined(__mips__) && (_MIPS_SIM == _ABIO32)

David Daney


>
> Lennart
>



More information about the systemd-devel mailing list