Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
4 * Copyright (C) 2012 Regents of the University of California
5 * Copyright (C) 2017 SiFive
6 */
7
8#ifndef _ASM_RISCV_THREAD_INFO_H
9#define _ASM_RISCV_THREAD_INFO_H
10
11#include <asm/page.h>
12#include <linux/const.h>
13
14/* thread information allocation */
15#ifdef CONFIG_64BIT
16#define THREAD_SIZE_ORDER (2)
17#else
18#define THREAD_SIZE_ORDER (1)
19#endif
20#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
21
22#ifndef __ASSEMBLY__
23
24#include <asm/processor.h>
25#include <asm/csr.h>
26
27typedef struct {
28 unsigned long seg;
29} mm_segment_t;
30
31/*
32 * low level task data that entry.S needs immediate access to
33 * - this struct should fit entirely inside of one cache line
34 * - if the members of this struct changes, the assembly constants
35 * in asm-offsets.c must be updated accordingly
36 * - thread_info is included in task_struct at an offset of 0. This means that
37 * tp points to both thread_info and task_struct.
38 */
39struct thread_info {
40 unsigned long flags; /* low level flags */
41 int preempt_count; /* 0=>preemptible, <0=>BUG */
42 mm_segment_t addr_limit;
43 /*
44 * These stack pointers are overwritten on every system call or
45 * exception. SP is also saved to the stack it can be recovered when
46 * overwritten.
47 */
48 long kernel_sp; /* Kernel stack pointer */
49 long user_sp; /* User stack pointer */
50 int cpu;
51};
52
53/*
54 * macros/functions for gaining access to the thread information structure
55 *
56 * preempt_count needs to be 1 initially, until the scheduler is functional.
57 */
58#define INIT_THREAD_INFO(tsk) \
59{ \
60 .flags = 0, \
61 .preempt_count = INIT_PREEMPT_COUNT, \
62 .addr_limit = KERNEL_DS, \
63}
64
65#endif /* !__ASSEMBLY__ */
66
67/*
68 * thread information flags
69 * - these are process state flags that various assembly files may need to
70 * access
71 * - pending work-to-be-done flags are in lowest half-word
72 * - other flags in upper half-word(s)
73 */
74#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
75#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
76#define TIF_SIGPENDING 2 /* signal pending */
77#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
78#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
79#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
80#define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
81#define TIF_SYSCALL_AUDIT 7 /* syscall auditing */
82#define TIF_SECCOMP 8 /* syscall secure computing */
83
84#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
85#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
86#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
87#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
88#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
89#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
90#define _TIF_SECCOMP (1 << TIF_SECCOMP)
91
92#define _TIF_WORK_MASK \
93 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED)
94
95#define _TIF_SYSCALL_WORK \
96 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT | _TIF_SYSCALL_AUDIT | \
97 _TIF_SECCOMP)
98
99#endif /* _ASM_RISCV_THREAD_INFO_H */