From 737cdd739789f681c172cbc15021882970969f31 Mon Sep 17 00:00:00 2001 From: Melissa Jost Date: Thu, 2 Sep 2021 12:25:25 -0700 Subject: [PATCH] arch-riscv: Fixed a bug in pmp.cc This commit fixes an issue that allowed illegal accesses to the pmpTable to take place. Change-Id: If517d0d9579260a8dd8a8d2e0c673564a649a728 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49870 Reviewed-by: Bobby R. Bruce Reviewed-by: Ayaz Akram Maintainer: Bobby R. Bruce Tested-by: kokoro --- src/arch/riscv/pmp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arch/riscv/pmp.cc b/src/arch/riscv/pmp.cc index dea0744ad3..77ef98f2d0 100644 --- a/src/arch/riscv/pmp.cc +++ b/src/arch/riscv/pmp.cc @@ -92,8 +92,8 @@ PMP::pmpCheck(const RequestPtr &req, BaseMMU::Mode mode, match_index = i; } - if ((PMP_OFF != pmpGetAField(pmpTable[match_index].pmpCfg)) - && (match_index > -1)) { + if ((match_index > -1) + && (PMP_OFF != pmpGetAField(pmpTable[match_index].pmpCfg))) { // check the RWX permissions from the pmp entry uint8_t allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC;