diff options
author | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2019-07-29 12:38:12 +0100 |
---|---|---|
committer | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2019-08-05 15:50:57 +0000 |
commit | 361bc8b47260a55902764054d3ac25694ac93f8a (patch) | |
tree | e6929b787500aa227333b4fe90fc4047838ef8c0 /src/arch/arm/isa.cc | |
parent | fd1a8bed393a2ef48d584fcabeee4d98eda0e3fa (diff) | |
download | gem5-361bc8b47260a55902764054d3ac25694ac93f8a.tar.xz |
arch-arm: Implement ARMv8.1-PAN, Privileged access never
ARMv8.1-PAN adds a new bit to PSTATE. When the value of this PAN state
bit is 1, any privileged data access from EL1 or EL2 to a virtual memory
address that is accessible at EL0 generates a Permission fault.
This feature is mandatory in ARMv8.1 implementations.
This feature is supported in AArch64 and AArch32 states.
The ID_AA64MMFR1_EL1.PAN, ID_MMFR3_EL1.PAN, and ID_MMFR3.PAN fields
identify the support for ARMv8.1-PAN.
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Change-Id: I94a76311711739dd2394c72944d88ba9321fd159
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19729
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/arch/arm/isa.cc')
-rw-r--r-- | src/arch/arm/isa.cc | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/arch/arm/isa.cc b/src/arch/arm/isa.cc index cdc44cdb9..23738c6ae 100644 --- a/src/arch/arm/isa.cc +++ b/src/arch/arm/isa.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 ARM Limited + * Copyright (c) 2010-2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -91,6 +91,7 @@ ISA::ISA(Params *p) haveLargeAsid64 = system->haveLargeAsid64(); physAddrRange = system->physAddrRange(); haveSVE = system->haveSVE(); + havePAN = system->havePAN(); sveVL = system->sveVL(); } else { highestELIs64 = true; // ArmSystem::highestELIs64 does the same @@ -99,6 +100,7 @@ ISA::ISA(Params *p) haveLargeAsid64 = false; physAddrRange = 32; // dummy value haveSVE = true; + havePAN = false; sveVL = p->sve_vl_se; } @@ -391,6 +393,10 @@ ISA::initID64(const ArmISAParams *p) miscRegs[MISCREG_ID_AA64ISAR0_EL1] = insertBits( miscRegs[MISCREG_ID_AA64ISAR0_EL1], 19, 4, haveCrypto ? 0x1112 : 0x0); + // PAN + miscRegs[MISCREG_ID_AA64MMFR1_EL1] = insertBits( + miscRegs[MISCREG_ID_AA64MMFR1_EL1], 23, 20, + havePAN ? 0x1 : 0x0); } void @@ -640,6 +646,10 @@ ISA::readMiscReg(int misc_reg, ThreadContext *tc) { return miscRegs[MISCREG_CPSR] & 0xc; } + case MISCREG_PAN: + { + return miscRegs[MISCREG_CPSR] & 0x400000; + } case MISCREG_L2CTLR: { // mostly unimplemented, just set NumCPUs field from sim and return @@ -1880,6 +1890,17 @@ ISA::setMiscReg(int misc_reg, RegVal val, ThreadContext *tc) misc_reg = MISCREG_CPSR; } break; + case MISCREG_PAN: + { + // PAN is affecting data accesses + getDTBPtr(tc)->invalidateMiscReg(); + + CPSR cpsr = miscRegs[MISCREG_CPSR]; + cpsr.pan = (uint8_t) ((CPSR) newVal).pan; + newVal = cpsr; + misc_reg = MISCREG_CPSR; + } + break; case MISCREG_AT_S1E1R_Xt: case MISCREG_AT_S1E1W_Xt: case MISCREG_AT_S1E0R_Xt: @@ -2020,9 +2041,13 @@ ISA::setMiscReg(int misc_reg, RegVal val, ThreadContext *tc) case MISCREG_SPSR_EL3: case MISCREG_SPSR_EL2: case MISCREG_SPSR_EL1: - // Force bits 23:21 to 0 - newVal = val & ~(0x7 << 21); - break; + { + RegVal spsr_mask = havePAN ? + ~(0x5 << 21) : ~(0x7 << 21); + + newVal = val & spsr_mask; + break; + } case MISCREG_L2CTLR: warn("miscreg L2CTLR (%s) written with %#x. ignored...\n", miscRegName[misc_reg], uint32_t(val)); |