Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
5fc7355
Documentation
LICENSES
arch
alpha
arc
arm
arm64
csky
hexagon
loongarch
m68k
microblaze
mips
nios2
openrisc
parisc
powerpc
riscv
boot
configs
crypto
errata
include
asm
vdso
vendor_extensions
Kbuild
acenv.h
acpi.h
alternative-macros.h
alternative.h
arch_hweight.h
archrandom.h
asm-extable.h
asm-offsets.h
asm-prototypes.h
asm.h
assembler.h
atomic.h
barrier.h
bitops.h
bug.h
cache.h
cacheflush.h
cacheinfo.h
cfi.h
checksum.h
clint.h
clocksource.h
cmpxchg.h
compat.h
cpu.h
cpu_ops.h
cpu_ops_sbi.h
cpufeature.h
cpuidle.h
crash_reserve.h
csr.h
current.h
delay.h
dma-noncoherent.h
dmi.h
efi.h
elf.h
entry-common.h
errata_list.h
exec.h
extable.h
fence.h
fixmap.h
fpu.h
ftrace.h
futex.h
gdb_xml.h
gpr-num.h
hugetlb.h
hwcap.h
hwprobe.h
image.h
insn-def.h
insn.h
io.h
irq.h
irq_stack.h
irq_work.h
irqflags.h
jump_label.h
kasan.h
kdebug.h
kexec.h
kfence.h
kgdb.h
kprobes.h
kvm_aia.h
kvm_host.h
kvm_types.h
kvm_vcpu_fp.h
kvm_vcpu_insn.h
kvm_vcpu_pmu.h
kvm_vcpu_sbi.h
kvm_vcpu_timer.h
kvm_vcpu_vector.h
linkage.h
membarrier.h
mmio.h
mmiowb.h
mmu.h
mmu_context.h
module.h
module.lds.h
numa.h
page.h
paravirt.h
paravirt_api_clock.h
patch.h
pci.h
perf_event.h
pgalloc.h
pgtable-32.h
pgtable-64.h
pgtable-bits.h
pgtable.h
probes.h
processor.h
ptrace.h
sbi.h
scs.h
seccomp.h
sections.h
semihost.h
set_memory.h
signal32.h
simd.h
smp.h
soc.h
sparsemem.h
stackprotector.h
stacktrace.h
string.h
suspend.h
switch_to.h
sync_core.h
syscall.h
syscall_table.h
syscall_wrapper.h
thread_info.h
timex.h
tlb.h
tlbbatch.h
tlbflush.h
topology.h
trace.h
uaccess.h
unistd.h
uprobes.h
vdso.h
vector.h
vendor_extensions.h
vendorid_list.h
vermagic.h
vmalloc.h
word-at-a-time.h
xip_fixup.h
xor.h
uapi
kernel
kvm
lib
mm
net
purgatory
tools
Kbuild
Kconfig
Kconfig.debug
Kconfig.errata
Kconfig.socs
Kconfig.vendor
Makefile
Makefile.postlink
s390
sh
sparc
um
x86
xtensa
.gitignore
Kconfig
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
arch
/
riscv
/
include
/
asm
/
switch_to.h
Copy path
Blame
Blame
Latest commit
History
History
117 lines (100 loc) · 3.03 KB
Breadcrumbs
linux
/
arch
/
riscv
/
include
/
asm
/
switch_to.h
Top
File metadata and controls
Code
Blame
117 lines (100 loc) · 3.03 KB
Raw
/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (C) 2012 Regents of the University of California */ #ifndef _ASM_RISCV_SWITCH_TO_H #define _ASM_RISCV_SWITCH_TO_H #include <linux/jump_label.h> #include <linux/sched/task_stack.h> #include <linux/mm_types.h> #include <asm/vector.h> #include <asm/cpufeature.h> #include <asm/processor.h> #include <asm/ptrace.h> #include <asm/csr.h> #ifdef CONFIG_FPU extern void __fstate_save(struct task_struct *save_to); extern void __fstate_restore(struct task_struct *restore_from); static inline void __fstate_clean(struct pt_regs *regs) { regs->status = (regs->status & ~SR_FS) | SR_FS_CLEAN; } static inline void fstate_off(struct task_struct *task, struct pt_regs *regs) { regs->status = (regs->status & ~SR_FS) | SR_FS_OFF; } static inline void fstate_save(struct task_struct *task, struct pt_regs *regs) { if ((regs->status & SR_FS) == SR_FS_DIRTY) { __fstate_save(task); __fstate_clean(regs); } } static inline void fstate_restore(struct task_struct *task, struct pt_regs *regs) { if ((regs->status & SR_FS) != SR_FS_OFF) { __fstate_restore(task); __fstate_clean(regs); } } static inline void __switch_to_fpu(struct task_struct *prev, struct task_struct *next) { struct pt_regs *regs; regs = task_pt_regs(prev); fstate_save(prev, regs); fstate_restore(next, task_pt_regs(next)); } static __always_inline bool has_fpu(void) { return riscv_has_extension_likely(RISCV_ISA_EXT_f) || riscv_has_extension_likely(RISCV_ISA_EXT_d); } #else static __always_inline bool has_fpu(void) { return false; } #define fstate_save(task, regs) do { } while (0) #define fstate_restore(task, regs) do { } while (0) #define __switch_to_fpu(__prev, __next) do { } while (0) #endif static inline void __switch_to_envcfg(struct task_struct *next) { asm volatile (ALTERNATIVE("nop", "csrw " __stringify(CSR_ENVCFG) ", %0", 0, RISCV_ISA_EXT_XLINUXENVCFG, 1) :: "r" (next->thread.envcfg) : "memory"); } extern struct task_struct *__switch_to(struct task_struct *, struct task_struct *); static inline bool switch_to_should_flush_icache(struct task_struct *task) { #ifdef CONFIG_SMP bool stale_mm = task->mm && task->mm->context.force_icache_flush; bool stale_thread = task->thread.force_icache_flush; bool thread_migrated = smp_processor_id() != task->thread.prev_cpu; return thread_migrated && (stale_mm || stale_thread); #else return false; #endif } #ifdef CONFIG_SMP #define __set_prev_cpu(thread) ((thread).prev_cpu = smp_processor_id()) #else #define __set_prev_cpu(thread) #endif #define switch_to(prev, next, last) \ do { \ struct task_struct *__prev = (prev); \ struct task_struct *__next = (next); \ __set_prev_cpu(__prev->thread); \ if (has_fpu()) \ __switch_to_fpu(__prev, __next); \ if (has_vector()) \ __switch_to_vector(__prev, __next); \ if (switch_to_should_flush_icache(__next)) \ local_flush_icache_all(); \ __switch_to_envcfg(__next); \ ((last) = __switch_to(__prev, __next)); \ } while (0) #endif /* _ASM_RISCV_SWITCH_TO_H */
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
You can’t perform that action at this time.