Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mmap address check test #279

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/scripts/run_regression_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ run_regression_test(){

# Run the test
mkdir -p ${DIR}
make -j`nproc` -C ${DIR} -f $RV_ROOT/tools/Makefile verilator CONF_PARAMS="${PARAMS}" TEST=${NAME} COVERAGE=${COVERAGE} 2>&1 | tee ${LOG}
if [ -z "$COMMON_PARAMS" ]; then
make -j`nproc` -C ${DIR} -f $RV_ROOT/tools/Makefile verilator TEST=${NAME} COVERAGE=${COVERAGE} 2>&1 | tee ${LOG}
else
make -j`nproc` -C ${DIR} -f $RV_ROOT/tools/Makefile verilator CONF_PARAMS+="${PARAMS}" TEST=${NAME} COVERAGE=${COVERAGE} 2>&1 | tee ${LOG}
fi
if [ ! -f "${DIR}/coverage.dat" ]; then
echo -e "${COLOR_WHITE}Test '${NAME}' ${COLOR_RED}FAILED${COLOR_CLEAR}"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
bus: ["axi", "ahb"]
test: ["hello_world", "hello_world_dccm", "hello_world_iccm", "cmark", "cmark_dccm", "cmark_iccm", "dhry", "ecc",
test: ["hello_world", "hello_world_dccm", "hello_world_iccm", "cmark", "cmark_dccm", "cmark_iccm", "dhry", "ecc", "mmap_check",
"csr_misa", "csr_access", "csr_mstatus", "csr_mseccfg", "modesw", "insns", "irq", "perf_counters", "pmp", "write_unaligned"]
coverage: ["all", "branch", "toggle"] #TODO: add functional coverage
priv: ["0", "1"]
Expand Down
2 changes: 2 additions & 0 deletions design/el2_pmp.sv
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ module el2_pmp

// PMP entries are statically prioritized, from 0 to N-1
// The lowest-numbered PMP entry which matches an address determines accessibility
/* verilator lint_off UNSIGNED */
for (int r = 0; r < pt.PMP_ENTRIES; r++) begin
if (!matched && match_all[r]) begin
access_fail = ~final_perm_check[r];
matched = 1'b1;
end
end
/* verilator lint_on UNSIGNED */
return access_fail;
endfunction

Expand Down
33 changes: 33 additions & 0 deletions testbench/tests/mmap_check/mmap_check.mki
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CONF_PARAMS+="-set=pmp_entries=0"

CONF_PARAMS+="-set=data_access_enable0=1"
CONF_PARAMS+="-set=data_access_mask0=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr0=0xd0580000"

CONF_PARAMS+="-set=data_access_enable1=1"
CONF_PARAMS+="-set=data_access_mask1=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr1=0xd0580000"

CONF_PARAMS+="-set=data_access_enable2=1"
CONF_PARAMS+="-set=data_access_mask2=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr2=0xd0580000"

CONF_PARAMS+="-set=data_access_enable3=1"
CONF_PARAMS+="-set=data_access_mask3=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr3=0xd0580000"

CONF_PARAMS+="-set=data_access_enable4=1"
CONF_PARAMS+="-set=data_access_mask4=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr4=0xd0580000"

CONF_PARAMS+="-set=data_access_enable5=1"
CONF_PARAMS+="-set=data_access_mask5=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr5=0xd0580000"

CONF_PARAMS+="-set=data_access_enable6=1"
CONF_PARAMS+="-set=data_access_mask6=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr6=0xd0580000"

CONF_PARAMS+="-set=data_access_enable7=1"
CONF_PARAMS+="-set=data_access_mask7=0x0000ffff"
CONF_PARAMS+="-set=data_access_addr7=0xd0580000"
72 changes: 72 additions & 0 deletions testbench/tests/mmap_check/mmap_check.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2019 Western Digital Corporation or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

// Assembly code for Hello World
// Not using only ALU ops for creating the string


#include "defines.h"

#define STDOUT 0xd0580000


// Code to execute
.section .text
.global _start
_start:

// Clear minstret
csrw minstret, zero
csrw minstreth, zero

// Set trap handler
la x1, _trap
csrw mtvec, x1

// Enable Caches in MRAC
li x1, 0x5f555555
csrw 0x7c0, x1

// Load string from hw_data
// and write to stdout address

li x3, 0x00000001
li x4, 32

loop:
li x5, STDOUT
or x5, x5, x3
lb x5, 0(x5)
slli x3, x3, 1
addi x4, x4, -1
bnez x4, loop
li a0, 0x01 # failure

// Write return value (a0) from printf to STDOUT for TB to termiate test.
_finish:
li x3, STDOUT
sb a0, 0(x3)
beq x0, x0, _finish
.rept 100
nop
.endr

.align 4
_trap:
li a0, 0xff # success
j _finish

.data
2 changes: 1 addition & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ clean:

# If define files do not exist, then run veer.config.
${BUILD_DIR}/defines.h:
BUILD_PATH=${BUILD_DIR} ${RV_ROOT}/configs/veer.config -target=$(target) $(CONF_PARAMS)
BUILD_PATH=${BUILD_DIR} ${VEER_CONFIG} -target=$(target) $(CONF_PARAMS)

verilator-build: ${TBFILES} ${BUILD_DIR}/defines.h $(TB_VERILATOR_SRCS)
$(VERILATOR) --cc -CFLAGS "${CFLAGS}" $(defines) \
Expand Down
Loading