Re: [PATCH 3/3] compiler: inline does not imply notrace

2022-11-22 Thread Nadav Amit
On Nov 22, 2022, at 12:09 PM, Arnd Bergmann wrote: > !! External Email > > On Tue, Nov 22, 2022, at 20:53, Nadav Amit wrote: >> From: Nadav Amit >> >> Functions that are marked as "inline" are currently also not tracable. >> Apparently, this has been done to prevent differences between differe

Re: [PATCH 3/3] compiler: inline does not imply notrace

2022-11-22 Thread Steven Rostedt
On Tue, 22 Nov 2022 21:09:08 +0100 "Arnd Bergmann" wrote: > On Tue, Nov 22, 2022, at 20:53, Nadav Amit wrote: > > From: Nadav Amit > > > > Functions that are marked as "inline" are currently also not tracable. > > Apparently, this has been done to prevent differences between different > > config

Re: [PATCH 3/3] compiler: inline does not imply notrace

2022-11-22 Thread Arnd Bergmann
On Tue, Nov 22, 2022, at 20:53, Nadav Amit wrote: > From: Nadav Amit > > Functions that are marked as "inline" are currently also not tracable. > Apparently, this has been done to prevent differences between different > configs that caused different functions to be tracable on different > platform

Re: Build regressions/improvements in v6.1-rc6

2022-11-22 Thread Randy Dunlap
On 11/22/22 07:00, Johannes Berg wrote: > On Tue, 2022-11-22 at 08:55 -0500, Alex Deucher wrote: >>> >>>+ /kisskb/src/arch/um/include/asm/processor-generic.h: error: called >>> object is not a function or function pointer: => 94:18 >>>+ /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/

Re: [PATCH printk v5 00/40] reduce console_lock scope

2022-11-22 Thread Greg Kroah-Hartman
On Wed, Nov 16, 2022 at 05:27:12PM +0106, John Ogness wrote: > This is v5 of a series to prepare for threaded/atomic > printing. v4 is here [0]. This series focuses on reducing the > scope of the BKL console_lock. It achieves this by switching to > SRCU and a dedicated mutex for console list iterat

Re: [PATCH mm-unstable v1 09/20] mm/gup: reliable R/O long-term pinning in COW mappings

2022-11-22 Thread Vlastimil Babka
On 11/16/22 11:26, David Hildenbrand wrote: > We already support reliable R/O pinning of anonymous memory. However, > assume we end up pinning (R/O long-term) a pagecache page or the shared > zeropage inside a writable private ("COW") mapping. The next write access > will trigger a write-fault and

Re: [PATCH mm-unstable v1 08/20] mm: extend FAULT_FLAG_UNSHARE support to anything in a COW mapping

2022-11-22 Thread Vlastimil Babka
On 11/16/22 11:26, David Hildenbrand wrote: > Extend FAULT_FLAG_UNSHARE to break COW on anything mapped into a > COW (i.e., private writable) mapping and adjust the documentation > accordingly. > > FAULT_FLAG_UNSHARE will now also break COW when encountering the shared > zeropage, a pagecache page

Re: Build regressions/improvements in v6.1-rc6

2022-11-22 Thread Johannes Berg
On Tue, 2022-11-22 at 08:55 -0500, Alex Deucher wrote: > > > >+ /kisskb/src/arch/um/include/asm/processor-generic.h: error: called > > object is not a function or function pointer: => 94:18 > >+ /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: > > error: control reaches

Re: [PATCH mm-unstable v1 07/20] mm: don't call vm_ops->huge_fault() in wp_huge_pmd()/wp_huge_pud() for private mappings

2022-11-22 Thread Vlastimil Babka
On 11/16/22 11:26, David Hildenbrand wrote: > If we already have a PMD/PUD mapped write-protected in a private mapping > and we want to break COW either due to FAULT_FLAG_WRITE or > FAULT_FLAG_UNSHARE, there is no need to inform the file system just like on > the PTE path. > > Let's just split (->

Re: [PATCH mm-unstable v1 06/20] mm: rework handling in do_wp_page() based on private vs. shared mappings

2022-11-22 Thread Vlastimil Babka
On 11/16/22 11:26, David Hildenbrand wrote: > We want to extent FAULT_FLAG_UNSHARE support to anything mapped into a > COW mapping (pagecache page, zeropage, PFN, ...), not just anonymous pages. > Let's prepare for that by handling shared mappings first such that we can > handle private mappings la

Re: Build regressions/improvements in v6.1-rc6

2022-11-22 Thread Alex Deucher
On Tue, Nov 22, 2022 at 5:56 AM Geert Uytterhoeven wrote: > > On Tue, 22 Nov 2022, Geert Uytterhoeven wrote: > > JFYI, when comparing v6.1-rc6[1] to v6.1-rc5[3], the summaries are: > > - build errors: +6/-0 > >+ /kisskb/src/arch/sh/include/asm/io.h: error: cast to pointer from > integer of d

Re: Build regressions/improvements in v6.1-rc6

2022-11-22 Thread Geert Uytterhoeven
On Tue, 22 Nov 2022, Geert Uytterhoeven wrote: JFYI, when comparing v6.1-rc6[1] to v6.1-rc5[3], the summaries are: - build errors: +6/-0 + /kisskb/src/arch/sh/include/asm/io.h: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]: => 239:34 sh4-gcc11/sh-allm

[PATCH v2 14/28] um: Remove stub-data.h include from common-offsets.h

2022-11-22 Thread benjamin
From: 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/s

[PATCH v2 27/28] um: Implement kernel side of SECCOMP based process handling

2022-11-22 Thread benjamin
From: Benjamin Berg This adds the kernel side of the seccomp based process handling. Co-authored-by: Johannes Berg Signed-off-by: Benjamin Berg --- arch/um/os-Linux/skas/mem.c | 35 +- arch/um/os-Linux/skas/process.c | 561 arch/um/os-Linux/start_up.c

[PATCH v2 17/28] um: Rework syscall handling

2022-11-22 Thread benjamin
From: 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

[PATCH v2 13/28] um: Mark 32bit syscall helpers as clobbering memory

2022-11-22 Thread benjamin
From: Benjamin Berg The 64bit helper are marked to clobber the memory, but the 32bit ones are not. Add the appropriate clobber to the 32bit helper routines so that the compiler cannot do invalid optimizations. Signed-off-by: Benjamin Berg --- arch/x86/um/shared/sysdep/stub_32.h | 18 ++

[PATCH v2 18/28] um: Store full CSGSFS and SS register from mcontext

2022-11-22 Thread benjamin
From: Benjamin Berg Doing this allows using registers as retrieved from an mcontext to be pushed to a process using PTRACE_SETREGS. It is not entirely clear to me why CSGSFS was masked. Doing so creates issues when using the mcontext as process state in seccomp and simply copying the register ap

[PATCH v2 00/28] Implement SECCOMP based userland

2022-11-22 Thread benjamin
From: Benjamin Berg Currently UML uses ptrace in order to implement userspace processes. This works really well, however, it requires six context switches per pagefault (get faultinfo, run syscalls, continue process). By switching to use SECCOMP, the whole process becomes more collaborative as t

[PATCH v2 10/28] um: Always inline stub functions

2022-11-22 Thread benjamin
From: Benjamin Berg The stub executable page is remapped to a different location in the userland process. As these functions may be used by the stub, they really need to be always inlined rather than permitting the compiler to emit a function. Signed-off-by: Benjamin Berg --- arch/x86/um/share

[PATCH v2 03/28] um: Drop support for hosts without SYSEMU_SINGLESTEP support

2022-11-22 Thread benjamin
From: Benjamin Berg These features have existed since Linux 2.6.14 and can be considered widely available at this point. Also drop the backward compatibility code for PTRACE_SETOPTIONS. Signed-off-by: Benjamin Berg v2: * Continue to define PTRACE_SYSEMU_SINGLESTEP as glibc only added it

[PATCH v2 08/28] um: Reap winch thread if it fails

2022-11-22 Thread benjamin
From: Benjamin Berg When the winch thread runs into an error condition, it would exit(1) and never be reaped until shutdown time. Change this to write a command byte which causes the driver to kill it, therefore reaping the child. Signed-off-by: Benjamin Berg --- arch/um/drivers/chan_user.c |

[PATCH v2 28/28] um: Delay flushing syscalls until the thread is restarted

2022-11-22 Thread benjamin
From: Benjamin Berg This way we can avoid doing two extra context switches when managing processes using seccomp. Signed-off-by: Benjamin Berg --- arch/um/include/shared/os.h| 1 + arch/um/include/shared/skas/skas.h | 1 + arch/um/kernel/skas/process.c | 8 arch/um/kernel/

[PATCH v2 15/28] um: Create signal stack memory assignment in stub_data

2022-11-22 Thread benjamin
From: 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

[PATCH v2 19/28] um: Pass full mm_id to functions creating helper processes

2022-11-22 Thread benjamin
From: Benjamin Berg For seccomp, we need all information about the original process in copy_context_skas0. For consistency, change both copy_context_skas0 and start_userspace to take the mm_id struct as parameter and directly set PID in addition to returning it. Signed-off-by: Benjamin Berg ---

[PATCH v2 22/28] um: Add UML_SECCOMP configuration option

2022-11-22 Thread benjamin
From: Benjamin Berg Add the UML_SECCOMP configuration options. The next commits will add the support itself in smaller chunks. Only x86_64 will be supported for now. Signed-off-by: Benjamin Berg --- arch/um/Kconfig | 19 +++ 1 file changed, 19 insertions(+) diff --git a/arch/

[PATCH v2 23/28] um: Add stub side of SECCOMP/futex based process handling

2022-11-22 Thread benjamin
From: Benjamin Berg This adds the stub side for the new seccomp process management code. In this case we do register save/restore through the signal handler mcontext. For the FS_BASE/GS_BASE register we need special handling. Co-authored-by: Johannes Berg Signed-off-by: Benjamin Berg --- arch

[PATCH v2 09/28] um: Do not use printk in userspace trampoline

2022-11-22 Thread benjamin
From: Benjamin Berg The trampoline is running in a cloned process. It is not safe to use printk for error printing there. Signed-off-by: Benjamin Berg --- arch/um/os-Linux/skas/process.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/um/os-Linux/skas/proc

[PATCH v2 16/28] um: Add generic stub_syscall6 function

2022-11-22 Thread benjamin
From: 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

[PATCH v2 25/28] um: Add SECCOMP support detection and initialization

2022-11-22 Thread benjamin
From: Benjamin Berg This detects seccomp support, sets the global using_seccomp variable and initilizes the exec registers. For now, the implementation simply falls through to the ptrace startup code, meaning that it is unused. Signed-off-by: Benjamin Berg --- arch/um/include/shared/skas/skas.

[PATCH v2 24/28] um: Add helper functions to get/set state for SECCOMP

2022-11-22 Thread benjamin
From: Benjamin Berg When not using ptrace, we need to both save and restore registers through the mcontext as provided by the host kernel to our signal handlers. Add corresponding functions to store the state to an mcontext and helpers to access the mcontext of the subprocess through the stub da

[PATCH v2 12/28] um: Remove unused register save/restore functions

2022-11-22 Thread benjamin
From: Benjamin Berg These functions were only used when calling PTRACE_ARCH_PRCTL, but this code has been removed. Signed-off-by: Benjamin Berg --- arch/um/include/shared/registers.h | 2 -- arch/um/os-Linux/registers.c | 20 2 files changed, 22 deletions(-) diff -

[PATCH v2 11/28] um: Rely on PTRACE_SETREGSET to set FS/GS base registers

2022-11-22 Thread benjamin
From: Benjamin Berg These registers are saved/restored together with the other general registers using ptrace. In arch_set_tls we then just need to set the register and it will be synced back normally. Most of this logic was introduced in commit f39cf7845 ("[PATCH] uml: x86_64 thread fixes")

[PATCH v2 07/28] um: Do not use printk in SIGWINCH helper thread

2022-11-22 Thread benjamin
From: Benjamin Berg The thread is running outside of the UML kernel scope and is a helper. As such, printk cannot work and os_info must be used instead. Signed-off-by: Benjamin Berg --- arch/um/drivers/chan_user.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(

[PATCH v2 01/28] um: Switch printk calls to adhere to correct coding style

2022-11-22 Thread benjamin
From: Benjamin Berg This means having the string literal in one line and using __func__ where appropriate. Signed-off-by: Benjamin Berg --- arch/um/kernel/exec.c | 4 +- arch/um/os-Linux/skas/mem.c | 19 +++-- arch/um/os-Linux/skas/process.c | 121 -

[PATCH v2 26/28] um: Die if a child dies unexpectedly in seccomp mode

2022-11-22 Thread benjamin
From: Benjamin Berg When in seccomp mode, we would hang forever on the futex if a child has died unexpectedly. In contrast, ptrace mode will notice it and kill the corresponding thread when it fails to run it. Fix this issue by simply printing a message and aborting. In this case something from

[PATCH v2 20/28] um: Move faultinfo extraction into userspace routine

2022-11-22 Thread benjamin
From: Benjamin Berg The segv handler is called slightly differently depending on whether PTRACE_FULL_FAULTINFO is set or not (32bit vs. 64bit). The only difference is that we don't try to pass the registers and instruction pointer to the segv handler. It would be good to either document or remov

[PATCH v2 04/28] um: Drop NULL check from start_userspace

2022-11-22 Thread benjamin
From: Benjamin Berg start_userspace is only called from exactly one location, and the passed pointer for the userspace process stack cannot be NULL. Remove the check, without changing the control flow. Signed-off-by: Benjamin Berg --- arch/um/os-Linux/skas/process.c | 53 +++--

[PATCH v2 06/28] um: Don't use vfprintf() for os_info()

2022-11-22 Thread benjamin
From: Benjamin Berg The threads allocated inside the kernel have only a single page of stack. Unfortunately, the vfprintf function in standard glibc may use too much stack-space, overflowing it. To make os_info safe to be used by helper threads, use the kernel vscnprintf function into a smallish

[PATCH v2 21/28] um: Use struct uml_pt_regs for copy_context_skas0

2022-11-22 Thread benjamin
From: Benjamin Berg This is done as preparation for seccomp support as we have no helper to copy the registers from a plain array. Signed-off-by: Benjamin Berg --- arch/um/os-Linux/skas/process.c | 23 +++ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/arch

[PATCH v2 05/28] um: Make errors to stop ptraced child fatal during startup

2022-11-22 Thread benjamin
From: Benjamin Berg For the detection code to check whether SYSEMU_SINGLESTEP works correctly we needed some error cases while stopping to be non-fatal. However, at this point stop_ptraced_child must always succeed, and we can therefore simplify it slightly to exit immediately on error. Signed-o

[PATCH v2 02/28] um: Declare fix_range_common as a static function

2022-11-22 Thread benjamin
From: Benjamin Berg It is only used within the same file. Signed-off-by: Benjamin Berg --- arch/um/kernel/tlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index bc38f79ca3a3..3c709e6146dc 100644 --- a/arch/um/kernel/tlb.c