From: "Arnd Bergmann" <arnd@arndb.de>
To: "Yann Sionneau" <ysionneau@kalrayinc.com>,
linux-kernel@vger.kernel.org,
"Christian Brauner" <brauner@kernel.org>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>
Cc: "Jonathan Borne" <jborne@kalrayinc.com>,
"Julian Vetter" <jvetter@kalrayinc.com>,
"Clement Leger" <clement@clement-leger.fr>,
"Guillaume Thouvenin" <thouveng@gmail.com>,
"Julien Villette" <julien.villette@gmail.com>,
"Marius Gligor" <mgligor@kalrayinc.com>,
linux-riscv@lists.infradead.org
Subject: Re: [RFC PATCH v3 25/37] kvx: Add system call support
Date: Tue, 23 Jul 2024 09:20:03 +0000 [thread overview]
Message-ID: <4896ca15-ca23-4723-92e8-c824ee6a8923@app.fastmail.com> (raw)
In-Reply-To: <20240722094226.21602-26-ysionneau@kalrayinc.com>
On Mon, Jul 22, 2024, at 09:41, ysionneau@kalrayinc.com wrote:
> +/**
> + * 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.
> + *
> + * 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.
> + */
> +#define access_ok(addr, size) ({ \
> + __chk_user_ptr(addr); \
> + likely(__access_ok((addr), (size))); \
> +})
> +
> +#include <asm-generic/access_ok.h>
You should not need a custom access_ok() function here, juse use
the asm-generic version directly.
> + * Copyright (C) 2017-2023 Kalray Inc.
> + * Author(s): Clement Leger
> + */
> +
> +#define __ARCH_WANT_SYS_CLONE
I previously commented that you should remove
__ARCH_WANT_NEW_STAT to match what we did for loongarch.
After long discussion, we now put that back though, so you
should probably do the same here. The way you do this is now
different with the move to the common syscall.tbl format,
and I think in the case of NEW_STAT this will change again
since we now should't even need that conditional any more.
> +
> +#define __ARCH_WANT_SYS_CLONE3
__ARCH_WANT_SYS_CLONE3 is now mandatory, and you can drop the
select in 6.11.
> +/* Additional KVX specific syscalls */
> +#define __NR_cachectl (__NR_arch_specific_syscall)
> +__SYSCALL(__NR_cachectl, sys_cachectl)
This one should now go into scripts/syscall.tbl instead.
> +SYSCALL_DEFINE4(cachectl, unsigned long, addr, unsigned long, len,
> + unsigned long, cache, unsigned long, flags)
> +{
> + bool wb = !!(flags & CACHECTL_FLAG_OP_WB);
> + bool inval = !!(flags & CACHECTL_FLAG_OP_INVAL);
> +
> + if (len == 0)
> + return 0;
> +
> + /* Check for overflow */
> + if (addr + len < addr)
> + return -EFAULT;
> +
> + if (cache != CACHECTL_CACHE_DCACHE)
> + return -EINVAL;
> +
> + if ((flags & CACHECTL_FLAG_OP_MASK) == 0)
> + return -EINVAL;
> +
> + if (flags & CACHECTL_FLAG_ADDR_PHYS) {
> + if (!IS_ENABLED(CONFIG_CACHECTL_UNSAFE_PHYS_OPERATIONS))
> + return -EINVAL;
> +
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
> +
> + dcache_wb_inval_phys_range(addr, len, wb, inval);
> + return 0;
> + }
> +
> + return dcache_wb_inval_virt_range(addr, len, wb, inval);
> +}
This syscall is different from apparently all other architectures
that have a cache management call, in two ways:
- The CONFIG_CACHECTL_UNSAFE_PHYS_OPERATIONS flag and the operation
behind it seems like a badly defined interface, I assume this is
a performance hack for a particular device driver, but it should
not really be done at the system call level. Ideally I think this
should be redesigned so it's never needed. If you do need it for
something, please make that a separate patch with a long explanation
about how it's used.
- The other architectures tend to use sys_cacheflush() with
more or less standardized calling conventions. Could you
use the callong conventions from arch/{csky,parisc} instead?
> +#include <linux/syscalls.h>
> +
> +#include <asm/syscalls.h>
> +
> +#undef __SYSCALL
> +#define __SYSCALL(nr, call)[nr] = (call),
> +
> +void *sys_call_table[__NR_syscalls] = {
> + [0 ... __NR_syscalls - 1] = sys_ni_syscall,
> +#include <asm/unistd.h>
> +};
This file will have to change in 6.11 as I replaced the
uapi/asm-generic/unistd.h file with a generated version
taking scripts/syscall.tbl as its input. Please copy the
code from arch/loongarch.
Arnd
next prev parent reply other threads:[~2024-07-23 9:20 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 9:41 [RFC PATCH v3 00/37] Upstream kvx Linux port ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 01/37] Documentation: kvx: Add basic documentation ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 02/37] dt-bindings: soc: kvx: Add binding for kalray,coolidge-pwr-ctrl ysionneau
2024-07-22 9:47 ` Krzysztof Kozlowski
2024-07-31 14:31 ` Yann Sionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 9:41 ` [RFC PATCH v3 03/37] dt-bindings: Add binding for kalray,kv3-1-intc ysionneau
2024-07-22 9:51 ` Krzysztof Kozlowski
2024-07-31 14:47 ` Yann Sionneau
2024-08-07 7:55 ` Krzysztof Kozlowski
2024-07-23 20:49 ` Rob Herring
2024-07-22 9:41 ` [RFC PATCH v3 04/37] dt-bindings: Add binding for kalray,coolidge-apic-gic ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 9:41 ` [RFC PATCH v3 05/37] dt-bindings: Add binding for kalray,coolidge-apic-mailbox ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 20:47 ` Rob Herring
2024-09-04 15:07 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 06/37] dt-bindings: Add binding for kalray,coolidge-itgen ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 9:41 ` [RFC PATCH v3 07/37] dt-bindings: Add binding for kalray,coolidge-ipi-ctrl ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 20:50 ` Rob Herring
2024-09-04 15:37 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 08/37] dt-bindings: Add binding for kalray,coolidge-dsu-clock ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 21:45 ` Stephen Boyd
2024-07-22 9:41 ` [RFC PATCH v3 09/37] dt-bindings: Add binding for kalray,kv3-1-timer ysionneau
2024-07-23 20:52 ` Rob Herring
2024-07-22 9:41 ` [RFC PATCH v3 10/37] dt-bindings: kalray: Add CPU bindings for Kalray kvx ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 20:58 ` Rob Herring
2024-07-22 9:41 ` [RFC PATCH v3 11/37] dt-bindings: kalray: Add Kalray SoC board compatibles ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 12/37] kvx: Add ELF-related definitions ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 13/37] kvx: Add build infrastructure ysionneau
2024-07-23 9:46 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 14/37] kvx: Add CPU definition headers ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 15/37] kvx: Add atomic/locking headers ysionneau
2024-07-23 8:26 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 16/37] kvx: Add other common headers ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 17/37] kvx: Add boot and setup routines ysionneau
2024-07-23 8:44 ` Arnd Bergmann
2024-07-27 14:31 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 18/37] kvx: Add exception/interrupt handling ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 19/37] irqchip: Add irq-kvx-apic-gic driver ysionneau
2024-07-22 12:28 ` Krzysztof Kozlowski
2024-08-23 12:37 ` Yann Sionneau
2024-07-27 13:10 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 20/37] irqchip: Add irq-kvx-itgen driver ysionneau
2024-07-22 12:30 ` Krzysztof Kozlowski
2024-08-23 12:42 ` Yann Sionneau
2024-07-27 13:18 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 21/37] irqchip: Add irq-kvx-apic-mailbox driver ysionneau
2024-07-27 13:35 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 22/37] irqchip: Add kvx-core-intc core interrupt controller driver ysionneau
2024-07-22 12:32 ` Krzysztof Kozlowski
2024-08-23 12:54 ` Yann Sionneau
2024-07-27 13:37 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 23/37] kvx: Add process management ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 24/37] kvx: Add memory management ysionneau
2024-07-22 14:58 ` Christoph Hellwig
2024-07-30 13:48 ` Robin Murphy
2024-08-23 16:02 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 25/37] kvx: Add system call support ysionneau
2024-07-23 9:20 ` Arnd Bergmann [this message]
2024-07-22 9:41 ` [RFC PATCH v3 26/37] kvx: Add signal handling support ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 27/37] kvx: Add ELF relocations and module support ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 28/37] kvx: Add misc common routines ysionneau
2024-07-23 8:50 ` Arnd Bergmann
2024-07-23 9:58 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 29/37] kvx: Add some library functions ysionneau
2024-07-23 9:26 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 30/37] kvx: Add multi-processor (SMP) support ysionneau
2024-07-27 14:22 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 31/37] kvx: Add kvx default config file ysionneau
2024-07-23 8:55 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 32/37] kvx: Add debugging related support ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 33/37] kvx: Add support for cpuinfo ysionneau
2024-07-22 12:35 ` Krzysztof Kozlowski
2024-08-23 13:00 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 34/37] kvx: Add power controller driver ysionneau
2024-07-22 12:37 ` Krzysztof Kozlowski
2024-08-23 13:07 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 35/37] kvx: Add IPI driver ysionneau
2024-07-22 12:39 ` Krzysztof Kozlowski
2024-08-23 14:46 ` Yann Sionneau
2024-09-07 13:20 ` Krzysztof Kozlowski
2024-07-27 14:08 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 36/37] kvx: dts: DeviceTree for qemu emulated Coolidge SoC ysionneau
2024-07-22 9:55 ` Krzysztof Kozlowski
2024-07-22 11:12 ` Conor Dooley
2024-07-31 15:38 ` Yann Sionneau
2024-07-31 16:57 ` Krzysztof Kozlowski
2024-07-22 9:41 ` [RFC PATCH v3 37/37] Add Kalray Inc. to the list of vendor-prefixes.yaml ysionneau
2024-07-22 9:56 ` Krzysztof Kozlowski
2024-08-01 7:35 ` Yann Sionneau
2024-07-24 7:59 ` [RFC PATCH v3 00/37] Upstream kvx Linux port Arnd Bergmann
2024-07-25 10:07 ` Yann Sionneau
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=4896ca15-ca23-4723-92e8-c824ee6a8923@app.fastmail.com \
--to=arnd@arndb.de \
--cc=aou@eecs.berkeley.edu \
--cc=brauner@kernel.org \
--cc=clement@clement-leger.fr \
--cc=jborne@kalrayinc.com \
--cc=julien.villette@gmail.com \
--cc=jvetter@kalrayinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mgligor@kalrayinc.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=thouveng@gmail.com \
--cc=ysionneau@kalrayinc.com \
/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
all inboxes | Powered by JetHome®