isa.cc revision 13114
16313Sgblack@eecs.umich.edu/* 26313Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan 36313Sgblack@eecs.umich.edu * All rights reserved. 46313Sgblack@eecs.umich.edu * 56313Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 66313Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 76313Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 86313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 96313Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 106313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 116313Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 126313Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 136313Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 146313Sgblack@eecs.umich.edu * this software without specific prior written permission. 156313Sgblack@eecs.umich.edu * 166313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276313Sgblack@eecs.umich.edu * 286313Sgblack@eecs.umich.edu * Authors: Gabe Black 296313Sgblack@eecs.umich.edu */ 306313Sgblack@eecs.umich.edu 3111793Sbrandon.potter@amd.com#include "arch/x86/isa.hh" 3211793Sbrandon.potter@amd.com 339376Sgblack@eecs.umich.edu#include "arch/x86/decoder.hh" 346336Sgblack@eecs.umich.edu#include "arch/x86/tlb.hh" 356336Sgblack@eecs.umich.edu#include "cpu/base.hh" 366313Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 379384SAndreas.Sandberg@arm.com#include "params/X86ISA.hh" 386336Sgblack@eecs.umich.edu#include "sim/serialize.hh" 396313Sgblack@eecs.umich.edu 406313Sgblack@eecs.umich.edunamespace X86ISA 416313Sgblack@eecs.umich.edu{ 426313Sgblack@eecs.umich.edu 436313Sgblack@eecs.umich.eduvoid 446336Sgblack@eecs.umich.eduISA::updateHandyM5Reg(Efer efer, CR0 cr0, 459376Sgblack@eecs.umich.edu SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags, 469376Sgblack@eecs.umich.edu ThreadContext *tc) 476336Sgblack@eecs.umich.edu{ 486712Snate@binkert.org HandyM5Reg m5reg = 0; 496336Sgblack@eecs.umich.edu if (efer.lma) { 506336Sgblack@eecs.umich.edu m5reg.mode = LongMode; 516336Sgblack@eecs.umich.edu if (csAttr.longMode) 526336Sgblack@eecs.umich.edu m5reg.submode = SixtyFourBitMode; 536336Sgblack@eecs.umich.edu else 546336Sgblack@eecs.umich.edu m5reg.submode = CompatabilityMode; 556336Sgblack@eecs.umich.edu } else { 566336Sgblack@eecs.umich.edu m5reg.mode = LegacyMode; 576336Sgblack@eecs.umich.edu if (cr0.pe) { 586336Sgblack@eecs.umich.edu if (rflags.vm) 596336Sgblack@eecs.umich.edu m5reg.submode = Virtual8086Mode; 606336Sgblack@eecs.umich.edu else 616336Sgblack@eecs.umich.edu m5reg.submode = ProtectedMode; 626336Sgblack@eecs.umich.edu } else { 636336Sgblack@eecs.umich.edu m5reg.submode = RealMode; 646336Sgblack@eecs.umich.edu } 656336Sgblack@eecs.umich.edu } 666336Sgblack@eecs.umich.edu m5reg.cpl = csAttr.dpl; 676336Sgblack@eecs.umich.edu m5reg.paging = cr0.pg; 686336Sgblack@eecs.umich.edu m5reg.prot = cr0.pe; 696336Sgblack@eecs.umich.edu 706336Sgblack@eecs.umich.edu // Compute the default and alternate operand size. 716336Sgblack@eecs.umich.edu if (m5reg.submode == SixtyFourBitMode || csAttr.defaultSize) { 726336Sgblack@eecs.umich.edu m5reg.defOp = 2; 736336Sgblack@eecs.umich.edu m5reg.altOp = 1; 746336Sgblack@eecs.umich.edu } else { 756336Sgblack@eecs.umich.edu m5reg.defOp = 1; 766336Sgblack@eecs.umich.edu m5reg.altOp = 2; 776336Sgblack@eecs.umich.edu } 786336Sgblack@eecs.umich.edu 796336Sgblack@eecs.umich.edu // Compute the default and alternate address size. 806336Sgblack@eecs.umich.edu if (m5reg.submode == SixtyFourBitMode) { 816336Sgblack@eecs.umich.edu m5reg.defAddr = 3; 826336Sgblack@eecs.umich.edu m5reg.altAddr = 2; 836336Sgblack@eecs.umich.edu } else if (csAttr.defaultSize) { 846336Sgblack@eecs.umich.edu m5reg.defAddr = 2; 856336Sgblack@eecs.umich.edu m5reg.altAddr = 1; 866336Sgblack@eecs.umich.edu } else { 876336Sgblack@eecs.umich.edu m5reg.defAddr = 1; 886336Sgblack@eecs.umich.edu m5reg.altAddr = 2; 896336Sgblack@eecs.umich.edu } 906336Sgblack@eecs.umich.edu 916336Sgblack@eecs.umich.edu // Compute the stack size 926336Sgblack@eecs.umich.edu if (m5reg.submode == SixtyFourBitMode) { 936336Sgblack@eecs.umich.edu m5reg.stack = 3; 946336Sgblack@eecs.umich.edu } else if (ssAttr.defaultSize) { 956336Sgblack@eecs.umich.edu m5reg.stack = 2; 966336Sgblack@eecs.umich.edu } else { 976336Sgblack@eecs.umich.edu m5reg.stack = 1; 986336Sgblack@eecs.umich.edu } 996336Sgblack@eecs.umich.edu 1006336Sgblack@eecs.umich.edu regVal[MISCREG_M5_REG] = m5reg; 1019376Sgblack@eecs.umich.edu if (tc) 1029376Sgblack@eecs.umich.edu tc->getDecoderPtr()->setM5Reg(m5reg); 1036336Sgblack@eecs.umich.edu} 1046336Sgblack@eecs.umich.edu 1056336Sgblack@eecs.umich.eduvoid 1066313Sgblack@eecs.umich.eduISA::clear() 1076313Sgblack@eecs.umich.edu{ 1086336Sgblack@eecs.umich.edu // Blank everything. 0 might not be an appropriate value for some things, 1096336Sgblack@eecs.umich.edu // but it is for most. 1106336Sgblack@eecs.umich.edu memset(regVal, 0, NumMiscRegs * sizeof(MiscReg)); 1116336Sgblack@eecs.umich.edu regVal[MISCREG_DR6] = (mask(8) << 4) | (mask(16) << 16); 1126336Sgblack@eecs.umich.edu regVal[MISCREG_DR7] = 1 << 10; 1136313Sgblack@eecs.umich.edu} 1146313Sgblack@eecs.umich.edu 1159384SAndreas.Sandberg@arm.comISA::ISA(Params *p) 1169384SAndreas.Sandberg@arm.com : SimObject(p) 1179384SAndreas.Sandberg@arm.com{ 1189384SAndreas.Sandberg@arm.com clear(); 1199384SAndreas.Sandberg@arm.com} 1209384SAndreas.Sandberg@arm.com 1219384SAndreas.Sandberg@arm.comconst X86ISAParams * 1229384SAndreas.Sandberg@arm.comISA::params() const 1239384SAndreas.Sandberg@arm.com{ 1249384SAndreas.Sandberg@arm.com return dynamic_cast<const Params *>(_params); 1259384SAndreas.Sandberg@arm.com} 1269384SAndreas.Sandberg@arm.com 1276313Sgblack@eecs.umich.eduMiscReg 12810698Sandreas.hansson@arm.comISA::readMiscRegNoEffect(int miscReg) const 1296313Sgblack@eecs.umich.edu{ 1306336Sgblack@eecs.umich.edu // Make sure we're not dealing with an illegal control register. 1316336Sgblack@eecs.umich.edu // Instructions should filter out these indexes, and nothing else should 1326336Sgblack@eecs.umich.edu // attempt to read them directly. 13311324Ssteve.reinhardt@amd.com assert(isValidMiscReg(miscReg)); 1346336Sgblack@eecs.umich.edu 1356336Sgblack@eecs.umich.edu return regVal[miscReg]; 1366313Sgblack@eecs.umich.edu} 1376313Sgblack@eecs.umich.edu 1386313Sgblack@eecs.umich.eduMiscReg 1396336Sgblack@eecs.umich.eduISA::readMiscReg(int miscReg, ThreadContext * tc) 1406313Sgblack@eecs.umich.edu{ 1416336Sgblack@eecs.umich.edu if (miscReg == MISCREG_TSC) { 1426336Sgblack@eecs.umich.edu return regVal[MISCREG_TSC] + tc->getCpuPtr()->curCycle(); 1436336Sgblack@eecs.umich.edu } 1449372Snilay@cs.wisc.edu 1459372Snilay@cs.wisc.edu if (miscReg == MISCREG_FSW) { 1469372Snilay@cs.wisc.edu MiscReg fsw = regVal[MISCREG_FSW]; 1479372Snilay@cs.wisc.edu MiscReg top = regVal[MISCREG_X87_TOP]; 14812692Smattdsinclair@gmail.com return insertBits(fsw, 13, 11, top); 1499372Snilay@cs.wisc.edu } 1509372Snilay@cs.wisc.edu 1516336Sgblack@eecs.umich.edu return readMiscRegNoEffect(miscReg); 1526313Sgblack@eecs.umich.edu} 1536313Sgblack@eecs.umich.edu 1546313Sgblack@eecs.umich.eduvoid 1556336Sgblack@eecs.umich.eduISA::setMiscRegNoEffect(int miscReg, MiscReg val) 1566313Sgblack@eecs.umich.edu{ 1576336Sgblack@eecs.umich.edu // Make sure we're not dealing with an illegal control register. 1586336Sgblack@eecs.umich.edu // Instructions should filter out these indexes, and nothing else should 1596336Sgblack@eecs.umich.edu // attempt to write to them directly. 16011324Ssteve.reinhardt@amd.com assert(isValidMiscReg(miscReg)); 16110899Snikos.nikoleris@gmail.com 16212368Sgabeblack@google.com HandyM5Reg m5Reg = regVal[MISCREG_M5_REG]; 16312368Sgabeblack@google.com int reg_width = 64; 16410899Snikos.nikoleris@gmail.com switch (miscReg) { 16510899Snikos.nikoleris@gmail.com case MISCREG_X87_TOP: 16612368Sgabeblack@google.com reg_width = 3; 16710899Snikos.nikoleris@gmail.com break; 16810899Snikos.nikoleris@gmail.com case MISCREG_FTW: 16912368Sgabeblack@google.com reg_width = 8; 17010899Snikos.nikoleris@gmail.com break; 17112368Sgabeblack@google.com case MISCREG_FSW: 17210899Snikos.nikoleris@gmail.com case MISCREG_FCW: 17310899Snikos.nikoleris@gmail.com case MISCREG_FOP: 17412368Sgabeblack@google.com reg_width = 16; 17510899Snikos.nikoleris@gmail.com break; 17610899Snikos.nikoleris@gmail.com case MISCREG_MXCSR: 17712368Sgabeblack@google.com reg_width = 32; 17810899Snikos.nikoleris@gmail.com break; 17910899Snikos.nikoleris@gmail.com case MISCREG_FISEG: 18010899Snikos.nikoleris@gmail.com case MISCREG_FOSEG: 18110899Snikos.nikoleris@gmail.com if (m5Reg.submode != SixtyFourBitMode) 18212368Sgabeblack@google.com reg_width = 16; 18310899Snikos.nikoleris@gmail.com break; 18410899Snikos.nikoleris@gmail.com case MISCREG_FIOFF: 18510899Snikos.nikoleris@gmail.com case MISCREG_FOOFF: 18610899Snikos.nikoleris@gmail.com if (m5Reg.submode != SixtyFourBitMode) 18712368Sgabeblack@google.com reg_width = 32; 18810899Snikos.nikoleris@gmail.com break; 18910899Snikos.nikoleris@gmail.com default: 19010899Snikos.nikoleris@gmail.com break; 19110899Snikos.nikoleris@gmail.com } 19210899Snikos.nikoleris@gmail.com 19312368Sgabeblack@google.com regVal[miscReg] = val & mask(reg_width); 1946313Sgblack@eecs.umich.edu} 1956313Sgblack@eecs.umich.edu 1966313Sgblack@eecs.umich.eduvoid 1976336Sgblack@eecs.umich.eduISA::setMiscReg(int miscReg, MiscReg val, ThreadContext * tc) 1986313Sgblack@eecs.umich.edu{ 1996336Sgblack@eecs.umich.edu MiscReg newVal = val; 2006336Sgblack@eecs.umich.edu switch(miscReg) 2016336Sgblack@eecs.umich.edu { 2026336Sgblack@eecs.umich.edu case MISCREG_CR0: 2036336Sgblack@eecs.umich.edu { 2046336Sgblack@eecs.umich.edu CR0 toggled = regVal[miscReg] ^ val; 2056336Sgblack@eecs.umich.edu CR0 newCR0 = val; 2066336Sgblack@eecs.umich.edu Efer efer = regVal[MISCREG_EFER]; 2076336Sgblack@eecs.umich.edu if (toggled.pg && efer.lme) { 2086336Sgblack@eecs.umich.edu if (newCR0.pg) { 2096336Sgblack@eecs.umich.edu //Turning on long mode 2106336Sgblack@eecs.umich.edu efer.lma = 1; 2116336Sgblack@eecs.umich.edu regVal[MISCREG_EFER] = efer; 2126336Sgblack@eecs.umich.edu } else { 2136336Sgblack@eecs.umich.edu //Turning off long mode 2146336Sgblack@eecs.umich.edu efer.lma = 0; 2156336Sgblack@eecs.umich.edu regVal[MISCREG_EFER] = efer; 2166336Sgblack@eecs.umich.edu } 2176336Sgblack@eecs.umich.edu } 2186336Sgblack@eecs.umich.edu if (toggled.pg) { 21912406Sgabeblack@google.com dynamic_cast<TLB *>(tc->getITBPtr())->flushAll(); 22012406Sgabeblack@google.com dynamic_cast<TLB *>(tc->getDTBPtr())->flushAll(); 2216336Sgblack@eecs.umich.edu } 2226336Sgblack@eecs.umich.edu //This must always be 1. 2236336Sgblack@eecs.umich.edu newCR0.et = 1; 2246336Sgblack@eecs.umich.edu newVal = newCR0; 2256336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2266336Sgblack@eecs.umich.edu newCR0, 2276336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 2286336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 2299376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2309376Sgblack@eecs.umich.edu tc); 2316336Sgblack@eecs.umich.edu } 2326336Sgblack@eecs.umich.edu break; 2336336Sgblack@eecs.umich.edu case MISCREG_CR2: 2346336Sgblack@eecs.umich.edu break; 2356336Sgblack@eecs.umich.edu case MISCREG_CR3: 23612406Sgabeblack@google.com dynamic_cast<TLB *>(tc->getITBPtr())->flushNonGlobal(); 23712406Sgabeblack@google.com dynamic_cast<TLB *>(tc->getDTBPtr())->flushNonGlobal(); 2386336Sgblack@eecs.umich.edu break; 2396336Sgblack@eecs.umich.edu case MISCREG_CR4: 2406336Sgblack@eecs.umich.edu { 2416336Sgblack@eecs.umich.edu CR4 toggled = regVal[miscReg] ^ val; 2426336Sgblack@eecs.umich.edu if (toggled.pae || toggled.pse || toggled.pge) { 24312406Sgabeblack@google.com dynamic_cast<TLB *>(tc->getITBPtr())->flushAll(); 24412406Sgabeblack@google.com dynamic_cast<TLB *>(tc->getDTBPtr())->flushAll(); 2456336Sgblack@eecs.umich.edu } 2466336Sgblack@eecs.umich.edu } 2476336Sgblack@eecs.umich.edu break; 2486336Sgblack@eecs.umich.edu case MISCREG_CR8: 2496336Sgblack@eecs.umich.edu break; 2506336Sgblack@eecs.umich.edu case MISCREG_CS_ATTR: 2516336Sgblack@eecs.umich.edu { 2526336Sgblack@eecs.umich.edu SegAttr toggled = regVal[miscReg] ^ val; 2536336Sgblack@eecs.umich.edu SegAttr newCSAttr = val; 2546336Sgblack@eecs.umich.edu if (toggled.longMode) { 2556336Sgblack@eecs.umich.edu if (newCSAttr.longMode) { 2566336Sgblack@eecs.umich.edu regVal[MISCREG_ES_EFF_BASE] = 0; 2576336Sgblack@eecs.umich.edu regVal[MISCREG_CS_EFF_BASE] = 0; 2586336Sgblack@eecs.umich.edu regVal[MISCREG_SS_EFF_BASE] = 0; 2596336Sgblack@eecs.umich.edu regVal[MISCREG_DS_EFF_BASE] = 0; 2606336Sgblack@eecs.umich.edu } else { 2616336Sgblack@eecs.umich.edu regVal[MISCREG_ES_EFF_BASE] = regVal[MISCREG_ES_BASE]; 2626336Sgblack@eecs.umich.edu regVal[MISCREG_CS_EFF_BASE] = regVal[MISCREG_CS_BASE]; 2636336Sgblack@eecs.umich.edu regVal[MISCREG_SS_EFF_BASE] = regVal[MISCREG_SS_BASE]; 2646336Sgblack@eecs.umich.edu regVal[MISCREG_DS_EFF_BASE] = regVal[MISCREG_DS_BASE]; 2656336Sgblack@eecs.umich.edu } 2666336Sgblack@eecs.umich.edu } 2676336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2686336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 2696336Sgblack@eecs.umich.edu newCSAttr, 2706336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 2719376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2729376Sgblack@eecs.umich.edu tc); 2736336Sgblack@eecs.umich.edu } 2746336Sgblack@eecs.umich.edu break; 2756336Sgblack@eecs.umich.edu case MISCREG_SS_ATTR: 2766336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2776336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 2786336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 2796336Sgblack@eecs.umich.edu val, 2809376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2819376Sgblack@eecs.umich.edu tc); 2826336Sgblack@eecs.umich.edu break; 2836336Sgblack@eecs.umich.edu // These segments always actually use their bases, or in other words 2846336Sgblack@eecs.umich.edu // their effective bases must stay equal to their actual bases. 2856336Sgblack@eecs.umich.edu case MISCREG_FS_BASE: 2866336Sgblack@eecs.umich.edu case MISCREG_GS_BASE: 2876336Sgblack@eecs.umich.edu case MISCREG_HS_BASE: 2886336Sgblack@eecs.umich.edu case MISCREG_TSL_BASE: 2896336Sgblack@eecs.umich.edu case MISCREG_TSG_BASE: 2906336Sgblack@eecs.umich.edu case MISCREG_TR_BASE: 2916336Sgblack@eecs.umich.edu case MISCREG_IDTR_BASE: 2926336Sgblack@eecs.umich.edu regVal[MISCREG_SEG_EFF_BASE(miscReg - MISCREG_SEG_BASE_BASE)] = val; 2936336Sgblack@eecs.umich.edu break; 2946336Sgblack@eecs.umich.edu // These segments ignore their bases in 64 bit mode. 2956336Sgblack@eecs.umich.edu // their effective bases must stay equal to their actual bases. 2966336Sgblack@eecs.umich.edu case MISCREG_ES_BASE: 2976336Sgblack@eecs.umich.edu case MISCREG_CS_BASE: 2986336Sgblack@eecs.umich.edu case MISCREG_SS_BASE: 2996336Sgblack@eecs.umich.edu case MISCREG_DS_BASE: 3006336Sgblack@eecs.umich.edu { 3016336Sgblack@eecs.umich.edu Efer efer = regVal[MISCREG_EFER]; 3026336Sgblack@eecs.umich.edu SegAttr csAttr = regVal[MISCREG_CS_ATTR]; 3036336Sgblack@eecs.umich.edu if (!efer.lma || !csAttr.longMode) // Check for non 64 bit mode. 3046336Sgblack@eecs.umich.edu regVal[MISCREG_SEG_EFF_BASE(miscReg - 3056336Sgblack@eecs.umich.edu MISCREG_SEG_BASE_BASE)] = val; 3066336Sgblack@eecs.umich.edu } 3076336Sgblack@eecs.umich.edu break; 3086336Sgblack@eecs.umich.edu case MISCREG_TSC: 3096336Sgblack@eecs.umich.edu regVal[MISCREG_TSC] = val - tc->getCpuPtr()->curCycle(); 3106336Sgblack@eecs.umich.edu return; 3116336Sgblack@eecs.umich.edu case MISCREG_DR0: 3126336Sgblack@eecs.umich.edu case MISCREG_DR1: 3136336Sgblack@eecs.umich.edu case MISCREG_DR2: 3146336Sgblack@eecs.umich.edu case MISCREG_DR3: 3156336Sgblack@eecs.umich.edu /* These should eventually set up breakpoints. */ 3166336Sgblack@eecs.umich.edu break; 3176336Sgblack@eecs.umich.edu case MISCREG_DR4: 3186336Sgblack@eecs.umich.edu miscReg = MISCREG_DR6; 31912392Sjason@lowepower.com M5_FALLTHROUGH; 3206336Sgblack@eecs.umich.edu case MISCREG_DR6: 3216336Sgblack@eecs.umich.edu { 3226336Sgblack@eecs.umich.edu DR6 dr6 = regVal[MISCREG_DR6]; 3236336Sgblack@eecs.umich.edu DR6 newDR6 = val; 3246336Sgblack@eecs.umich.edu dr6.b0 = newDR6.b0; 3256336Sgblack@eecs.umich.edu dr6.b1 = newDR6.b1; 3266336Sgblack@eecs.umich.edu dr6.b2 = newDR6.b2; 3276336Sgblack@eecs.umich.edu dr6.b3 = newDR6.b3; 3286336Sgblack@eecs.umich.edu dr6.bd = newDR6.bd; 3296336Sgblack@eecs.umich.edu dr6.bs = newDR6.bs; 3306336Sgblack@eecs.umich.edu dr6.bt = newDR6.bt; 3316336Sgblack@eecs.umich.edu newVal = dr6; 3326336Sgblack@eecs.umich.edu } 3336336Sgblack@eecs.umich.edu break; 3346336Sgblack@eecs.umich.edu case MISCREG_DR5: 3356336Sgblack@eecs.umich.edu miscReg = MISCREG_DR7; 33612392Sjason@lowepower.com M5_FALLTHROUGH; 3376336Sgblack@eecs.umich.edu case MISCREG_DR7: 3386336Sgblack@eecs.umich.edu { 3396336Sgblack@eecs.umich.edu DR7 dr7 = regVal[MISCREG_DR7]; 3406336Sgblack@eecs.umich.edu DR7 newDR7 = val; 3416336Sgblack@eecs.umich.edu dr7.l0 = newDR7.l0; 3426336Sgblack@eecs.umich.edu dr7.g0 = newDR7.g0; 3436336Sgblack@eecs.umich.edu if (dr7.l0 || dr7.g0) { 3446336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3456336Sgblack@eecs.umich.edu } else { 3466336Sgblack@eecs.umich.edu /* Disable breakpoint 0. */ 3476336Sgblack@eecs.umich.edu } 3486336Sgblack@eecs.umich.edu dr7.l1 = newDR7.l1; 3496336Sgblack@eecs.umich.edu dr7.g1 = newDR7.g1; 3506336Sgblack@eecs.umich.edu if (dr7.l1 || dr7.g1) { 3516336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3526336Sgblack@eecs.umich.edu } else { 3536336Sgblack@eecs.umich.edu /* Disable breakpoint 1. */ 3546336Sgblack@eecs.umich.edu } 3556336Sgblack@eecs.umich.edu dr7.l2 = newDR7.l2; 3566336Sgblack@eecs.umich.edu dr7.g2 = newDR7.g2; 3576336Sgblack@eecs.umich.edu if (dr7.l2 || dr7.g2) { 3586336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3596336Sgblack@eecs.umich.edu } else { 3606336Sgblack@eecs.umich.edu /* Disable breakpoint 2. */ 3616336Sgblack@eecs.umich.edu } 3626336Sgblack@eecs.umich.edu dr7.l3 = newDR7.l3; 3636336Sgblack@eecs.umich.edu dr7.g3 = newDR7.g3; 3646336Sgblack@eecs.umich.edu if (dr7.l3 || dr7.g3) { 3656336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3666336Sgblack@eecs.umich.edu } else { 3676336Sgblack@eecs.umich.edu /* Disable breakpoint 3. */ 3686336Sgblack@eecs.umich.edu } 3696336Sgblack@eecs.umich.edu dr7.gd = newDR7.gd; 3706336Sgblack@eecs.umich.edu dr7.rw0 = newDR7.rw0; 3716336Sgblack@eecs.umich.edu dr7.len0 = newDR7.len0; 3726336Sgblack@eecs.umich.edu dr7.rw1 = newDR7.rw1; 3736336Sgblack@eecs.umich.edu dr7.len1 = newDR7.len1; 3746336Sgblack@eecs.umich.edu dr7.rw2 = newDR7.rw2; 3756336Sgblack@eecs.umich.edu dr7.len2 = newDR7.len2; 3766336Sgblack@eecs.umich.edu dr7.rw3 = newDR7.rw3; 3776336Sgblack@eecs.umich.edu dr7.len3 = newDR7.len3; 3786336Sgblack@eecs.umich.edu } 3796336Sgblack@eecs.umich.edu break; 3806336Sgblack@eecs.umich.edu case MISCREG_M5_REG: 3816336Sgblack@eecs.umich.edu // Writing anything to the m5reg with side effects makes it update 3826336Sgblack@eecs.umich.edu // based on the current values of the relevant registers. The actual 3836336Sgblack@eecs.umich.edu // value written is discarded. 3846336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 3856336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 3866336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 3876336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 3889376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 3899376Sgblack@eecs.umich.edu tc); 3906336Sgblack@eecs.umich.edu return; 3916336Sgblack@eecs.umich.edu default: 3926336Sgblack@eecs.umich.edu break; 3936336Sgblack@eecs.umich.edu } 3946336Sgblack@eecs.umich.edu setMiscRegNoEffect(miscReg, newVal); 3956336Sgblack@eecs.umich.edu} 3966336Sgblack@eecs.umich.edu 3976336Sgblack@eecs.umich.eduvoid 39810905Sandreas.sandberg@arm.comISA::serialize(CheckpointOut &cp) const 3996336Sgblack@eecs.umich.edu{ 4006336Sgblack@eecs.umich.edu SERIALIZE_ARRAY(regVal, NumMiscRegs); 4016336Sgblack@eecs.umich.edu} 4026336Sgblack@eecs.umich.edu 4036336Sgblack@eecs.umich.eduvoid 40410905Sandreas.sandberg@arm.comISA::unserialize(CheckpointIn &cp) 4056336Sgblack@eecs.umich.edu{ 4066336Sgblack@eecs.umich.edu UNSERIALIZE_ARRAY(regVal, NumMiscRegs); 4077533Ssteve.reinhardt@amd.com updateHandyM5Reg(regVal[MISCREG_EFER], 4087533Ssteve.reinhardt@amd.com regVal[MISCREG_CR0], 4097533Ssteve.reinhardt@amd.com regVal[MISCREG_CS_ATTR], 4107533Ssteve.reinhardt@amd.com regVal[MISCREG_SS_ATTR], 4119376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 4129376Sgblack@eecs.umich.edu NULL); 4136313Sgblack@eecs.umich.edu} 4146313Sgblack@eecs.umich.edu 4159461Snilay@cs.wisc.eduvoid 4169461Snilay@cs.wisc.eduISA::startup(ThreadContext *tc) 4179461Snilay@cs.wisc.edu{ 4189461Snilay@cs.wisc.edu tc->getDecoderPtr()->setM5Reg(regVal[MISCREG_M5_REG]); 4199461Snilay@cs.wisc.edu} 4209461Snilay@cs.wisc.edu 4216313Sgblack@eecs.umich.edu} 4229384SAndreas.Sandberg@arm.com 4239384SAndreas.Sandberg@arm.comX86ISA::ISA * 4249384SAndreas.Sandberg@arm.comX86ISAParams::create() 4259384SAndreas.Sandberg@arm.com{ 4269384SAndreas.Sandberg@arm.com return new X86ISA::ISA(this); 4279384SAndreas.Sandberg@arm.com} 428