Skip to content

Commit 4423c67

Browse files
committed
[FiSim] Cherry-pick fixes
Cherry-pick fixes for the eg100 branch for the FiSIm framework from master. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
1 parent 31715d1 commit 4423c67

File tree

5 files changed

+15
-77
lines changed

5 files changed

+15
-77
lines changed

sw/device/tests/penetrationtests/firmware/testdata/BUILD

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ offline_presigning_artifacts(
5353
name = "non_signed_firmware",
5454
testonly = True,
5555
srcs = [":bl0_firmware"],
56-
ecdsa_key = {"//sw/device/silicon_creator/lib/ownership/keys/fake:app_prod_ecdsa": "prod_key_0"},
56+
ecdsa_key = {"//hw/ip/otp_ctrl/data/earlgrey_skus/sival/keys:keyset": "sv00-earlgrey-a1-root-ecdsa-prod-0"},
5757
manifest = "//sw/device/silicon_owner:manifest",
5858
spx_key = {},
5959
tags = ["manual"],
@@ -111,7 +111,7 @@ otp_json(
111111

112112
otp_image(
113113
name = "otp_img_rom_ext_fi",
114-
src = "//hw/top_earlgrey/data/otp:otp_json_rma",
114+
src = "//hw/ip/otp_ctrl/data:otp_json_rma",
115115
overlays = STD_OTP_OVERLAYS + [
116116
":otp_json_rom_ext_fi",
117117
],
@@ -149,7 +149,7 @@ otp_json(
149149

150150
otp_image(
151151
name = "otp_img_rom_rollback_fi",
152-
src = "//hw/top_earlgrey/data/otp:otp_json_rma",
152+
src = "//hw/ip/otp_ctrl/data:otp_json_rma",
153153
overlays = STD_OTP_OVERLAYS + [
154154
":otp_json_rom_rollback_fi",
155155
],
@@ -187,7 +187,7 @@ otp_json(
187187

188188
otp_image(
189189
name = "otp_img_rom_ext_rollback_fi",
190-
src = "//hw/top_earlgrey/data/otp:otp_json_rma",
190+
src = "//hw/ip/otp_ctrl/data:otp_json_rma",
191191
overlays = STD_OTP_OVERLAYS + [
192192
":otp_json_rom_ext_rollback_fi",
193193
],

sw/host/penetrationtests/python/fi/gdb_testing/fi_rom_ext_python_gdb_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ def test_rom_ext_secure_boot(self):
293293
# Get the rom_ext path.
294294
rom_ext_path = r.Rlocation("lowrisc_opentitan/" + ROM_EXT)
295295
# Get the disassembly path.
296-
rom_ext_dis_path = rom_ext_path.replace(".prod_key_0.signed.bin", ".dis")
296+
rom_ext_dis_path = rom_ext_path.replace(".prod_key_0.prod_key_0.signed.bin", ".dis")
297297
# And the path for the elf.
298-
rom_ext_elf_path = rom_ext_path.replace(".prod_key_0.signed.bin", ".elf")
298+
rom_ext_elf_path = rom_ext_path.replace(".prod_key_0.prod_key_0.signed.bin", ".elf")
299299

300300
if "fpga" in BOOTSTRAP:
301301
target_type = "fpga"

sw/host/penetrationtests/python/fi/gdb_testing/fi_rom_ext_rollback_python_gdb_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ def test_rom_ext_rollback(self):
291291
# Get the rom_ext path.
292292
rom_ext_path = r.Rlocation("lowrisc_opentitan/" + ROM_EXT)
293293
# Get the disassembly path.
294-
rom_ext_dis_path = rom_ext_path.replace(".prod_key_0.signed.bin", ".dis")
294+
rom_ext_dis_path = rom_ext_path.replace(".prod_key_0.prod_key_0.signed.bin", ".dis")
295295
# And the path for the elf.
296-
rom_ext_elf_path = rom_ext_path.replace(".prod_key_0.signed.bin", ".elf")
296+
rom_ext_elf_path = rom_ext_path.replace(".prod_key_0.prod_key_0.signed.bin", ".elf")
297297

298298
if "fpga" in BOOTSTRAP:
299299
target_type = "fpga"

sw/host/penetrationtests/python/fi/gdb_testing/fi_rom_python_gdb_test.py

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def test_rom_secure_boot(self):
8484
print("Starting the rom secure boot test")
8585

8686
# Directory for the trace log files
87-
pc_trace_file_1 = os.path.join(log_dir, "rom_secure_boot_pc_trace_1.log")
88-
pc_trace_file_2 = os.path.join(log_dir, "rom_secure_boot_pc_trace_2.log")
87+
pc_trace_file = os.path.join(log_dir, "rom_secure_boot_pc_trace.log")
8988
# Directory for the the log of the campaign
9089
campaign_file = os.path.join(log_dir, "rom_secure_boot_test_campaign.log")
9190

@@ -112,8 +111,6 @@ def test_rom_secure_boot(self):
112111
gdb.reset_target()
113112
gdb.send_command(f"set $pc={jump_address}")
114113

115-
# Tracing in done in two steps to jump over sc_otbn_cmd_run which makes GDB hang
116-
117114
# Functions where we can get GDB to jump over
118115
upsert_register_address = rom_parser.get_function_start_address("upsert_register")
119116

@@ -123,74 +120,16 @@ def test_rom_secure_boot(self):
123120
"sigverify_ecdsa_p256_key_id_get"
124121
)
125122

126-
# We stop tracing when we execute the p256 verify in the otbn
127-
trace_end_address = rom_parser.get_function_start_address("sc_otbn_cmd_run")
128-
129-
print(
130-
"Start and stop addresses for the rom for trace 1: ",
131-
trace_start_address,
132-
trace_end_address,
133-
flush=True,
134-
)
135-
print("First trace data is logged in ", pc_trace_file_1, flush=True)
136-
137-
# Start the tracing
138-
# We set a short timeout to detect whether GDB has connected properly
139-
# and a long timeout for the entire tracing
140-
initial_timeout = 20
141-
total_timeout = 60 * 60 * 5
142-
143-
gdb.setup_pc_trace(
144-
pc_trace_file_1,
145-
trace_start_address,
146-
trace_end_address,
147-
skip_addrs=[upsert_register_address],
148-
)
149-
gdb.send_command("c", check_response=False)
150-
151-
start_time = time.time()
152-
initial_timeout_stopped = False
153-
total_timeout_stopped = False
154-
155-
# Run the tracing to get the trace log
156-
# Sometimes the tracing fails due to race conditions,
157-
# we have a quick initial timeout to catch this
158-
while time.time() - start_time < initial_timeout:
159-
output = gdb.read_output()
160-
if "breakpoint 1, " in output:
161-
initial_timeout_stopped = True
162-
break
163-
if not initial_timeout_stopped:
164-
print("No initial break point found, can be a misfire, try again")
165-
sys.exit(1)
166-
while time.time() - start_time < total_timeout:
167-
output = gdb.read_output()
168-
if "PC trace complete" in output:
169-
print("\nTrace complete")
170-
total_timeout_stopped = True
171-
break
172-
if not total_timeout_stopped:
173-
print("Final tracing timeout reached")
174-
sys.exit(1)
175-
176-
# Reset the target, flush the output, and close gdb
177-
gdb = reset_target_and_gdb(gdb, jump_address)
178-
179-
# We ready the second part of the trace
180-
181-
# We start from sc_otbn_dmem_read which reads p256 verify's results from otbn
182-
trace_start_address = rom_parser.get_function_start_address("sc_otbn_dmem_read")
183-
184123
# We expect with the test that we end up in shutdown_finalize
185124
trace_end_address = rom_parser.get_function_start_address("shutdown_finalize")
186125

187126
print(
188-
"Start and stop addresses for the rom for trace 2: ",
127+
"Start and stop addresses for the rom: ",
189128
trace_start_address,
190129
trace_end_address,
191130
flush=True,
192131
)
193-
print("Second trace data is logged in ", pc_trace_file_2, flush=True)
132+
print("Trace data is logged in ", pc_trace_file, flush=True)
194133

195134
# Start the tracing
196135
# We set a short timeout to detect whether GDB has connected properly
@@ -199,7 +138,7 @@ def test_rom_secure_boot(self):
199138
total_timeout = 60 * 60 * 5
200139

201140
gdb.setup_pc_trace(
202-
pc_trace_file_2,
141+
pc_trace_file,
203142
trace_start_address,
204143
trace_end_address,
205144
skip_addrs=[upsert_register_address],
@@ -232,8 +171,7 @@ def test_rom_secure_boot(self):
232171
sys.exit(1)
233172

234173
# Parse and truncate the trace log to get all PCs in a list
235-
pc_list = gdb.parse_pc_trace_file(pc_trace_file_1)
236-
pc_list.extend(gdb.parse_pc_trace_file(pc_trace_file_2))
174+
pc_list = gdb.parse_pc_trace_file(pc_trace_file)
237175
# Get the unique PCs and annotate their occurence count
238176
pc_count_dict = Counter(pc_list)
239177
if len(pc_count_dict) <= 0:

sw/host/penetrationtests/python/fi/gdb_testing/fi_rom_rollback_python_gdb_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ def test_rom_rollback(self):
114114
# Functions where we can get GDB to jump over
115115
upsert_register_address = rom_parser.get_function_start_address("upsert_register")
116116

117-
# We perform the tracing over the rom_start function
117+
# We perform the tracing over the rom_main function
118118
trace_start_address = rom_parser.get_function_start_address(
119-
"rom_state_boot_rom_ext"
119+
"rom_main"
120120
)
121121
# We expect with the test that we end up in shutdown
122122
trace_end_address = rom_parser.get_function_start_address("shutdown_finalize")

0 commit comments

Comments
 (0)