* Re: [PATCH v3 02/22] compat: provide compat_ptr() on all architectures
2020-01-02 14:55 ` [PATCH v3 02/22] compat: provide compat_ptr() on all architectures Arnd Bergmann
@ 2020-01-06 17:40 ` Will Deacon
2020-01-06 17:59 ` H. Peter Anvin
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2020-01-06 17:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Heiko Carstens, linux-mips, James E.J. Bottomley, Paul Mackerras,
H. Peter Anvin, sparclinux, linux-s390, Paul Burton, Helge Deller,
x86, Christian Borntraeger, Ingo Molnar, oprofile-list,
Catalin Marinas, James Hogan, Robert Richter, Vasily Gorbik,
James E.J. Bottomley, Borislav Petkov, Thomas Gleixner,
linux-parisc, Martin K. Petersen, linux-kernel, Ralf Baechle,
linuxppc-dev, David S. Miller
On Thu, Jan 02, 2020 at 03:55:20PM +0100, Arnd Bergmann wrote:
> In order to avoid needless #ifdef CONFIG_COMPAT checks,
> move the compat_ptr() definition to linux/compat.h
> where it can be seen by any file regardless of the
> architecture.
>
> Only s390 needs a special definition, this can use the
> self-#define trick we have elsewhere.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arm64/include/asm/compat.h | 17 -----------------
> arch/mips/include/asm/compat.h | 18 ------------------
> arch/parisc/include/asm/compat.h | 17 -----------------
> arch/powerpc/include/asm/compat.h | 17 -----------------
> arch/powerpc/oprofile/backtrace.c | 2 +-
> arch/s390/include/asm/compat.h | 6 +-----
> arch/sparc/include/asm/compat.h | 17 -----------------
> arch/x86/include/asm/compat.h | 17 -----------------
> include/linux/compat.h | 18 ++++++++++++++++++
> 9 files changed, 20 insertions(+), 109 deletions(-)
For arm64:
Acked-by: Will Deacon <will@kernel.org>
Will
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 02/22] compat: provide compat_ptr() on all architectures
2020-01-02 14:55 ` [PATCH v3 02/22] compat: provide compat_ptr() on all architectures Arnd Bergmann
2020-01-06 17:40 ` Will Deacon
@ 2020-01-06 17:59 ` H. Peter Anvin
2020-01-07 2:05 ` Michael Ellerman
2020-01-07 17:51 ` Heiko Carstens
3 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2020-01-06 17:59 UTC (permalink / raw)
To: Arnd Bergmann, James E.J. Bottomley, Martin K. Petersen
Cc: Heiko Carstens, linux-mips, James E.J. Bottomley, Paul Mackerras,
sparclinux, Will Deacon, linux-s390, Paul Burton, Helge Deller,
x86, Christian Borntraeger, Ingo Molnar, oprofile-list,
Catalin Marinas, James Hogan, Robert Richter, Vasily Gorbik,
Borislav Petkov, Thomas Gleixner, linux-parisc, linux-kernel,
Ralf Baechle, linuxppc-dev, David S. Miller
On 2020-01-02 06:55, Arnd Bergmann wrote:
> In order to avoid needless #ifdef CONFIG_COMPAT checks,
> move the compat_ptr() definition to linux/compat.h
> where it can be seen by any file regardless of the
> architecture.
>
> Only s390 needs a special definition, this can use the
> self-#define trick we have elsewhere.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arm64/include/asm/compat.h | 17 -----------------
> arch/mips/include/asm/compat.h | 18 ------------------
> arch/parisc/include/asm/compat.h | 17 -----------------
> arch/powerpc/include/asm/compat.h | 17 -----------------
> arch/powerpc/oprofile/backtrace.c | 2 +-
> arch/s390/include/asm/compat.h | 6 +-----
> arch/sparc/include/asm/compat.h | 17 -----------------
> arch/x86/include/asm/compat.h | 17 -----------------
> include/linux/compat.h | 18 ++++++++++++++++++
> 9 files changed, 20 insertions(+), 109 deletions(-)
>
For x86:
Reviewed-by: H. Peter Anvin <hpa@zytor.com>
It still suffers from the zero-one-infinity rule failure of the compat
architecture as a whole, but that is a very different problem. In this case
"compat" is obviously meaning "a 32-on-64 ABI" and simply centralizes a common
API, which is a Good Thing[TM].
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 02/22] compat: provide compat_ptr() on all architectures
2020-01-02 14:55 ` [PATCH v3 02/22] compat: provide compat_ptr() on all architectures Arnd Bergmann
2020-01-06 17:40 ` Will Deacon
2020-01-06 17:59 ` H. Peter Anvin
@ 2020-01-07 2:05 ` Michael Ellerman
2020-01-07 8:08 ` Arnd Bergmann
2020-01-07 17:51 ` Heiko Carstens
3 siblings, 1 reply; 7+ messages in thread
From: Michael Ellerman @ 2020-01-07 2:05 UTC (permalink / raw)
To: Arnd Bergmann, James E.J. Bottomley, Martin K. Petersen
Cc: Heiko Carstens, linux-mips, James E.J. Bottomley, Paul Mackerras,
H. Peter Anvin, sparclinux, Will Deacon, linux-s390,
Arnd Bergmann, Paul Burton, Helge Deller, x86,
Christian Borntraeger, Ingo Molnar, oprofile-list,
Catalin Marinas, James Hogan, Robert Richter, Vasily Gorbik,
Borislav Petkov, Thomas Gleixner, linux-parisc, linux-kernel,
Ralf Baechle, linuxppc-dev, David S. Miller
Arnd Bergmann <arnd@arndb.de> writes:
> In order to avoid needless #ifdef CONFIG_COMPAT checks,
> move the compat_ptr() definition to linux/compat.h
> where it can be seen by any file regardless of the
> architecture.
>
> Only s390 needs a special definition, this can use the
> self-#define trick we have elsewhere.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arm64/include/asm/compat.h | 17 -----------------
> arch/mips/include/asm/compat.h | 18 ------------------
> arch/parisc/include/asm/compat.h | 17 -----------------
> arch/powerpc/include/asm/compat.h | 17 -----------------
> arch/powerpc/oprofile/backtrace.c | 2 +-
LGTM.
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
One minor comment:
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index 68f79d855c3d..11083d84eb23 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -958,4 +958,22 @@ static inline bool in_compat_syscall(void) { return false; }
>
> #endif /* CONFIG_COMPAT */
>
> +/*
> + * A pointer passed in from user mode. This should not
> + * be used for syscall parameters, just declare them
> + * as pointers because the syscall entry code will have
> + * appropriately converted them already.
> + */
> +#ifndef compat_ptr
> +static inline void __user *compat_ptr(compat_uptr_t uptr)
> +{
> + return (void __user *)(unsigned long)uptr;
> +}
> +#endif
> +
> +static inline compat_uptr_t ptr_to_compat(void __user *uptr)
> +{
> + return (u32)(unsigned long)uptr;
> +}
Is there a reason we cast to u32 directly instead of using compat_uptr_t?
cheers
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 02/22] compat: provide compat_ptr() on all architectures
2020-01-07 2:05 ` Michael Ellerman
@ 2020-01-07 8:08 ` Arnd Bergmann
2020-01-07 8:19 ` H. Peter Anvin
0 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2020-01-07 8:08 UTC (permalink / raw)
To: Michael Ellerman
Cc: Heiko Carstens, open list:BROADCOM NVRAM DRIVER,
James E.J. Bottomley, Paul Mackerras, H. Peter Anvin, sparclinux,
Will Deacon, linux-s390, Paul Burton, Helge Deller,
the arch/x86 maintainers, Christian Borntraeger, Ingo Molnar,
oprofile-list, Catalin Marinas, James Hogan, Robert Richter,
Vasily Gorbik, James E.J. Bottomley, Borislav Petkov,
Thomas Gleixner, Parisc List, Martin K. Petersen,
linux-kernel@vger.kernel.org, Ralf Baechle, linuxppc-dev,
David S. Miller
On Tue, Jan 7, 2020 at 3:05 AM Michael Ellerman <mpe@ellerman.id.au> wrote:
> Arnd Bergmann <arnd@arndb.de> writes:
> > +
> > +static inline compat_uptr_t ptr_to_compat(void __user *uptr)
> > +{
> > + return (u32)(unsigned long)uptr;
> > +}
>
> Is there a reason we cast to u32 directly instead of using compat_uptr_t?
Probably Al found this to be more explicit at the time when he introduced
it on all the architectures in 2005. I just moved it here and kept the
definition.
Arnd
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 02/22] compat: provide compat_ptr() on all architectures
2020-01-07 8:08 ` Arnd Bergmann
@ 2020-01-07 8:19 ` H. Peter Anvin
0 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2020-01-07 8:19 UTC (permalink / raw)
To: Arnd Bergmann, Michael Ellerman
Cc: Heiko Carstens, open list:BROADCOM NVRAM DRIVER,
James E.J. Bottomley, Paul Mackerras, Will Deacon, Paul Burton,
Helge Deller, the arch/x86 maintainers, Christian Borntraeger,
Ingo Molnar, Catalin Marinas, James Hogan, linuxppc-dev,
Robert Richter, Vasily Gorbik, James E.J. Bottomley,
Borislav Petkov, Thomas Gleixner, Parisc List, Martin K. Petersen,
linux-kernel@vger.kernel.org, Ralf Baechle, David S. Miller
<linuxppc-dev@lists.ozlabs.org>,oprofile-list@lists.sf.net,linux-s390 <linux-s390@vger.kernel.org>,sparclinux <sparclinux@vger.kernel.org>
From: hpa@zytor.com
Message-ID: <41625F06-D755-4C82-86DF-A9415FEEE13D@zytor.com>
On January 7, 2020 12:08:31 AM PST, Arnd Bergmann <arnd@arndb.de> wrote:
>On Tue, Jan 7, 2020 at 3:05 AM Michael Ellerman <mpe@ellerman.id.au>
>wrote:
>> Arnd Bergmann <arnd@arndb.de> writes:
>> > +
>> > +static inline compat_uptr_t ptr_to_compat(void __user *uptr)
>> > +{
>> > + return (u32)(unsigned long)uptr;
>> > +}
>>
>> Is there a reason we cast to u32 directly instead of using
>compat_uptr_t?
>
>Probably Al found this to be more explicit at the time when he
>introduced
>it on all the architectures in 2005. I just moved it here and kept the
>definition.
>
> Arnd
Did compat_uptr_t exist back then?
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 02/22] compat: provide compat_ptr() on all architectures
2020-01-02 14:55 ` [PATCH v3 02/22] compat: provide compat_ptr() on all architectures Arnd Bergmann
` (2 preceding siblings ...)
2020-01-07 2:05 ` Michael Ellerman
@ 2020-01-07 17:51 ` Heiko Carstens
3 siblings, 0 replies; 7+ messages in thread
From: Heiko Carstens @ 2020-01-07 17:51 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-mips, James E.J. Bottomley, Paul Mackerras, H. Peter Anvin,
sparclinux, Will Deacon, linux-s390, Paul Burton, Helge Deller,
x86, Christian Borntraeger, Ingo Molnar, oprofile-list,
Catalin Marinas, James Hogan, Robert Richter, Vasily Gorbik,
James E.J. Bottomley, Borislav Petkov, Thomas Gleixner,
linux-parisc, Martin K. Petersen, linux-kernel, Ralf Baechle,
linuxppc-dev, David S. Miller
On Thu, Jan 02, 2020 at 03:55:20PM +0100, Arnd Bergmann wrote:
> In order to avoid needless #ifdef CONFIG_COMPAT checks,
> move the compat_ptr() definition to linux/compat.h
> where it can be seen by any file regardless of the
> architecture.
>
> Only s390 needs a special definition, this can use the
> self-#define trick we have elsewhere.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arm64/include/asm/compat.h | 17 -----------------
> arch/mips/include/asm/compat.h | 18 ------------------
> arch/parisc/include/asm/compat.h | 17 -----------------
> arch/powerpc/include/asm/compat.h | 17 -----------------
> arch/powerpc/oprofile/backtrace.c | 2 +-
> arch/s390/include/asm/compat.h | 6 +-----
> arch/sparc/include/asm/compat.h | 17 -----------------
> arch/x86/include/asm/compat.h | 17 -----------------
> include/linux/compat.h | 18 ++++++++++++++++++
> 9 files changed, 20 insertions(+), 109 deletions(-)
For s390:
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread