processor.h (d4abde52b4b116111537593e2744b3234d18808d) processor.h (ecd2ada8a5e0b464dab54f71d4ba7bbf5708711f)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 */
5
6#ifndef _ASM_RISCV_PROCESSOR_H
7#define _ASM_RISCV_PROCESSOR_H
8
9#include <linux/const.h>
10#include <linux/cache.h>
11#include <linux/prctl.h>
12
13#include <vdso/processor.h>
14
15#include <asm/ptrace.h>
16
17#ifdef CONFIG_64BIT
18#define DEFAULT_MAP_WINDOW (UL(1) << (MMAP_VA_BITS - 1))
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 */
5
6#ifndef _ASM_RISCV_PROCESSOR_H
7#define _ASM_RISCV_PROCESSOR_H
8
9#include <linux/const.h>
10#include <linux/cache.h>
11#include <linux/prctl.h>
12
13#include <vdso/processor.h>
14
15#include <asm/ptrace.h>
16
17#ifdef CONFIG_64BIT
18#define DEFAULT_MAP_WINDOW (UL(1) << (MMAP_VA_BITS - 1))
19#define STACK_TOP_MAX TASK_SIZE
19#define STACK_TOP_MAX TASK_SIZE_64
20
21#define arch_get_mmap_end(addr, len, flags) \
22({ \
23 unsigned long mmap_end; \
24 typeof(addr) _addr = (addr); \
25 if ((_addr) == 0 || (IS_ENABLED(CONFIG_COMPAT) && is_compat_task())) \
26 mmap_end = STACK_TOP_MAX; \
27 else if ((_addr) >= VA_USER_SV57) \

--- 40 unchanged lines hidden (view full) ---

68#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
69#endif
70
71#ifndef __ASSEMBLY__
72
73struct task_struct;
74struct pt_regs;
75
20
21#define arch_get_mmap_end(addr, len, flags) \
22({ \
23 unsigned long mmap_end; \
24 typeof(addr) _addr = (addr); \
25 if ((_addr) == 0 || (IS_ENABLED(CONFIG_COMPAT) && is_compat_task())) \
26 mmap_end = STACK_TOP_MAX; \
27 else if ((_addr) >= VA_USER_SV57) \

--- 40 unchanged lines hidden (view full) ---

68#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
69#endif
70
71#ifndef __ASSEMBLY__
72
73struct task_struct;
74struct pt_regs;
75
76/*
77 * We use a flag to track in-kernel Vector context. Currently the flag has the
78 * following meaning:
79 *
80 * - bit 0: indicates whether the in-kernel Vector context is active. The
81 * activation of this state disables the preemption.
82 */
83#define RISCV_KERNEL_MODE_V 0x1
84
76/* CPU-specific state of a task */
77struct thread_struct {
78 /* Callee-saved registers */
79 unsigned long ra;
80 unsigned long sp; /* Kernel mode stack */
81 unsigned long s[12]; /* s[0]: frame pointer */
82 struct __riscv_d_ext_state fstate;
83 unsigned long bad_cause;
85/* CPU-specific state of a task */
86struct thread_struct {
87 /* Callee-saved registers */
88 unsigned long ra;
89 unsigned long sp; /* Kernel mode stack */
90 unsigned long s[12]; /* s[0]: frame pointer */
91 struct __riscv_d_ext_state fstate;
92 unsigned long bad_cause;
84 unsigned long vstate_ctrl;
93 u32 riscv_v_flags;
94 u32 vstate_ctrl;
85 struct __riscv_v_ext_state vstate;
86 unsigned long align_ctl;
87};
88
89/* Whitelist the fstate from the task_struct for hardened usercopy */
90static inline void arch_thread_struct_whitelist(unsigned long *offset,
91 unsigned long *size)
92{

--- 58 unchanged lines hidden ---
95 struct __riscv_v_ext_state vstate;
96 unsigned long align_ctl;
97};
98
99/* Whitelist the fstate from the task_struct for hardened usercopy */
100static inline void arch_thread_struct_whitelist(unsigned long *offset,
101 unsigned long *size)
102{

--- 58 unchanged lines hidden ---