Re: [PATCH] um: insert scheduler ticks when userspace does not yield

2024-09-19 Thread Benjamin Berg
Hi, On Thu, 2024-09-19 at 16:37 +0200, Benjamin Beichler wrote: > Am 19.09.2024 um 16:22 schrieb Benjamin Berg: > > > Could this also eliminate/address the busy-loop hack in timer_read in > > > time.c? > > Hmm, I was considering changing the other hack in handle_syscall to > > also use this approa

Re: [PATCH] um: insert scheduler ticks when userspace does not yield

2024-09-19 Thread Benjamin Beichler
Am 19.09.2024 um 16:22 schrieb Benjamin Berg: Could this also eliminate/address the busy-loop hack in timer_read in time.c? Hmm, I was considering changing the other hack in handle_syscall to also use this approach. But, I don't think the timer_read hack can be removed. In the case of userspace

Re: [PATCH] um: insert scheduler ticks when userspace does not yield

2024-09-19 Thread Benjamin Berg
Hi, On Thu, 2024-09-19 at 16:11 +0200, Benjamin Beichler wrote: > Could this also eliminate/address the busy-loop hack in timer_read in > time.c? Hmm, I was considering changing the other hack in handle_syscall to also use this approach. But, I don't think the timer_read hack can be removed. In

Re: [PATCH] um: insert scheduler ticks when userspace does not yield

2024-09-19 Thread Benjamin Beichler
Hi, Could this also eliminate/address the busy-loop hack in timer_read in time.c? And another question: Why you remove only 1 extra jiffy in the timer callbacks and not all the extra jiffies? Is there always only 1 or could there be multiple? regards Benjamin Beichler Am 13.09.2024 um 22

[PATCH v9 06/10] um: Calculate stub data address relative to stub code

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg Instead of using the current stack pointer, we can also use the current instruction to calculate where the stub data is. With this the stub data only needs to be aligned to a full page boundary. Changing this has the advantage that we do not have a hole in the memory space ab

[PATCH v9 08/10] um: Discover host_task_size from envp

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg When loading the UML binary, the host kernel will place the stack at the highest possible address. It will then map the program name and environment variables onto the start of the stack. As such, an easy way to figure out the host_task_size is to use the highest pointer to a

[PATCH v9 10/10] um: Switch to 4 level page tables on 64 bit

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg The larger memory space is useful to support more applications inside UML. One example for this is ASAN instrumentation of userspace applications which requires addresses that would otherwise not be available. Signed-off-by: Benjamin Berg --- v9: - Drop support for 3 level

[PATCH v9 09/10] um: clear all memory in new userspace processes

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg With the change to use execve() we can now safely clear the memory up to STUB_START as rseq will not be trying to use memory in that region. Also, on 64 bit the previous changes should mean that there is no usable memory range above the stub. Make the change and remove the co

[PATCH v9 05/10] um: Add compile time assert that stub fits on a page

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg The code assumes that the stub code can fit into a single page. This is unlikely to ever change, but add a link time assert instead so that there will be no hard to debug error. Signed-off-by: Benjamin Berg --- arch/um/kernel/dyn.lds.S | 3 +++ 1 file changed, 3 insertions(

[PATCH v9 07/10] um: Limit TASK_SIZE to the addressable range

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg We may have a TASK_SIZE from the host that is bigger than UML is able to address with a three-level pagetable on 64-bit. Guard against that by clipping the maximum TASK_SIZE to the maximum addressable area. Signed-off-by: Benjamin Berg --- v9: This patch is technically not

[PATCH v9 04/10] um: Set parent death signal for winch thread/process

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg The winch "thread" is really a separate process. Using prctl to set PR_SET_PDEATHSIG ensures that this separate thread will be killed if the UML kernel itself dies unexpectedly and does not perform proper cleanup. Signed-off-by: Benjamin Berg --- arch/um/drivers/chan_user.c

[PATCH v9 01/10] um: Add generic stub_syscall1 function

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg The 64bit version did not have a stub_syscall1 function yet. Add it as it will be useful to implement a static binary for stub loading. Signed-off-by: Benjamin Berg --- arch/x86/um/shared/sysdep/stub_64.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch

[PATCH v9 00/10] Increased address space for 64 bit

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg The new version of the patchset uses execveat on a memfd instead of cloning twice to disable rseq. This should be much more robust going forward as it will also avoid issues with other new features like mseal. This patchset fixes a few bugs, adds a new method of discovering t

[PATCH v9 03/10] um: Set parent death signal for userspace process

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg Enable PR_SET_PDEATHSIG so that the UML userspace process will be killed when the kernel exits unexpectedly. Signed-off-by: Benjamin Berg --- arch/um/kernel/skas/stub_exe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/um/kernel/skas/stub_exe.c b/arch/um/kerne

[PATCH v9 02/10] um: use execveat to create userspace MMs

2024-09-19 Thread Benjamin Berg
From: Benjamin Berg Using clone will not undo features that have been enabled by libc. An example of this already happening is rseq, which could cause the kernel to read/write memory of the userspace process. In the future the standard library might also use mseal by default to protect itself, wh

Re: [PATCH v8 2/7] um: use execveat to create userspace MMs

2024-09-19 Thread Tiwei Bie
On 2024/7/5 03:05, Benjamin Berg wrote: [...] > static int userspace_tramp(void *stack) > { > - struct sigaction sa; > - void *addr; > - int fd; > + char *const argv[] = { "uml-userspace", NULL }; > + int pipe_fds[2]; > unsigned long long offset; > - unsigned long se

Re: [PATCH v8 5/7] um: Discover host_task_size from envp

2024-09-19 Thread Tiwei Bie
On 2024/7/5 03:05, Benjamin Berg wrote: [...] > diff --git a/arch/x86/um/os-Linux/task_size.c > b/arch/x86/um/os-Linux/task_size.c > index 1dc9adc20b1c..a91599799b1a 100644 > --- a/arch/x86/um/os-Linux/task_size.c > +++ b/arch/x86/um/os-Linux/task_size.c > @@ -1,151 +1,19 @@ > // SPDX-License-Ide

Re: [PATCH v3 7/8] execmem: add support for cache of large ROX pages

2024-09-19 Thread Liam R. Howlett
* Mike Rapoport [240909 02:49]: > From: "Mike Rapoport (Microsoft)" > > Using large pages to map text areas reduces iTLB pressure and improves > performance. > > Extend execmem_alloc() with an ability to use huge pages with ROX > permissions as a cache for smaller allocations. > > To populate

Re: [PATCH] um: Remove 3-level page table support on i386

2024-09-19 Thread Tiwei Bie
On 2024/9/19 15:22, Benjamin Berg wrote: > On Thu, 2024-09-19 at 08:54 +0200, Johannes Berg wrote: >> On Wed, 2024-09-18 at 14:17 +0800, Tiwei Bie wrote: >>> The highmem support has been removed by commit a98a6d864d3b ("um: >>> Remove broken highmem support"). The 2-level page table is >>> sufficie

Re: [PATCH] um: Remove 3-level page table support on i386

2024-09-19 Thread Benjamin Berg
On Thu, 2024-09-19 at 08:54 +0200, Johannes Berg wrote: > On Wed, 2024-09-18 at 14:17 +0800, Tiwei Bie wrote: > > The highmem support has been removed by commit a98a6d864d3b ("um: > > Remove broken highmem support"). The 2-level page table is > > sufficient > > on UML/i386 now. Remove the 3-level p