Commit graph

2477 commits

Author SHA1 Message Date
Harry Callahan
882ee0f95b Bump up pmp_full_random timeout to 600s 2022-10-28 16:24:53 +01:00
Harry Callahan
6234aafe35 SQUASHED: Add new uvm test to hit hardware breakpoints coverpoints
Generate test_done: and test_fail: sections using handshake mechanism

Adding this behaviour to ibex_asm_program_gen allows all test to benefit
from the option of jumping directly to these label. Previously, ECALL was
used to provide a single path to this code.

Redefine ECALL handler to no-longer jump to 'write_tohost:'

This prevents the simulation from entering an infinite loop which it can no
longer detect and terminate from.

Add new uvm test to hit hardware breakpoints coverpoints

Overrides some riscv-dv classes to create a custom debug_rom for this test,
which is used to setup the breakpoint registers.
I have found it difficult to get stimulus of this hardware feature without
a more directed test. Improvements or ideas are welcome here.

Test-specific timeout of 5min within which I see >90% pass rate.

Change defaults for bad_intg on uninit accesses for Dmem/Imem

Imem : never create bad_intg on uninit access
Dmem : by default, enable bad_intg on uninit access. Plusarg to change behaviour.
2022-10-28 13:55:24 +01:00
Marno van der Maas
b8d8e23380 Tweak regressions around PMP, allow for double_faults, uninit_accesses
Add 180s timeout for pmp_full_random tests (this sees a reasonable pass-rate)

Tweaked to latest api for double_fault detector

Squashed changes from Marno's ongoing work:
[pmp] Adjust full random PMP to use random memory addresses
[pmp] Enable double fault detecter for MML read only test
[dv,pmp] Add double fault pass flag
[dv,pmp] Different parameters for pmp full random test
2022-10-28 13:54:07 +01:00
Harry Callahan
8762e0f221 [RISCV-DV] Change push_gpr_to_kernel_stack to prevent off-by-one store
If the DUT comes out of reset and immediately jumps into debug mode, the first
routine executed is to push the gpr's to the kernel stack. The register used as
the effective stack-pointer is initialized to zero, and the routine reserves the
address space (XLEN/4) * 31 to push the GPR's (excluding x0).

This routine however assumes that the original value in the sp register is valid
to be stored to. This is often not the case out of reset, when it is 0x00000000.
Therefore an address range from 0xffffff80 up to and including
0x00000000 (wrapping) is stored to.

This patch reserves 32 words instead, preventing the final gpr from writing to
an invalid addr in this case.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>

[RISCV-DV] Functional changes to fix nested_interrupt_test
2022-10-28 13:53:40 +01:00
Greg Chadwick
bbda68a0df [dv] Disable bad integrity on uninitialised memory for selected tests
From an initial triage and test regression run these tests benefit from
this.
2022-10-26 22:08:32 +01:00
Greg Chadwick
1d4cf9b207 [dv] Add single step over exception coverpoint 2022-10-26 12:13:19 +01:00
Greg Chadwick
bfe71faf5f [dv] Remove cp_insn_trigger_exception coverpoint
This coverpoint does not make sense. The hardware breakpoint is
triggered as the instruction moves into the ID/EX stage so it never has
a chance to take an exception (it effectively never begins executing).
2022-10-26 12:13:19 +01:00
Greg Chadwick
1851e86113 [rtl] Fix ebreak debug cause
We should only indicate an ebreak debug cause if an ebreak leads to a
debug entry (otherwise when single stepping over an ebreak that traps to
an exception we incorrectly enter debug mode with an ebreak cause).
2022-10-26 12:13:19 +01:00
Harry Callahan
659dc458f2 Fix bug in passing cosim_agent handle to the data_intf_seq
The handle was passed before the cosim was constructed, so when it came to use
the handle it caused a null pointer exception.
2022-10-25 16:07:57 +01:00
Harry Callahan
639f563a47 Update google_riscv-dv to google/riscv-dv@ada58fc
Update code from upstream repository https://github.com/google/riscv-
dv to revision ada58fc57a6bc1265e6c261b0f468a79c946a640

* [pmp] Fix plusarg detection for MML and MMWP (Marno van der Maas)
* [pmp] Add missing line return (Marno van der Maas)
* [pmp] Improve formatting of PMP addresses for debug (Marno van der
  Maas)
* [pmp] Add a register for loop counter in PMP traps instead of
  mscratch (Marno van der Maas)
* [pmp] Add illegal TOR and NAPOT address mode constraints (Marno van
  der Maas)
* [pmp] Try to skip instruction if no PMP match and in MMWP (Marno van
  der Maas)
* [pmp] Store and load faults caused by locked PMP regions now skip to
  next instruction (Marno van der Maas)
* [pmp] Check for MML before modifying PMP entry in trap handler
  (Marno van der Maas)
* [pmp] Allow already configured addresses to be overwritten with
  plusargs (Marno van der Maas)
* [pmp] Use kernel_inst_end for end of code entry (Marno van der Maas)
* [pmp] Add end of kernel stack to stack entry (Marno van der Maas)
* [pmp] Put signature and stack in last PMP entries (Marno van der
  Maas)

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-10-25 16:07:33 +01:00
Pirmin Vogel
28935490c2 [rtl] Protect core_busy_o with a multi-bit encoding
This commit protects the core_busy_o signal using a multi-bit encoding
to reduce the chances of an adversary for glitching this signal to low,
thereby putting the core to sleep and e.g. not handling an alert.

Without this commit, the glitch would only be detected once both the
main core and the shadow core wake up again and the comparison of the
core_busy_o signals continues.

This resolves lowRISC/Ibex#1827.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-10-25 12:52:01 +02:00
Greg Chadwick
f385d4d6b1 [dv] Add cpuctrlsts writes to riscv_rand_instr_test
This will have the effect of randomly enabling/disabling

 - The ICache
 - Dummy instruction insertion
 - Data independent timing
2022-10-22 20:30:49 +01:00
Greg Chadwick
a0fe5ea3b7 [dv] Fix RVFI stage valid logic
Previously if a dummy instruction entered the pipeline whilst it
wouldn't make RVFI stage 0 valid, it would make RVFI stage 1 valid.

Now stage 1 can only become valid if stage 0 was valid.
2022-10-22 20:30:49 +01:00
Greg Chadwick
4effc487e0 [cosim] Implement double fault detection
This adds an implementation of the double_fault_seen and sync_exc_seen
fields in cpuctrlsts.
2022-10-22 20:30:49 +01:00
Harry Callahan
e38f534ac2 Add wall-clock timeout within rtl simulation to gracefully end
Use a DPI call to unix 'date' to implement a wall-clock timeout entirely within
a simulation. This allows the UVM environment to gracefully end when the
threshold is reached, and for things like logs and coverage databases to be
generated correctly.
Previously, a process-level timeout was used, which gave the running simulation
no time to commit any logs/databases to disk before ending. Hence we would not
gather any coverage from timed-out tests.

A plusarg 'test_timeout_s' can be specified to each test to set the timeout. The
default timeout is 1800s.
2022-10-21 17:22:09 +01:00
Harry Callahan
0b2a7c4f4e Add mechanism for test-specific timeout
Adding the key 'timeout_s' to the testlist.yaml file for each test
now sets the timeout for all iterations of that test. Value in seconds.

e.g.
Set all iterations of the pmp_full_random test to have a 10s timeout.
```
- test: riscv_pmp_full_random_test
  timeout_s: 10
```
2022-10-21 17:22:09 +01:00
Harry Callahan
a44d9827d7 Fixup mem_intf seq to update cosim mem on DMEM uninit accesses
Give the sequence a handle to the cosim_agent, upon which it can call a method
to update the cosim memory model directly.
This required a small restructure of the mem_intf packages to prevent a circular dependency.
2022-10-21 17:13:18 +01:00
Harry Callahan
ee0fd38e7d Change ibex_mem_intf_response_seq to handle uninit memory differently
Reading uninit DMEM returns a random value.
Reading uninit IMEM returns returns {2{C.unimp}}.

Inserting intg errors upon uninit accesses is now gated with a plusarg
"+enable_bad_intg_on_uninit_access=1"

Fix missing update of the rtl mem_model when returning random data.
2022-10-21 17:13:18 +01:00
Marno van der Maas
a376f85f26 [lint] Shellcheck bash scripts in repo 2022-10-21 14:52:42 +01:00
Andreas Kurth
ce536ae476 [rtl] Assert that dummy instructions only write R0
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-10-19 10:50:01 +01:00
Marno van der Maas
73e46b4fc7 [fcov,pmp] Illegal PMP write coverpoints check dside request error not low 2022-10-19 10:20:32 +01:00
Canberk Topal
33f1d0a702 Update google_riscv-dv to google/riscv-dv@e0eae9e
Update code from upstream repository https://github.com/google/riscv-
dv to revision e0eae9e0ca69770c519c82c48421005f65521eac

* [sv] Explicit type casting for VCS compability (Canberk Topal)

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-17 11:00:35 +01:00
Canberk Topal
c02a3d1662 [vcs] Fix Ibex DV runs for VCS
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-17 11:00:35 +01:00
Harry Callahan
bece44f4d6 Change double_fault detector to on by default, fatal error if triggered
Add a plusargs "+is_double_fault_detected_fatal" to the top-level cfg,
which is set to 1 by default.

Set the default for the "+enable_double_fault_detector" to 1.
2022-10-17 10:37:04 +01:00
Harry Callahan
b214fa1c72 Add a double_fault detector to core_ibex uvm environment
Add a new scoreboard component to the core_ibex uvm environment, which contains
a double_fault detector task. This uses the top-level output
'double_fault_seen_o' to count the number of total and consecutive double_faults
seen with a test. A helper task allows the base_test to wait upon each of these
counters reaching the configured thresholds, and then to end the test early with
a passing result.

The default thresholds are 100 for consecutive faults, and 1000 for total faults.

The double_fault detector is disabled by default.
A plusarg '+enable_double_fault_detector=1' enables the checker.

This commit enables it for only the 'pmp_full_random_test', as that is a useful
test candidate to begin with.
2022-10-17 10:37:04 +01:00
Greg Chadwick
083fe2a54f [dv] Use fetch enable sequence by default
This sequence randomly toggles the fetch enable.
2022-10-16 17:17:15 +01:00
Greg Chadwick
7feffd566f [dv] Increase various timeouts
When the fetch enable sequence is employed in some tests these timeouts
are hit. Increasing them allows these tests to pass.
2022-10-16 17:17:15 +01:00
Greg Chadwick
12952cfe13 [dv] fetch_enable_seq tweaks
Previously the time over which fetch enable was disabled was randomized
at the start of the sequence and kept constant throught. Now it is
randomized for every `send_req`.

Stop generating FetchEnableOn as a possible fetch_enable value to set
and use the SecureIbex parameter to decide if full randomisation off all
of the non FetchEnableOn MUBI values if needed or we just always switch
between FetchEnableOn/FetchEnableOff

Tweaks the default min/max delay values for how long fetch remains
disabled.
2022-10-16 17:17:15 +01:00
Greg Chadwick
27907d1d4a [rtl] Immediately stop execution when fetch disabled
Previously `fetch_enable_i` only controlled the request going into the
instruction fetch stage.  Due to buffering in the prefetch queue and
icache when this request is dropped it's possible for multiple
instructions to still be available for the ID/EX stage to consume. So
when `fetch_enable_i` was set to off you would get a 'soft stop'. Some
finite number of instructions may still execute and Ibex would come to
an eventual halt.

Now `fetch_enable_i` also gates the instruction moving between the fetch
stage and the ID/EX stage. This gives a 'hard stop' where once fetch is
disabled Ibex comes to an immediate halt.
2022-10-16 17:17:15 +01:00
Harry Callahan
75a93dbed0 Fixup signal used when checking for ebreak cause 2022-10-14 18:44:02 +01:00
Canberk Topal
f2c1d6dc9d [rtl] Change how we record debug causes
This commit changes when we cath the debug causes. Since debug_cause_o
only gets latched when `csr_save_cause_o` is high, it would work if
we change the cause with a mux that is connected to the input signals.

Resolves #1772

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-14 18:44:02 +01:00
Greg Chadwick
298c8789da [rtl/dv] Bring back data integrity check on write responses
Previously Ibex signalled a major alert on an integrity error (where
incoming read data doesn't match its integrity bits) for both read and
write responses. This was removed as the data part of a response to a
write is ignored.

This brings it back in a more measured way. This provides a little extra
fault injection hardening as an attacker glitching the memory bus will
generate an alert on both read and write responses.
2022-10-14 18:22:58 +01:00
Greg Chadwick
d7ce082779 [dv] Remove riscv_perf_counter_test
This test doesn't actually check the performance counters, it just runs
a random instruction test and dumps the performance counters at the end
for some final checking. That checking does not exist. The test is
currently broken as well so just remove it as it adds nothing to the
regression.
2022-10-14 12:59:20 +01:00
Greg Chadwick
511a3516a6 [dv] Remove CPUCTRLSTS from riscv_csr_test
Bit 8 of this CSR cannot be predicted by the CSR test generator leading
to test failures. Remove it from the test for now until this is
addressed.
2022-10-14 12:59:20 +01:00
Greg Chadwick
48733e23ec [rtl] Ignore MIE bit in U mode 2022-10-13 17:30:05 +01:00
Greg Chadwick
48789dd095 [rtl] Don't take interrupts when single stepping
Fixes #1814
2022-10-13 17:30:05 +01:00
Harry Callahan
25d81afef6 Update google_riscv-dv to google/riscv-dv@c6acc18
Update code from upstream repository https://github.com/google/riscv-
dv to revision c6acc1897429f5245cc89b2ecee2e3eefdefd18d

* Add plusarg to enable ECALL insn in main randomized body (Harry
  Callahan)

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-10-11 17:42:23 +01:00
Marno van der Maas
4608df4606 [dv] Shellcheck prettify script
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-10-11 17:08:46 +01:00
Marno van der Maas
322ab3a285 [dv] Shellcheck objdump script and check for RISCV_TOOLCHAIN variable
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-10-11 17:08:46 +01:00
Canberk Topal
7c28d3caf3 [ci] Update IBEX_COSIM_VERSION to latest
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-11 15:52:42 +01:00
Canberk Topal
e27deb1015 [dv] Add MHPM Counter number param to SpikeCosim
This commit adds another field in SpikeCosim class so that Spike
can hardcode the correct event registers.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-11 15:52:42 +01:00
Marno van der Maas
08115056f9 [doc] Add NAPOT address mode to coverage plan 2022-10-10 13:46:17 +01:00
Marno van der Maas
671b924f66 [pmp] Add coverpoints for large NAPOT regions 2022-10-10 13:46:17 +01:00
Greg Chadwick
574d993dcd [ci] Switch to downloading verilator from GCP bucket
Previously it was sourced from the OpenSUSE build service. This has
produced some reliability issues. Downloading pre-built binaries from a
GCP bucket should improve things.
2022-10-07 13:34:07 +01:00
Greg Chadwick
b57c9a4349 [ci] Switch to using Ubuntu 20 LTS azure agent
The Ubuntu 18 LTS image has been deprecated by Azure so we need to
switch to a new version.
2022-10-07 13:34:07 +01:00
Harry Callahan
3c11ef10b9 single_step test : only drive debug_req_i after stepping finishes
This addresses a current testbench issue where asserting debug_req_i close to
when single_stepping over an instruction causes an incorrect 'cause' to be
recorded within DCSR.
2022-10-06 17:52:36 +01:00
Harry Callahan
377382fb78 Single step debugging test changes for fcov
This builds upon the cosimulation environment to allow us to rip-out all the
existing checking from the test, and instead focus on generating good stimulus
to hit all our coverage points.
Make use of the riscv-dv changes to insert ecall into the main test body, now
that we have a different mechanism for ending the test.
Allow illegal instructions, csr instructions, ebreak, etc. which the previous
brittle checking paradigms could not handle.
2022-10-06 17:52:36 +01:00
Marno van der Maas
7ab2571bea [if,pmp] Check second bit instead of third for instruction alignment
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-10-06 10:23:01 +01:00
Harry Callahan
0e396d5944 Change failure modes and add comments with more clarifying details 2022-10-05 17:00:31 +01:00
Harry Callahan
3650e08e4e Record test failure due to timeout in regr.log
This commit adds a new field to the trr (test-run-result) structured data
that records the failure_mode of a testcase. If the test failed due to a
timeout, print a small addendum {T} to each log-line in the summary.

eg.

23.33% PASS 7 PASSED, 23 FAILED
riscv_debug_basic_test.21259:                     PASS
riscv_debug_basic_test.21260:                     FAILED {T}
riscv_debug_basic_test.21261:                     PASS
riscv_debug_basic_test.21262:                     FAILED {T}
riscv_debug_basic_test.21263:                     FAILED {T}
riscv_debug_instr_test.21259:                     FAILED {T}
riscv_debug_instr_test.21260:                     FAILED {T}
riscv_debug_instr_test.21261:                     FAILED {T}
riscv_debug_instr_test.21262:                     PASS
riscv_debug_instr_test.21263:                     FAILED {T}
riscv_dret_test.21259:                            FAILED
riscv_dret_test.21260:                            FAILED
riscv_dret_test.21261:                            FAILED {T}
2022-10-05 17:00:31 +01:00