[dv] Add checks for Aes, Otbn sideload
Also add shadow error test in hjson
Signed-off-by: Weicai Yang <weicai@google.com>
diff --git a/hw/dv/sv/cip_lib/seq_lib/cip_base_vseq.sv b/hw/dv/sv/cip_lib/seq_lib/cip_base_vseq.sv
index d9d4cc4..5a3114d 100644
--- a/hw/dv/sv/cip_lib/seq_lib/cip_base_vseq.sv
+++ b/hw/dv/sv/cip_lib/seq_lib/cip_base_vseq.sv
@@ -798,8 +798,9 @@
rand_val = gen_storage_err_val(shadowed_csrs[index], origin_val);
csr_poke(.ptr(shadowed_csrs[index]), .value(rand_val), .kind(kind), .predict(1));
- `uvm_info(`gfn, $sformatf("backdoor write %0s with value %0h", kind.name, rand_val),
- UVM_HIGH);
+ `uvm_info(`gfn, $sformatf("backdoor write %s through %s with value 0x%0h",
+ shadowed_csrs[index].`gfn, kind.name, rand_val),
+ UVM_MEDIUM);
// check shadow_reg storage error
if ((origin_val ^ rand_val) & ((1 << shadow_reg_width) - 1)) begin
diff --git a/hw/ip/keymgr/dv/env/keymgr_if.sv b/hw/ip/keymgr/dv/env/keymgr_if.sv
index a8c92f1..5b48fde 100644
--- a/hw/ip/keymgr/dv/env/keymgr_if.sv
+++ b/hw/ip/keymgr/dv/env/keymgr_if.sv
@@ -192,30 +192,30 @@
function automatic void update_sideload_key(keymgr_env_pkg::kmac_digests_t key_shares,
keymgr_pkg::keymgr_working_state_e state,
keymgr_cdi_type_e cdi_type,
- keymgr_pkg::keymgr_key_dest_e dest = keymgr_pkg::Kmac,
- bit good_key = 1);
+ keymgr_pkg::keymgr_key_dest_e dest = keymgr_pkg::Kmac
+ );
keymgr_env_pkg::key_shares_t trun_key_shares = {key_shares[1][keymgr_pkg::KeyWidth-1:0],
key_shares[0][keymgr_pkg::KeyWidth-1:0]};
case (dest)
keymgr_pkg::Kmac: begin
kmac_key_exp <= '{1'b1, trun_key_shares};
- is_kmac_key_good <= good_key;
+ is_kmac_key_good <= 1;
is_kmac_sideload_avail <= 1;
kmac_sideload_key_shares <= trun_key_shares;
end
keymgr_pkg::Aes: begin
aes_key_exp <= '{1'b1, trun_key_shares};
- is_aes_key_good <= good_key;
+ is_aes_key_good <= 1;
end
keymgr_pkg::Otbn: begin
// only otbn uses full 384 bits digest data
otbn_key_exp <= '{1'b1, key_shares};
- is_otbn_key_good <= good_key;
+ is_otbn_key_good <= 1;
end
default: `uvm_fatal("keymgr_if", $sformatf("Unexpect dest type %0s", dest.name))
endcase
- if (good_key) keys_a_array[state][cdi_type][dest.name] = trun_key_shares;
+ keys_a_array[state][cdi_type][dest.name] = trun_key_shares;
endfunction
function automatic bit get_keymgr_en();
@@ -322,12 +322,14 @@
// These asserts are commented out because the advance operation is now 2-pass and will require
// updated handling
`KM_ASSERT(CheckKmacKey, is_kmac_key_good && kmac_key_exp.valid -> kmac_key == kmac_key_exp)
-
`KM_ASSERT(CheckKmacKeyValid, kmac_key_exp.valid == kmac_key.valid)
// TODO update hmac and aes checker later
- //`KM_ASSERT(AesKeyStable, $stable(aes_key_exp) |=> $stable(aes_key))
- //`KM_ASSERT(AesKeyUpdate, !$stable(aes_key_exp) |=> aes_key == aes_key_exp)
+ `KM_ASSERT(CheckAesKey, is_aes_key_good && aes_key_exp.valid -> aes_key == aes_key_exp)
+ `KM_ASSERT(CheckAesKeyValid, aes_key_exp.valid == aes_key.valid)
+
+ `KM_ASSERT(CheckOtbnKey, is_otbn_key_good && otbn_key_exp.valid -> otbn_key == otbn_key_exp)
+ `KM_ASSERT(CheckOtbnKeyValid, otbn_key_exp.valid == otbn_key.valid)
// for EDN assertion
// sync req/ack to core clk domain
diff --git a/hw/ip/keymgr/dv/env/keymgr_scoreboard.sv b/hw/ip/keymgr/dv/env/keymgr_scoreboard.sv
index 8db4573..d02ffb9 100644
--- a/hw/ip/keymgr/dv/env/keymgr_scoreboard.sv
+++ b/hw/ip/keymgr/dv/env/keymgr_scoreboard.sv
@@ -207,13 +207,11 @@
end
UpdateHwOut: begin
kmac_digests_t key_shares = {item.rsp_digest_share1, item.rsp_digest_share0};
- bit good_key = (get_err_code() == 0);
keymgr_pkg::keymgr_key_dest_e dest = keymgr_pkg::keymgr_key_dest_e'(
`gmv(ral.control.dest_sel));
if (dest != keymgr_pkg::None) begin
- cfg.keymgr_vif.update_sideload_key(key_shares, current_state, current_cdi,
- dest, good_key);
+ cfg.keymgr_vif.update_sideload_key(key_shares, current_state, current_cdi, dest);
`uvm_info(`gfn, $sformatf("Update sideload key 0x%0h for %s", key_shares, dest.name),
UVM_MEDIUM)
end
diff --git a/hw/ip/keymgr/dv/keymgr_sim_cfg.hjson b/hw/ip/keymgr/dv/keymgr_sim_cfg.hjson
index 62d9eaf..be04bff 100644
--- a/hw/ip/keymgr/dv/keymgr_sim_cfg.hjson
+++ b/hw/ip/keymgr/dv/keymgr_sim_cfg.hjson
@@ -32,6 +32,7 @@
"{proj_root}/hw/dv/tools/dvsim/tests/intr_test.hjson",
"{proj_root}/hw/dv/tools/dvsim/tests/alert_test.hjson",
"{proj_root}/hw/dv/tools/dvsim/tests/tl_access_tests.hjson",
+ "{proj_root}/hw/dv/tools/dvsim/tests/shadow_reg_errors_tests.hjson",
"{proj_root}/hw/dv/tools/dvsim/tests/stress_tests.hjson"
]