From a84a15ab1701ce708f65d13c68a4e8a1798c752a Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Tue, 18 May 2021 10:43:16 +0100 Subject: [PATCH] arch-arm: Fix FEAT_VMID16 for Self Hosted debug The existing code was querying the vmidbits but it was not checking the VTCR_EL2.VS bit, which dynamically enables/disables VMID16 Signed-off-by: Giacomo Travaglini Change-Id: Id1e7df758a636267173c4fcd4db99e5834f21ee9 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45659 Reviewed-by: Richard Cooper Tested-by: kokoro --- src/arch/arm/self_debug.cc | 16 ++++++++++------ src/arch/arm/self_debug.hh | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/arch/arm/self_debug.cc b/src/arch/arm/self_debug.cc index 5b92fb891d..310ccb47ee 100644 --- a/src/arch/arm/self_debug.cc +++ b/src/arch/arm/self_debug.cc @@ -1,4 +1,5 @@ /* + * Copyright (c) 2021 Arm Limited * Copyright (c) 2019 Metempsy Technology LSC * All rights reserved * @@ -452,15 +453,18 @@ BrkPoint::testContextMatch(ThreadContext *tc, bool ctx1, bool low_ctx) bool BrkPoint::testVMIDMatch(ThreadContext *tc) { + const bool vs = ((VTCR_t)(tc->readMiscReg(MISCREG_VTCR_EL2))).vs; + uint32_t vmid_index = 55; - if (VMID16enabled) + if (VMID16enabled && vs) vmid_index = 63; ExceptionLevel el = currEL(tc); if (el == EL2) return false; - uint32_t vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), vmid_index, 48); - uint32_t v = getVMIDfromReg(tc); + vmid_t vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), vmid_index, 48); + vmid_t v = getVMIDfromReg(tc, vs); + return (v == vmid); } @@ -520,11 +524,11 @@ BrkPoint::isEnabled(ThreadContext *tc, ExceptionLevel el, return v && SelfDebug::securityStateMatch(tc, ssc, hmc || !aarch32); } -uint32_t -BrkPoint::getVMIDfromReg(ThreadContext *tc) +vmid_t +BrkPoint::getVMIDfromReg(ThreadContext *tc, bool vs) { uint32_t vmid_index = 39; - if (VMID16enabled) + if (VMID16enabled && vs) vmid_index = 47; return bits(tc->readMiscReg(valRegIndex), vmid_index, 32); } diff --git a/src/arch/arm/self_debug.hh b/src/arch/arm/self_debug.hh index 55e74a74b5..d1db5cc55a 100644 --- a/src/arch/arm/self_debug.hh +++ b/src/arch/arm/self_debug.hh @@ -1,4 +1,5 @@ /* + * Copyright (c) 2021 Arm Limited * Copyright (c) 2019 Metempsy Technology LSC * All rights reserved * @@ -103,7 +104,7 @@ class BrkPoint } - inline uint32_t getVMIDfromReg(ThreadContext *tc); + vmid_t getVMIDfromReg(ThreadContext *tc, bool vs); public: bool testAddrMatch(ThreadContext *tc, Addr pc, uint8_t bas);