From f113d0cf3f7e06a3bb360f2b4bf8dcc9bdf96b21 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 13 Nov 2025 12:21:21 -0700 Subject: [PATCH 1/3] thread: change USER_TLS_BEGIN to match Nintendo reserved-space --- nx/source/kernel/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx/source/kernel/thread.c b/nx/source/kernel/thread.c index bd7585271..e35879cc7 100644 --- a/nx/source/kernel/thread.c +++ b/nx/source/kernel/thread.c @@ -12,7 +12,7 @@ #include "../internal.h" #include "../runtime/alloc.h" -#define USER_TLS_BEGIN 0x108 +#define USER_TLS_BEGIN 0x180 #define USER_TLS_END (0x200 - sizeof(ThreadVars)) #define NUM_TLS_SLOTS ((USER_TLS_END - USER_TLS_BEGIN) / sizeof(void*)) From 0f36ee119b617ee039e90b25cdddf5cc9bb8a424 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 13 Nov 2025 12:21:36 -0700 Subject: [PATCH 2/3] pm: add pmshellGetProcessId (19.0.0+) --- nx/include/switch/services/pm.h | 1 + nx/source/services/pm.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/nx/include/switch/services/pm.h b/nx/include/switch/services/pm.h index 13e1fd1f9..1401a5ddc 100644 --- a/nx/include/switch/services/pm.h +++ b/nx/include/switch/services/pm.h @@ -138,3 +138,4 @@ Result pmshellGetApplicationProcessIdForShell(u64* pid_out); Result pmshellBoostSystemMemoryResourceLimit(u64 boost_size); Result pmshellBoostApplicationThreadResourceLimit(void); Result pmshellBoostSystemThreadResourceLimit(void); +Result pmshellGetProcessId(u64* pid_out, u64 program_id); diff --git a/nx/source/services/pm.c b/nx/source/services/pm.c index a178394b9..a4c56b61c 100644 --- a/nx/source/services/pm.c +++ b/nx/source/services/pm.c @@ -199,3 +199,8 @@ Result pmshellBoostSystemThreadResourceLimit(void) { if (!hosversionIsAtmosphere() && hosversionBefore(14,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return _pmCmdVoid(&g_pmshellSrv, 10); } + +Result pmshellGetProcessId(u64* pid_out, u64 program_id) { + if (!hosversionIsAtmosphere() && hosversionBefore(19,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _pmCmdInU64OutU64(pid_out, program_id, &g_pmshellSrv, 12); +} From 02813ae22a7ae75db356512a58506c7a5a3f81c4 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 13 Nov 2025 16:26:54 -0700 Subject: [PATCH 3/3] libnx: add marker for programs compiled after 21.x tls abi change --- nx/source/runtime/switch_crt0.s | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nx/source/runtime/switch_crt0.s b/nx/source/runtime/switch_crt0.s index 85a2ea300..2823592bc 100644 --- a/nx/source/runtime/switch_crt0.s +++ b/nx/source/runtime/switch_crt0.s @@ -83,6 +83,10 @@ __nx_mod0: .word __relro_start - __nx_mod0 .word __data_start - __nx_mod0 + .ascii "LNY2" + .word 0x1 // Version/Fix field, increment on recompile-the-worlds as needed + .word 0x0 // Reserved + .section .bss.__stack_top, "aw", %nobits .global __stack_top .align 3