@@ -14,7 +14,7 @@ struct pt_regs {
struct uml_pt_regs regs;
};
-#define arch_has_single_step() (1)
+#define arch_has_single_step() (IS_ENABLED(CONFIG_MMU))
#define EMPTY_REGS { .regs = EMPTY_UML_PT_REGS }
@@ -5,4 +5,4 @@ else
BITS := 64
endif
-obj-y = do_syscall_$(BITS).o entry_$(BITS).o os-Linux/
+obj-y = do_syscall_$(BITS).o entry_$(BITS).o syscalls_$(BITS).o os-Linux/
@@ -86,6 +86,8 @@ END(__kernel_vsyscall)
*/
ENTRY(userspace)
+ /* 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 */
@@ -13,4 +13,6 @@
extern long current_top_of_stack;
extern long current_ptregs;
+void arch_set_stack_to_current(void);
+
#endif
new file mode 100644
@@ -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 <linux/sched.h>
+#include <linux/sched/mm.h>
+#include <linux/syscalls.h>
+#include <linux/uaccess.h>
+#include <asm/prctl.h> /* XXX This should get the constants from libc */
+#include <registers.h>
+#include <os.h>
+#include "syscalls.h"
+
+void arch_set_stack_to_current(void)
+{
+ current_top_of_stack = task_top_of_stack(current);
+ current_ptregs = (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 = task_top_of_stack(to);
+ current_ptregs = (long)task_pt_regs(to);
+
+ if ((to->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)] == 0) ||
+ (to->mm == 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 long)]);
+}
@@ -45,7 +45,7 @@ SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
return arch_prctl(current, option, (unsigned long __user *) arg2);
}
-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.