[RFC PATCH 00/13] nommu UML

2024-10-25 Thread Hajime Tazaki
This is a series of patches of nommu arch addition to UML. It would be nice to ask comments/opinions on this. There are several limitations/issues which we already found; here is the list of those issues. - prompt configured with /etc/profile is broken (variables are not expanded, ${HOSTNAME%%

[PATCH 1/4] um: Add os_set_pdeathsig helper function

2024-10-25 Thread Tiwei Bie
This helper can be used to set the parent-death signal of the calling process to SIGKILL to ensure that the process will be killed if the UML kernel dies unexpectedly without proper cleanup. This helper will be used in the follow-up patches. Signed-off-by: Tiwei Bie --- arch/um/include/shared/os

[RFC PATCH 05/13] x86/um: nommu: syscall translation by zpoline

2024-10-25 Thread Hajime Tazaki
This commit adds a mechanism to hook syscalls for unmodified userspace programs used under UML in !MMU mode. The mechanism, called zpoline, translates syscall/sysenter instructions with `call *%rax`, which can be processed by a trampoline code also installed upon an initcall during boot. The transl

[RFC PATCH 04/13] x86/um: nommu: syscall handling

2024-10-25 Thread Hajime Tazaki
This commit introduces an entry point of syscall interface for !MMU mode. It uses an entry function, __kernel_vsyscall, a kernel-wide global symbol accessible from any locations. Although it isn't in the scope of this commit, it can be also exposed via vdso image which is directly accessible from

[PATCH] um: fix stub exe build with CONFIG_GCOV

2024-10-25 Thread Johannes Berg
From: Johannes Berg CONFIG_GCOV is special and only in UML since it builds the kernel with a "userspace" option. This is fine, but the stub is even more special and not really a full userspace process, so it then fails to link as reported. For good measure, also remove the GPROF options, even th

Re: [PATCH 0/4] um: Set parent-death signal for sub-processes

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 22:28 +0800, Tiwei Bie wrote: > The ubd io and write_sigio threads/processes may leak e.g. when > the main process is killed by "kill -9". Fix it by setting the > parent-death signal for them. > I always used killall, but yeah, good idea, thanks! johannes

Re: [RFC PATCH 06/13] x86/um: nommu: process/thread handling

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > Since ptrace facility isn't used under !MMU of UML, there is different > code path to invoke proceeses/threads; on an entry to the syscall typo: processes > /* Called magically, see new_thread_handler above */ > static void fork_handler(

Re: [RFC PATCH 05/13] x86/um: nommu: syscall translation by zpoline

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > This commit adds a mechanism to hook syscalls for unmodified userspace > programs used under UML in !MMU mode. The mechanism, called zpoline, > translates syscall/sysenter instructions with `call *%rax`, which can be > processed by a trampol

Re: [RFC PATCH 05/13] x86/um: nommu: syscall translation by zpoline

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:19:25 +0900, Johannes Berg wrote: > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > This commit adds a mechanism to hook syscalls for unmodified userspace > > programs used under UML in !MMU mode. The mechanism, called zpoline, > > translates syscall/sysenter

Re: [RFC PATCH 04/13] x86/um: nommu: syscall handling

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:14:19 +0900, Johannes Berg wrote: > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > > > +++ b/arch/x86/um/do_syscall_64.c > > @@ -0,0 +1,42 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +#include > > +#include > > +#include > > +#include > > +#in

Re: [RFC PATCH 08/13] x86/um/vdso: nommu: vdso memory update

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:29:07 +0900, Johannes Berg wrote: > > > > oom: > > - printk(KERN_ERR "Cannot allocate vdso\n"); > > + pr_err("Cannot allocate vdso"); > > kind of unrelated change thanks, will fix it. -- Hajime

Re: [RFC PATCH 07/13] um: nommu: configure fs register on host syscall invocation

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:28:01 +0900, Johannes Berg wrote: > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > > > +static void sigill(int sig, siginfo_t *si, void *ctx_void) > > +{ > > + longjmp(jmpbuf, 1); > > +} > > Should this code use sigsetjmp/siglongjmp? the code is referr

Re: [RFC PATCH 13/13] um: nommu: plug nommu code into build system

2024-10-25 Thread Johannes Berg
On Fri, 2024-10-25 at 22:05 +0900, Hajime Tazaki wrote: > On Fri, 25 Oct 2024 18:33:06 +0900, > Johannes Berg wrote: > > > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > > > > > config MMU > > > - bool > > > + bool "MMU-based Paged Memory Management Support" > > > default y > >

Re: [RFC PATCH 02/13] x86/um: nommu: elf loader for fdpic

2024-10-25 Thread Hajime Tazaki
Hello Johannes, On Fri, 25 Oct 2024 17:56:51 +0900, Johannes Berg wrote: > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > > > +#ifndef CONFIG_MMU > > +#include > > Not sure that makes so much sense in the middle of the file, no harm > always having it? agree. > > +static inl

Re: [RFC PATCH 03/13] um: nommu: memory handling

2024-10-25 Thread Johannes Berg
On Fri, 2024-10-25 at 21:55 +0900, Hajime Tazaki wrote: > > > > Should that really do _nothing_? Perhaps it's not called at all in no- > > MMU, but then you don't need it, but otherwise it seems it should do > > something even if it's just panic()? > > it is called also in !MMU. I'll think to fi

Re: [RFC PATCH 05/13] x86/um: nommu: syscall translation by zpoline

2024-10-25 Thread Johannes Berg
On Fri, 2024-10-25 at 21:58 +0900, Hajime Tazaki wrote: > > > > + if (down_write_killable(&mm->mmap_lock)) { > > > + err = -EINTR; > > > + return err; > > > > ? > > the lock isn't needed actually so, will remove it. Oh, I was just looking at the weird handling of the err variabl

Re: [RFC PATCH 07/13] um: nommu: configure fs register on host syscall invocation

2024-10-25 Thread Johannes Berg
On Fri, 2024-10-25 at 22:27 +0900, Hajime Tazaki wrote: > > On Fri, 25 Oct 2024 18:28:01 +0900, > Johannes Berg wrote: > > > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > > > > > +static void sigill(int sig, siginfo_t *si, void *ctx_void) > > > +{ > > > + longjmp(jmpbuf, 1); > >

Re: [RFC PATCH 13/13] um: nommu: plug nommu code into build system

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:33:06 +0900, Johannes Berg wrote: > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > > > config MMU > > - bool > > + bool "MMU-based Paged Memory Management Support" > > default y > > "if !64bit" or something not sure if I understand correctly but

[PATCH 3/4] um: Set parent-death signal for write_sigio thread/process

2024-10-25 Thread Tiwei Bie
The write_sigio thread is not really a traditional thread. Set the parent-death signal for it to ensure that it will be killed if the UML kernel dies unexpectedly without proper cleanup. Signed-off-by: Tiwei Bie --- arch/um/os-Linux/sigio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arc

Re: [RFC PATCH 03/13] um: nommu: memory handling

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:11:01 +0900, Johannes Berg wrote: > > (I should say, I'm still reading through this, and haven't formed an > overall opinion. Just nitpicking on the details as I see them for now) thanks anyway. looking forward to any opinions. > > +#endif > > + > > > > #include >

Re: [RFC PATCH 06/13] x86/um: nommu: process/thread handling

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:22:29 +0900, Johannes Berg wrote: > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > Since ptrace facility isn't used under !MMU of UML, there is different > > code path to invoke proceeses/threads; on an entry to the syscall > > typo: processes thanks. (I t

Re: [RFC PATCH 09/13] x86/um: nommu: signal handling

2024-10-25 Thread Hajime Tazaki
On Fri, 25 Oct 2024 18:30:41 +0900, Johannes Berg wrote: > > On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > This commit updates the behavior of signal handling under !MMU > > environment. 1) the stack preparation for the signal handlers and > > 2) retoration of stack after rt_sigret

Re: provide generic page_to_phys and phys_to_page implementations v3

2024-10-25 Thread Arnd Bergmann
On Wed, Oct 23, 2024, at 05:36, Christoph Hellwig wrote: > page_to_phys is duplicated by all architectures, and from some strange > reason placed in where it doesn't fit at all. > > phys_to_page is only provided by a few architectures despite having a lot > of open coded users. > > Provide gene

[PATCH][next] um: Malloc just enough space for fitting pid file

2024-10-25 Thread Paulo Miguel Almeida
umid is already generated during make_umid_init __initcall so there is no need to allocate UMID_LEN bytes to accommodate the max possible name for the umid segment of the filepath This patch replaces UMID_LEN occurences in which it's redundant Signed-off-by: Paulo Miguel Almeida --- arch/um/os-

Re: [RFC PATCH 13/13] um: nommu: plug nommu code into build system

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > config MMU > - bool > + bool "MMU-based Paged Memory Management Support" > default y "if !64bit" or something > config UML_DMA_EMULATION > @@ -187,8 +190,14 @@ config MAGIC_SYSRQ > The keys are documented in >

[PATCH v5] um: Remove double zero check

2024-10-25 Thread Shaojie Dong
free_pages() performs a parameter null check inside therefore remove double zero check here. Signed-off-by: Shaojie Dong --- Changes in v5: - EDITME: fit the git setup and simplify commit description - Link to v4: https://lore.kernel.org/r/20241025-upstream_branch-v4-1-8967d1b6e...@quicinc.com

Re: [RFC PATCH 02/13] x86/um: nommu: elf loader for fdpic

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > +#ifndef CONFIG_MMU > +#include Not sure that makes so much sense in the middle of the file, no harm always having it? > > +static inline const struct user_regset_view *task_user_regset_view( > + struct task_struct *task) What hap

Re: [RFC PATCH 03/13] um: nommu: memory handling

2024-10-25 Thread Johannes Berg
(I should say, I'm still reading through this, and haven't formed an overall opinion. Just nitpicking on the details as I see them for now) > +#endif > + > > #include extra newline > /* tlb.c */ > +#ifdef CONFIG_MMU > extern void report_enomem(void); > +#else > +static inline void report_e

Re: [RFC PATCH 04/13] x86/um: nommu: syscall handling

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > +++ b/arch/x86/um/do_syscall_64.c > @@ -0,0 +1,42 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#include > +#include > +#include > +#include > +#include > + > +#ifndef CONFIG_MMU This seems unnecessary, you don't build the file w

Re: [RFC PATCH 07/13] um: nommu: configure fs register on host syscall invocation

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > > +static void sigill(int sig, siginfo_t *si, void *ctx_void) > +{ > + longjmp(jmpbuf, 1); > +} Should this code use sigsetjmp/siglongjmp? > +int os_has_fsgsbase(void) > +{ > + return has_fsgsbase; > +} Why should this be a funct

Re: [RFC PATCH 08/13] x86/um/vdso: nommu: vdso memory update

2024-10-25 Thread Johannes Berg
> oom: > - printk(KERN_ERR "Cannot allocate vdso\n"); > + pr_err("Cannot allocate vdso"); kind of unrelated change johannes

Re: [RFC PATCH 09/13] x86/um: nommu: signal handling

2024-10-25 Thread Johannes Berg
On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote: > This commit updates the behavior of signal handling under !MMU > environment. 1) the stack preparation for the signal handlers and > 2) retoration of stack after rt_sigreturn(2) syscall. Those areĀ  typo: restoration > @@ -562,6 +574,20 @@