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
5147da9
Documentation
LICENSES
arch
alpha
arc
arm
arm64
csky
h8300
hexagon
ia64
m68k
microblaze
mips
nds32
nios2
openrisc
parisc
powerpc
riscv
s390
sh
sparc
boot
configs
crypto
include
kernel
syscalls
.gitignore
Makefile
adi_64.c
apc.c
asm-offsets.c
audit.c
auxio_32.c
auxio_64.c
btext.c
central.c
cherrs.S
chmc.c
compat_audit.c
cpu.c
cpumap.c
cpumap.h
devices.c
ds.c
dtlb_miss.S
dtlb_prot.S
ebus.c
entry.S
entry.h
etrap_32.S
etrap_64.S
fpu_traps.S
ftrace.c
getsetcc.S
head_32.S
head_64.S
helpers.S
hvapi.c
hvcalls.S
hvtramp.S
idprom.c
iommu-common.c
iommu.c
iommu_common.h
ioport.c
irq.h
irq_32.c
irq_64.c
itlb_miss.S
ivec.S
jump_label.c
kernel.h
kgdb_32.c
kgdb_64.c
kprobes.c
kstack.h
ktlb.S
ldc.c
led.c
leon_kernel.c
leon_pci.c
leon_pci_grpci1.c
leon_pci_grpci2.c
leon_pmc.c
leon_smp.c
mdesc.c
misctrap.S
module.c
nmi.c
of_device_32.c
of_device_64.c
of_device_common.c
of_device_common.h
pci.c
pci_common.c
pci_fire.c
pci_impl.h
pci_msi.c
pci_psycho.c
pci_sabre.c
pci_schizo.c
pci_sun4v.c
pci_sun4v.h
pci_sun4v_asm.S
pcic.c
pcr.c
perf_event.c
pmc.c
power.c
process.c
process_32.c
process_64.c
prom.h
prom_32.c
prom_64.c
prom_common.c
prom_irqtrans.c
psycho_common.c
psycho_common.h
ptrace_32.c
ptrace_64.c
reboot.c
rtrap_32.S
rtrap_64.S
sbus.c
setup_32.c
setup_64.c
signal32.c
signal_32.c
signal_64.c
sigutil.h
sigutil_32.c
sigutil_64.c
smp_32.c
smp_64.c
sparc_ksyms.c
spiterrs.S
sstate.c
stacktrace.c
starfire.c
sun4d_irq.c
sun4d_smp.c
sun4m_irq.c
sun4m_smp.c
sun4v_ivec.S
sun4v_mcd.S
sun4v_tlb_miss.S
sys32.S
sys_sparc32.c
sys_sparc_32.c
sys_sparc_64.c
syscalls.S
sysfs.c
systbls.h
systbls_32.S
systbls_64.S
time_32.c
time_64.c
trampoline_32.S
trampoline_64.S
traps_32.c
traps_64.c
tsb.S
ttable_32.S
ttable_64.S
una_asm_32.S
una_asm_64.S
unaligned_32.c
unaligned_64.c
uprobes.c
urtt_fill.S
utrap.S
vdso.c
vio.c
viohs.c
visemul.c
vmlinux.lds.S
windows.c
winfixup.S
wof.S
wuf.S
lib
math-emu
mm
net
power
prom
vdso
Kbuild
Kconfig
Kconfig.debug
Makefile
um
x86
xtensa
.gitignore
Kconfig
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
arch
/
sparc
/
kernel
/
windows.c
Copy path
Blame
Blame
Latest commit
History
History
130 lines (113 loc) · 3.33 KB
Breadcrumbs
linux
/
arch
/
sparc
/
kernel
/
windows.c
Top
File metadata and controls
Code
Blame
130 lines (113 loc) · 3.33 KB
Raw
// SPDX-License-Identifier: GPL-2.0 /* windows.c: Routines to deal with register window management * at the C-code level. * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ #include <linux/kernel.h> #include <linux/sched.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/smp.h> #include <asm/cacheflush.h> #include <linux/uaccess.h> #include "kernel.h" /* Do save's until all user register windows are out of the cpu. */ void flush_user_windows(void) { register int ctr asm("g5"); ctr = 0; __asm__ __volatile__( "\n1:\n\t" "ld [%%g6 + %2], %%g4\n\t" "orcc %%g0, %%g4, %%g0\n\t" "add %0, 1, %0\n\t" "bne 1b\n\t" " save %%sp, -64, %%sp\n" "2:\n\t" "subcc %0, 1, %0\n\t" "bne 2b\n\t" " restore %%g0, %%g0, %%g0\n" : "=&r" (ctr) : "0" (ctr), "i" ((const unsigned long)TI_UWINMASK) : "g4", "cc"); } static inline void shift_window_buffer(int first_win, int last_win, struct thread_info *tp) { int i; for(i = first_win; i < last_win; i++) { tp->rwbuf_stkptrs[i] = tp->rwbuf_stkptrs[i+1]; memcpy(&tp->reg_window[i], &tp->reg_window[i+1], sizeof(struct reg_window32)); } } /* Place as many of the user's current register windows * on the stack that we can. Even if the %sp is unaligned * we still copy the window there, the only case that we don't * succeed is if the %sp points to a bum mapping altogether. * setup_frame() and do_sigreturn() use this before shifting * the user stack around. Future instruction and hardware * bug workaround routines will need this functionality as * well. */ void synchronize_user_stack(void) { struct thread_info *tp = current_thread_info(); int window; flush_user_windows(); if(!tp->w_saved) return; /* Ok, there is some dirty work to do. */ for(window = tp->w_saved - 1; window >= 0; window--) { unsigned long sp = tp->rwbuf_stkptrs[window]; /* Ok, let it rip. */ if (copy_to_user((char __user *) sp, &tp->reg_window[window], sizeof(struct reg_window32))) continue; shift_window_buffer(window, tp->w_saved - 1, tp); tp->w_saved--; } } #if 0 /* An optimization. */ static inline void copy_aligned_window(void *dest, const void *src) { __asm__ __volatile__("ldd [%1], %%g2\n\t" "ldd [%1 + 0x8], %%g4\n\t" "std %%g2, [%0]\n\t" "std %%g4, [%0 + 0x8]\n\t" "ldd [%1 + 0x10], %%g2\n\t" "ldd [%1 + 0x18], %%g4\n\t" "std %%g2, [%0 + 0x10]\n\t" "std %%g4, [%0 + 0x18]\n\t" "ldd [%1 + 0x20], %%g2\n\t" "ldd [%1 + 0x28], %%g4\n\t" "std %%g2, [%0 + 0x20]\n\t" "std %%g4, [%0 + 0x28]\n\t" "ldd [%1 + 0x30], %%g2\n\t" "ldd [%1 + 0x38], %%g4\n\t" "std %%g2, [%0 + 0x30]\n\t" "std %%g4, [%0 + 0x38]\n\t" : : "r" (dest), "r" (src) : "g2", "g3", "g4", "g5"); } #endif /* Try to push the windows in a threads window buffer to the * user stack. Unaligned %sp's are not allowed here. */ void try_to_clear_window_buffer(struct pt_regs *regs, int who) { struct thread_info *tp = current_thread_info(); int window; flush_user_windows(); for(window = 0; window < tp->w_saved; window++) { unsigned long sp = tp->rwbuf_stkptrs[window]; if ((sp & 7) || copy_to_user((char __user *) sp, &tp->reg_window[window], sizeof(struct reg_window32))) { force_fatal_sig(SIGILL); return; } } tp->w_saved = 0; }
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
118
119
120
121
122
123
124
125
126
127
128
129
130
You can’t perform that action at this time.