Skip to content

Commit

Permalink
[rom_e2e] enhance ROM_EXT immutable section tests
Browse files Browse the repository at this point in the history
This enhances the ROM_EXT immutable section tests to also test executing
the immutable section with address translation enabled.

Signed-off-by: Tim Trippel <ttrippel@google.com>
  • Loading branch information
timothytrippel committed Aug 26, 2024
1 parent 8066bda commit cd58176
Showing 1 changed file with 91 additions and 26 deletions.
117 changes: 91 additions & 26 deletions sw/device/silicon_creator/rom/e2e/immutable_rom_ext_section/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load(
"@bazel_skylib//lib:dicts.bzl",
"dicts",
)
load(
"//rules:const.bzl",
"CONST",
"hex",
"hex_digits",
)
load(
"//sw/device/silicon_creator/rom_ext:defs.bzl",
"ROM_EXT_VERSION",
)
load("//rules:manifest.bzl", "manifest")
load(
"//rules:otp.bzl",
"STD_OTP_OVERLAYS",
Expand All @@ -30,6 +40,11 @@ load(

package(default_visibility = ["//visibility:public"])

ROM_EXT_LINKER_SCRIPTS = [
"a",
"virtual",
]

IMMUTABLE_PARTITION_TEST_CASES = [
{
"name": "exec_enabled_hash_valid",
Expand Down Expand Up @@ -125,75 +140,125 @@ IMMUTABLE_PARTITION_TEST_CASES = [

[
otp_json_immutable_rom_ext(
name = "otp_json_immutable_rom_ext_{}".format(t["name"]),
name = "otp_json_immutable_rom_ext_{}_{}".format(
t["name"],
ld_script,
),
testonly = True,
partitions = [
otp_partition(
name = "CREATOR_SW_CFG",
items = t["otp_fields"],
),
],
rom_ext = ":immutable_rom_ext_section_test",
rom_ext = ":immutable_rom_ext_section_test_{}".format(ld_script),
visibility = ["//visibility:private"],
)
for ld_script in ROM_EXT_LINKER_SCRIPTS
for t in IMMUTABLE_PARTITION_TEST_CASES
]

[
otp_image(
name = "otp_img_immutable_rom_ext_{}".format(t["name"]),
name = "otp_img_immutable_rom_ext_{}_{}".format(
t["name"],
ld_script,
),
testonly = True,
src = "//hw/ip/otp_ctrl/data:otp_json_prod",
overlays = STD_OTP_OVERLAYS + [
":otp_json_immutable_rom_ext_{}".format(t["name"]),
":otp_json_immutable_rom_ext_{}_{}".format(
t["name"],
ld_script,
),
],
visibility = ["//visibility:private"],
)
for ld_script in ROM_EXT_LINKER_SCRIPTS
for t in IMMUTABLE_PARTITION_TEST_CASES
]

opentitan_binary(
name = "immutable_rom_ext_section_test",
testonly = True,
srcs = ["immutable_rom_ext_section_test.c"],
exec_env = [
"//hw/top_earlgrey:fpga_cw310_sival",
],
deps = [
"//hw/ip/otp_ctrl/data:otp_ctrl_c_regs",
"//hw/top_earlgrey/sw/autogen:top_earlgrey",
"//sw/device/lib/base:hardened",
"//sw/device/lib/base:status",
"//sw/device/lib/testing/test_framework:ottf_main",
"//sw/device/silicon_creator/lib/drivers:otp",
"//sw/device/silicon_creator/lib/drivers:retention_sram",
"//sw/device/silicon_creator/lib/drivers:uart",
],
)
_MANIFEST_CONFIG = {
"identifier": hex(CONST.ROM_EXT),
"version_major": ROM_EXT_VERSION.MAJOR,
"version_minor": ROM_EXT_VERSION.MINOR,
"security_version": ROM_EXT_VERSION.SECURITY,
}

manifest(d = dicts.add(
_MANIFEST_CONFIG,
{
"name": "manifest_addr_trans_on",
"address_translation": hex(CONST.HARDENED_TRUE),
},
))

manifest(d = dicts.add(
_MANIFEST_CONFIG,
{
"name": "manifest_addr_trans_off",
"address_translation": hex(CONST.HARDENED_FALSE),
},
))

[
opentitan_binary(
name = "immutable_rom_ext_section_test_{}".format(ld_script),
testonly = True,
srcs = ["immutable_rom_ext_section_test.c"],
exec_env = [
"//hw/top_earlgrey:fpga_cw310_sival",
],
linker_script = "//sw/device/lib/testing/test_framework:ottf_ld_silicon_creator_slot_{}".format(ld_script),
manifest = ":manifest_addr_trans_on" if ld_script == "virtual" else ":manifest_addr_trans_off",
deps = [
"//hw/ip/otp_ctrl/data:otp_ctrl_c_regs",
"//hw/top_earlgrey/sw/autogen:top_earlgrey",
"//sw/device/lib/base:hardened",
"//sw/device/lib/base:status",
"//sw/device/lib/testing/test_framework:ottf_main",
"//sw/device/silicon_creator/lib/drivers:otp",
"//sw/device/silicon_creator/lib/drivers:retention_sram",
"//sw/device/silicon_creator/lib/drivers:uart",
],
)
for ld_script in ROM_EXT_LINKER_SCRIPTS
]

[
opentitan_test(
name = "immutable_section_{}".format(t["name"]),
name = "immutable_section_{}_{}".format(
t["name"],
ld_script,
),
exec_env = {
"//hw/top_earlgrey:fpga_cw310_sival": None,
},
fpga = fpga_params(
binaries = {
":immutable_rom_ext_section_test": "firmware",
":immutable_rom_ext_section_test_{}".format(ld_script): "firmware",
},
exit_failure = t["exit_failure"],
exit_success = t["exit_success"],
otp = ":otp_img_immutable_rom_ext_{}".format(t["name"]),
otp = ":otp_img_immutable_rom_ext_{}_{}".format(
t["name"],
ld_script,
),
),
)
for ld_script in ROM_EXT_LINKER_SCRIPTS
for t in IMMUTABLE_PARTITION_TEST_CASES
]

test_suite(
name = "immutable_rom_ext_section",
tags = ["manual"],
tests = [
"immutable_section_{}".format(t["name"])
"immutable_section_{}_{}".format(
t["name"],
ld_script,
)
for ld_script in ROM_EXT_LINKER_SCRIPTS
for t in IMMUTABLE_PARTITION_TEST_CASES
],
)

0 comments on commit cd58176

Please sign in to comment.