1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * thread_info.h: LoongArch low-level thread information 4 * 5 * Copyright (C) 2020 Loongson Technology Corporation Limited 6 */ 7 8#ifndef _ASM_THREAD_INFO_H 9#define _ASM_THREAD_INFO_H 10 11#ifdef __KERNEL__ 12 13#ifndef __ASSEMBLY__ 14 15#include <asm/processor.h> 16 17/* 18 * low level task data that entry.S needs immediate access to 19 * - this struct should fit entirely inside of one cache line 20 * - this struct shares the supervisor stack pages 21 * - if the contents of this structure are changed, the assembly constants 22 * must also be changed 23 */ 24struct thread_info { 25 struct task_struct *task; /* main task structure */ 26 unsigned long flags; /* low level flags */ 27 unsigned long tp_value; /* thread pointer */ 28 __u32 cpu; /* current CPU */ 29 int preempt_count; /* 0 => preemptable, <0 => BUG */ 30 struct pt_regs *regs; 31 long syscall; /* syscall number */ 32}; 33 34/* 35 * macros/functions for gaining access to the thread information structure 36 */ 37#define INIT_THREAD_INFO(tsk) \ 38{ \ 39 .task = &tsk, \ 40 .flags = _TIF_FIXADE, \ 41 .cpu = 0, \ 42 .preempt_count = INIT_PREEMPT_COUNT, \ 43} 44 45/* How to get the thread information struct from C. */ 46register struct thread_info *__current_thread_info __asm__("$r2"); 47 48static inline struct thread_info *current_thread_info(void) 49{ 50 return __current_thread_info; 51} 52 53register unsigned long current_stack_pointer __asm__("$r3"); 54 55#endif /* !__ASSEMBLY__ */ 56 57/* thread information allocation */ 58#define THREAD_SIZE SZ_16K 59#define THREAD_MASK (THREAD_SIZE - 1UL) 60#define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE) 61/* 62 * thread information flags 63 * - these are process state flags that various assembly files may need to 64 * access 65 * - pending work-to-be-done flags are in LSW 66 * - other flags in MSW 67 */ 68#define TIF_SIGPENDING 1 /* signal pending */ 69#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 70#define TIF_NOTIFY_RESUME 3 /* callback before returning to user */ 71#define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */ 72#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ 73#define TIF_NOHZ 6 /* in adaptive nohz mode */ 74#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 75#define TIF_SYSCALL_TRACE 8 /* syscall trace active */ 76#define TIF_SYSCALL_TRACEPOINT 9 /* syscall tracepoint instrumentation */ 77#define TIF_SECCOMP 10 /* secure computing */ 78#define TIF_UPROBE 11 /* breakpointed or singlestepping */ 79#define TIF_USEDFPU 12 /* FPU was used by this task this quantum (SMP) */ 80#define TIF_USEDSIMD 13 /* SIMD has been used this quantum */ 81#define TIF_MEMDIE 14 /* is terminating due to OOM killer */ 82#define TIF_FIXADE 15 /* Fix address errors in software */ 83#define TIF_LOGADE 16 /* Log address errors to syslog */ 84#define TIF_32BIT_REGS 17 /* 32-bit general purpose registers */ 85#define TIF_32BIT_ADDR 18 /* 32-bit address space */ 86#define TIF_LOAD_WATCH 19 /* If set, load watch registers */ 87#define TIF_SINGLESTEP 20 /* Single Step */ 88#define TIF_LSX_CTX_LIVE 21 /* LSX context must be preserved */ 89#define TIF_LASX_CTX_LIVE 22 /* LASX context must be preserved */ 90#define TIF_PATCH_PENDING 23 /* pending live patching update */ 91#define TIF_USEDLBT 24 /* LBT has been used */ 92#define TIF_LBT_CTX_LIVE 25 /* LBT context */ 93 94#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 95#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 96#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 97#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL) 98#define _TIF_NOHZ (1<<TIF_NOHZ) 99#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 100#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 101#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) 102#define _TIF_SECCOMP (1<<TIF_SECCOMP) 103#define _TIF_UPROBE (1<<TIF_UPROBE) 104#define _TIF_USEDFPU (1<<TIF_USEDFPU) 105#define _TIF_USEDSIMD (1<<TIF_USEDSIMD) 106#define _TIF_FIXADE (1<<TIF_FIXADE) 107#define _TIF_LOGADE (1<<TIF_LOGADE) 108#define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS) 109#define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR) 110#define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH) 111#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 112#define _TIF_LSX_CTX_LIVE (1<<TIF_LSX_CTX_LIVE) 113#define _TIF_LASX_CTX_LIVE (1<<TIF_LASX_CTX_LIVE) 114#define _TIF_USEDLBT (1<<TIF_USEDLBT) 115#define _TIF_LBT_CTX_LIVE (1<<TIF_LBT_CTX_LIVE) 116 117#endif /* __KERNEL__ */ 118#endif /* _ASM_THREAD_INFO_H */ 119