Files
stambha/third_party/patches/linux/0015-bind-initial-stack-and-root-at-mount.patch
T

53 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tyler Smith <74526874+tylertms@users.noreply.github.com>
Date: Tue, 3 Nov 2026 02:07:14 +0000
Subject: [PATCH] fix(init): bind the original initial stack and root at mount
---
init/init_task.c | 6 +++++-
mm/init-mm.c | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/init/init_task.c b/init/init_task.c
index fd564bb2750e5331e3932f9be0bc50231fe6e46a..75919de8c8f0cb7bd54bba7326a6c68e0f6f2b03 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -96,13 +96,17 @@ static struct cred init_cred = {
* Set up the first task table, touch at your own risk!. Base=0,
* limit=0x1fffff (=2MB)
*/
+#ifndef INIT_TASK_STACK
+#define INIT_TASK_STACK init_stack
+#endif
+
struct task_struct init_task __aligned(L1_CACHE_BYTES) = {
#ifdef CONFIG_THREAD_INFO_IN_TASK
.thread_info = INIT_THREAD_INFO(init_task),
.stack_refcount = REFCOUNT_INIT(1),
#endif
.__state = 0,
- .stack = init_stack,
+ .stack = INIT_TASK_STACK,
.usage = REFCOUNT_INIT(2),
.flags = PF_KTHREAD,
.prio = MAX_PRIO - 20,
diff --git a/mm/init-mm.c b/mm/init-mm.c
index 3e792aad762616ec611d272aec2630f142df4c33..bf18457b1a1bef2d3fdde60ef0bc03b7bf36061d 100644
--- a/mm/init-mm.c
+++ b/mm/init-mm.c
@@ -29,9 +29,13 @@ const struct vm_operations_struct vma_dummy_vm_ops;
* Since there is only one init_mm in the entire system, keep it simple
* and size this cpu_bitmask to NR_CPUS.
*/
+#ifndef INIT_MM_PGD
+#define INIT_MM_PGD swapper_pg_dir
+#endif
+
struct mm_struct init_mm = {
.mm_mt = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, init_mm.mmap_lock),
- .pgd = swapper_pg_dir,
+ .pgd = INIT_MM_PGD,
.mm_users = ATOMIC_INIT(2),
.mm_count = ATOMIC_INIT(1),
.write_protect_seq = SEQCNT_ZERO(init_mm.write_protect_seq),