Giacomo Travaglini has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/45187 )

Change subject: arch-arm: Implement ARMv8.1-VMID16, 16-bit VMID
......................................................................

arch-arm: Implement ARMv8.1-VMID16, 16-bit VMID

In an Armv8.1 implementation, when EL2 is using AArch64, the VMID size
is an IMPLEMENTATION DEFINED choice of 8 bits or 16 bits.
When implemented, this feature is supported only when EL2 is using AArch64.
The ID_AA64MMFR1_EL1.VMIDBits field identifies the supported VMID size.

Change-Id: I7acde0a9ba285d4740771133debd60a7a7515954
Signed-off-by: Giacomo Travaglini <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45187
Reviewed-by: Richard Cooper <[email protected]>
Reviewed-by: Andreas Sandberg <[email protected]>
Maintainer: Andreas Sandberg <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/arch/arm/isa.cc
M src/arch/arm/regs/misc_types.hh
M src/arch/arm/tlb.cc
M src/arch/arm/tlb.hh
4 files changed, 39 insertions(+), 4 deletions(-)

Approvals:
  Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
  Richard Cooper: Looks good to me, approved
  Giacomo Travaglini: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/arch/arm/isa.cc b/src/arch/arm/isa.cc
index 80035ae..69a350f 100644
--- a/src/arch/arm/isa.cc
+++ b/src/arch/arm/isa.cc
@@ -2177,6 +2177,7 @@
           case MISCREG_TCR_EL1:
           case MISCREG_TCR_EL2:
           case MISCREG_TCR_EL3:
+          case MISCREG_VTCR_EL2:
           case MISCREG_SCTLR_EL2:
           case MISCREG_SCTLR_EL3:
           case MISCREG_HSCTLR:
diff --git a/src/arch/arm/regs/misc_types.hh b/src/arch/arm/regs/misc_types.hh
index c3fd06e..66b1809 100644
--- a/src/arch/arm/regs/misc_types.hh
+++ b/src/arch/arm/regs/misc_types.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2020 ARM Limited
+ * Copyright (c) 2010-2021 Arm Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -563,6 +563,7 @@
         Bitfield<13, 12> sh0;
         Bitfield<15, 14> tg0;
         Bitfield<18, 16> ps; // Only defined for VTCR_EL2
+        Bitfield<19> vs;     // Only defined for VTCR_EL2
         Bitfield<21> ha;     // Only defined for VTCR_EL2
         Bitfield<22> hd;     // Only defined for VTCR_EL2
     EndBitUnion(VTCR_t)
diff --git a/src/arch/arm/tlb.cc b/src/arch/arm/tlb.cc
index c367d47..a776d76 100644
--- a/src/arch/arm/tlb.cc
+++ b/src/arch/arm/tlb.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2013, 2016-2020 ARM Limited
+ * Copyright (c) 2010-2013, 2016-2021 Arm Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -1373,6 +1373,35 @@
     return &stage2Mmu->getDMAPort();
 }

+vmid_t
+TLB::getVMID(ThreadContext *tc) const
+{
+    AA64MMFR1 mmfr1 = tc->readMiscReg(MISCREG_ID_AA64MMFR1_EL1);
+    VTCR_t vtcr = tc->readMiscReg(MISCREG_VTCR_EL2);
+    vmid_t vmid = 0;
+
+    switch (mmfr1.vmidbits) {
+      case 0b0000:
+        // 8 bits
+        vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), 55, 48);
+        break;
+      case 0b0010:
+        if (vtcr.vs && ELIs64(tc, EL2)) {
+            // 16 bits
+            vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), 63, 48);
+        } else {
+            // 8 bits
+            vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), 55, 48);
+        }
+        break;
+      default:
+        panic("Reserved ID_AA64MMFR1_EL1.VMIDBits value: %#x",
+              mmfr1.vmidbits);
+    }
+
+    return vmid;
+}
+
 void
 TLB::updateMiscReg(ThreadContext *tc, ArmTranslationType tranType)
 {
@@ -1457,7 +1486,7 @@
         scr = tc->readMiscReg(MISCREG_SCR_EL3);
         isPriv = aarch64EL != EL0;
         if (haveVirtualization) {
-            vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), 55, 48);
+            vmid = getVMID(tc);
             isHyp = aarch64EL == EL2;
             isHyp |= tranType & HypMode;
             isHyp &= (tranType & S1S2NsTran) == 0;
diff --git a/src/arch/arm/tlb.hh b/src/arch/arm/tlb.hh
index 3d531b7..8414d43 100644
--- a/src/arch/arm/tlb.hh
+++ b/src/arch/arm/tlb.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2013, 2016, 2019-2020 ARM Limited
+ * Copyright (c) 2010-2013, 2016, 2019-2021 Arm Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -443,6 +443,10 @@
     void updateMiscReg(ThreadContext *tc,
                        ArmTranslationType tranType = NormalTran);

+    /** Returns the current VMID
+     * (information stored in the VTTBR_EL2 register) */
+    vmid_t getVMID(ThreadContext *tc) const;
+
 public:
     void invalidateMiscReg() { miscRegValid = false; }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/45187
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7acde0a9ba285d4740771133debd60a7a7515954
Gerrit-Change-Number: 45187
Gerrit-PatchSet: 4
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Richard Cooper <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to