[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a2kroHVN3fTabuFVMz08SXytz-SC8X11BxxszsUCksJ4g@mail.gmail.com>
Date: Mon, 21 Mar 2022 09:54:11 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, Andy Lutomirski <luto@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
David Airlie <airlied@...ux.ie>,
Jonathan Corbet <corbet@....net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
linux-arch <linux-arch@...r.kernel.org>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Xuefeng Li <lixuefeng@...ngson.cn>,
Yanteng Si <siyanteng@...ngson.cn>,
Huacai Chen <chenhuacai@...il.com>,
Jiaxun Yang <jiaxun.yang@...goat.com>,
Huacai Chen <chenhuacai@...ngson.cn>
Subject: Re: [PATCH V8 13/22] LoongArch: Add system call support
On Sat, Mar 19, 2022 at 3:38 PM Huacai Chen <chenhuacai@...nel.org> wrote:
>
> This patch adds system call support and related uaccess.h for LoongArch.
>
> Q: Why keep __ARCH_WANT_NEW_STAT definition while there is statx:
> A: Until the latest glibc release (2.34), statx is only used for 32-bit
> platforms, or 64-bit platforms with 32-bit timestamp. I.e., Most 64-
> bit platforms still use newstat now.
>
> Q: Why keep _ARCH_WANT_SYS_CLONE definition while there is clone3:
> A: The latest glibc release (2.34) has some basic support for clone3 but
> it isn't complete. E.g., pthread_create() and spawni() have converted
> to use clone3 but fork() will still use clone. Moreover, some seccomp
> related applications can still not work perfectly with clone3.
Please leave those out of the mainline kernel support though: Any users
of existing glibc binaries can keep using patched kernels for the moment,
and then later drop those pages when the proper glibc support gets
merged.
> +#define __ua_size(size) \
> + ((__builtin_constant_p(size) && (signed long) (size) > 0) ? 0 : (size))
> +
> +/*
> + * access_ok: - Checks if a user space pointer is valid
> + * @addr: User space pointer to start of block to check
> + * @size: Size of block to check
> + *
> + * Context: User context only. This function may sleep if pagefaults are
> + * enabled.
> + *
> + * Checks if a pointer to a block of memory in user space is valid.
> + *
> + * Returns true (nonzero) if the memory block may be valid, false (zero)
> + * if it is definitely invalid.
> + *
> + * Note that, depending on architecture, this function probably just
> + * checks that the pointer is in the user space range - after calling
> + * this function, memory access functions may still return -EFAULT.
> + */
> +static inline int __access_ok(const void __user *p, unsigned long size)
> +{
> + unsigned long addr = (unsigned long)p;
> + unsigned long end = addr + size - !!size;
> +
> + return (__UA_LIMIT & (addr | end | __ua_size(size))) == 0;
> +}
> +
> +#define access_ok(addr, size) \
> + likely(__access_ok((addr), (size)))
I rewrote this bit a series that is currently queued for 5.18, so you
will have to adapt it to the new version, by just removing your
custom definitions.
> +#define __get_user(x, ptr) \
> +({ \
> + int __gu_err = 0; \
> + \
> + __chk_user_ptr(ptr); \
> + __get_user_common((x), sizeof(*(ptr)), ptr); \
> + __gu_err; \
> +})
It would be good to also provide a
__kernel_kernel_nofault()/__put_kernel_nofault()
implementation, as the default based on __get_user()/__put_user is not
ideal.
Arnd
Powered by blists - more mailing lists