Commit 2f681ba4 authored by Benjamin Berg's avatar Benjamin Berg Committed by Johannes Berg
Browse files

um: move thread info into task



This selects the THREAD_INFO_IN_TASK option for UM and changes the way
that the current task is discovered. This is trivial though, as UML
already tracks the current task in cpu_tasks[] and this can be used to
retrieve it.

Also remove the signal handler code that copies the thread information
into the IRQ stack. It is obsolete now, which also means that the
mentioned race condition cannot happen anymore.

Signed-off-by: default avatarBenjamin Berg <benjamin.berg@intel.com>
Reviewed-by: default avatarHajime Tazaki <thehajime@gmail.com>
Link: https://patch.msgid.link/20241111102910.46512-1-benjamin@sipsolutions.net


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 0f659ff3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ config UML
	select HAVE_RUST
	select ARCH_HAS_UBSAN
	select HAVE_ARCH_TRACEHOOK
	select THREAD_INFO_IN_TASK

config MMU
	bool
+0 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
generic-y += bug.h
generic-y += compat.h
generic-y += current.h
generic-y += device.h
generic-y += dma-mapping.h
generic-y += emergency-restart.h
+23 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_CURRENT_H
#define __ASM_CURRENT_H

#include <linux/compiler.h>
#include <linux/threads.h>

#ifndef __ASSEMBLY__

struct task_struct;
extern struct task_struct *cpu_tasks[NR_CPUS];

static __always_inline struct task_struct *get_current(void)
{
	return cpu_tasks[0];
}


#define current get_current()

#endif /* __ASSEMBLY__ */

#endif /* __ASM_CURRENT_H */
+0 −16
Original line number Diff line number Diff line
@@ -17,33 +17,17 @@
#include <sysdep/ptrace_user.h>

struct thread_info {
	struct task_struct	*task;		/* main task structure */
	unsigned long		flags;		/* low level flags */
	__u32			cpu;		/* current CPU */
	int			preempt_count;  /* 0 => preemptable,
						   <0 => BUG */
	struct thread_info	*real_thread;    /* Points to non-IRQ stack */
};

#define INIT_THREAD_INFO(tsk)			\
{						\
	.task =		&tsk,			\
	.flags =		0,		\
	.cpu =		0,			\
	.preempt_count = INIT_PREEMPT_COUNT,	\
	.real_thread = NULL,			\
}

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
	struct thread_info *ti;
	unsigned long mask = THREAD_SIZE - 1;
	void *p;

	asm volatile ("" : "=r" (p) : "0" (&ti));
	ti = (struct thread_info *) (((unsigned long)p) & ~mask);
	return ti;
}

#endif
+2 −5
Original line number Diff line number Diff line
@@ -30,11 +30,8 @@

#include <sysdep/ptrace.h>

struct cpu_task {
	void *task;
};

extern struct cpu_task cpu_tasks[];
struct task_struct;
extern struct task_struct *cpu_tasks[];

extern unsigned long long physmem_size;

Loading