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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/securerom/secureromasm.S $
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2017
# [+] Google Inc.
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
.include "kernel/ppcconsts.S"
#****************************************************************************
#* SecureROM info - useful info used by HBBL. Must match ROM.H
#****************************************************************************
.set SECROM_EYECATCHER, 0x23534543524F4D00 # uint64_t '#SECROM.'
.set SECROM_VERSION, 0x0000000900000001 # uint64_t
# Before the SecureRom code starts there is SecureRomInfo see ROM.H
# - [8 bytes] - eyeCatch
# - [8 bytes] - version
# - [8 bytes] - branchtable offset
# - [16 bytes] - reserved
.section .text.securerominfo
eyeCatch:
.quad SECROM_EYECATCHER
version:
.quad SECROM_VERSION
branchtableoffset:
.quad .text.branchtable
reserved:
.zero 16 # 'reserve 16 bytes'
#****************************************************************************
#* branch table - a more stable location for software entering rom code
#****************************************************************************
.section .text.branchtable
.globl _SHA512_Init
_SHA512_Init:
li r0, .L.SHA512_Init@l
b remove_sha512_init_offset
.globl _SHA512_Update
_SHA512_Update:
li r0, .L.SHA512_Update@l
b remove_sha512_update_offset
.globl _SHA512_Final
_SHA512_Final:
li r0, .L.SHA512_Final@l
b remove_sha512_final_offset
.globl _SHA512_Hash
_SHA512_Hash:
li r0, .L.SHA512_Hash@l
b remove_sha512_hash_offset
.globl _ec_verify
_ec_verify:
li r0, .L.ec_verify@l
b remove_ec_verify_offset
.globl _ROM_verify
_ROM_verify:
li r0, .L.ROM_verify@l
b remove_rom_verify_offset
# Helper Functions to load the negative offset into r10.
#
# In an effort to not move anything around in the branchtable nor change any of
# the parameters in the Hostboot C code, we have these helper functions to
# provide springboard with the offest to subtract to find the base secureROM
# address.
# NOTE: Originally each of the following helper functions was formatted to
# subtract the starting offset of the calling assembly from r10 like the
# following example:
# li r10, -_SHA512_Init
# b springboard
# However, some tool chain versions do not correctly support this convention, so
# instead put the non-negative offset into r10 and then negate it
remove_sha512_init_offset:
li r10, _SHA512_Init
neg r10,r10
b springboard
remove_sha512_update_offset:
li r10, _SHA512_Update
neg r10,r10
b springboard
remove_sha512_final_offset:
li r10, _SHA512_Final
neg r10,r10
b springboard
remove_sha512_hash_offset:
li r10, _SHA512_Hash
neg r10,r10
b springboard
remove_ec_verify_offset:
li r10, _ec_verify
neg r10,r10
b springboard
remove_rom_verify_offset:
li r10, _ROM_verify
neg r10,r10
b springboard
springboard:
b boingboing
boingboing:
mfctr r2
add r2, r2, r10 # get secureROM base address
add r0, r0, r2 # calculate entry relative
addi r2, r2, 0x4000 #TOC+0x8000 part 1
addi r2, r2, (__toc_start+0x4000)@l #TOC+0x8000 part 2
mtctr r0
bctr # jump
# could put other assembly code routines here to conserve ROM space
# including the sreset routine
# need to align on branchtablebase+0x100 !!!
.org .text.branchtable+0x100
.globl _rom_sreset
_rom_sreset:
li r0, rom_sreset@l
b springboard
nop
.section .data
|