Re: [PATCH] um: register power-off handler

2024-07-03 Thread Anton Ivanov
On 03/07/2024 16:38, Johannes Berg wrote: From: Johannes Berg Otherwise we always get reboot: Power off not available: System halted instead which is really quite pointless. Signed-off-by: Johannes Berg --- arch/um/kernel/reboot.c | 15 +++ 1 file changed, 15 insertions(

Re: [PATCH] um: line: always fill *error_out in setup_one_line()

2024-07-03 Thread Anton Ivanov
On 03/07/2024 16:22, Johannes Berg wrote: From: Johannes Berg The pointer isn't initialized by callers, but I have encountered cases where it's still printed; initialize it in all possible cases in setup_one_line(). Signed-off-by: Johannes Berg --- arch/um/drivers/line.c | 2 ++ 1 file

Re: [PATCH] um: remove pcap driver from documentation

2024-07-03 Thread Anton Ivanov
On 03/07/2024 16:20, Johannes Berg wrote: From: Johannes Berg We just removed the driver, but forgot the row in the documentation table mentioning it. Remove that. Signed-off-by: Johannes Berg --- Documentation/virt/uml/user_mode_linux_howto_v2.rst | 2 -- 1 file changed, 2 deletions(-)

Re: vector: spinlock ordering problems

2024-07-03 Thread Anton Ivanov
On 03/07/2024 17:26, Johannes Berg wrote: Lockdep reports a spinlock ordering problem: sometimes we take head_lock first, sometimes tail_lock, so there's a classic ABBA deadlock possible. It may not happen now because of UML being single-CPU and all that, but perhaps with preempt? You need both

[PATCH] um: vector: always reset vp->opened

2024-07-03 Thread Johannes Berg
From: Johannes Berg If open fails, we have already set vp->opened, but it's not reset so that any further attempts will just return -ENXIO. Reset vp->opened even if close has nothing to do. This helps e.g. with slirp4netns handling only a single connection, you can then restart it and open the d

[PATCH v2] um: vector: remove vp->lock

2024-07-03 Thread Johannes Berg
From: Johannes Berg This lock is useless, all the places that are using it for some locking will already hold the RTNL. Just remove it. Signed-off-by: Johannes Berg --- v2: remove unused flags variables --- arch/um/drivers/vector_kern.c | 16 +--- arch/um/drivers/vector_kern.h | 1

[PATCH] um: vector: remove vp->lock

2024-07-03 Thread Johannes Berg
From: Johannes Berg This lock is useless, all the places that are using it for some locking will already hold the RTNL. Just remove it. Signed-off-by: Johannes Berg --- arch/um/drivers/vector_kern.c | 14 +- arch/um/drivers/vector_kern.h | 1 - 2 files changed, 1 insertion(+), 14

vector: spinlock ordering problems

2024-07-03 Thread Johannes Berg
Lockdep reports a spinlock ordering problem: sometimes we take head_lock first, sometimes tail_lock, so there's a classic ABBA deadlock possible. It may not happen now because of UML being single-CPU and all that, but perhaps with preempt? Report: =

[PATCH] um: register power-off handler

2024-07-03 Thread Johannes Berg
From: Johannes Berg Otherwise we always get reboot: Power off not available: System halted instead which is really quite pointless. Signed-off-by: Johannes Berg --- arch/um/kernel/reboot.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/arch/um/kernel/reboot.c b/arch/um

[PATCH] um: line: always fill *error_out in setup_one_line()

2024-07-03 Thread Johannes Berg
From: Johannes Berg The pointer isn't initialized by callers, but I have encountered cases where it's still printed; initialize it in all possible cases in setup_one_line(). Signed-off-by: Johannes Berg --- arch/um/drivers/line.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/um/dr

[PATCH] um: remove pcap driver from documentation

2024-07-03 Thread Johannes Berg
From: Johannes Berg We just removed the driver, but forgot the row in the documentation table mentioning it. Remove that. Signed-off-by: Johannes Berg --- Documentation/virt/uml/user_mode_linux_howto_v2.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/Documentation/virt/uml/user_mode_l

[PATCH v4 09/12] um: Do not flush MM in flush_thread

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg There should be no need to flush the memory in flush_thread. Doing this likely worked around some issue where memory was still incorrectly mapped when creating or cloning an MM. With the removal of the special clone path, that isn't relevant anymore. However, add the flush in

[PATCH v4 00/12] Rework stub syscall and page table handling

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg This patchset reworks the stub syscall handling and also redos how page table updates are tracked and synchronized. Some of this originated in the SECCOMP patchset, but it became clear that these refactorings make sense independently as they result in a considerably fewer page

[PATCH v4 12/12] um: refactor TLB update handling

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg Conceptually, we want the memory mappings to always be up to date and represent whatever is in the TLB. To ensure that, we need to sync them over in the userspace case and for the kernel we need to process the mappings. The kernel will call flush_tlb_* if page table entries t

[PATCH v4 11/12] um: simplify and consolidate TLB updates

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg The HVC update was mostly used to compress consecutive calls into one. This is mostly relevant for userspace where it is already handled by the syscall stub code. Simplify the whole logic and consolidate it for both kernel and userspace. This does remove the sequential syscal

[PATCH v4 07/12] um: remove copy_context_skas0

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg The kernel flushes the memory ranges anyway for CoW and does not assume that the userspace process has anything set up already. So, start with a fresh process for the new mm context. Signed-off-by: Benjamin Berg --- arch/um/include/shared/os.h | 1 - arch/um/i

[PATCH v4 04/12] um: Rework syscall handling

2024-07-03 Thread Benjamin Berg
Rework syscall handling to be platform independent. Also create a clean split between queueing of syscalls and flushing them out, removing the need to keep state in the code that triggers the syscalls. The code adds syscall_data_len to the global mm_id structure. This will be used later to allow s

[PATCH v4 10/12] um: remove force_flush_all from fork_handler

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg There should be no need for this. It may be that this used to work around another issue where after a clone the MM was in a bad state. Signed-off-by: Benjamin Berg --- arch/um/include/asm/mmu_context.h | 2 -- arch/um/kernel/process.c | 2 -- arch/um/kernel/tlb.c

[PATCH v4 08/12] um: Delay flushing syscalls until the thread is restarted

2024-07-03 Thread Benjamin Berg
As running the syscalls is expensive due to context switches, we should do so as late as possible in case more syscalls need to be queued later on. This will also benefit a later move to a SECCOMP enabled userspace as in that case the need for extra context switches is removed entirely. Signed-off

[PATCH v4 02/12] um: Create signal stack memory assignment in stub_data

2024-07-03 Thread Benjamin Berg
When we switch to use seccomp, we need both the signal stack and other data (i.e. syscall information) to co-exist in the stub data. To facilitate this, start by defining separate memory areas for the stack and syscall data. This moves the signal stack onto a new page as the memory area is not suf

[PATCH v4 01/12] um: Remove stub-data.h include from common-offsets.h

2024-07-03 Thread Benjamin Berg
Further commits will require values from common-offsets.h inside stub-data.h. Resolve the possible circular dependency and simply use offsetof() inside stub_32.h and stub_64.h. Signed-off-by: Benjamin Berg --- arch/um/include/shared/common-offsets.h | 5 - arch/x86/um/shared/sysdep/stub_32.h

[PATCH v4 06/12] um: remove LDT support

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg The current LDT code has a few issues that mean it should be redone in a different way once we always start with a fresh MM even when cloning. In a new and better world, the kernel would just ensure its own LDT is clear at startup. At that point, all that is needed is a simpl

[PATCH v4 03/12] um: Add generic stub_syscall6 function

2024-07-03 Thread Benjamin Berg
This function will be used by the new syscall handling code. Signed-off-by: Benjamin Berg --- arch/x86/um/shared/sysdep/stub_32.h | 22 ++ arch/x86/um/shared/sysdep/stub_64.h | 16 2 files changed, 38 insertions(+) diff --git a/arch/x86/um/shared/sysdep/stub

[PATCH v4 05/12] um: compress memory related stub syscalls while adding them

2024-07-03 Thread Benjamin Berg
From: Benjamin Berg To keep the number of syscalls that the stub has to do lower, compress two consecutive syscalls of the same type if the second is just a continuation of the first. Signed-off-by: Benjamin Berg --- arch/um/os-Linux/skas/mem.c | 39 + 1 fil

Re: [PATCH v3 10/12] um: remove force_flush_all from fork_handler

2024-07-03 Thread Johannes Berg
On Wed, 2024-07-03 at 11:45 +0200, Johannes Berg wrote: > On Fri, 2024-05-24 at 23:37 +0200, benja...@sipsolutions.net wrote: > > From: Benjamin Berg > > > > There should be no need for this. > > "should" ;-) > > This breaks things if glibc enables rseq. That might even be already > broken in t

Re: [PATCH v6 7/7] um: Add 4 level page table support

2024-07-03 Thread Johannes Berg
On Wed, 2024-06-26 at 15:53 +0200, Benjamin Berg wrote: > > +choice > + prompt "Pagetable levels" > + default 2_LEVEL_PGTABLES if !64BIT > + default 4_LEVEL_PGTABLES if 64BIT > + > + config 2_LEVEL_PGTABLES > + bool "Two-level pagetables" if !64BIT > + depen

[PATCH v2] um: time-travel: fix signal blocking race/hang

2024-07-03 Thread Johannes Berg
From: Johannes Berg When signals are hard-blocked in order to do time-travel socket processing, we set signals_blocked and then handle SIGIO signals by setting the SIGIO bit in signals_pending. When unblocking, we first set signals_blocked to 0, and then handle all pending signals. We have to set

[PATCH] um: time-travel: remove time_exit()

2024-07-03 Thread Johannes Berg
From: Johannes Berg This function is unused and unneeded, remove it. Signed-off-by: Johannes Berg --- arch/um/kernel/time.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index d44eaad53d9d..47b9f5e63566 100644 --- a/arch/um/kernel/time.c

Re: [PATCH v3 10/12] um: remove force_flush_all from fork_handler

2024-07-03 Thread Johannes Berg
On Wed, 2024-07-03 at 12:08 +0200, Benjamin Berg wrote: > On Wed, 2024-07-03 at 11:45 +0200, Johannes Berg wrote: > > On Fri, 2024-05-24 at 23:37 +0200, benja...@sipsolutions.net wrote: > > > From: Benjamin Berg > > > > > > There should be no need for this. > > > > "should" ;-) > > Hmm, I would

Re: [PATCH v3 10/12] um: remove force_flush_all from fork_handler

2024-07-03 Thread Benjamin Berg
On Wed, 2024-07-03 at 11:45 +0200, Johannes Berg wrote: > On Fri, 2024-05-24 at 23:37 +0200, benja...@sipsolutions.net wrote: > > From: Benjamin Berg > > > > There should be no need for this. > > "should" ;-) Hmm, I would have expected the previous patch is what breaks it. i.e. this line that

Re: [PATCH v3 10/12] um: remove force_flush_all from fork_handler

2024-07-03 Thread Johannes Berg
On Fri, 2024-05-24 at 23:37 +0200, benja...@sipsolutions.net wrote: > From: Benjamin Berg > > There should be no need for this. "should" ;-) This breaks things if glibc enables rseq. That might even be already broken in the sense that it might corrupt memory that's put at the same place the rse