Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 1 | // Copyright lowRISC contributors. |
| 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | { |
| 5 | name: "csrng" |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 6 | import_testplans: ["hw/dv/tools/dvsim/testplans/csr_testplan.hjson", |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 7 | "hw/dv/tools/dvsim/testplans/intr_test_testplan.hjson", |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 8 | "hw/dv/tools/dvsim/testplans/alert_test_testplan.hjson", |
| 9 | "hw/dv/tools/dvsim/testplans/tl_device_access_types_testplan.hjson", |
Srikrishna Iyer | a463e17 | 2022-02-02 12:09:39 -0800 | [diff] [blame] | 10 | "hw/dv/tools/dvsim/testplans/stress_all_with_reset_testplan.hjson", |
| 11 | "csrng_sec_cm_testplan.hjson"] |
Srikrishna Iyer | 86169d0 | 2021-05-10 09:35:52 -0700 | [diff] [blame] | 12 | testpoints: [ |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 13 | { |
Cindy Chen | cb03ee9 | 2020-11-11 10:19:14 -0800 | [diff] [blame] | 14 | name: smoke |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 15 | desc: ''' |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 16 | Verify that sending an instantiate command via the SW path returns OK. |
| 17 | Instantiate the CSRNG with flag0 set to true and clen set to 12. |
| 18 | Verify that sending a generate command via the SW path returns glen=1 number of words followed by an OK. |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 19 | ''' |
Michael Schaffner | d1be61b | 2022-08-23 17:41:35 -0700 | [diff] [blame] | 20 | stage: V1 |
Cindy Chen | cb03ee9 | 2020-11-11 10:19:14 -0800 | [diff] [blame] | 21 | tests: ["csrng_smoke"] |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 22 | } |
| 23 | { |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 24 | name: interrupts |
| 25 | desc: ''' |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 26 | This test verifies the behavior of the Interrupt State Register. |
| 27 | Verify cs_cmd_req_done interrupt asserts when glen number of genbit words have been generated. |
| 28 | Verify cs_entropy_req interrupt asserts when instantiate or reseed is called with flag0 |
| 29 | set to false. |
| 30 | Verify cs_hw_inst_exc interrupt asserts when any of the application interfaces responds with a CSRNG_ERROR response status signal. |
| 31 | Verify cs_fatal_err interrupt asserts when any bit of err_code register is set. |
| 32 | Verify that each interrupt clears back to 0 after writing the corresponding interrupt state bit. |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 33 | ''' |
Michael Schaffner | d1be61b | 2022-08-23 17:41:35 -0700 | [diff] [blame] | 34 | stage: V2 |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 35 | tests: ["csrng_intr"] |
| 36 | } |
| 37 | { |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 38 | //TODO For the following untested features add it to the test or create explicit coverpoints in csrng_cmd_cg: |
| 39 | //TODO - Invalid MuBi values for flag0 are currently untested. |
| 40 | //TODO - Illegal commands are currently untested. |
| 41 | //TODO - Fatal alerts are currently untested. |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 42 | name: alerts |
| 43 | desc: ''' |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 44 | Verify recov_alert asserts when recov_alert_sts becomes non-zero. |
| 45 | Verify each respective bit of recov_alert_sts asserts when: |
| 46 | - Either of the 3 values in the control register are not valid kMultiBitBool values. |
| 47 | - When an initiate or reseed command is sent where flag0 is not a valid kMultiBitBool value. |
| 48 | - The genbits bus value is equal to the prior valid value. |
| 49 | - When an illegal command is used (0x0,0x6-0xf). |
| 50 | Verify that writing zeros to the recoverable alert status register resets all the status bits. |
| 51 | Verify fatal_alert asserts when: |
| 52 | - An illegal state is reached. |
| 53 | - The AES block raises a fatal alert. |
| 54 | - There is an integrity failure on the bus (this is covered by an automated test). |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 55 | ''' |
Michael Schaffner | d1be61b | 2022-08-23 17:41:35 -0700 | [diff] [blame] | 56 | stage: V2 |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 57 | tests: ["csrng_alert"] |
| 58 | } |
| 59 | { |
| 60 | name: err |
| 61 | desc: ''' |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 62 | Verify err_code register bits assert when: |
| 63 | - An error has been detected in any of the internal fifos and the corresponding write/read/state bits. |
| 64 | - An illegal state is reached in any of the 6 state machines. |
| 65 | - An error is detected in the generate command counter. |
| 66 | Verify that the err_code register clears all bits after reset. |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 67 | ''' |
Michael Schaffner | d1be61b | 2022-08-23 17:41:35 -0700 | [diff] [blame] | 68 | stage: V2 |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 69 | tests: ["csrng_err"] |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 70 | } |
| 71 | { |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 72 | //TODO For the following untested features add it to the test or create explicit coverpoints in csrng_cmd_cg: |
| 73 | //TODO - Verification of otp_en_csrng_sw_app_read is currently untested. |
| 74 | //TODO - FIPS bit going low from entropy source is currently untested. |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 75 | name: cmds |
| 76 | desc: ''' |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 77 | Verify all csrng commands req/status behave as predicted on all applications: HW0, HW1 and SW. |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 78 | Verify above for all valid values of acmd, clen, flags, glen. |
| 79 | Verify for multiple hw app interfaces running in parallel. |
Steve Nelson | eea7992 | 2021-01-26 06:31:54 -0800 | [diff] [blame] | 80 | Verify sw/hw app interfaces running in parallel. |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 81 | Verify main_sm_state for sw/hw apps. |
| 82 | Verify that genbits generates the amount specified by glen. |
| 83 | Verify fips bit is set to the inverse of flag0 that was used on the last initialize or reseed. |
| 84 | Verify that if otp_en_csrng_sw_app_read is set, genbits and int_state_value registers are readable, and unreadable otherwise. |
| 85 | Verify that when AES_HALT is set during a generate command that no request is sent to the AES block. |
Steve Nelson | 544f83e | 2022-03-30 13:27:31 -0700 | [diff] [blame] | 86 | Verify commands with continuous/non-continuous valid. |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 87 | Verify that if FIPS bit drops at input from entropy source that the generated block also has FIPS low. |
Steve Nelson | eea7992 | 2021-01-26 06:31:54 -0800 | [diff] [blame] | 88 | ''' |
Michael Schaffner | d1be61b | 2022-08-23 17:41:35 -0700 | [diff] [blame] | 89 | stage: V2 |
Steve Nelson | f508d2d | 2021-12-30 12:04:47 -0800 | [diff] [blame] | 90 | tests: ["csrng_cmds"] |
Steve Nelson | eea7992 | 2021-01-26 06:31:54 -0800 | [diff] [blame] | 91 | } |
| 92 | { |
| 93 | name: life cycle |
| 94 | desc: ''' |
Steve Nelson | 544f83e | 2022-03-30 13:27:31 -0700 | [diff] [blame] | 95 | Verify lifecycle hardware debug mode. |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 96 | When lc_hw_debug_en_i is set to on, the seed from the entropy source must be xor'ed with the diversification value. |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 97 | ''' |
Michael Schaffner | d1be61b | 2022-08-23 17:41:35 -0700 | [diff] [blame] | 98 | stage: V2 |
Steve Nelson | 544f83e | 2022-03-30 13:27:31 -0700 | [diff] [blame] | 99 | tests: ["csrng_cmds"] |
Steve Nelson | c13ff41 | 2020-12-01 14:25:29 -0800 | [diff] [blame] | 100 | } |
| 101 | { |
| 102 | name: stress_all |
| 103 | desc: ''' |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 104 | Combine the other individual testpoints while injecting TL errors and running CSR tests in parallel. |
Srikrishna Iyer | e8713f4 | 2021-05-26 20:13:29 -0700 | [diff] [blame] | 105 | ''' |
Michael Schaffner | d1be61b | 2022-08-23 17:41:35 -0700 | [diff] [blame] | 106 | stage: V2 |
Steve Nelson | f508d2d | 2021-12-30 12:04:47 -0800 | [diff] [blame] | 107 | tests: ["csrng_stress_all"] |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 108 | } |
| 109 | ] |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 110 | |
| 111 | covergroups: [ |
| 112 | { |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 113 | //TODO Configuration for enable is currently not covered. |
Steve Nelson | 544f83e | 2022-03-30 13:27:31 -0700 | [diff] [blame] | 114 | name: csrng_cfg_cg |
| 115 | desc: ''' |
| 116 | Covers that all csrng configuration options have been tested. |
| 117 | Individual config settings that will be covered include: |
| 118 | - otp_en_cs_sw_app_read |
| 119 | - sw_app_enable |
| 120 | - read_int_state |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 121 | - enable |
Marno van der Maas | 1c8875d | 2022-11-22 15:35:30 +0000 | [diff] [blame] | 122 | - regwen has been true and false |
| 123 | - intr_state has had each bit set and unset at least once (handled in comportable ip coverage) |
| 124 | Cross: |
| 125 | - intr_enable and intr_state (handled in comportable ip coverage) |
Steve Nelson | 544f83e | 2022-03-30 13:27:31 -0700 | [diff] [blame] | 126 | ''' |
| 127 | } |
| 128 | { |
| 129 | name: csrng_cmds_cg |
| 130 | desc: ''' |
| 131 | Covers that all csrng commands and variations have been tested for all apps. |
| 132 | Individual commands and command options that will be covered include: |
| 133 | - app |
| 134 | - acmd, clen, flags, glen |
Steve Nelson | 544f83e | 2022-03-30 13:27:31 -0700 | [diff] [blame] | 135 | - continuous/non-continuous valid |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 136 | Crosses of |
| 137 | - app/acmd |
| 138 | - acmd/clen |
| 139 | - acmd/flag0 |
| 140 | - acmd/glen |
| 141 | - For the instantiate and reseed command: |
| 142 | - flag0 false and clen 0 |
| 143 | - flag0 false and clen >0 |
| 144 | - flag0 true and clen 0 |
| 145 | - flag0 true and clen >0 |
| 146 | ''' |
| 147 | } |
| 148 | { |
Marno van der Maas | 1c8875d | 2022-11-22 15:35:30 +0000 | [diff] [blame] | 149 | name: csrng_sts_cg |
Marno van der Maas | 0e15155 | 2022-11-08 14:27:18 +0000 | [diff] [blame] | 150 | desc: ''' |
Marno van der Maas | 1c8875d | 2022-11-22 15:35:30 +0000 | [diff] [blame] | 151 | Covers all possible hw_exc_sts responses from each HW instance and the sub-fields of |
| 152 | sw_cmd_sts, which are cmd_rdy and cmd_sts. |
Steve Nelson | 544f83e | 2022-03-30 13:27:31 -0700 | [diff] [blame] | 153 | ''' |
| 154 | } |
| 155 | { |
Canberk Topal | dd26b24 | 2022-11-11 16:57:57 +0000 | [diff] [blame] | 156 | name: csrng_err_code_cg |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 157 | desc: ''' |
Marno van der Maas | 1c8875d | 2022-11-22 15:35:30 +0000 | [diff] [blame] | 158 | Covers all possible fatal errors and possible AES FSM errors inside CSRNG. |
Canberk Topal | dd26b24 | 2022-11-11 16:57:57 +0000 | [diff] [blame] | 159 | ''' |
| 160 | } |
| 161 | { |
| 162 | name: csrng_err_code_test_cg |
| 163 | desc: ''' |
| 164 | Covers ERR_CODE_TEST register values for setting up fatal errors. |
| 165 | ''' |
| 166 | } |
| 167 | { |
| 168 | name: csrng_recov_alert_sts_cg |
| 169 | desc: ''' |
| 170 | Covers all possible recoverable alert cases. |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 171 | ''' |
| 172 | } |
Canberk Topal | 6ae0003 | 2022-11-16 15:29:37 +0000 | [diff] [blame] | 173 | { |
| 174 | name: csrng_sfifo_cg |
| 175 | desc: ''' |
| 176 | Covers each app's stage FIFO statuses. |
| 177 | - cp_hw0_cmd_depth, cp_hw1_cmd_depth, cp_sw_cmd_depth : Covers current number of commands in FIFO |
| 178 | - cp_hw0_genbits_depth, cp_hw1_genbits_depth, cp_sw_genbits_depth : Covers current number of genbit responses in FIFO |
| 179 | - cmd_depth_cross : Cross for checking each command FIFO status in different apps |
| 180 | - genbits_depth_cross : Cross for checking genbits FIFO status in different apps |
Pirmin Vogel | 7dd9dcc | 2022-11-21 17:46:32 +0100 | [diff] [blame] | 181 | - hw0_cmd_push_cross, hw1_cmd_push_cross, sw_cmd_push_cross : command FIFO fill status x command FIFO write valid x command FIFO write ready |
| 182 | - hw0_cmd_pop_cross, hw1_cmd_pop_cross, sw_cmd_pop_cross : command FIFO fill status x command FIFO read ready |
| 183 | - hw0_genbits_pop_cross, hw1_genbits_pop_cross, sw_genbits_pop_cross : genbits FIFO fill status x genbits FIFO read valid x genbits FIFO read ready |
Canberk Topal | 6ae0003 | 2022-11-16 15:29:37 +0000 | [diff] [blame] | 184 | ''' |
| 185 | } |
Muqing Liu | 39786f6 | 2022-01-09 18:10:54 -0800 | [diff] [blame] | 186 | ] |
Steve Nelson | 87a9d12 | 2020-10-26 13:10:20 -0700 | [diff] [blame] | 187 | } |