Skip to content

Commit 09d3d61

Browse files
committed
[dv] V2S Coverage Implementation
This commit adds coverpoints and crosses for security countermeasures implemented in the design. Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
1 parent c145ac3 commit 09d3d61

File tree

5 files changed

+87
-1
lines changed

5 files changed

+87
-1
lines changed

doc/03_reference/coverage_plan.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,30 @@ Basic read/write functionality must be tested on all implemented CSRs.
299299
CSRs addresses do not need to be crossed with the variety of CSR instructions as these all use the same basic read & write interface into ``ibex_cs_registers``.
300300
Coverage of the above points will be sampled at the ``ibex_cs_registers`` interface (as opposed to sampling CSR instructions).
301301

302+
Security Countermeasures
303+
^^^^^^^^^^^^^^^^^^^^^^^^
304+
For more detail about each security countermeasure in Ibex see :ref:`security`
305+
306+
* ``cp_data_ind_timing`` - Enabling/Disabling "Data Independent Timing" feature.
307+
308+
* ``cp_data_ind_timing_instr`` - Executing each instruction category while data independent timing feature is enabled.
309+
310+
* ``cp_dummy_instr_en`` - Enabling/Disabling "Dummy Instruction Insertion" feature.
311+
312+
* ``cp_dummy_instr_mask`` - Frequency of injection for the dummy instructions.
313+
314+
* ``cp_dummy_instr_type`` - Type of the injected dummy instruction.
315+
316+
* ``cp_dummy_instr`` - Executing each instruction category while dummy instruction insertion feature is enabled.
317+
318+
* ``cp_rf_a_ecc_err``, ``cp_rf_b_ecc_err`` - Register file integrity (ECC) fault is seen for port A/B.
319+
320+
* ``cp_icache_ecc_err`` - ICache has seen an integrity (ECC) fault.
321+
322+
* ``cp_lockstep_err`` - Lockstep glitch fault seen.
323+
324+
* ``cp_rf_we_glitch_err`` - Register file write enable glitch fault seen.
325+
302326
Miscellaneous
303327
^^^^^^^^^^^^^
304328
Various points of interest do not fit into the categories above.
@@ -348,3 +372,7 @@ There must be a documented reason a particular bin is added to the illegal or ig
348372
* ``pmp_iside_priv_bits_cross``, ``pmp_iside2_priv_bits_cross``, ``pmp_dside_priv_bits_cross``, PMP regions x permissions x access fail/pass x privilege level
349373

350374
* Three crosses, one for each PMP channel (instruction, instruction 2 and data).
375+
376+
* ``dummy_instr_config_cross`` - Dummy Instruction Type x Dummy Instruction Insertion Frequency to explore all possible configurations.
377+
378+
* ``rf_ecc_err_cross`` - ECC Error on Port A x ECC Error on Port A to explore all possible combinations of reported ECC errors.

dv/uvm/core_ibex/fcov/core_ibex_fcov_if.sv

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ interface core_ibex_fcov_if import ibex_pkg::*; (
1515
input debug_mode,
1616

1717
input fcov_csr_read_only,
18-
input fcov_csr_write
18+
input fcov_csr_write,
19+
20+
input fcov_rf_ecc_err_a_id,
21+
input fcov_rf_ecc_err_b_id
1922
);
2023
`include "dv_fcov_macros.svh"
2124
import uvm_pkg::*;
@@ -381,6 +384,10 @@ interface core_ibex_fcov_if import ibex_pkg::*; (
381384
(id_stall_type == IdStallTypeNone) && (id_stall_type_last != IdStallTypeNone) &&
382385
id_stall_type_last_valid;
383386

387+
// V2S Related Probes for Top-Level
388+
logic rf_we_glitch_err;
389+
logic lockstep_glitch_err;
390+
384391
covergroup uarch_cg @(posedge clk_i);
385392
option.per_instance = 1;
386393
option.name = "uarch_cg";
@@ -423,6 +430,31 @@ interface core_ibex_fcov_if import ibex_pkg::*; (
423430
cp_id_stage_state : coverpoint id_stage_state;
424431
cp_wb_stage_state : coverpoint wb_stage_state;
425432

433+
// V2S Coverpoints
434+
cp_data_ind_timing: coverpoint cs_registers_i.data_ind_timing_o;
435+
cp_data_ind_timing_instr: coverpoint id_instr_category iff (cs_registers_i.data_ind_timing_o){
436+
// Not certain if InstrCategoryOtherIllegal can occur. Put it in illegal_bins for now and
437+
// revisit if any issues are seen
438+
illegal_bins illegal = {InstrCategoryOther, InstrCategoryOtherIllegal};
439+
}
440+
441+
cp_dummy_instr_en: coverpoint cs_registers_i.dummy_instr_en_o;
442+
cp_dummy_instr_mask: coverpoint cs_registers_i.dummy_instr_mask_o;
443+
cp_dummy_instr_type: coverpoint if_stage_i.fcov_dummy_instr_type;
444+
cp_dummy_instr: coverpoint id_instr_category iff (cs_registers_i.dummy_instr_en_o){
445+
// Not certain if InstrCategoryOtherIllegal can occur. Put it in illegal_bins for now and
446+
// revisit if any issues are seen
447+
illegal_bins illegal = {InstrCategoryOther, InstrCategoryOtherIllegal};
448+
}
449+
450+
cp_rf_a_ecc_err: coverpoint fcov_rf_ecc_err_a_id;
451+
cp_rf_b_ecc_err: coverpoint fcov_rf_ecc_err_b_id;
452+
453+
cp_icache_ecc_err : coverpoint if_stage_i.icache_ecc_error_o;
454+
455+
cp_lockstep_err : coverpoint lockstep_glitch_err;
456+
cp_rf_we_glitch_err : coverpoint rf_we_glitch_err;
457+
426458
// TODO: MRET/WFI in debug mode?
427459
// Specific cover points for these as `id_instr_category` will be InstrCategoryPrivIllegal when
428460
// executing these instructions in U-mode.
@@ -673,6 +705,12 @@ interface core_ibex_fcov_if import ibex_pkg::*; (
673705
// Only care about specific debug CSRs
674706
ignore_bins ignore = !binsof(cp_csr_write) intersect {`DEBUG_CSRS};
675707
}
708+
709+
dummy_instr_config_cross: cross cp_dummy_instr_type, cp_dummy_instr_mask
710+
iff (cs_registers_i.dummy_instr_en_o);
711+
712+
rf_ecc_err_cross: cross cp_rf_a_ecc_err, cp_rf_a_ecc_err
713+
iff (id_stage_i.instr_valid_i);
676714
endgroup
677715

678716
bit en_uarch_cov;

dv/uvm/core_ibex/tb/core_ibex_tb_top.sv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ module core_ibex_tb_top;
161161
`ASSERT(NoAlertsTriggered,
162162
!dut_if.alert_minor && !dut_if.alert_major_internal && !dut_if.alert_major_bus, clk, !rst_n)
163163

164+
assign dut.u_ibex_top.u_ibex_core.u_fcov_bind.rf_we_glitch_err =
165+
dut.u_ibex_top.rf_alert_major_internal;
166+
167+
assign dut.u_ibex_top.u_ibex_core.u_fcov_bind.lockstep_glitch_err =
168+
dut.u_ibex_top.lockstep_alert_major_internal;
169+
164170
// Data load/store vif connection
165171
assign data_mem_vif.reset = ~rst_n;
166172
// Instruction fetch vif connnection

rtl/ibex_core.sv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,10 @@ module ibex_core import ibex_pkg::*; #(
17031703
//////////
17041704

17051705
`ifndef SYNTHESIS
1706+
// fcov signals for V2S
1707+
`DV_FCOV_SIGNAL_GEN_IF(logic, rf_ecc_err_a_id, gen_regfile_ecc.rf_ecc_err_a_id, RegFileECC)
1708+
`DV_FCOV_SIGNAL_GEN_IF(logic, rf_ecc_err_b_id, gen_regfile_ecc.rf_ecc_err_b_id, RegFileECC)
1709+
17061710
// fcov signals for CSR access. These are complicated by illegal accesses. Where an access is
17071711
// legal `csr_op_en` signals the operation occurring, but this is deasserted where an access is
17081712
// illegal. Instead `illegal_insn_id` confirms the instruction is taking an illegal instruction

rtl/ibex_if_stage.sv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,16 @@ module ibex_if_stage import ibex_pkg::*; #(
681681
assign fetch_ready = id_in_ready_i & ~stall_dummy_instr;
682682
end
683683

684+
//////////
685+
// FCOV //
686+
//////////
687+
688+
`ifndef SYNTHESIS
689+
// fcov signals for V2S
690+
`DV_FCOV_SIGNAL_GEN_IF(logic [1:0], dummy_instr_type,
691+
gen_dummy_instr.dummy_instr_i.lfsr_data.instr_type, DummyInstructions)
692+
`endif
693+
684694
////////////////
685695
// Assertions //
686696
////////////////

0 commit comments

Comments
 (0)