second bug test
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
@@ -585,6 +585,91 @@ module cpu_tb_top;
|
||||
};
|
||||
run_directed("duplicate_store_beq_test", prog);
|
||||
|
||||
// test derived from bug hunt SEED=3333
|
||||
// incorrect sw addr
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADD), .rd(2), .rs1(5), .rs2(3)),
|
||||
asm_instr(.op(OP_ADD), .rd(18), .rs1(1), .rs2(2)),
|
||||
asm_instr(.op(OP_SLL), .rd(15), .rs1(1), .rs2(3)),
|
||||
asm_instr(.op(OP_ADDI), .rd(2), .rs1(12), .imm(1703)),
|
||||
asm_instr(.op(OP_SRL), .rd(4), .rs1(12), .rs2(0)),
|
||||
asm_instr(.op(OP_SLL), .rd(6), .rs1(28), .rs2(7)),
|
||||
asm_instr(.op(OP_ADD), .rd(6), .rs1(1), .rs2(6)),
|
||||
asm_instr(.op(OP_SW), .rs1(10), .rs2(4), .imm(1524)),
|
||||
asm_instr(.op(OP_ADDI), .rd(2), .rs1(7), .imm(1309)),
|
||||
asm_instr(.op(OP_SLL), .rd(6), .rs1(4), .rs2(7)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(4), .rs2(1), .imm(8)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(9), .rs2(6), .imm(36)),
|
||||
asm_instr(.op(OP_SRL), .rd(24), .rs1(0), .rs2(13)),
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(7), .imm(2039)),
|
||||
asm_instr(.op(OP_ADD), .rd(4), .rs1(5), .rs2(6)),
|
||||
asm_instr(.op(OP_ADD), .rd(6), .rs1(22), .rs2(2)),
|
||||
asm_instr(.op(OP_SLL), .rd(6), .rs1(12), .rs2(4)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(6), .rs2(6), .imm(64)),
|
||||
asm_instr(.op(OP_SW), .rs1(6), .rs2(3), .imm(496)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(11), .rs2(3), .imm(108)),
|
||||
asm_instr(.op(OP_ADD), .rd(10), .rs1(0), .rs2(29)),
|
||||
asm_instr(.op(OP_ADD), .rd(5), .rs1(9), .rs2(5)),
|
||||
asm_instr(.op(OP_SLL), .rd(10), .rs1(4), .rs2(17)),
|
||||
asm_instr(.op(OP_SUB), .rd(27), .rs1(0), .rs2(5)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(14), .rs2(1), .imm(48)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(19), .rs2(7), .imm(76)),
|
||||
asm_instr(.op(OP_SRL), .rd(3), .rs1(2), .rs2(2)),
|
||||
asm_instr(.op(OP_LW), .rd(7), .rs1(0), .imm(828)),
|
||||
asm_instr(.op(OP_SRL), .rd(3), .rs1(3), .rs2(23)),
|
||||
asm_instr(.op(OP_SRL), .rd(0), .rs1(3), .rs2(15)),
|
||||
asm_instr(.op(OP_ADDI), .rd(6), .rs1(4), .imm(997)),
|
||||
asm_instr(.op(OP_LW), .rd(14), .rs1(2), .imm(-1297)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(5), .rs2(7), .imm(56)),
|
||||
asm_instr(.op(OP_SUB), .rd(0), .rs1(7), .rs2(0)),
|
||||
asm_instr(.op(OP_ADD), .rd(5), .rs1(6), .rs2(2)),
|
||||
asm_instr(.op(OP_SLL), .rd(4), .rs1(15), .rs2(1)),
|
||||
asm_instr(.op(OP_LW), .rd(4), .rs1(0), .imm(1576)),
|
||||
asm_instr(.op(OP_SLL), .rd(9), .rs1(7), .rs2(7)),
|
||||
asm_instr(.op(OP_SLL), .rd(4), .rs1(1), .rs2(2)),
|
||||
asm_instr(.op(OP_SRL), .rd(9), .rs1(7), .rs2(1)),
|
||||
asm_instr(.op(OP_ADD), .rd(6), .rs1(6), .rs2(7)),
|
||||
asm_instr(.op(OP_SUB), .rd(7), .rs1(6), .rs2(28)),
|
||||
asm_instr(.op(OP_ADD), .rd(5), .rs1(24), .rs2(6)),
|
||||
asm_instr(.op(OP_ADDI), .rd(4), .rs1(4), .imm(765)),
|
||||
asm_instr(.op(OP_SRL), .rd(2), .rs1(3), .rs2(4)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(6), .rs2(4), .imm(12)),
|
||||
asm_instr(.op(OP_SUB), .rd(23), .rs1(0), .rs2(12)),
|
||||
asm_instr(.op(OP_SLL), .rd(2), .rs1(4), .rs2(24)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(3), .imm(213)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("incorrect_store_bug", prog);
|
||||
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(2039)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(0), .imm(213)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("sw_addr_carry_bit8_orig", prog);
|
||||
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(252)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(1), .imm(8)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("sw_addr_carry_bit8_aligned", prog);
|
||||
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(100)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(1), .imm(8)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("sw_addr_no_carry_control", prog);
|
||||
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(255)),
|
||||
asm_instr(.op(OP_ADDI), .rd(2), .rs1(1), .imm(1)),
|
||||
asm_instr(.op(OP_SW), .rs1(0), .rs2(2), .imm(0)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("alu_carry_bit8", prog);
|
||||
|
||||
// CHIP-LEVEL DIRECTED TESTS
|
||||
run_reset_while_running();
|
||||
run_external_halt();
|
||||
|
||||
+138
-1
@@ -1330,6 +1330,7 @@ STABLE_WHEN_DISABLED :
|
||||
|
||||
## 4. Encrypted CPU Bug Hunt
|
||||
### Random discovery
|
||||
##### 4.1 Bug 1 - Duplicate Store
|
||||
|
||||
| Field | Evidence |
|
||||
| ------------------------ | ------------------------------------------------------------------------------ |
|
||||
@@ -1375,7 +1376,7 @@ run_directed("duplicate_store_beq", prog);
|
||||
| ------------------- | ---------- | ------------------------- | ---------- |
|
||||
| sw x1, 1004(x1) | 0x00000000 | 0x00000000 (stored twice) | |
|
||||
|
||||
**First architectural divergence:** duplicate SW when one is expected after a branch is taken
|
||||
**First architectural divergence:** duplicate SW when one is expected, seems to happen when branch is taken
|
||||
<!-- State the first register, memory, or control-flow result that becomes incorrect. -->
|
||||
|
||||
### Minimization
|
||||
@@ -1415,5 +1416,141 @@ Include a screenshot showing the offending instruction and the first incorrect a
|
||||
|
||||
<!-- One precise sentence. Do not speculate about hidden RTL. -->
|
||||
|
||||
##### 4.2 Bug 2 - Incorrect Store Addr
|
||||
|
||||
| Field | Evidence |
|
||||
| ------------------------ | -------------------------------------------------------------------------- |
|
||||
| Discovery command | `make bug_hunt SEED=random` |
|
||||
| Numeric `SVSEED` | 3333 |
|
||||
| Failing iteration | 0 |
|
||||
| First failure message | store #2 wrote dmem[0x17d] = 0x00000000, expected dmem[0x233] = 0x00000000 |
|
||||
| Reproduction command | `make bug_hunt SEED=3333` |
|
||||
| Reproduces consistently? | Yes |
|
||||
|
||||
**Original failing program:**
|
||||
|
||||
```systemverilog
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADD), .rd(2), .rs1(5), .rs2(3)),
|
||||
asm_instr(.op(OP_ADD), .rd(18), .rs1(1), .rs2(2)),
|
||||
asm_instr(.op(OP_SLL), .rd(15), .rs1(1), .rs2(3)),
|
||||
asm_instr(.op(OP_ADDI), .rd(2), .rs1(12), .imm(1703)),
|
||||
asm_instr(.op(OP_SRL), .rd(4), .rs1(12), .rs2(0)),
|
||||
asm_instr(.op(OP_SLL), .rd(6), .rs1(28), .rs2(7)),
|
||||
asm_instr(.op(OP_ADD), .rd(6), .rs1(1), .rs2(6)),
|
||||
asm_instr(.op(OP_SW), .rs1(10), .rs2(4), .imm(1524)),
|
||||
asm_instr(.op(OP_ADDI), .rd(2), .rs1(7), .imm(1309)),
|
||||
asm_instr(.op(OP_SLL), .rd(6), .rs1(4), .rs2(7)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(4), .rs2(1), .imm(8)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(9), .rs2(6), .imm(36)),
|
||||
asm_instr(.op(OP_SRL), .rd(24), .rs1(0), .rs2(13)),
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(7), .imm(2039)),
|
||||
asm_instr(.op(OP_ADD), .rd(4), .rs1(5), .rs2(6)),
|
||||
asm_instr(.op(OP_ADD), .rd(6), .rs1(22), .rs2(2)),
|
||||
asm_instr(.op(OP_SLL), .rd(6), .rs1(12), .rs2(4)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(6), .rs2(6), .imm(64)),
|
||||
asm_instr(.op(OP_SW), .rs1(6), .rs2(3), .imm(496)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(11), .rs2(3), .imm(108)),
|
||||
asm_instr(.op(OP_ADD), .rd(10), .rs1(0), .rs2(29)),
|
||||
asm_instr(.op(OP_ADD), .rd(5), .rs1(9), .rs2(5)),
|
||||
asm_instr(.op(OP_SLL), .rd(10), .rs1(4), .rs2(17)),
|
||||
asm_instr(.op(OP_SUB), .rd(27), .rs1(0), .rs2(5)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(14), .rs2(1), .imm(48)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(19), .rs2(7), .imm(76)),
|
||||
asm_instr(.op(OP_SRL), .rd(3), .rs1(2), .rs2(2)),
|
||||
asm_instr(.op(OP_LW), .rd(7), .rs1(0), .imm(828)),
|
||||
asm_instr(.op(OP_SRL), .rd(3), .rs1(3), .rs2(23)),
|
||||
asm_instr(.op(OP_SRL), .rd(0), .rs1(3), .rs2(15)),
|
||||
asm_instr(.op(OP_ADDI), .rd(6), .rs1(4), .imm(997)),
|
||||
asm_instr(.op(OP_LW), .rd(14), .rs1(2), .imm(-1297)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(5), .rs2(7), .imm(56)),
|
||||
asm_instr(.op(OP_SUB), .rd(0), .rs1(7), .rs2(0)),
|
||||
asm_instr(.op(OP_ADD), .rd(5), .rs1(6), .rs2(2)),
|
||||
asm_instr(.op(OP_SLL), .rd(4), .rs1(15), .rs2(1)),
|
||||
asm_instr(.op(OP_LW), .rd(4), .rs1(0), .imm(1576)),
|
||||
asm_instr(.op(OP_SLL), .rd(9), .rs1(7), .rs2(7)),
|
||||
asm_instr(.op(OP_SLL), .rd(4), .rs1(1), .rs2(2)),
|
||||
asm_instr(.op(OP_SRL), .rd(9), .rs1(7), .rs2(1)),
|
||||
asm_instr(.op(OP_ADD), .rd(6), .rs1(6), .rs2(7)),
|
||||
asm_instr(.op(OP_SUB), .rd(7), .rs1(6), .rs2(28)),
|
||||
asm_instr(.op(OP_ADD), .rd(5), .rs1(24), .rs2(6)),
|
||||
asm_instr(.op(OP_ADDI), .rd(4), .rs1(4), .imm(765)),
|
||||
asm_instr(.op(OP_SRL), .rd(2), .rs1(3), .rs2(4)),
|
||||
asm_instr(.op(OP_BEQ), .rs1(6), .rs2(4), .imm(12)),
|
||||
asm_instr(.op(OP_SUB), .rd(23), .rs1(0), .rs2(12)),
|
||||
asm_instr(.op(OP_SLL), .rd(2), .rs1(4), .rs2(24)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(3), .imm(213)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("incorrect_store_bug", prog);
|
||||
```
|
||||
|
||||
### Expected vs. actual
|
||||
|
||||
| Instruction / event | Expected | Actual | Cycle/time |
|
||||
| ------------------- | ---------- | ------------------------- | ---------- |
|
||||
| sw x1, 1004(x1) | 0x00000000 | 0x00000000 (stored twice) | |
|
||||
|
||||
**First architectural divergence:** 17d is the computed addr to store into, which is not what the scoreboard is expecting
|
||||
<!-- State the first register, memory, or control-flow result that becomes incorrect. -->
|
||||
|
||||
### Minimization
|
||||
|
||||
**Minimized reproducer:**
|
||||
|
||||
```systemverilog
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(2039)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(0), .imm(213)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("sw_addr_carry_bit8_orig", prog);
|
||||
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(252)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(1), .imm(8)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("sw_addr_carry_bit8_aligned", prog);
|
||||
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(100)),
|
||||
asm_instr(.op(OP_SW), .rs1(1), .rs2(1), .imm(8)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("sw_addr_no_carry_control", prog);
|
||||
|
||||
prog = '{
|
||||
asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(255)),
|
||||
asm_instr(.op(OP_ADDI), .rd(2), .rs1(1), .imm(1)),
|
||||
asm_instr(.op(OP_SW), .rs1(0), .rs2(2), .imm(0)),
|
||||
EBREAK_WORD
|
||||
};
|
||||
run_directed("alu_carry_bit8", prog);
|
||||
```
|
||||
|
||||
### Waveform evidence
|
||||
|
||||
Include a screenshot showing the offending instruction and the first incorrect architectural result.
|
||||
![[Pasted image 20261007184043.png]]
|
||||
|
||||
### Conclusion
|
||||
|
||||
**Trigger:** sw + beq
|
||||
|
||||
<!-- Smallest condition that causes the failure. -->
|
||||
|
||||
**Expected behavior:** one single sw and beq is successful
|
||||
|
||||
<!-- ISA-correct behavior. -->
|
||||
|
||||
**Observed behavior:** sw is counted twice, while the scoreboard only expects one store
|
||||
|
||||
<!-- What the encrypted CPU does instead. -->
|
||||
|
||||
**Behavioral characterization:** the cpu holds write enable high for more than one cycle, leading to two stores
|
||||
|
||||
<!-- One precise sentence. Do not speculate about hidden RTL. -->
|
||||
|
||||
### 5. Code coverage >98% for cpu_tb_top
|
||||
![[Pasted image 20261006143238.png]]
|
||||
Reference in New Issue
Block a user