2012-03-05 19:49:28 +08:00
|
|
|
/*
|
|
|
|
* Based on arch/arm/include/asm/thread_info.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Russell King.
|
|
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_THREAD_INFO_H
|
|
|
|
#define __ASM_THREAD_INFO_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
struct task_struct;
|
|
|
|
|
2017-07-14 23:39:21 +08:00
|
|
|
#include <asm/memory.h>
|
2016-11-04 04:23:05 +08:00
|
|
|
#include <asm/stack_pointer.h>
|
2012-03-05 19:49:28 +08:00
|
|
|
#include <asm/types.h>
|
|
|
|
|
|
|
|
typedef unsigned long mm_segment_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* low level task data that entry.S needs immediate access to.
|
|
|
|
*/
|
|
|
|
struct thread_info {
|
|
|
|
unsigned long flags; /* low level flags */
|
|
|
|
mm_segment_t addr_limit; /* address limit */
|
2016-07-01 23:53:00 +08:00
|
|
|
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
|
|
|
|
u64 ttbr0; /* saved TTBR0_EL1 */
|
|
|
|
#endif
|
2018-09-20 17:26:40 +08:00
|
|
|
union {
|
|
|
|
u64 preempt_count; /* 0 => preemptible, <0 => bug */
|
|
|
|
struct {
|
|
|
|
#ifdef CONFIG_CPU_BIG_ENDIAN
|
|
|
|
u32 need_resched;
|
|
|
|
u32 count;
|
|
|
|
#else
|
|
|
|
u32 count;
|
|
|
|
u32 need_resched;
|
|
|
|
#endif
|
|
|
|
} preempt;
|
|
|
|
};
|
2012-03-05 19:49:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define thread_saved_pc(tsk) \
|
|
|
|
((unsigned long)(tsk->thread.cpu_context.pc))
|
|
|
|
#define thread_saved_sp(tsk) \
|
|
|
|
((unsigned long)(tsk->thread.cpu_context.sp))
|
|
|
|
#define thread_saved_fp(tsk) \
|
|
|
|
((unsigned long)(tsk->thread.cpu_context.fp))
|
|
|
|
|
2017-08-20 18:20:48 +08:00
|
|
|
void arch_setup_new_exec(void);
|
|
|
|
#define arch_setup_new_exec arch_setup_new_exec
|
|
|
|
|
arm64/sve: Core task context handling
This patch adds the core support for switching and managing the SVE
architectural state of user tasks.
Calls to the existing FPSIMD low-level save/restore functions are
factored out as new functions task_fpsimd_{save,load}(), since SVE
now dynamically may or may not need to be handled at these points
depending on the kernel configuration, hardware features discovered
at boot, and the runtime state of the task. To make these
decisions as fast as possible, const cpucaps are used where
feasible, via the system_supports_sve() helper.
The SVE registers are only tracked for threads that have explicitly
used SVE, indicated by the new thread flag TIF_SVE. Otherwise, the
FPSIMD view of the architectural state is stored in
thread.fpsimd_state as usual.
When in use, the SVE registers are not stored directly in
thread_struct due to their potentially large and variable size.
Because the task_struct slab allocator must be configured very
early during kernel boot, it is also tricky to configure it
correctly to match the maximum vector length provided by the
hardware, since this depends on examining secondary CPUs as well as
the primary. Instead, a pointer sve_state in thread_struct points
to a dynamically allocated buffer containing the SVE register data,
and code is added to allocate and free this buffer at appropriate
times.
TIF_SVE is set when taking an SVE access trap from userspace, if
suitable hardware support has been detected. This enables SVE for
the thread: a subsequent return to userspace will disable the trap
accordingly. If such a trap is taken without sufficient system-
wide hardware support, SIGILL is sent to the thread instead as if
an undefined instruction had been executed: this may happen if
userspace tries to use SVE in a system where not all CPUs support
it for example.
The kernel will clear TIF_SVE and disable SVE for the thread
whenever an explicit syscall is made by userspace. For backwards
compatibility reasons and conformance with the spirit of the base
AArch64 procedure call standard, the subset of the SVE register
state that aliases the FPSIMD registers is still preserved across a
syscall even if this happens. The remainder of the SVE register
state logically becomes zero at syscall entry, though the actual
zeroing work is currently deferred until the thread next tries to
use SVE, causing another trap to the kernel. This implementation
is suboptimal: in the future, the fastpath case may be optimised
to zero the registers in-place and leave SVE enabled for the task,
where beneficial.
TIF_SVE is also cleared in the following slowpath cases, which are
taken as reasonable hints that the task may no longer use SVE:
* exec
* fork and clone
Code is added to sync data between thread.fpsimd_state and
thread.sve_state whenever enabling/disabling SVE, in a manner
consistent with the SVE architectural programmer's model.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Alex Bennée <alex.bennee@linaro.org>
[will: added #include to fix allnoconfig build]
[will: use enable_daif in do_sve_acc]
Signed-off-by: Will Deacon <will.deacon@arm.com>
2017-10-31 23:51:05 +08:00
|
|
|
void arch_release_task_struct(struct task_struct *tsk);
|
|
|
|
|
2012-03-05 19:49:28 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* thread information flags:
|
|
|
|
* TIF_SYSCALL_TRACE - syscall trace active
|
2014-04-30 17:51:29 +08:00
|
|
|
* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace
|
|
|
|
* TIF_SYSCALL_AUDIT - syscall auditing
|
|
|
|
* TIF_SECOMP - syscall secure computing
|
2012-03-05 19:49:28 +08:00
|
|
|
* TIF_SIGPENDING - signal pending
|
|
|
|
* TIF_NEED_RESCHED - rescheduling necessary
|
|
|
|
* TIF_NOTIFY_RESUME - callback before returning to user
|
|
|
|
*/
|
|
|
|
#define TIF_SIGPENDING 0
|
|
|
|
#define TIF_NEED_RESCHED 1
|
|
|
|
#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
|
2014-05-08 17:20:23 +08:00
|
|
|
#define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
|
2016-11-02 17:10:46 +08:00
|
|
|
#define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */
|
2017-06-15 09:12:03 +08:00
|
|
|
#define TIF_FSCHECK 5 /* Check FS is USER_DS on return */
|
2014-05-31 03:34:15 +08:00
|
|
|
#define TIF_NOHZ 7
|
2012-03-05 19:49:28 +08:00
|
|
|
#define TIF_SYSCALL_TRACE 8
|
2014-04-30 17:51:29 +08:00
|
|
|
#define TIF_SYSCALL_AUDIT 9
|
|
|
|
#define TIF_SYSCALL_TRACEPOINT 10
|
|
|
|
#define TIF_SECCOMP 11
|
2012-03-05 19:49:28 +08:00
|
|
|
#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
|
|
|
|
#define TIF_FREEZE 19
|
|
|
|
#define TIF_RESTORE_SIGMASK 20
|
|
|
|
#define TIF_SINGLESTEP 21
|
|
|
|
#define TIF_32BIT 22 /* 32bit process */
|
arm64/sve: Core task context handling
This patch adds the core support for switching and managing the SVE
architectural state of user tasks.
Calls to the existing FPSIMD low-level save/restore functions are
factored out as new functions task_fpsimd_{save,load}(), since SVE
now dynamically may or may not need to be handled at these points
depending on the kernel configuration, hardware features discovered
at boot, and the runtime state of the task. To make these
decisions as fast as possible, const cpucaps are used where
feasible, via the system_supports_sve() helper.
The SVE registers are only tracked for threads that have explicitly
used SVE, indicated by the new thread flag TIF_SVE. Otherwise, the
FPSIMD view of the architectural state is stored in
thread.fpsimd_state as usual.
When in use, the SVE registers are not stored directly in
thread_struct due to their potentially large and variable size.
Because the task_struct slab allocator must be configured very
early during kernel boot, it is also tricky to configure it
correctly to match the maximum vector length provided by the
hardware, since this depends on examining secondary CPUs as well as
the primary. Instead, a pointer sve_state in thread_struct points
to a dynamically allocated buffer containing the SVE register data,
and code is added to allocate and free this buffer at appropriate
times.
TIF_SVE is set when taking an SVE access trap from userspace, if
suitable hardware support has been detected. This enables SVE for
the thread: a subsequent return to userspace will disable the trap
accordingly. If such a trap is taken without sufficient system-
wide hardware support, SIGILL is sent to the thread instead as if
an undefined instruction had been executed: this may happen if
userspace tries to use SVE in a system where not all CPUs support
it for example.
The kernel will clear TIF_SVE and disable SVE for the thread
whenever an explicit syscall is made by userspace. For backwards
compatibility reasons and conformance with the spirit of the base
AArch64 procedure call standard, the subset of the SVE register
state that aliases the FPSIMD registers is still preserved across a
syscall even if this happens. The remainder of the SVE register
state logically becomes zero at syscall entry, though the actual
zeroing work is currently deferred until the thread next tries to
use SVE, causing another trap to the kernel. This implementation
is suboptimal: in the future, the fastpath case may be optimised
to zero the registers in-place and leave SVE enabled for the task,
where beneficial.
TIF_SVE is also cleared in the following slowpath cases, which are
taken as reasonable hints that the task may no longer use SVE:
* exec
* fork and clone
Code is added to sync data between thread.fpsimd_state and
thread.sve_state whenever enabling/disabling SVE, in a manner
consistent with the SVE architectural programmer's model.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Alex Bennée <alex.bennee@linaro.org>
[will: added #include to fix allnoconfig build]
[will: use enable_daif in do_sve_acc]
Signed-off-by: Will Deacon <will.deacon@arm.com>
2017-10-31 23:51:05 +08:00
|
|
|
#define TIF_SVE 23 /* Scalable Vector Extension in use */
|
2017-10-31 23:51:06 +08:00
|
|
|
#define TIF_SVE_VL_INHERIT 24 /* Inherit sve_vl_onexec across exec */
|
2018-05-29 20:11:13 +08:00
|
|
|
#define TIF_SSBD 25 /* Wants SSB mitigation */
|
2012-03-05 19:49:28 +08:00
|
|
|
|
|
|
|
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
|
|
|
|
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
|
|
|
|
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
|
2014-05-08 17:20:23 +08:00
|
|
|
#define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
|
2014-05-31 03:34:15 +08:00
|
|
|
#define _TIF_NOHZ (1 << TIF_NOHZ)
|
2014-04-30 17:51:29 +08:00
|
|
|
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
|
|
|
|
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
|
|
|
|
#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
|
|
|
|
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
|
2016-11-02 17:10:46 +08:00
|
|
|
#define _TIF_UPROBE (1 << TIF_UPROBE)
|
2017-06-15 09:12:03 +08:00
|
|
|
#define _TIF_FSCHECK (1 << TIF_FSCHECK)
|
2012-03-05 19:49:28 +08:00
|
|
|
#define _TIF_32BIT (1 << TIF_32BIT)
|
arm64/sve: Core task context handling
This patch adds the core support for switching and managing the SVE
architectural state of user tasks.
Calls to the existing FPSIMD low-level save/restore functions are
factored out as new functions task_fpsimd_{save,load}(), since SVE
now dynamically may or may not need to be handled at these points
depending on the kernel configuration, hardware features discovered
at boot, and the runtime state of the task. To make these
decisions as fast as possible, const cpucaps are used where
feasible, via the system_supports_sve() helper.
The SVE registers are only tracked for threads that have explicitly
used SVE, indicated by the new thread flag TIF_SVE. Otherwise, the
FPSIMD view of the architectural state is stored in
thread.fpsimd_state as usual.
When in use, the SVE registers are not stored directly in
thread_struct due to their potentially large and variable size.
Because the task_struct slab allocator must be configured very
early during kernel boot, it is also tricky to configure it
correctly to match the maximum vector length provided by the
hardware, since this depends on examining secondary CPUs as well as
the primary. Instead, a pointer sve_state in thread_struct points
to a dynamically allocated buffer containing the SVE register data,
and code is added to allocate and free this buffer at appropriate
times.
TIF_SVE is set when taking an SVE access trap from userspace, if
suitable hardware support has been detected. This enables SVE for
the thread: a subsequent return to userspace will disable the trap
accordingly. If such a trap is taken without sufficient system-
wide hardware support, SIGILL is sent to the thread instead as if
an undefined instruction had been executed: this may happen if
userspace tries to use SVE in a system where not all CPUs support
it for example.
The kernel will clear TIF_SVE and disable SVE for the thread
whenever an explicit syscall is made by userspace. For backwards
compatibility reasons and conformance with the spirit of the base
AArch64 procedure call standard, the subset of the SVE register
state that aliases the FPSIMD registers is still preserved across a
syscall even if this happens. The remainder of the SVE register
state logically becomes zero at syscall entry, though the actual
zeroing work is currently deferred until the thread next tries to
use SVE, causing another trap to the kernel. This implementation
is suboptimal: in the future, the fastpath case may be optimised
to zero the registers in-place and leave SVE enabled for the task,
where beneficial.
TIF_SVE is also cleared in the following slowpath cases, which are
taken as reasonable hints that the task may no longer use SVE:
* exec
* fork and clone
Code is added to sync data between thread.fpsimd_state and
thread.sve_state whenever enabling/disabling SVE, in a manner
consistent with the SVE architectural programmer's model.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Alex Bennée <alex.bennee@linaro.org>
[will: added #include to fix allnoconfig build]
[will: use enable_daif in do_sve_acc]
Signed-off-by: Will Deacon <will.deacon@arm.com>
2017-10-31 23:51:05 +08:00
|
|
|
#define _TIF_SVE (1 << TIF_SVE)
|
2012-03-05 19:49:28 +08:00
|
|
|
|
|
|
|
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
|
2016-11-02 17:10:46 +08:00
|
|
|
_TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
|
2017-06-15 09:12:03 +08:00
|
|
|
_TIF_UPROBE | _TIF_FSCHECK)
|
2012-03-05 19:49:28 +08:00
|
|
|
|
2014-04-30 17:51:29 +08:00
|
|
|
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
|
2014-05-31 03:34:15 +08:00
|
|
|
_TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
|
|
|
|
_TIF_NOHZ)
|
2012-03-05 19:49:28 +08:00
|
|
|
|
2018-05-24 22:54:30 +08:00
|
|
|
#define INIT_THREAD_INFO(tsk) \
|
|
|
|
{ \
|
|
|
|
.flags = _TIF_FOREIGN_FPSTATE, \
|
|
|
|
.preempt_count = INIT_PREEMPT_COUNT, \
|
|
|
|
.addr_limit = KERNEL_DS, \
|
|
|
|
}
|
|
|
|
|
2012-03-05 19:49:28 +08:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* __ASM_THREAD_INFO_H */
|