From 64d981681c354aaf444cd08f8dc33cbd6fdab1af Mon Sep 17 00:00:00 2001 From: Phanikiran Harithas Date: Sun, 10 Jun 2018 16:11:41 +0530 Subject: [PATCH] power: Add support for real-mode addressing (translation is off) This patch adds support for executing programs which don't have the translation support (MSR[IR, DR] = 0). With this change, we should be able to run 64 little endian elf binaries executing previleged instructions with translation off. Change-Id: Iaa64a37676874cee1ed1a0591b51b5e842774b45 Signed-off-by: Phanikiran Harithas Signed-off-by: Venkatnarayan Kulkarni --- src/arch/power/isa.cc | 16 ++++++++++++++++ src/arch/power/isa.hh | 24 +++++++++--------------- src/arch/power/tlb.cc | 38 +++++++++++++++++++++++++++++++++----- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/src/arch/power/isa.cc b/src/arch/power/isa.cc index 87eb71674..8d0942e9f 100644 --- a/src/arch/power/isa.cc +++ b/src/arch/power/isa.cc @@ -37,6 +37,8 @@ #include "arch/power/isa.hh" +#include "arch/power/miscregs.hh" +#include "cpu/base.hh" #include "params/PowerISA.hh" namespace PowerISA @@ -53,6 +55,20 @@ ISA::params() const return dynamic_cast(_params); } +MiscReg +ISA::readMiscRegNoEffect(int misc_reg) const +{ + assert(isValidMiscReg(misc_reg)); + return regVal[misc_reg]; +} + +void +ISA::setMiscRegNoEffect(int misc_reg, const MiscReg &val) +{ + assert(isValidMiscReg(misc_reg)); + regVal[misc_reg] = val; +} + } PowerISA::ISA * diff --git a/src/arch/power/isa.hh b/src/arch/power/isa.hh index a0d4a4660..d48f2b139 100644 --- a/src/arch/power/isa.hh +++ b/src/arch/power/isa.hh @@ -31,6 +31,7 @@ #define __ARCH_POWER_ISA_HH__ #include "arch/generic/isa.hh" +#include "arch/power/miscregs.hh" #include "arch/power/registers.hh" #include "arch/power/types.hh" #include "base/logging.hh" @@ -48,22 +49,19 @@ namespace PowerISA class ISA : public BaseISA { protected: - RegVal dummy; - RegVal miscRegs[NumMiscRegs]; + MiscReg regVal[NumMiscRegs]; + MiscReg dummy; public: typedef PowerISAParams Params; - - void clear() {} - - public: - RegVal - readMiscRegNoEffect(int misc_reg) const + void + clear() { - fatal("Power does not currently have any misc regs defined\n"); - return dummy; + memset(regVal, 0, NumMiscRegs * sizeof(MiscReg)); } + MiscReg readMiscRegNoEffect(int misc_reg) const; + RegVal readMiscReg(int misc_reg) { @@ -71,11 +69,7 @@ class ISA : public BaseISA return dummy; } - void - setMiscRegNoEffect(int misc_reg, RegVal val) - { - fatal("Power does not currently have any misc regs defined\n"); - } + void setMiscRegNoEffect(int misc_reg, const MiscReg &val); void setMiscReg(int misc_reg, RegVal val) diff --git a/src/arch/power/tlb.cc b/src/arch/power/tlb.cc index 2726ca341..5162764ca 100644 --- a/src/arch/power/tlb.cc +++ b/src/arch/power/tlb.cc @@ -35,7 +35,9 @@ #include #include "arch/power/faults.hh" +#include "arch/power/miscregs.hh" #include "arch/power/pagetable.hh" +#include "arch/power/registers.hh" #include "arch/power/utility.hh" #include "base/inifile.hh" #include "base/str.hh" @@ -237,13 +239,39 @@ TLB::translateData(const RequestPtr &req, ThreadContext *tc, bool write) Fault TLB::translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) { - panic_if(FullSystem, - "translateAtomic not yet implemented for full system."); - + if (FullSystem){ + Msr msr = tc->readIntReg(MISCREG_MSR); + if (mode == Execute){ + if (msr.ir) + fatal("Translate Atomic not Implemented for POWER"); + else{ + Addr vaddr = req->getVaddr(); + DPRINTF(TLB, "Translating vaddr %#x.\n", vaddr); + Addr paddr = vaddr; + DPRINTF(TLB, "Translated %#x -> %#x.\n", vaddr, paddr); + req->setPaddr(paddr); + return NoFault; + } + } + else{ + if (msr.dr) + fatal("Translate Atomic not Implemented for POWER"); + else{ + Addr vaddr = req->getVaddr(); + DPRINTF(TLB, "Translating vaddr %#x.\n", vaddr); + Addr paddr = vaddr; + DPRINTF(TLB, "Translated %#x -> %#x.\n", vaddr, paddr); + req->setPaddr(paddr); + return NoFault; + } + } + } if (mode == Execute) - return translateInst(req, tc); - else + return translateInst(req, tc); + else{ + std::cout<<"translateData"<