linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Airlie <airlied@linux.ie>, Jonathan Corbet <corbet@lwn.net>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Xuefeng Li <lixuefeng@loongson.cn>,
	Yanteng Si <siyanteng@loongson.cn>,
	Huacai Chen <chenhuacai@gmail.com>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Huacai Chen <chenhuacai@loongson.cn>
Subject: Re: [PATCH V8 13/22] LoongArch: Add system call support
Date: Mon, 21 Mar 2022 09:54:11 +0100	[thread overview]
Message-ID: <CAK8P3a2kroHVN3fTabuFVMz08SXytz-SC8X11BxxszsUCksJ4g@mail.gmail.com> (raw)
In-Reply-To: <20220319143817.1026708-6-chenhuacai@loongson.cn>

On Sat, Mar 19, 2022 at 3:38 PM Huacai Chen <chenhuacai@kernel.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

  reply	other threads:[~2022-03-21  9:47 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-19 14:27 [PATCH V8 00/22] arch: Add basic LoongArch support Huacai Chen
2022-03-19 14:31 ` [PATCH V8 01/22] Documentation: LoongArch: Add basic documentations Huacai Chen
2022-03-19 14:31   ` [PATCH V8 02/22] Documentation/zh_CN: Add basic LoongArch documentations Huacai Chen
2022-03-19 14:31   ` [PATCH V8 03/22] LoongArch: Add elf-related definitions Huacai Chen
2022-03-19 14:31   ` [PATCH V8 04/22] LoongArch: Add writecombine support for drm Huacai Chen
2022-03-19 14:31   ` [PATCH V8 05/22] LoongArch: Add build infrastructure Huacai Chen
2022-03-21  8:31     ` Arnd Bergmann
2022-03-21  8:53       ` Huacai Chen
2022-03-19 14:31   ` [PATCH V8 06/22] LoongArch: Add CPU definition headers Huacai Chen
2022-03-19 14:31   ` [PATCH V8 07/22] LoongArch: Add atomic/locking headers Huacai Chen
2022-03-21  9:42     ` Arnd Bergmann
2022-03-22  3:03       ` Huacai Chen
2022-03-22  9:23         ` Arnd Bergmann
2022-03-19 14:38 ` [PATCH V8 08/22] LoongArch: Add other common headers Huacai Chen
2022-03-19 14:38   ` [PATCH V8 09/22] LoongArch: Add boot and setup routines Huacai Chen
2022-03-21  9:58     ` Arnd Bergmann
2022-03-19 14:38   ` [PATCH V8 10/22] LoongArch: Add exception/interrupt handling Huacai Chen
2022-03-21  8:38     ` Arnd Bergmann
2022-03-21  8:46       ` Huacai Chen
2022-03-21  9:49         ` Arnd Bergmann
2022-03-22  2:53           ` Huacai Chen
2022-03-19 14:38   ` [PATCH V8 11/22] LoongArch: Add process management Huacai Chen
2022-03-21  8:42     ` Arnd Bergmann
2022-03-22  3:07       ` Huacai Chen
2022-03-22  9:00         ` Arnd Bergmann
2022-03-19 14:38   ` [PATCH V8 12/22] LoongArch: Add memory management Huacai Chen
2022-03-19 14:38   ` [PATCH V8 13/22] LoongArch: Add system call support Huacai Chen
2022-03-21  8:54     ` Arnd Bergmann [this message]
2022-03-21  9:41       ` Huacai Chen
2022-03-21  9:47         ` Arnd Bergmann
2022-03-22  2:56           ` Huacai Chen
2022-03-22 16:02           ` Christian Brauner
2022-03-24  2:32             ` Feiyang Chen
2022-03-19 14:38   ` [PATCH V8 14/22] LoongArch: Add signal handling support Huacai Chen
2022-03-19 14:38   ` [PATCH V8 15/22] LoongArch: Add elf and module support Huacai Chen
2022-03-19 14:38   ` [PATCH V8 16/22] LoongArch: Add misc common routines Huacai Chen
2022-03-19 14:38   ` [PATCH V8 17/22] LoongArch: Add some library functions Huacai Chen
2022-03-19 14:38   ` [PATCH V8 18/22] LoongArch: Add PCI controller support Huacai Chen
2022-03-19 14:38   ` [PATCH V8 19/22] LoongArch: Add VDSO and VSYSCALL support Huacai Chen
2022-03-19 14:38   ` [PATCH V8 20/22] LoongArch: Add multi-processor (SMP) support Huacai Chen
2022-03-19 14:38   ` [PATCH V8 21/22] LoongArch: Add Non-Uniform Memory Access (NUMA) support Huacai Chen
2022-03-19 14:38   ` [PATCH V8 22/22] LoongArch: Add Loongson-3 default config file Huacai Chen
2022-03-21 10:09 ` [PATCH V8 00/22] arch: Add basic LoongArch support Arnd Bergmann
2022-03-21 16:59   ` Linus Torvalds
2022-03-21 21:55     ` Arnd Bergmann
2022-03-21 22:03       ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK8P3a2kroHVN3fTabuFVMz08SXytz-SC8X11BxxszsUCksJ4g@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=airlied@linux.ie \
    --cc=akpm@linux-foundation.org \
    --cc=chenhuacai@gmail.com \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=corbet@lwn.net \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=siyanteng@loongson.cn \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).