Skip to content

Commit f338555

Browse files
andrea-caforionileshbpat
authored andcommitted
[fuse_ctrl, test] caliptra_ss_fuse_ctrl_init_fail (#265)
* [fuse_ctrl, test] caliptra_ss_fuse_ctrl_init_fail Signed-off-by: Andrea Caforio <andrea.caforio@lowrisc.org> * MICROSOFT AUTOMATED PIPELINE: Stamp 'caliptra_ss_fuse_ctrl_init_fail' with updated timestamp and hash after successful run --------- Signed-off-by: Andrea Caforio <andrea.caforio@lowrisc.org>
1 parent ed305d6 commit f338555

File tree

12 files changed

+210
-5
lines changed

12 files changed

+210
-5
lines changed

.github/workflow_metadata/pr_hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
be28f2dc551667ded53365e3fb1bc2ec38cc9ceb0797387e714aa7d37d2cc20d18c002e900a6ffedb239d00fe0bfad64
1+
cffe193254f81be9b6907d79acf2c1129a0017e1762731a2d200c1de3accb97561e2bc78e3602d9867e46f390e77bb79
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1744862093
1+
1744901509

src/integration/stimulus/L1_Nightly_Random_caliptra_ss_top_tb_regression.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ contents:
2020
$CALIPTRA_SS_ROOT/src/integration/test_suites/smoke_test_mcu_sram_execution_region/smoke_test_mcu_sram_execution_region_max_size: { weight: 100 }
2121
$CALIPTRA_SS_ROOT/src/integration/test_suites/caliptra_ss_mcu_sram_to_sha/caliptra_ss_mcu_sram_to_sha: { weight: 100 }
2222
$CALIPTRA_SS_ROOT/src/integration/test_suites/caliptra_ss_fuse_ctrl_external_clock/caliptra_ss_fuse_ctrl_external_clock: { weight: 100 }
23+
$CALIPTRA_SS_ROOT/src/integration/test_suites/caliptra_ss_lcc_escalation/caliptra_ss_lcc_escalation: { weight: 100 }
24+
$CALIPTRA_SS_ROOT/src/integration/test_suites/caliptra_ss_fuse_ctrl_integrity_check/caliptra_ss_fuse_ctrl_init_fail: { weight: 100 }

src/integration/stimulus/testsuites/caliptra_ss_master_test_list.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ $CALIPTRA_SS_ROOT/src/integration/test_suites/caliptra_ss_fuse_ctrl_bus_ecc_erro
5757
$CALIPTRA_SS_ROOT/src/integration/test_suites/smoke_test_wdt/smoke_test_wdt , None , None , L0 , None, caliptra_ss_top_tb, Promote , None , 100
5858
$CALIPTRA_SS_ROOT/src/integration/test_suites/smoke_test_wdt_rst/smoke_test_wdt_rst , Directed , Nightly , None, L1 , caliptra_ss_top_tb, None , None , 100
5959
$CALIPTRA_SS_ROOT/src/integration/test_suites/smoke_test_lcc_st_trans/smoke_test_lcc_st_trans , Directed , Nightly , L0 , L1 , caliptra_ss_top_tb, Promote , None , 100
60+
$CALIPTRA_SS_ROOT/src/integration/test_suites/caliptra_ss_fuse_ctrl_integrity_check/caliptra_ss_fuse_ctrl_init_fail , Random , Nightly , None, L1 , caliptra_ss_top_tb, None , None , 100
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#include <string.h>
2+
#include <stdint.h>
3+
#include <time.h>
4+
#include <stdlib.h>
5+
6+
#include "soc_address_map.h"
7+
#include "printf.h"
8+
#include "riscv_hw_if.h"
9+
#include "soc_ifc.h"
10+
#include "caliptra_ss_lc_ctrl_address_map.h"
11+
#include "caliptra_ss_lib.h"
12+
#include "fuse_ctrl.h"
13+
#include "lc_ctrl.h"
14+
15+
volatile char* stdout = (char *)SOC_MCI_TOP_MCI_REG_DEBUG_OUT;
16+
#ifdef CPT_VERBOSITY
17+
enum printf_verbosity verbosity_g = CPT_VERBOSITY;
18+
#else
19+
enum printf_verbosity verbosity_g = LOW;
20+
#endif
21+
22+
typedef struct {
23+
uint32_t address;
24+
uint32_t digest_address;
25+
uint32_t index;
26+
} partition_t;
27+
28+
// XXX: Fuse addresses, eventually these should be generated automatically.
29+
// Buffered partitions.
30+
static partition_t partitions[8] = {
31+
// SECRET_TEST_UNLOCK_PARTITION
32+
{ .address = 0x000, .digest_address = 0x040, .index = 0 },
33+
// SECRET_MANUF_PARTITION
34+
{ .address = 0x048, .digest_address = 0x088, .index = 1 },
35+
// SECRET_PROD_PARTITION_0
36+
{ .address = 0x090, .digest_address = 0x098, .index = 2 },
37+
// SECRET_PROD_PARTITION_1
38+
{ .address = 0x0A0, .digest_address = 0x0A8, .index = 3 },
39+
// SECRET_PROD_PARTITION_2
40+
{ .address = 0x0B0, .digest_address = 0x0B8, .index = 4 },
41+
// SECRET_PROD_PARTITION_3
42+
{ .address = 0x0C0, .digest_address = 0x0C8, .index = 5 },
43+
// SECRET_LC_TRANSITION_PARTITION
44+
{ .address = 0x4C0, .digest_address = 0x570, .index = 7 },
45+
// VENDOR_SECRET_PROD_PARTITION
46+
{ .address = 0x9A8, .digest_address = 0xBA8, .index = 13 }
47+
};
48+
49+
void init_fail() {
50+
const uint32_t faults[2] = {
51+
CMD_FC_LCC_CORRECTABLE_FAULT,
52+
CMD_FC_LCC_UNCORRECTABLE_FAULT
53+
};
54+
55+
partition_t partition = partitions[xorshift32() % 8];
56+
uint32_t fault = faults[xorshift32() % 2];
57+
58+
if (partition.address < 0x090) {
59+
grant_caliptra_core_for_fc_writes();
60+
} else {
61+
grant_mcu_for_fc_writes();
62+
}
63+
64+
// Write one word in the selected partition and lock it afterwards.
65+
dai_wr(partition.address, 0x1, 0x2, 64, 0);
66+
calculate_digest(partition.address);
67+
68+
// Inject either a correctable or uncorrectable error into the written partition.
69+
lsu_write_32(SOC_MCI_TOP_MCI_REG_DEBUG_OUT, fault);
70+
wait_dai_op_idle(0);
71+
72+
reset_fc_lcc_rtl();
73+
wait_dai_op_idle(
74+
fault == CMD_FC_LCC_CORRECTABLE_FAULT ? 1 << partition.index : 0x3FFFF
75+
);
76+
77+
uint32_t err_reg = lsu_read_32(SOC_OTP_CTRL_ERR_CODE_RF_ERR_CODE_0 + 0x4*partition.index);
78+
uint32_t status_reg = lsu_read_32(SOC_OTP_CTRL_STATUS);
79+
80+
if (fault == CMD_FC_LCC_CORRECTABLE_FAULT) {
81+
if (err_reg != 0x2) {
82+
VPRINTF(LOW, "ERROR: err code register does not show correctable error: %08X\n", err_reg);
83+
return;
84+
}
85+
} else {
86+
if (err_reg != 0x3) {
87+
VPRINTF(LOW, "ERROR: err code register does not show uncorrectable error: %08X\n", err_reg);
88+
return;
89+
}
90+
}
91+
}
92+
93+
void main (void) {
94+
VPRINTF(LOW, "=================\nMCU Caliptra Boot Go\n=================\n\n")
95+
96+
mcu_cptra_init_d();
97+
wait_dai_op_idle(0);
98+
99+
lcc_initialization();
100+
grant_mcu_for_fc_writes();
101+
102+
transition_state(TEST_UNLOCKED0, raw_unlock_token[0], raw_unlock_token[1], raw_unlock_token[2], raw_unlock_token[3], 1);
103+
wait_dai_op_idle(0);
104+
105+
initialize_otp_controller();
106+
107+
init_fail();
108+
109+
for (uint8_t ii = 0; ii < 160; ii++) {
110+
__asm__ volatile ("nop"); // Sleep loop as "nop"
111+
}
112+
113+
SEND_STDOUT_CTRL(0xff);
114+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
seed: ${PLAYBOOK_RANDOM_SEED}
3+
testname: caliptra_ss_fuse_ctrl_init_fail
4+
pre-exec: |
5+
echo "Running pre_exec for [caliptra_ss_fuse_ctrl_init_fail]"
6+
CALIPTRA_ROOT=$CALIPTRA_SS_ROOT/third_party/caliptra-rtl make -f $CALIPTRA_SS_ROOT/third_party/caliptra-rtl/tools/scripts/Makefile CALIPTRA_INTERNAL_TRNG=0 TESTNAME=smoke_test_mbox program.hex
7+
make -f $CALIPTRA_SS_ROOT/tools/scripts/Makefile TESTNAME=caliptra_ss_fuse_ctrl_init_fail mcu_program.hex

src/integration/test_suites/caliptra_ss_fuse_ctrl_integrity_check/caliptra_ss_fuse_ctrl_integrity_check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void main (void) {
3737

3838
initialize_otp_controller();
3939

40-
wait_dai_op_idle(0x1BFFFF);
40+
wait_dai_op_idle(0x3FFFF);
4141

4242
for (uint8_t ii = 0; ii < 160; ii++) {
4343
__asm__ volatile ("nop"); // Sleep loop as "nop"

src/integration/test_suites/libs/caliptra_ss_lib/caliptra_ss_lib.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#define CMD_LC_TRIGGER_ESCALATION1 FC_LCC_CMD_OFFSET + 0x13
4646
#define CMD_LC_DISABLE_SVA FC_LCC_CMD_OFFSET + 0x14
4747
#define CMD_LC_ENABLE_SVA FC_LCC_CMD_OFFSET + 0x15
48+
#define CMD_FC_LCC_CORRECTABLE_FAULT FC_LCC_CMD_OFFSET + 0x16
49+
#define CMD_FC_LCC_UNCORRECTABLE_FAULT FC_LCC_CMD_OFFSET + 0x17
4850

4951

5052
#define TB_CMD_DISABLE_MCU_SRAM_PROT_ASSERTS 0xC0
@@ -224,6 +226,28 @@ static inline void mcu_mbox_write_cmd_status(uint32_t mbox_num, enum mcu_mbox_cm
224226
lsu_write_32(SOC_MCI_TOP_MCU_MBOX0_CSR_MBOX_CMD_STATUS + MCU_MBOX_NUM_STRIDE * mbox_num, (cmd_status & MCU_MBOX0_CSR_MBOX_CMD_STATUS_STATUS_MASK));
225227
}
226228

229+
#define FC_LCC_CMD_OFFSET 0x90
230+
#define CMD_FC_LCC_RESET FC_LCC_CMD_OFFSET + 0x02
231+
#define CMD_FORCE_FC_AWUSER_CPTR_CORE FC_LCC_CMD_OFFSET + 0x03
232+
#define CMD_FORCE_FC_AWUSER_MCU FC_LCC_CMD_OFFSET + 0x04
233+
#define CMD_RELEASE_AWUSER FC_LCC_CMD_OFFSET + 0x05
234+
#define CMD_FC_FORCE_ZEROIZATION FC_LCC_CMD_OFFSET + 0x06
235+
#define CMD_FC_FORCE_ZEROIZATION_RESET FC_LCC_CMD_OFFSET + 0x07
236+
#define CMD_RELEASE_ZEROIZATION FC_LCC_CMD_OFFSET + 0x08
237+
#define CMD_FORCE_LC_TOKENS FC_LCC_CMD_OFFSET + 0x09
238+
#define CMD_LC_FORCE_RMA_SCRAP_PPD FC_LCC_CMD_OFFSET + 0x0a
239+
#define CMD_FC_TRIGGER_ESCALATION FC_LCC_CMD_OFFSET + 0x0b
240+
#define CMD_FC_LCC_EXT_CLK_500MHZ FC_LCC_CMD_OFFSET + 0x0c
241+
#define CMD_FC_LCC_EXT_CLK_160MHZ FC_LCC_CMD_OFFSET + 0x0d
242+
#define CMD_FC_LCC_EXT_CLK_400MHZ FC_LCC_CMD_OFFSET + 0x0e
243+
#define CMD_FC_LCC_EXT_CLK_1000MHZ FC_LCC_CMD_OFFSET + 0x0f
244+
#define CMD_FC_LCC_FAULT_DIGEST FC_LCC_CMD_OFFSET + 0x10
245+
#define CMD_FC_LCC_FAULT_BUS_ECC FC_LCC_CMD_OFFSET + 0x11
246+
#define CMD_LC_TRIGGER_ESCALATION0 FC_LCC_CMD_OFFSET + 0x12
247+
#define CMD_LC_TRIGGER_ESCALATION1 FC_LCC_CMD_OFFSET + 0x13
248+
#define CMD_FC_LCC_CORRECTABLE_FAULT FC_LCC_CMD_OFFSET + 0x14
249+
#define CMD_FC_LCC_UNCORRECTABLE_FAULT FC_LCC_CMD_OFFSET + 0x15
250+
227251
static inline uint32_t mcu_mbox_read_cmd_status(uint32_t mbox_num) {
228252
uint32_t rd_data = lsu_read_32(SOC_MCI_TOP_MCU_MBOX0_CSR_MBOX_CMD_STATUS + MCU_MBOX_NUM_STRIDE * mbox_num);
229253
VPRINTF(LOW, "MCU: Mbox%x Reading CMD_STATUS: 0x%x\n", mbox_num, rd_data);

src/integration/test_suites/libs/fuse_ctrl/fuse_ctrl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ void wait_dai_op_idle(uint32_t status_mask) {
4949
status = lsu_read_32(SOC_OTP_CTRL_STATUS);
5050
dai_idle = (status >> OTP_CTRL_STATUS_DAI_IDLE_LOW) & 0x1;
5151
check_pending = (status >> OTP_CTRL_STATUS_CHECK_PENDING_LOW) & 0x1;
52-
} while ((!dai_idle || check_pending) && (status != 0x1BFFFF));
52+
} while ((!dai_idle || check_pending) && ((status & 0x3FFFF) != 0x3FFFF));
5353

5454
// Clear the IDLE bit from the status value
5555
status &= ((((uint32_t)1) << (OTP_CTRL_STATUS_DAI_IDLE_LOW - 1)) - 1);
5656
if (status != status_mask) {
5757
VPRINTF(LOW, "ERROR: unexpected status: expected: %08X actual: %08X\n", status_mask, status);
58-
exit(1);
5958
}
6059
VPRINTF(LOW, "DEBUG: DAI is now idle.\n");
6160
return;

src/integration/testbench/caliptra_ss_tb_cmd_list.svh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ localparam CMD_LC_TRIGGER_ESCALATION0 = FC_LCC_CMD_OFFSET + 8'h12;
8383
localparam CMD_LC_TRIGGER_ESCALATION1 = FC_LCC_CMD_OFFSET + 8'h13;
8484
localparam CMD_LC_DISABLE_SVA = FC_LCC_CMD_OFFSET + 8'h14;
8585
localparam CMD_LC_ENABLE_SVA = FC_LCC_CMD_OFFSET + 8'h15;
86+
localparam CMD_FC_LCC_CORRECTABLE_FAULT = FC_LCC_CMD_OFFSET + 8'h16;
87+
localparam CMD_FC_LCC_UNCORRECTABLE_FAULT = FC_LCC_CMD_OFFSET + 8'h17;
88+
8689

8790
localparam TB_DISABLE_MCU_SRAM_PROT_ASSERTS = 8'hc0;
8891

0 commit comments

Comments
 (0)