From 0a43dc31e694db2b0610e8be860d7684149b2db8 Mon Sep 17 00:00:00 2001 From: Andrew de los Reyes Date: Tue, 15 Aug 2023 11:04:20 -0700 Subject: [PATCH 1/3] Svadu: Pull in headers from env submodule --- env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env b/env index 4fabfb4e0..14eb0d202 160000 --- a/env +++ b/env @@ -1 +1 @@ -Subproject commit 4fabfb4e0d3eacc1dc791da70e342e4b68ea7e46 +Subproject commit 14eb0d20249924ced641c42e07fe6d27f19be653 From a7c23c56de91937e423851d57057cd9e42d6965d Mon Sep 17 00:00:00 2001 From: Andrew de los Reyes Date: Tue, 11 Jul 2023 16:32:23 -0700 Subject: [PATCH 2/3] dirty.S: Add test for ADUE bit --- isa/Makefile | 4 +-- isa/rv64si/dirty.S | 72 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/isa/Makefile b/isa/Makefile index d66b9017a..1d41cc738 100644 --- a/isa/Makefile +++ b/isa/Makefile @@ -50,10 +50,10 @@ vpath %.S $(src_dir) $(RISCV_OBJDUMP) $< > $@ %.out: % - $(RISCV_SIM) --isa=rv64gc_zfh_zicboz_svnapot_zicntr --misaligned $< 2> $@ + $(RISCV_SIM) --isa=rv64gc_zfh_zicboz_svnapot_zicntr_svadu --misaligned $< 2> $@ %.out32: % - $(RISCV_SIM) --isa=rv32gc_zfh_zicboz_svnapot_zicntr --misaligned $< 2> $@ + $(RISCV_SIM) --isa=rv32gc_zfh_zicboz_svnapot_zicntr_svadu --misaligned $< 2> $@ define compile_template diff --git a/isa/rv64si/dirty.S b/isa/rv64si/dirty.S index 15f31632a..c9aba49da 100644 --- a/isa/rv64si/dirty.S +++ b/isa/rv64si/dirty.S @@ -34,8 +34,20 @@ RVTEST_CODE_BEGIN li t2, 1 sw t2, dummy - DRAM_BASE, a0 - # Set SUM=1 so user memory access is permitted li TESTNUM, 3 + # set ADUE to 0 +#if __riscv_xlen == 64 + li a1, MENVCFG_ADUE + csrc menvcfg, a1 +#else + li a1, MENVCFGH_ADUE + csrc menvcfgh, a1 +#endif + + # We do this test twice (as 3 and again as 4). For the second run, + # we'll have toggled ADUE and branch to here: +1: + # Set SUM=1 so user memory access is permitted li a1, ((MSTATUS_MPP & ~(MSTATUS_MPP<<1)) * PRV_S) | MSTATUS_SUM csrs mstatus, a1 @@ -43,7 +55,24 @@ RVTEST_CODE_BEGIN lw t0, dummy - DRAM_BASE bnez t0, die - # Try a non-faulting store to make sure dirty bit is set + # Clear D bit, then do a non-faulting store and ensure D bit is set + # Leave MPRV + li t0, MSTATUS_MPRV + csrc mstatus, t0 + + # Clear D bit + lw t0, page_table_1 + li a0, ~(PTE_D) + and t0, t0, a0 + sw t0, page_table_1, a0 + sfence.vma + + # Enter MPRV again + li t0, MSTATUS_MPRV + csrs mstatus, t0 + + # Now, the non-faulting store + addi t2, t2, 1 sw t2, dummy - DRAM_BASE, a0 # Make sure it succeeded @@ -55,6 +84,7 @@ RVTEST_CODE_BEGIN csrc mstatus, t0 # Make sure D bit is set + sfence.vma lw t0, page_table_1 li a0, PTE_A | PTE_D and t0, t0, a0 @@ -64,8 +94,26 @@ RVTEST_CODE_BEGIN li t0, MSTATUS_MPRV csrs mstatus, t0 + addi TESTNUM, TESTNUM, 1 + li t0, 5 + beq TESTNUM, t0, 1f + + # reset this value: + sw zero, dummy - DRAM_BASE, a0 + + # set ADUE to 1 +#if __riscv_xlen == 64 + li a1, MENVCFG_ADUE + csrs menvcfg, a1 +#else + li a1, MENVCFGH_ADUE + csrs menvcfgh, a1 +#endif + + j 1b +1: # Make sure that superpage entries trap when PPN LSBs are set. - li TESTNUM, 4 + li TESTNUM, 5 lw a0, page_table_1 - DRAM_BASE or a0, a0, 1 << PTE_PPN_SHIFT sw a0, page_table_1 - DRAM_BASE, t0 @@ -97,9 +145,21 @@ skip: mret 1: - li t1, 3 - bne TESTNUM, t1, 1f + li t1, 4 + bgt TESTNUM, t1, 1f # The implementation doesn't appear to set D bits in HW. + # Verify that ADUE is 0. +#if __riscv_xlen == 64 + csrr a1, menvcfg + li t0, MENVCFG_ADUE + and a1, a1, t0 + bnez a1, die +#else + csrr a1, menvcfgh + li t0, MENVCFGH_ADUE + and a1, a1, t0 + bnez a1, die +#endif # Make sure the D bit really is clear. lw t0, page_table_1 and t1, t0, PTE_D @@ -111,7 +171,7 @@ skip: mret 1: - li t1, 4 + li t1, 5 bne TESTNUM, t1, 1f j pass From 670dbba3157ce41e8d2a89a35f9ba7ff9fba52ad Mon Sep 17 00:00:00 2001 From: Andrew de los Reyes Date: Wed, 12 Jul 2023 15:25:37 -0700 Subject: [PATCH 3/3] Disable RISCV_ATTRIBUTES Elf program header This header is causing problems w/ SAIL, so for now just omit it. --- isa/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/isa/Makefile b/isa/Makefile index 1d41cc738..c8cdae520 100644 --- a/isa/Makefile +++ b/isa/Makefile @@ -58,7 +58,7 @@ vpath %.S $(src_dir) define compile_template $$($(1)_p_tests): $(1)-p-%: $(1)/%.S - $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(src_dir)/../env/p -I$(src_dir)/macros/scalar -T$(src_dir)/../env/p/link.ld $$< -o $$@ + $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -Wa,-mno-arch-attr -I$(src_dir)/../env/p -I$(src_dir)/macros/scalar -T$(src_dir)/../env/p/link.ld $$< -o $$@ $(1)_tests += $$($(1)_p_tests) $$($(1)_v_tests): $(1)-v-%: $(1)/%.S