2016-10-26 12:30:41

by Paul Bolle

[permalink] [raw]
Subject: Re: [tip:x86/vdso] x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*

This is bit late, but we're still on v4.9-rc2, so anyhow.

On Wed, 2016-09-14 at 12:34 -0700, tip-bot for Dmitry Safonov wrote:
> Commit-ID:  2eefd8789698e89c4a5d610921dc3c1b66e3bd0d
> Gitweb:     http://git.kernel.org/tip/2eefd8789698e89c4a5d610921dc3c1b66e3bd0d
> Author:     Dmitry Safonov <[email protected]>
> AuthorDate: Mon, 5 Sep 2016 16:33:05 +0300
> Committer:  Thomas Gleixner <[email protected]>
> CommitDate: Wed, 14 Sep 2016 21:28:09 +0200
>
> x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*
>
> Add API to change vdso blob type with arch_prctl.
> As this is usefull only by needs of CRIU, expose
> this interface under CONFIG_CHECKPOINT_RESTORE.
>
> Signed-off-by: Dmitry Safonov <[email protected]>
> Acked-by: Andy Lutomirski <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Link: http://lkml.kernel.org/r/[email protected]
> Signed-off-by: Thomas Gleixner <[email protected]>

> --- a/arch/x86/include/uapi/asm/prctl.h
> +++ b/arch/x86/include/uapi/asm/prctl.h

>  #define ARCH_GET_FS 0x1003
>  #define ARCH_GET_GS 0x1004
>  
> +#ifdef CONFIG_CHECKPOINT_RESTORE
> +# define ARCH_MAP_VDSO_X32 0x2001
> +# define ARCH_MAP_VDSO_32 0x2002
> +# define ARCH_MAP_VDSO_64 0x2003
> +#endif
> +
>  #endif /* _ASM_X86_PRCTL_H */

On my machine this header ends up in /usr/include/asm/prctl.h. But in
userspace CONFIG_CHECKPOINT_RESTORE is meaningless. I think if you
actually want to export these three macros to userspace the guard
should read:
    #if defined(CONFIG_CHECKPOINT_RESTORE) || !defined(__KERNEL__)

And if you don't want to export these macros the guard should read:
    #if defined(CONFIG_CHECKPOINT_RESTORE) && defined(__KERNEL__)

(In that case you're probably better of defining these macros outside
of uapi.)

I've only lightly tested those two alternatives, so please double
check.


Paul Bolle


2016-10-26 12:52:26

by Dmitry Safonov

[permalink] [raw]
Subject: Re: [tip:x86/vdso] x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*

On 10/26/2016 03:30 PM, Paul Bolle wrote:
> This is bit late, but we're still on v4.9-rc2, so anyhow.
>
> On Wed, 2016-09-14 at 12:34 -0700, tip-bot for Dmitry Safonov wrote:
>> Commit-ID: 2eefd8789698e89c4a5d610921dc3c1b66e3bd0d
>> Gitweb: http://git.kernel.org/tip/2eefd8789698e89c4a5d610921dc3c1b66e3bd0d
>> Author: Dmitry Safonov <[email protected]>
>> AuthorDate: Mon, 5 Sep 2016 16:33:05 +0300
>> Committer: Thomas Gleixner <[email protected]>
>> CommitDate: Wed, 14 Sep 2016 21:28:09 +0200
>>
>> x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*
>>
>> Add API to change vdso blob type with arch_prctl.
>> As this is usefull only by needs of CRIU, expose
>> this interface under CONFIG_CHECKPOINT_RESTORE.
>>
>> Signed-off-by: Dmitry Safonov <[email protected]>
>> Acked-by: Andy Lutomirski <[email protected]>
>> Cc: [email protected]
>> Cc: [email protected]
>> Cc: [email protected]
>> Cc: [email protected]
>> Cc: [email protected]
>> Link: http://lkml.kernel.org/r/[email protected]
>> Signed-off-by: Thomas Gleixner <[email protected]>
>
>> --- a/arch/x86/include/uapi/asm/prctl.h
>> +++ b/arch/x86/include/uapi/asm/prctl.h
>
>> #define ARCH_GET_FS 0x1003
>> #define ARCH_GET_GS 0x1004
>>
>> +#ifdef CONFIG_CHECKPOINT_RESTORE
>> +# define ARCH_MAP_VDSO_X32 0x2001
>> +# define ARCH_MAP_VDSO_32 0x2002
>> +# define ARCH_MAP_VDSO_64 0x2003
>> +#endif
>> +
>> #endif /* _ASM_X86_PRCTL_H */
>
> On my machine this header ends up in /usr/include/asm/prctl.h. But in
> userspace CONFIG_CHECKPOINT_RESTORE is meaningless. I think if you
> actually want to export these three macros to userspace the guard
> should read:
> #if defined(CONFIG_CHECKPOINT_RESTORE) || !defined(__KERNEL__)
>
> And if you don't want to export these macros the guard should read:
> #if defined(CONFIG_CHECKPOINT_RESTORE) && defined(__KERNEL__)
>
> (In that case you're probably better of defining these macros outside
> of uapi.)
>
> I've only lightly tested those two alternatives, so please double
> check.
>

Hi Paul,

thanks for noting that!
Well, I think, I'll remove ifdeffery around those constants.
Let them be always defined, that would be the simplest solution.
Somehow I managed to forget that userspace knows nothing about enabled
kernel options.

Thanks again,
Dmitry

>
> Paul Bolle
>