/* SPDX-License-Identifier: GPL-2.0 */ /* * thread_info.h: LoongArch low-level thread information * * Copyright (C) 2020 Loongson Technology Corporation Limited */ #ifndef _ASM_THREAD_INFO_H #define _ASM_THREAD_INFO_H #ifdef __KERNEL__ #ifndef __ASSEMBLY__ #include /* * low level task data that entry.S needs immediate access to * - this struct should fit entirely inside of one cache line * - this struct shares the supervisor stack pages * - if the contents of this structure are changed, the assembly constants * must also be changed */ struct thread_info { struct task_struct *task; /* main task structure */ unsigned long flags; /* low level flags */ unsigned long tp_value; /* thread pointer */ __u32 cpu; /* current CPU */ int preempt_count; /* 0 => preemptible, <0 => BUG */ struct pt_regs *regs; long syscall; /* syscall number */ }; /* * macros/functions for gaining access to the thread information structure */ #define INIT_THREAD_INFO(tsk) \ { \ .task = &tsk, \ .flags = _TIF_FIXADE, \ .cpu = 0, \ .preempt_count = INIT_PREEMPT_COUNT, \ } /* How to get the thread information struct from C. */ register struct thread_info *__current_thread_info __asm__("$r2"); static inline struct thread_info *current_thread_info(void) { return __current_thread_info; } register unsigned long current_stack_pointer __asm__("$r3"); #endif /* !__ASSEMBLY__ */ /* thread information allocation */ #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT) #define THREAD_SIZE_ORDER (1) #endif #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_64BIT) #define THREAD_SIZE_ORDER (2) #endif #ifdef CONFIG_PAGE_SIZE_16KB #define THREAD_SIZE_ORDER (0) #endif #ifdef CONFIG_PAGE_SIZE_64KB #define THREAD_SIZE_ORDER (0) #endif #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) #define THREAD_MASK (THREAD_SIZE - 1UL) #define STACK_WARN (THREAD_SIZE / 8) /* * thread information flags * - these are process state flags that various assembly files may need to * access * - pending work-to-be-done flags are in LSW * - other flags in MSW */ #define TIF_SIGPENDING 1 /* signal pending */ #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ #define TIF_NOTIFY_RESUME 3 /* callback before returning to user */ #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ #define TIF_NOHZ 5 /* in adaptive nohz mode */ #define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ #define TIF_SYSCALL_TRACE 7 /* syscall trace active */ #define TIF_SYSCALL_TRACEPOINT 8 /* syscall tracepoint instrumentation */ #define TIF_SECCOMP 9 /* secure computing */ #define TIF_UPROBE 10 /* breakpointed or singlestepping */ #define TIF_USEDFPU 11 /* FPU was used by this task this quantum (SMP) */ #define TIF_USEDSIMD 12 /* SIMD has been used this quantum */ #define TIF_MEMDIE 13 /* is terminating due to OOM killer */ #define TIF_FIXADE 14 /* Fix address errors in software */ #define TIF_LOGADE 15 /* Log address errors to syslog */ #define TIF_32BIT_REGS 16 /* 32-bit general purpose registers */ #define TIF_32BIT_ADDR 17 /* 32-bit address space */ #define TIF_FPUBOUND 18 /* thread bound to FPU-full CPU set */ #define TIF_LOAD_WATCH 19 /* If set, load watch registers */ #define TIF_LSX_CTX_LIVE 20 /* LSX context must be preserved */ #define TIF_LASX_CTX_LIVE 21 /* LASX context must be preserved */ #define TIF_PATCH_PENDING 22 /* pending live patching update */ #define TIF_USEDLBT 23 /* LBT has been used */ #define TIF_LBT_CTX_LIVE 24 /* LBT context */ #define TIF_SINGLESTEP 25 #define _TIF_SIGPENDING (1<