Skip to content

Commit 86bae1c

Browse files
Stephen Cprekwghoffa
authored andcommitted
Modify securerom branchtable to eliminate use of privileged instruction
Change-Id: I66fb89c4994d5d9c98082806208f9593c4866da8 RTC: 170636 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/37609 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Marshall J. Wilks <mjwilks@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Reviewed-by: Christopher J. Engel <cjengel@us.ibm.com> Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com> Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
1 parent 79c1190 commit 86bae1c

File tree

1 file changed

+43
-17
lines changed

1 file changed

+43
-17
lines changed

src/securerom/secureromasm.S

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#****************************************************************************
2828
#* SecureROM info - useful info used by HBBL. Must match ROM.H
2929
#****************************************************************************
30-
.set SECROM_EYECATCHER, 0x23534543524F4D00 ;// uint64_t '#SECROM.'
31-
.set SECROM_VERSION, 0x0000000900000001 ;// uint64_t
30+
.set SECROM_EYECATCHER, 0x23534543524F4D00 # uint64_t '#SECROM.'
31+
.set SECROM_VERSION, 0x0000000900000001 # uint64_t
3232

3333
# Before the SecureRom code starts there is SecureRomInfo see ROM.H
3434
# - [8 bytes] - eyeCatch
@@ -47,7 +47,7 @@ branchtableoffset:
4747
.quad .text.branchtable
4848

4949
reserved:
50-
.zero 16 ;// 'reserve 16 bytes'
50+
.zero 16 # 'reserve 16 bytes'
5151

5252
#****************************************************************************
5353
#* branch table - a more stable location for software entering rom code
@@ -57,47 +57,73 @@ reserved:
5757
.globl _SHA512_Init
5858
_SHA512_Init:
5959
li r0, .L.SHA512_Init@l
60-
b springboard
60+
b remove_sha512_init_offset
6161

6262
.globl _SHA512_Update
6363
_SHA512_Update:
6464
li r0, .L.SHA512_Update@l
65-
b springboard
65+
b remove_sha512_update_offset
6666

6767
.globl _SHA512_Final
6868
_SHA512_Final:
6969
li r0, .L.SHA512_Final@l
70-
b springboard
70+
b remove_sha512_final_offset
7171

7272
.globl _SHA512_Hash
7373
_SHA512_Hash:
7474
li r0, .L.SHA512_Hash@l
75-
b springboard
75+
b remove_sha512_hash_offset
7676

7777
.globl _ec_verify
7878
_ec_verify:
7979
li r0, .L.ec_verify@l
80-
b springboard
80+
b remove_ec_verify_offset
8181

8282
.globl _ROM_verify
8383
_ROM_verify:
8484
li r0, .L.ROM_verify@l
85+
b remove_rom_verify_offset
86+
87+
# Helper Functions to load the negative offset into r10.
88+
#
89+
# In an effort to not move anything around in the branchtable nor change any of
90+
# the parameters in the Hostboot C code, we have these helper functions to
91+
# provide springboard with the offest to subtract to find the base secureROM
92+
# address.
93+
remove_sha512_init_offset:
94+
li r10, -_SHA512_Init
95+
b springboard
96+
97+
remove_sha512_update_offset:
98+
li r10, -_SHA512_Update
99+
b springboard
100+
101+
remove_sha512_final_offset:
102+
li r10, -_SHA512_Final
103+
b springboard
104+
105+
remove_sha512_hash_offset:
106+
li r10, -_SHA512_Hash
107+
b springboard
108+
109+
remove_ec_verify_offset:
110+
li r10, -_ec_verify
85111
b springboard
86112

87-
#define CFAR 28
113+
remove_rom_verify_offset:
114+
li r10, -_ROM_verify
115+
b springboard
88116

89117
springboard:
90118
b boingboing
91119
boingboing:
92-
# @TODO RTC:156485 ROM blob will have to change to allow PHyp to use,
93-
# unless PHyp directly uses
94-
mfspr r2, CFAR ;// get address of springboard
95-
addi r2, r2, .text.securerominfo-springboard ;// base address
96-
add r0, r0, r2 ;// calculate entry relative
97-
addi r2, r2, 0x4000 ;//TOC+0x8000 part 1
98-
addi r2, r2, (__toc_start+0x4000)@l ;//TOC+0x8000 part 2
120+
mfctr r2
121+
add r2, r2, r10 # get secureROM base address
122+
add r0, r0, r2 # calculate entry relative
123+
addi r2, r2, 0x4000 #TOC+0x8000 part 1
124+
addi r2, r2, (__toc_start+0x4000)@l #TOC+0x8000 part 2
99125
mtctr r0
100-
bctr ;// jump
126+
bctr # jump
101127

102128
# could put other assembly code routines here to conserve ROM space
103129
# including the sreset routine

0 commit comments

Comments
 (0)