From nobody Sun Feb 8 04:23:39 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 346322BDC05 for ; Wed, 4 Feb 2026 02:28:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770172117; cv=none; b=fQVGh41r3Oucb27Rv7cx/y9KoNZjbqkAHAnXSlPK4ZiStinHB4blULb6NzjChyy6m/fRQglChmrhQjmvjmrBnAqUTQD8i57YxyNLLHDSvXs7sYBjepkC4KT7zD3XEyHwEyX0dSYMsXGfnpQemB1YF7Qn9awKL/5lnzdcMBub0G0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770172117; c=relaxed/simple; bh=eK7W1+4srvp6F74qzJFzXiz4md/zD2rIs58+CYifDHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NVopEyiCewATfhFXV6CtusN/u3zeXVfE+XHKArbn+dIdGA6CuJk8n4fOLMUHeue71F8JT/Vvm0ed0NOecZ+MGPMW3qFF0xdas539gn4O0fxVr8cdmM3ifpYzVL7aJp4nKO6A4iq6q/DLHYmOVHpcfPIrsngJYnud4PlqVTi937c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RjlDfCHv; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RjlDfCHv" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-81f4dfa82edso3377652b3a.0 for ; Tue, 03 Feb 2026 18:28:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770172107; x=1770776907; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RjNnT/qNufze77W5gRyvHPSLcanY/U9dlqiEm3iR1Nk=; b=RjlDfCHvxnF2IcHkjwVLi42vVSMcfNP4f5yYx3jBJBfX2gghUwpmMojeymfkOMFnxS numYfC0i1whmlHKRAj0z9R3WTORleZYtEwhJmQfH6lsye9FXDnJpQkJSBsOb/MFGyUsj eJYkwTtxYK0hHiRLxHAQGoi0/d8CBVAiEA3YaYpoCiaERDVYgyDMJAhrE5XlowwEjHUc w3J4pDAjJVdwrqvep8jCwRKT7Qfsa3vCAz4mF1ZbtwNHeHxLK7x8gBNsdESVlwYU9zHS M67wk7Z6PolXOOy3DCrLku64918tChP5HWawAEawdri983n+X2uDUu+lHwo9l6If5y+x Z5kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770172107; x=1770776907; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RjNnT/qNufze77W5gRyvHPSLcanY/U9dlqiEm3iR1Nk=; b=naYHxufZtJu5Vbt9zrwMleTzZz/k/pkeqegKY3kCZh+wNZ53oYndl7jIlTU1kOHT9j lpvWfMLPoY7pvN+F3vGq6UBiT1ws9T1TSyYER1LKjPLlxFQqFHUZZGk+8GiuHHp2exAK WP5lm0SHOQvaXVrUv89YXV1pn6r4xvEbCZK+PEZX839JC/HQh7aEMDSakFLW7b9tCthD 8C7TECpTkcK/xssJLgWYWquBkBupCljInlWMVXv1xGVW6Zx6IGz7pG0loFvIhUer4XEp mnxSukQevld5BsIEui1TeC42eUvoBHOQUFN56oOa9v4gyI6ekhmfC5d+Not0K2E/1KLd 5Nuw== X-Forwarded-Encrypted: i=1; AJvYcCWY7hCDZSaCXRYnR+yhQFF1qTENIhzAKINDWRFMdrR8OaJyhq1qb9//1fwE7Cu+Sj5YilrI432l17KzrSw=@vger.kernel.org X-Gm-Message-State: AOJu0YwfrVuMmh6896QBKY1KujBYRQZk6Ugqlz32ywCHjRHfx/ri3+85 J5UWmqSy08bN7Lsts/VpVJZmfC8FmHgt4i98RkO5qYk+fVk6YNvyuJUh X-Gm-Gg: AZuq6aIabpu0u8wlEYgZw7vy7Ae9bC+5iJmsSfZC4sbaoHD6OqYLiwHCQf8yroscWzS sbiqQPRnVuV9iQMftgs58KCEwFqOMyBgfChxY8oZU3lVMointYIwOUnJC9eTk2/X1QwOKHUUHln 4DjvD32seSW68y4JeMKgzTXM3P5d9JrXB+vMpi1JGwirbv3voy+9PDuyI4DY9sEJ+vGbZRgu54F vLY7HZhqa5Zd5MLjCIu+rvBea+3VQZRnKZgU6tHDcXwZWV9mIZ9lVrOh+wdEGs307qi7L5BvQf1 7oSdEaSA1ssjeLdFPGjyVjd13QJEZWZGylKVa98+jw1bu7ZehK1bvbz2ACO/A0JwRYqNs0VdpUl mcjpEOxASL53lO0z4JiXO7Q310HlBP6esP4ZK588Rspp7JJbMUUCxPk4mBJ8cE4PiPc1m6U1k4q /p+SOxQ5zuIqHXKDNfn3yJrJQpi3/CUkYyQ+3wAN10ymykfmCQUnWfyrs9A85LLWH1iw57oOSbW HPI6jAFL3YdibJI X-Received: by 2002:a05:6a00:2d10:b0:81f:be3c:8a24 with SMTP id d2e1a72fcca58-8241c5e9c88mr1483790b3a.36.1770172107592; Tue, 03 Feb 2026 18:28:27 -0800 (PST) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8241d4a5c28sm707551b3a.62.2026.02.03.18.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 18:28:26 -0800 (PST) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id 0A3F21200C3B; Wed, 4 Feb 2026 11:28:24 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org Cc: thehajime@gmail.com, ricarkol@google.com, Liam.Howlett@oracle.com, linux-kernel@vger.kernel.org Subject: [PATCH v14 06/13] x86/um: nommu: process/thread handling Date: Wed, 4 Feb 2026 11:28:04 +0900 Message-ID: <4a58e2e3f5a18c5bae50dd41dc0dc8ae901085ee.1770170302.git.thehajime@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since ptrace facility isn't used under !MMU of UML, there is different code path to invoke processes/threads; there are no external process used, and need to properly configure some of registers (fs segment register for TLS, etc) on every context switch, etc. Signals aren't delivered in non-ptrace syscall entry/leave so, we also need to handle pending signal by ourselves. ptrace related syscalls are not tested yet so, marked arch_has_single_step() unsupported in !MMU environment. Signed-off-by: Hajime Tazaki Signed-off-by: Ricardo Koller --- arch/um/include/asm/ptrace-generic.h | 2 +- arch/x86/um/nommu/Makefile | 2 +- arch/x86/um/nommu/entry_64.S | 2 ++ arch/x86/um/nommu/syscalls.h | 2 ++ arch/x86/um/nommu/syscalls_64.c | 40 ++++++++++++++++++++++++++++ arch/x86/um/syscalls_64.c | 2 +- 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 arch/x86/um/nommu/syscalls_64.c diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptr= ace-generic.h index 62e9916078ec..5aa38fe6b2fb 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h @@ -14,7 +14,7 @@ struct pt_regs { struct uml_pt_regs regs; }; =20 -#define arch_has_single_step() (1) +#define arch_has_single_step() (IS_ENABLED(CONFIG_MMU)) =20 #define EMPTY_REGS { .regs =3D EMPTY_UML_PT_REGS } =20 diff --git a/arch/x86/um/nommu/Makefile b/arch/x86/um/nommu/Makefile index ebe47d4836f4..4018d9e0aba0 100644 --- a/arch/x86/um/nommu/Makefile +++ b/arch/x86/um/nommu/Makefile @@ -5,4 +5,4 @@ else BITS :=3D 64 endif =20 -obj-y =3D do_syscall_$(BITS).o entry_$(BITS).o os-Linux/ +obj-y =3D do_syscall_$(BITS).o entry_$(BITS).o syscalls_$(BITS).o os-Linux/ diff --git a/arch/x86/um/nommu/entry_64.S b/arch/x86/um/nommu/entry_64.S index 485c578aae64..a58922fc81e5 100644 --- a/arch/x86/um/nommu/entry_64.S +++ b/arch/x86/um/nommu/entry_64.S @@ -86,6 +86,8 @@ END(__kernel_vsyscall) */ ENTRY(userspace) =20 + /* set stack and pt_regs to the current task */ + call arch_set_stack_to_current /* clear direction flag to meet ABI */ cld /* align the stack for x86_64 ABI */ diff --git a/arch/x86/um/nommu/syscalls.h b/arch/x86/um/nommu/syscalls.h index a2433756b1fc..ce16bf8abd59 100644 --- a/arch/x86/um/nommu/syscalls.h +++ b/arch/x86/um/nommu/syscalls.h @@ -13,4 +13,6 @@ extern long current_top_of_stack; extern long current_ptregs; =20 +void arch_set_stack_to_current(void); + #endif diff --git a/arch/x86/um/nommu/syscalls_64.c b/arch/x86/um/nommu/syscalls_6= 4.c new file mode 100644 index 000000000000..3b1610280110 --- /dev/null +++ b/arch/x86/um/nommu/syscalls_64.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Copyright 2003 PathScale, Inc. + * + * Licensed under the GPL + */ + +#include +#include +#include +#include +#include /* XXX This should get the constants from libc */ +#include +#include +#include "syscalls.h" + +void arch_set_stack_to_current(void) +{ + current_top_of_stack =3D task_top_of_stack(current); + current_ptregs =3D (long)task_pt_regs(current); +} + +void arch_switch_to(struct task_struct *to) +{ + /* + * In !CONFIG_MMU, it doesn't ptrace thus, + * The FS_BASE registers are saved here. + */ + current_top_of_stack =3D task_top_of_stack(to); + current_ptregs =3D (long)task_pt_regs(to); + + if ((to->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)] =3D=3D 0) || + (to->mm =3D=3D NULL)) + return; + + /* this changes the FS on every context switch */ + arch_prctl(to, ARCH_SET_FS, + (void __user *) to->thread.regs.regs.gp[FS_BASE / sizeof(unsigned lon= g)]); +} diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c index 6a00a28c9cca..9684850603a2 100644 --- a/arch/x86/um/syscalls_64.c +++ b/arch/x86/um/syscalls_64.c @@ -45,7 +45,7 @@ SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, a= rg2) return arch_prctl(current, option, (unsigned long __user *) arg2); } =20 -void arch_switch_to(struct task_struct *to) +__weak void arch_switch_to(struct task_struct *to) { /* * Nothing needs to be done on x86_64. --=20 2.43.0