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
|
/*
*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <linux/linkage.h>
#include <asm/assembler.h>
.section .hyperdrive, "ax"
.global _start_hyperdrive
_start_hyperdrive:
# Need a nop otherwise GCC keeps _start_hyperdrive label but NOT
# jopp_springboard_bl label.
nop
#define RRX x16
#define RRX_32 w16
#define RRS x18
#define RRS_32 w18
#ifdef CONFIG_RKP_CFP_JOPP
/*
* Load the word just before the function instructions.
* Halt execution if the word doesn't match the magic number placed at function
* entries.
*/
.macro springboard_blr, reg
jopp_springboard_blr_\reg:
push RRX, RRS
ldr RRX_32, [\reg, #-4]
subs RRX_32, RRX_32, #0xbe7, lsl #12
cmp RRX_32, #0xbad
b.eq 1f
/*
//fix for FIMC
mov RRX, #0xffffff80ffffffff
movk RRX, 0xf9ff, lsl #16
cmp \reg, RRX
b.ls 2f
movk RRX, #0xfa5f, lsl #16
cmp \reg, RRX
b.hi 2f
*/
.inst 0xdeadc0de //crash for sure
1:
pop RRX, RRS
br \reg
2:
//.inst 0xdeadc0de //crash for sure
.endm
// Only add springboards for a register rX if there exists a "BLR rX" instruction in vmlinux to instrument
springboard_blr x0
springboard_blr x1
springboard_blr x2
springboard_blr x3
springboard_blr x4
springboard_blr x5
springboard_blr x6
springboard_blr x7
springboard_blr x8
springboard_blr x9
springboard_blr x10
springboard_blr x11
springboard_blr x12
springboard_blr x13
springboard_blr x14
springboard_blr x15
springboard_blr x16
springboard_blr x17
springboard_blr x18
springboard_blr x19
springboard_blr x20
springboard_blr x21
springboard_blr x22
springboard_blr x23
springboard_blr x24
springboard_blr x25
springboard_blr x26
springboard_blr x27
springboard_blr x28
springboard_blr x29
springboard_blr x30
// Don't need springboards for x31 (not allowed in RET by assembler)
#endif
.global _end_hyperdrive
_end_hyperdrive:
.section .text
|