Re: UML for arm64

2023-06-22 Thread Benjamin Berg
Hi, On Thu, 2023-06-22 at 21:41 +0200, Johannes Berg wrote: > On Thu, 2023-06-22 at 13:22 -0600, Rob Herring wrote: > > I'm interested in getting UML working on Arm. Is anyone aware of any > > efforts to do this already? > > Not me ... But yeah, agree that it seems likely to require some > refac

Re: UML for arm64

2023-06-23 Thread Benjamin Berg
HI, On Thu, 2023-06-22 at 22:23 +0200, Richard Weinberger wrote: > [SNIP] >   > > At least a lot of the register handling, but that will always be > > somewhat architecture specific. > > > > > ... , so perhaps it'd be easier to start with the seccomp-based model: > > > > > > https://patchwork.oz

Re: UML for arm64

2023-06-24 Thread Benjamin Berg
On Sat, 2023-06-24 at 15:15 +0200, Johannes Berg wrote: > On Fri, 2023-06-23 at 16:34 -0600, Rob Herring wrote: > > > > > > > > Either way, the old patchset will give you a good idea about how it all > > > works, the changes are mostly in the details. I am happy to push out a > > > new version so

Re: [PATCH] um: clean up mm creation

2023-09-22 Thread Benjamin Berg
On Fri, 2023-09-22 at 13:16 +0200, Johannes Berg wrote: > From: Johannes Berg > > While enabling PREEMPT on UML, we found that the call to > force_flush_all() cannot be done where it is, it sleeps > while atomic. > > Further investigation shows that all this seems at least > a bit roundabout and

Re: [PATCH] um: clean up mm creation

2023-09-22 Thread Benjamin Berg
Hi, On Fri, 2023-09-22 at 14:41 +0100, Anton Ivanov wrote: > > On 22/09/2023 12:16, Johannes Berg wrote: > > From: Johannes Berg > > > > While enabling PREEMPT on UML, we found that the call to > > force_flush_all() cannot be done where it is, it sleeps > > while atomic. > > > > Further invest

Re: [RFC PATCH 0/3] um: clean up mm creation - another attempt

2023-09-27 Thread Benjamin Berg
Hi, On Tue, 2023-09-26 at 14:38 +0200, Johannes Berg wrote: > [SNIP] > 1. Start from scratch, without copying, which my other patch [1] did. I really think we should go ahead with that approach. Then follow up with optimizations. > [SNIP] > > I think the better approach for correctness and inte

Re: [RFC PATCH 0/3] um: clean up mm creation - another attempt

2023-09-27 Thread Benjamin Berg
Hi, On Wed, 2023-09-27 at 10:59 +0100, Anton Ivanov wrote: > [SNIP] > > I was just looking at all the workaround which are in place to > prevent guest processes doing a syscall on the host. If this is > prohibited at a higher level we should get quite a boost as all these > PTRACE_PEEKs will beco

Re: [PATCH 1/4] um: irqs: process outstanding IRQs when unblocking signals

2023-10-20 Thread Benjamin Berg
On Fri, 2023-10-20 at 11:15 +0200, Benjamin Beichler wrote: > Am 18.10.2023 um 14:36 schrieb benja...@sipsolutions.net: > > From: Benjamin Berg > > > > When in time-travel mode, the eventfd events are read even when signals > > are blocked as SIGIO still needs to be p

Re: [PATCH] um: hostfs: catch EINTR and partial read/write

2023-11-10 Thread Benjamin Berg
Hi, On Fri, 2023-11-10 at 10:56 +, Anton Ivanov wrote: > On 10/11/2023 10:42, Anton Ivanov wrote: > > [SNIP] > > > > If we are going to use this definition of CATCH_EINTR throughout we > > might as well remove the partial read/write code in UBD and other > > places. > > Actually - some of it

Re: [PATCH] um: hostfs: catch EINTR and partial read/write

2023-11-10 Thread Benjamin Berg
On Fri, 2023-11-10 at 11:12 +, Anton Ivanov wrote: > > > On 10/11/2023 11:10, Benjamin Berg wrote: > > Hi, > > > > On Fri, 2023-11-10 at 10:56 +, Anton Ivanov wrote: > > > On 10/11/2023 10:42, Anton Ivanov wrote: > > > > [SNIP] > >

Re: [PATCH RFC 10/11] um: Delay timer_read only in possible busy loops in TT-mode

2023-11-10 Thread Benjamin Berg
ABLES=-AVX512CD in the environment just in case the CPU feature set is slightly different. That would cause ld.so to search for a different set of optimized library versions (affecting syscalls and with that randomness). Benjamin From 0b51202872111f1a5f7a59435ff741ef0272d30f Mon Sep 17 00:00:00 20

Re: [PATCH v3 04/11] um: Don't use vfprintf() for os_info()

2024-01-05 Thread Benjamin Berg
Hi, On Thu, 2024-01-04 at 23:37 +0100, Richard Weinberger wrote: > On Fri, Nov 10, 2023 at 12:03 PM wrote: > > > > From: Benjamin Berg > > > > The threads allocated inside the kernel have only a single page of > > stack. Unfortunately, the vfprintf function

Re: [PATCH v3 09/11] um: Rely on PTRACE_SETREGSET to set FS/GS base registers

2024-01-05 Thread Benjamin Berg
Hi, On Fri, 2024-01-05 at 00:05 +0100, Richard Weinberger wrote: > On Fri, Nov 10, 2023 at 12:03 PM wrote: > > > > From: Benjamin Berg > > > > These registers are saved/restored together with the other general > > registers using ptrace. In arch_set_tls

Re: [PATCH] um: hostfs: catch EINTR and partial read/write

2024-01-05 Thread Benjamin Berg
On Thu, 2024-01-04 at 23:27 +0100, Richard Weinberger wrote: > On Fri, Nov 10, 2023 at 10:44 AM wrote: > > > > From: Benjamin Berg > > > > The UM kernel uses signals for various purposes (SIGALRM for > > scheduling > > for example). These signals

Re: [RFC PATCH 0/3] um: clean up mm creation - another attempt

2024-01-17 Thread Benjamin Berg
Hi, On Wed, 2023-09-27 at 11:52 +0200, Benjamin Berg wrote: > [SNIP] > Once we are there, we can look for optimizations. The fundamental > problem is that page faults (even minor ones) are extremely expensive > for us. > > Just throwing out ideas on what we could do: >

Re: [RFC PATCH 0/3] um: clean up mm creation - another attempt

2024-01-17 Thread Benjamin Berg
On Wed, 2024-01-17 at 19:45 +, Anton Ivanov wrote: > On 17/01/2024 17:17, Benjamin Berg wrote: > > Hi, > > > > On Wed, 2023-09-27 at 11:52 +0200, Benjamin Berg wrote: > > > [SNIP] > > > Once we are there, we can look for optimizations. The fundamental

Re: [PATCH v9] um: Enable preemption in UML

2024-04-19 Thread Benjamin Berg
Hi, On Wed, 2024-04-03 at 07:27 +0100, anton.iva...@cambridgegreys.com wrote: > From: Anton Ivanov > > 1. Preemption requires saving/restoring FPU state. This patch > adds support for it using GCC intrinsics as well as appropriate > storage space in the thread structure. We reuse the space > whi

Re: [PATCH v9] um: Enable preemption in UML

2024-04-21 Thread Benjamin Berg
Hi, On Sat, 2024-04-20 at 13:22 +0100, Anton Ivanov wrote: > On 19/04/2024 14:47, Benjamin Berg wrote: > > Hi, > > > > On Wed, 2024-04-03 at 07:27 +0100, anton.iva...@cambridgegreys.com > > wrote: > > > From: Anton Ivanov > > > > > > 1

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

2024-04-22 Thread Benjamin Berg
On Mon, 2024-04-22 at 10:51 +0800, Tiwei Bie wrote: > On 4/18/24 5:23 PM, benja...@sipsolutions.net wrote: > > diff --git a/arch/um/include/asm/mmu.h b/arch/um/include/asm/mmu.h > > index 37eb6e89e79a..bf8da736609c 100644 > > --- a/arch/um/include/asm/mmu.h > > +++ b/arch/um/include/asm/mmu.h > > @

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

2024-04-22 Thread Benjamin Berg
Hi Tiwei, On Mon, 2024-04-22 at 10:35 +0800, Tiwei Bie wrote: > On 4/18/24 5:23 PM, benja...@sipsolutions.net wrote: > > From: Benjamin Berg > > > > This patchset reworks the stub syscall handling and also redos how page > > table updates are tracked and synchronized.

Re: [PATCH 3/5] um: Do a double clone to disable rseq

2024-05-28 Thread Benjamin Berg
Hi Tiwei, On Tue, 2024-05-28 at 18:16 +0800, Tiwei Bie wrote: > On 5/28/24 4:54 PM, benja...@sipsolutions.net wrote: > > From: Benjamin Berg > > > > Newer glibc versions are enabling rseq support by default. This remains > > enabled in the cloned child process, p

Re: [PATCH 3/5] um: Do a double clone to disable rseq

2024-05-30 Thread Benjamin Berg
Hi, On Thu, 2024-05-30 at 10:54 +0800, Tiwei Bie wrote: > On 5/28/24 10:13 PM, Tiwei Bie wrote: > > On 5/28/24 7:57 PM, Johannes Berg wrote: > > > On Tue, 2024-05-28 at 18:16 +0800, Tiwei Bie wrote: > > > > On 5/28/24 4:54 PM, benja...@sipsolutions.net wrote:

[PATCH v5 1/7] um: Add generic stub_syscall6 function

2024-06-19 Thread Benjamin Berg
This function will be used by the new static stub binary. 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

[PATCH v5 0/7] Increased address space for 64 bit

2024-06-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

[PATCH v5 2/7] um: Add generic stub_syscall1 function

2024-06-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

[PATCH v5 3/7] um: use execveat on memfd to create userspace MMs

2024-06-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

[PATCH v5 4/7] um: Fix stub_start address calculation

2024-06-19 Thread Benjamin Berg
From: Benjamin Berg The calculation was wrong as it only subtracted one and then rounded down for alignment. However, this is incorrect if host_task_size is not already aligned. This probably worked fine because on 64 bit the host_task_size is bigger than returned by os_get_top_address. Signed

[PATCH v5 5/7] um: Limit TASK_SIZE to the addressable range

2024-06-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. Guard against that by clipping the maximum TASK_SIZE to the maximum addressable area. Signed-off-by: Benjamin Berg --- arch/um/kernel/um_arch.c | 7 ++- 1

[PATCH v5 6/7] um: Discover host_task_size from envp

2024-06-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

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

2024-06-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 --- v2: - Do not hide option

[PATCH v6 3/7] um: use execveat to create userspace MMs

2024-06-26 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

[PATCH v6 1/7] um: Add generic stub_syscall6 function

2024-06-26 Thread Benjamin Berg
This function will be used by the new static stub binary. 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

[PATCH v6 5/7] um: Limit TASK_SIZE to the addressable range

2024-06-26 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. Guard against that by clipping the maximum TASK_SIZE to the maximum addressable area. Signed-off-by: Benjamin Berg --- arch/um/kernel/um_arch.c | 7 ++- 1

[PATCH v6 4/7] um: Fix stub_start address calculation

2024-06-26 Thread Benjamin Berg
From: Benjamin Berg The calculation was wrong as it only subtracted one and then rounded down for alignment. However, this is incorrect if host_task_size is not already aligned. This probably worked fine because on 64 bit the host_task_size is bigger than returned by os_get_top_address. Signed

[PATCH v6 6/7] um: Discover host_task_size from envp

2024-06-26 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

[PATCH v6 2/7] um: Add generic stub_syscall1 function

2024-06-26 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

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

2024-06-26 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 --- v2: - Do not hide option

[PATCH v6 0/7] Increased address space for 64 bit

2024-06-26 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

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

[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

[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

[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

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

2024-07-03 Thread Benjamin Berg
sufficient to hold both signal stack and syscall information. Only change the signal stack setup for now, as the syscall code will be reworked later. Signed-off-by: Benjamin Berg --- arch/um/include/shared/as-layout.h | 2 +- arch/um/include/shared/skas/stub-data.h | 9 + arch/um

[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

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

2024-07-03 Thread Benjamin Berg
-off-by: Benjamin Berg --- v4: Fix indentation and typo in commit message --- arch/um/include/shared/os.h | 4 +++ arch/um/include/shared/skas/mm_id.h | 1 - arch/um/include/shared/skas/skas.h | 1 + arch/um/kernel/skas/process.c | 8 ++ arch/um/kernel/tlb.c

[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

[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

[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

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

2024-07-03 Thread Benjamin Berg
surrounding code to track whether syscalls still need to run and if errors occurred. Signed-off-by: Benjamin Berg --- arch/um/include/shared/os.h | 22 +-- arch/um/include/shared/skas/mm_id.h | 1 + arch/um/include/shared/skas/stub-data.h | 35 +++- arch/um/include/shared

[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

[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

[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

[PATCH v7 1/7] um: Add generic stub_syscall1 function

2024-07-04 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

[PATCH v7 0/7] Increased address space for 64 bit

2024-07-04 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

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

2024-07-04 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

[PATCH v7 4/7] um: Limit TASK_SIZE to the addressable range

2024-07-04 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. Guard against that by clipping the maximum TASK_SIZE to the maximum addressable area. Signed-off-by: Benjamin Berg --- v7: Fix integer overflow on 32 bit with 3

[PATCH v7 3/7] um: Fix stub_start address calculation

2024-07-04 Thread Benjamin Berg
From: Benjamin Berg The calculation was wrong as it only subtracted one and then rounded down for alignment. However, this is incorrect if host_task_size is not already aligned. This probably worked fine because on 64 bit the host_task_size is bigger than returned by os_get_top_address. Signed

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

2024-07-04 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

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

2024-07-04 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 --- v7: - Reword options and fix

[PATCH v7 6/7] um: clear all memory in new userspace processes

2024-07-04 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

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

2024-07-04 Thread Benjamin Berg
On Thu, 2024-07-04 at 18:49 +0200, Johannes Berg wrote: > On Thu, 2024-07-04 at 18:27 +0200, Benjamin Berg wrote: > > > > + /* set a nice name */ > > + stub_syscall2(__NR_prctl, PR_SET_NAME, (unsigned long)"uml-userspace"); > > Is that even needed when y

[PATCH v8 1/7] um: Add generic stub_syscall1 function

2024-07-04 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

[PATCH v8 0/7] Increased address space for 64 bit

2024-07-04 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

[PATCH v8 4/7] um: Limit TASK_SIZE to the addressable range

2024-07-04 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. Guard against that by clipping the maximum TASK_SIZE to the maximum addressable area. Signed-off-by: Benjamin Berg --- v7: Fix integer overflow on 32 bit with 3

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

2024-07-04 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

[PATCH v8 3/7] um: Fix stub_start address calculation

2024-07-04 Thread Benjamin Berg
From: Benjamin Berg The calculation was wrong as it only subtracted one and then rounded down for alignment. However, this is incorrect if host_task_size is not already aligned. This probably worked fine because on 64 bit the host_task_size is bigger than returned by os_get_top_address. Signed

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

2024-07-04 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

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

2024-07-04 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 --- v7: - Reword options and fix

[PATCH v8 6/7] um: clear all memory in new userspace processes

2024-07-04 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

Re: [PATCH 4/6] um: Remove unused mm_fd field from mm_id

2024-08-15 Thread Benjamin Berg
Hi Tiwei, On Fri, 2024-08-16 at 09:54 +0800, Tiwei Bie wrote: > It's no longer used since the removal of the SKAS3/4 support. > > Signed-off-by: Tiwei Bie > --- >  arch/um/include/shared/skas/mm_id.h | 1 - >  1 file changed, 1 deletion(-) > > diff --git a/arch/um/include/shared/skas/mm_id.h > b

[PATCH] um: add RCU syscall hack for time-travel

2024-08-30 Thread Benjamin Berg
From: Benjamin Berg In time-travel mode userspace can do a lot of work without any time passing. Unfortunately, this can result in OOM situations as the RCU core code will never be run. Work around that by kicking the RCU using rcu_sched_clock_irq. So behave to the RCU code as if a clock tick

[PATCH] um: always use the internal copy of the FP registers

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg When switching from userspace to the kernel, all registers including the FP registers are copied into the kernel and restored later on. As such, the true source for the FP register state is actually already in the kernel and they should never be grabbed from the userspace

Re: [PATCH] um: always use the internal copy of the FP registers

2024-09-13 Thread Benjamin Berg
On Fri, 2024-09-13 at 10:22 +0200, Benjamin Berg wrote: > From: Benjamin Berg > > When switching from userspace to the kernel, all registers including the > FP registers are copied into the kernel and restored later on. As such, > the true source for the FP register state is actu

Re: [PATCH] um: add RCU syscall hack for time-travel

2024-09-13 Thread Benjamin Berg
Hi, On Thu, 2024-09-12 at 21:02 +0200, Richard Weinberger wrote: > On Fri, Aug 30, 2024 at 5:38 PM Benjamin Berg > wrote: > > > > From: Benjamin Berg > > > > In time-travel mode userspace can do a lot of work without any time > > passing. Unfortunately,

Re: [PATCH] um: add RCU syscall hack for time-travel

2024-09-13 Thread Benjamin Berg
n Fri, 2024-09-13 at 13:47 +0200, Richard Weinberger wrote: > - Ursprüngliche Mail - > > Von: "Benjamin Berg" > > > While I acknowledge that time-travel itself is a beautiful hack, I'd > > > like to keep the hacks > > > to keep it working m

Re: [PATCH] um: always use the internal copy of the FP registers

2024-09-13 Thread Benjamin Berg
Hi, On Fri, 2024-09-13 at 21:09 +0800, Tiwei Bie wrote: > On 2024/9/13 16:22, Benjamin Berg wrote: > > From: Benjamin Berg > > [SNIP] > > diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c > > index be2856af6d4c..ad798d40f8a4 100644 > > --- a/arch/u

[PATCH 2/5] um: Remove unused os_process_parent

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere. --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 39 - 2 files changed, 40 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index c8c1a93c8d2c

[PATCH 3/5] um: Remove unused os_stop_process

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere. --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 5 - 2 files changed, 6 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 4bdd4fb5dd80..a94093bfa5e4 100644 --- a/arch/um

[PATCH 0/5] Minor cleanups for UML

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg This removes a set of unused functions and also select HAVE_EFFICIENT_UNALIGNED_ACCESS on x86 to avoid UBSAN spewing warnings by default. Benjamin Berg (5): um: Remove unused os_process_pc um: Remove unused os_process_parent um: Remove unused os_stop_process um

[PATCH 1/5] um: Remove unused os_process_pc

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere in the codebase. --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 33 - 2 files changed, 34 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index

[PATCH 4/5] um: Remove unused os_getpgrp function

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere. --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 5 - 2 files changed, 6 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index a94093bfa5e4..e54f64f55bb7 100644 --- a/arch/um

[PATCH 5/5] um: Set HAVE_EFFICIENT_UNALIGNED_ACCESS for x86

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The x86 port of UM has efficient unaligned access. Set the option as it is appropriate and will e.g. cause UBSAN to not enable unaligned memory access checking by default. --- arch/x86/um/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/um/Kconfig b/arch

[PATCH v2] um: always use the internal copy of the FP registers

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg When switching from userspace to the kernel, all registers including the FP registers are copied into the kernel and restored later on. As such, the true source for the FP register state is actually already in the kernel and they should never be grabbed from the userspace

[PATCH v2 0/5] Minor cleanups for UML

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg This removes a set of unused functions and also selects HAVE_EFFICIENT_UNALIGNED_ACCESS on x86 to avoid UBSAN spewing warnings by default. v2: Add Signed-off-by to all patches Benjamin Berg (5): um: Remove unused os_process_pc um: Remove unused os_process_parent um

[PATCH v2 1/5] um: Remove unused os_process_pc

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere in the codebase. Signed-off-by: Benjamin Berg --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 33 - 2 files changed, 34 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um

[PATCH v2 2/5] um: Remove unused os_process_parent

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere. Signed-off-by: Benjamin Berg --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 39 - 2 files changed, 40 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include

[PATCH v2 3/5] um: Remove unused os_stop_process

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere. Signed-off-by: Benjamin Berg --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 5 - 2 files changed, 6 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 4bdd4fb5dd80

[PATCH v2 5/5] um: Set HAVE_EFFICIENT_UNALIGNED_ACCESS for x86

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The x86 port of UM has efficient unaligned access. Set the option as it is appropriate and will e.g. cause UBSAN to not enable unaligned memory access checking by default. Signed-off-by: Benjamin Berg --- arch/x86/um/Kconfig | 1 + 1 file changed, 1 insertion(+) diff

[PATCH v2 4/5] um: Remove unused os_getpgrp function

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg The function is not used anywhere. Signed-off-by: Benjamin Berg --- arch/um/include/shared/os.h | 1 - arch/um/os-Linux/process.c | 5 - 2 files changed, 6 deletions(-) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index a94093bfa5e4

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

2024-09-13 Thread Benjamin Berg
From: Benjamin Berg In time-travel mode userspace can do a lot of work without any time passing. Unfortunately, this can result in OOM situations as the RCU core code will never be run. Work around this by keeping track of userspace processes that do not yield for a lot of operations. When this

Re: [PATCH 2/3] um: Remove highmem leftovers

2024-09-15 Thread Benjamin Berg
Hi, does that mean we can also drop the 3-level page table support on i386? It seems like the two level page table is entirely sufficient on a system without high memory (i.e. only 32bit physical addresses). When I took a look at it for the 4-level page table support on 64 bit I got a bit confuse

Re: UML not coming up on "INTEL(R) XEON(R) GOLD 6542Y"

2024-09-17 Thread Benjamin Berg
Hi, if it is really only on that CPU, then maybe it is related to AMX support? Though, not sure how exactly that might be affecting PTRACE_{S,G}ETFPREGS on x86_64. Benjamin On Mon, 2024-09-16 at 13:09 +, Vijay Tandeker wrote: > > > Hi, thanks to all for helping me in the past. I need one m

Re: [PATCH] um: Abandon the _PAGE_NEWPROT bit

2024-10-11 Thread Benjamin Berg
t might make it more clear how everything ties together. Anyway, the change looks good to me. Benjamin Reviewed-by: Benjamin Berg > Signed-off-by: Tiwei Bie > --- >  arch/um/include/asm/pgtable.h   | 40 --- >  arch/um/include/shared/os.h |  2 - >

Re: [RFC PATCH 8/9] um: Implement kernel side of SECCOMP based process handling

2024-10-10 Thread Benjamin Berg
On Thu, 2024-10-10 at 14:12 +0200, Johannes Berg wrote: > On Wed, 2024-09-25 at 22:32 +0200, Benjamin Berg wrote: > > > > + /* > > +* If in seccomp mode, install the SECCOMP filter and > > trigger a syscall. > > +* Otherwise set PTRACE_TRACEME and do

Re: [RFC PATCH 4/9] um: Add stub side of SECCOMP/futex based process handling

2024-10-10 Thread Benjamin Berg
On Thu, 2024-10-10 at 13:51 +0200, Johannes Berg wrote: > On Wed, 2024-09-25 at 22:32 +0200, Benjamin Berg wrote: > > > > --- /dev/null > > +++ b/arch/x86/um/shared/sysdep/stub-data.h > > @@ -0,0 +1,18 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > Th

[PATCH v2] um: switch to regset API and depend on XSTATE

2024-10-10 Thread Benjamin Berg
From: Benjamin Berg The PTRACE_GETREGSET API has now existed since Linux 2.6.33. The XSAVE CPU feature should also be sufficiently common to be able to rely on it. With this, define our internal FP state to be the hosts XSAVE data. Add discovery for the hosts XSAVE size and place the FP

[PATCH] um: switch to regset API and depend on XSTATE

2024-10-07 Thread Benjamin Berg
From: Benjamin Berg The PTRACE_GETREGSET API has now existed since Linux 2.6.33. The XSAVE CPU feature should also be sufficiently common to be able to rely on it. With this, define our internal FP state to be the hosts XSAVE data. Add discovery for the hosts XSAVE size and place the FP

Re: UML not coming up on "INTEL(R) XEON(R) GOLD 6542Y"

2024-10-04 Thread Benjamin Berg
Hi, On Tue, 2024-09-17 at 10:08 +0200, Benjamin Berg wrote: > if it is really only on that CPU, then maybe it is related to AMX > support? Though, not sure how exactly that might be affecting > PTRACE_{S,G}ETFPREGS on x86_64. Just, FYI, it really cannot work if the host kernel has AM

[PATCH] um: remove auxiliary FP registers

2024-10-04 Thread Benjamin Berg
From: Benjamin Berg We do not need the extra save/restore of the FP registers when getting the fault information. This was originally added in commit 2f56debd77a8 ("uml: fix FP register corruption") but at that time the code was not saving/restoring the FP registers when switching to

[RFC PATCH] um: switch to regset API and depend on XSTATE

2024-10-04 Thread Benjamin Berg
From: Benjamin Berg The PTRACE_GETREGSET API has now existed since Linux 2.6.33. The XSAVE CPU feature should also be sufficiently common to be able to rely on it. With this, define our internal FP state to be the hosts XSAVE data. Add discovery for the hosts XSAVE register size and place the

  1   2   3   >