isa.cc revision 11165
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 319376Sgblack@eecs.umich.edu#include "arch/x86/decoder.hh" 326313Sgblack@eecs.umich.edu#include "arch/x86/isa.hh" 336336Sgblack@eecs.umich.edu#include "arch/x86/tlb.hh" 346336Sgblack@eecs.umich.edu#include "cpu/base.hh" 356313Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 369384SAndreas.Sandberg@arm.com#include "params/X86ISA.hh" 376336Sgblack@eecs.umich.edu#include "sim/serialize.hh" 386313Sgblack@eecs.umich.edu 396313Sgblack@eecs.umich.edunamespace X86ISA 406313Sgblack@eecs.umich.edu{ 416313Sgblack@eecs.umich.edu 426313Sgblack@eecs.umich.eduvoid 436336Sgblack@eecs.umich.eduISA::updateHandyM5Reg(Efer efer, CR0 cr0, 449376Sgblack@eecs.umich.edu SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags, 459376Sgblack@eecs.umich.edu ThreadContext *tc) 466336Sgblack@eecs.umich.edu{ 476712Snate@binkert.org HandyM5Reg m5reg = 0; 486336Sgblack@eecs.umich.edu if (efer.lma) { 496336Sgblack@eecs.umich.edu m5reg.mode = LongMode; 506336Sgblack@eecs.umich.edu if (csAttr.longMode) 516336Sgblack@eecs.umich.edu m5reg.submode = SixtyFourBitMode; 526336Sgblack@eecs.umich.edu else 536336Sgblack@eecs.umich.edu m5reg.submode = CompatabilityMode; 546336Sgblack@eecs.umich.edu } else { 556336Sgblack@eecs.umich.edu m5reg.mode = LegacyMode; 566336Sgblack@eecs.umich.edu if (cr0.pe) { 576336Sgblack@eecs.umich.edu if (rflags.vm) 586336Sgblack@eecs.umich.edu m5reg.submode = Virtual8086Mode; 596336Sgblack@eecs.umich.edu else 606336Sgblack@eecs.umich.edu m5reg.submode = ProtectedMode; 616336Sgblack@eecs.umich.edu } else { 626336Sgblack@eecs.umich.edu m5reg.submode = RealMode; 636336Sgblack@eecs.umich.edu } 646336Sgblack@eecs.umich.edu } 656336Sgblack@eecs.umich.edu m5reg.cpl = csAttr.dpl; 666336Sgblack@eecs.umich.edu m5reg.paging = cr0.pg; 676336Sgblack@eecs.umich.edu m5reg.prot = cr0.pe; 686336Sgblack@eecs.umich.edu 696336Sgblack@eecs.umich.edu // Compute the default and alternate operand size. 706336Sgblack@eecs.umich.edu if (m5reg.submode == SixtyFourBitMode || csAttr.defaultSize) { 716336Sgblack@eecs.umich.edu m5reg.defOp = 2; 726336Sgblack@eecs.umich.edu m5reg.altOp = 1; 736336Sgblack@eecs.umich.edu } else { 746336Sgblack@eecs.umich.edu m5reg.defOp = 1; 756336Sgblack@eecs.umich.edu m5reg.altOp = 2; 766336Sgblack@eecs.umich.edu } 776336Sgblack@eecs.umich.edu 786336Sgblack@eecs.umich.edu // Compute the default and alternate address size. 796336Sgblack@eecs.umich.edu if (m5reg.submode == SixtyFourBitMode) { 806336Sgblack@eecs.umich.edu m5reg.defAddr = 3; 816336Sgblack@eecs.umich.edu m5reg.altAddr = 2; 826336Sgblack@eecs.umich.edu } else if (csAttr.defaultSize) { 836336Sgblack@eecs.umich.edu m5reg.defAddr = 2; 846336Sgblack@eecs.umich.edu m5reg.altAddr = 1; 856336Sgblack@eecs.umich.edu } else { 866336Sgblack@eecs.umich.edu m5reg.defAddr = 1; 876336Sgblack@eecs.umich.edu m5reg.altAddr = 2; 886336Sgblack@eecs.umich.edu } 896336Sgblack@eecs.umich.edu 906336Sgblack@eecs.umich.edu // Compute the stack size 916336Sgblack@eecs.umich.edu if (m5reg.submode == SixtyFourBitMode) { 926336Sgblack@eecs.umich.edu m5reg.stack = 3; 936336Sgblack@eecs.umich.edu } else if (ssAttr.defaultSize) { 946336Sgblack@eecs.umich.edu m5reg.stack = 2; 956336Sgblack@eecs.umich.edu } else { 966336Sgblack@eecs.umich.edu m5reg.stack = 1; 976336Sgblack@eecs.umich.edu } 986336Sgblack@eecs.umich.edu 996336Sgblack@eecs.umich.edu regVal[MISCREG_M5_REG] = m5reg; 1009376Sgblack@eecs.umich.edu if (tc) 1019376Sgblack@eecs.umich.edu tc->getDecoderPtr()->setM5Reg(m5reg); 1026336Sgblack@eecs.umich.edu} 1036336Sgblack@eecs.umich.edu 1046336Sgblack@eecs.umich.eduvoid 1056313Sgblack@eecs.umich.eduISA::clear() 1066313Sgblack@eecs.umich.edu{ 1076336Sgblack@eecs.umich.edu // Blank everything. 0 might not be an appropriate value for some things, 1086336Sgblack@eecs.umich.edu // but it is for most. 1096336Sgblack@eecs.umich.edu memset(regVal, 0, NumMiscRegs * sizeof(MiscReg)); 1106336Sgblack@eecs.umich.edu regVal[MISCREG_DR6] = (mask(8) << 4) | (mask(16) << 16); 1116336Sgblack@eecs.umich.edu regVal[MISCREG_DR7] = 1 << 10; 1126313Sgblack@eecs.umich.edu} 1136313Sgblack@eecs.umich.edu 1149384SAndreas.Sandberg@arm.comISA::ISA(Params *p) 1159384SAndreas.Sandberg@arm.com : SimObject(p) 1169384SAndreas.Sandberg@arm.com{ 1179384SAndreas.Sandberg@arm.com clear(); 1189384SAndreas.Sandberg@arm.com} 1199384SAndreas.Sandberg@arm.com 1209384SAndreas.Sandberg@arm.comconst X86ISAParams * 1219384SAndreas.Sandberg@arm.comISA::params() const 1229384SAndreas.Sandberg@arm.com{ 1239384SAndreas.Sandberg@arm.com return dynamic_cast<const Params *>(_params); 1249384SAndreas.Sandberg@arm.com} 1259384SAndreas.Sandberg@arm.com 1266313Sgblack@eecs.umich.eduMiscReg 12710698Sandreas.hansson@arm.comISA::readMiscRegNoEffect(int miscReg) const 1286313Sgblack@eecs.umich.edu{ 1296336Sgblack@eecs.umich.edu // Make sure we're not dealing with an illegal control register. 1306336Sgblack@eecs.umich.edu // Instructions should filter out these indexes, and nothing else should 1316336Sgblack@eecs.umich.edu // attempt to read them directly. 13210899Snikos.nikoleris@gmail.com assert(miscReg >= MISCREG_CR0 && 13310899Snikos.nikoleris@gmail.com miscReg < NUM_MISCREGS && 13410899Snikos.nikoleris@gmail.com miscReg != MISCREG_CR1 && 13510899Snikos.nikoleris@gmail.com !(miscReg > MISCREG_CR4 && 13610899Snikos.nikoleris@gmail.com miscReg < MISCREG_CR8) && 13710899Snikos.nikoleris@gmail.com !(miscReg > MISCREG_CR8 && 13810899Snikos.nikoleris@gmail.com miscReg <= MISCREG_CR15)); 1396336Sgblack@eecs.umich.edu 1406336Sgblack@eecs.umich.edu return regVal[miscReg]; 1416313Sgblack@eecs.umich.edu} 1426313Sgblack@eecs.umich.edu 1436313Sgblack@eecs.umich.eduMiscReg 1446336Sgblack@eecs.umich.eduISA::readMiscReg(int miscReg, ThreadContext * tc) 1456313Sgblack@eecs.umich.edu{ 1466336Sgblack@eecs.umich.edu if (miscReg == MISCREG_TSC) { 1476336Sgblack@eecs.umich.edu return regVal[MISCREG_TSC] + tc->getCpuPtr()->curCycle(); 1486336Sgblack@eecs.umich.edu } 1499372Snilay@cs.wisc.edu 1509372Snilay@cs.wisc.edu if (miscReg == MISCREG_FSW) { 1519372Snilay@cs.wisc.edu MiscReg fsw = regVal[MISCREG_FSW]; 1529372Snilay@cs.wisc.edu MiscReg top = regVal[MISCREG_X87_TOP]; 1539372Snilay@cs.wisc.edu return (fsw & (~(7ULL << 11))) + (top << 11); 1549372Snilay@cs.wisc.edu } 1559372Snilay@cs.wisc.edu 1566336Sgblack@eecs.umich.edu return readMiscRegNoEffect(miscReg); 1576313Sgblack@eecs.umich.edu} 1586313Sgblack@eecs.umich.edu 1596313Sgblack@eecs.umich.eduvoid 1606336Sgblack@eecs.umich.eduISA::setMiscRegNoEffect(int miscReg, MiscReg val) 1616313Sgblack@eecs.umich.edu{ 1626336Sgblack@eecs.umich.edu // Make sure we're not dealing with an illegal control register. 1636336Sgblack@eecs.umich.edu // Instructions should filter out these indexes, and nothing else should 1646336Sgblack@eecs.umich.edu // attempt to write to them directly. 16510899Snikos.nikoleris@gmail.com assert(miscReg >= MISCREG_CR0 && 16610899Snikos.nikoleris@gmail.com miscReg < NUM_MISCREGS && 16710899Snikos.nikoleris@gmail.com miscReg != MISCREG_CR1 && 16810899Snikos.nikoleris@gmail.com !(miscReg > MISCREG_CR4 && 16910899Snikos.nikoleris@gmail.com miscReg < MISCREG_CR8) && 17010899Snikos.nikoleris@gmail.com !(miscReg > MISCREG_CR8 && 17110899Snikos.nikoleris@gmail.com miscReg <= MISCREG_CR15)); 17210899Snikos.nikoleris@gmail.com 17310899Snikos.nikoleris@gmail.com HandyM5Reg m5Reg = readMiscRegNoEffect(MISCREG_M5_REG); 17410899Snikos.nikoleris@gmail.com switch (miscReg) { 17510899Snikos.nikoleris@gmail.com case MISCREG_FSW: 17610899Snikos.nikoleris@gmail.com val &= (1ULL << 16) - 1; 17710899Snikos.nikoleris@gmail.com regVal[miscReg] = val; 17810899Snikos.nikoleris@gmail.com miscReg = MISCREG_X87_TOP; 17910899Snikos.nikoleris@gmail.com val <<= 11; 18010899Snikos.nikoleris@gmail.com case MISCREG_X87_TOP: 18110899Snikos.nikoleris@gmail.com val &= (1ULL << 3) - 1; 18210899Snikos.nikoleris@gmail.com break; 18310899Snikos.nikoleris@gmail.com case MISCREG_FTW: 18410899Snikos.nikoleris@gmail.com val &= (1ULL << 8) - 1; 18510899Snikos.nikoleris@gmail.com break; 18610899Snikos.nikoleris@gmail.com case MISCREG_FCW: 18710899Snikos.nikoleris@gmail.com case MISCREG_FOP: 18810899Snikos.nikoleris@gmail.com val &= (1ULL << 16) - 1; 18910899Snikos.nikoleris@gmail.com break; 19010899Snikos.nikoleris@gmail.com case MISCREG_MXCSR: 19110899Snikos.nikoleris@gmail.com val &= (1ULL << 32) - 1; 19210899Snikos.nikoleris@gmail.com break; 19310899Snikos.nikoleris@gmail.com case MISCREG_FISEG: 19410899Snikos.nikoleris@gmail.com case MISCREG_FOSEG: 19510899Snikos.nikoleris@gmail.com if (m5Reg.submode != SixtyFourBitMode) 19610899Snikos.nikoleris@gmail.com val &= (1ULL << 16) - 1; 19710899Snikos.nikoleris@gmail.com break; 19810899Snikos.nikoleris@gmail.com case MISCREG_FIOFF: 19910899Snikos.nikoleris@gmail.com case MISCREG_FOOFF: 20010899Snikos.nikoleris@gmail.com if (m5Reg.submode != SixtyFourBitMode) 20110899Snikos.nikoleris@gmail.com val &= (1ULL << 32) - 1; 20210899Snikos.nikoleris@gmail.com break; 20310899Snikos.nikoleris@gmail.com default: 20410899Snikos.nikoleris@gmail.com break; 20510899Snikos.nikoleris@gmail.com } 20610899Snikos.nikoleris@gmail.com 2076336Sgblack@eecs.umich.edu regVal[miscReg] = val; 2086313Sgblack@eecs.umich.edu} 2096313Sgblack@eecs.umich.edu 2106313Sgblack@eecs.umich.eduvoid 2116336Sgblack@eecs.umich.eduISA::setMiscReg(int miscReg, MiscReg val, ThreadContext * tc) 2126313Sgblack@eecs.umich.edu{ 2136336Sgblack@eecs.umich.edu MiscReg newVal = val; 2146336Sgblack@eecs.umich.edu switch(miscReg) 2156336Sgblack@eecs.umich.edu { 2166336Sgblack@eecs.umich.edu case MISCREG_CR0: 2176336Sgblack@eecs.umich.edu { 2186336Sgblack@eecs.umich.edu CR0 toggled = regVal[miscReg] ^ val; 2196336Sgblack@eecs.umich.edu CR0 newCR0 = val; 2206336Sgblack@eecs.umich.edu Efer efer = regVal[MISCREG_EFER]; 2216336Sgblack@eecs.umich.edu if (toggled.pg && efer.lme) { 2226336Sgblack@eecs.umich.edu if (newCR0.pg) { 2236336Sgblack@eecs.umich.edu //Turning on long mode 2246336Sgblack@eecs.umich.edu efer.lma = 1; 2256336Sgblack@eecs.umich.edu regVal[MISCREG_EFER] = efer; 2266336Sgblack@eecs.umich.edu } else { 2276336Sgblack@eecs.umich.edu //Turning off long mode 2286336Sgblack@eecs.umich.edu efer.lma = 0; 2296336Sgblack@eecs.umich.edu regVal[MISCREG_EFER] = efer; 2306336Sgblack@eecs.umich.edu } 2316336Sgblack@eecs.umich.edu } 2326336Sgblack@eecs.umich.edu if (toggled.pg) { 2339423SAndreas.Sandberg@arm.com tc->getITBPtr()->flushAll(); 2349423SAndreas.Sandberg@arm.com tc->getDTBPtr()->flushAll(); 2356336Sgblack@eecs.umich.edu } 2366336Sgblack@eecs.umich.edu //This must always be 1. 2376336Sgblack@eecs.umich.edu newCR0.et = 1; 2386336Sgblack@eecs.umich.edu newVal = newCR0; 2396336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2406336Sgblack@eecs.umich.edu newCR0, 2416336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 2426336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 2439376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2449376Sgblack@eecs.umich.edu tc); 2456336Sgblack@eecs.umich.edu } 2466336Sgblack@eecs.umich.edu break; 2476336Sgblack@eecs.umich.edu case MISCREG_CR2: 2486336Sgblack@eecs.umich.edu break; 2496336Sgblack@eecs.umich.edu case MISCREG_CR3: 2509423SAndreas.Sandberg@arm.com tc->getITBPtr()->flushNonGlobal(); 2519423SAndreas.Sandberg@arm.com tc->getDTBPtr()->flushNonGlobal(); 2526336Sgblack@eecs.umich.edu break; 2536336Sgblack@eecs.umich.edu case MISCREG_CR4: 2546336Sgblack@eecs.umich.edu { 2556336Sgblack@eecs.umich.edu CR4 toggled = regVal[miscReg] ^ val; 2566336Sgblack@eecs.umich.edu if (toggled.pae || toggled.pse || toggled.pge) { 2579423SAndreas.Sandberg@arm.com tc->getITBPtr()->flushAll(); 2589423SAndreas.Sandberg@arm.com tc->getDTBPtr()->flushAll(); 2596336Sgblack@eecs.umich.edu } 2606336Sgblack@eecs.umich.edu } 2616336Sgblack@eecs.umich.edu break; 2626336Sgblack@eecs.umich.edu case MISCREG_CR8: 2636336Sgblack@eecs.umich.edu break; 2646336Sgblack@eecs.umich.edu case MISCREG_CS_ATTR: 2656336Sgblack@eecs.umich.edu { 2666336Sgblack@eecs.umich.edu SegAttr toggled = regVal[miscReg] ^ val; 2676336Sgblack@eecs.umich.edu SegAttr newCSAttr = val; 2686336Sgblack@eecs.umich.edu if (toggled.longMode) { 2696336Sgblack@eecs.umich.edu if (newCSAttr.longMode) { 2706336Sgblack@eecs.umich.edu regVal[MISCREG_ES_EFF_BASE] = 0; 2716336Sgblack@eecs.umich.edu regVal[MISCREG_CS_EFF_BASE] = 0; 2726336Sgblack@eecs.umich.edu regVal[MISCREG_SS_EFF_BASE] = 0; 2736336Sgblack@eecs.umich.edu regVal[MISCREG_DS_EFF_BASE] = 0; 2746336Sgblack@eecs.umich.edu } else { 2756336Sgblack@eecs.umich.edu regVal[MISCREG_ES_EFF_BASE] = regVal[MISCREG_ES_BASE]; 2766336Sgblack@eecs.umich.edu regVal[MISCREG_CS_EFF_BASE] = regVal[MISCREG_CS_BASE]; 2776336Sgblack@eecs.umich.edu regVal[MISCREG_SS_EFF_BASE] = regVal[MISCREG_SS_BASE]; 2786336Sgblack@eecs.umich.edu regVal[MISCREG_DS_EFF_BASE] = regVal[MISCREG_DS_BASE]; 2796336Sgblack@eecs.umich.edu } 2806336Sgblack@eecs.umich.edu } 2816336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2826336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 2836336Sgblack@eecs.umich.edu newCSAttr, 2846336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 2859376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2869376Sgblack@eecs.umich.edu tc); 2876336Sgblack@eecs.umich.edu } 2886336Sgblack@eecs.umich.edu break; 2896336Sgblack@eecs.umich.edu case MISCREG_SS_ATTR: 2906336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2916336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 2926336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 2936336Sgblack@eecs.umich.edu val, 2949376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2959376Sgblack@eecs.umich.edu tc); 2966336Sgblack@eecs.umich.edu break; 2976336Sgblack@eecs.umich.edu // These segments always actually use their bases, or in other words 2986336Sgblack@eecs.umich.edu // their effective bases must stay equal to their actual bases. 2996336Sgblack@eecs.umich.edu case MISCREG_FS_BASE: 3006336Sgblack@eecs.umich.edu case MISCREG_GS_BASE: 3016336Sgblack@eecs.umich.edu case MISCREG_HS_BASE: 3026336Sgblack@eecs.umich.edu case MISCREG_TSL_BASE: 3036336Sgblack@eecs.umich.edu case MISCREG_TSG_BASE: 3046336Sgblack@eecs.umich.edu case MISCREG_TR_BASE: 3056336Sgblack@eecs.umich.edu case MISCREG_IDTR_BASE: 3066336Sgblack@eecs.umich.edu regVal[MISCREG_SEG_EFF_BASE(miscReg - MISCREG_SEG_BASE_BASE)] = val; 3076336Sgblack@eecs.umich.edu break; 3086336Sgblack@eecs.umich.edu // These segments ignore their bases in 64 bit mode. 3096336Sgblack@eecs.umich.edu // their effective bases must stay equal to their actual bases. 3106336Sgblack@eecs.umich.edu case MISCREG_ES_BASE: 3116336Sgblack@eecs.umich.edu case MISCREG_CS_BASE: 3126336Sgblack@eecs.umich.edu case MISCREG_SS_BASE: 3136336Sgblack@eecs.umich.edu case MISCREG_DS_BASE: 3146336Sgblack@eecs.umich.edu { 3156336Sgblack@eecs.umich.edu Efer efer = regVal[MISCREG_EFER]; 3166336Sgblack@eecs.umich.edu SegAttr csAttr = regVal[MISCREG_CS_ATTR]; 3176336Sgblack@eecs.umich.edu if (!efer.lma || !csAttr.longMode) // Check for non 64 bit mode. 3186336Sgblack@eecs.umich.edu regVal[MISCREG_SEG_EFF_BASE(miscReg - 3196336Sgblack@eecs.umich.edu MISCREG_SEG_BASE_BASE)] = val; 3206336Sgblack@eecs.umich.edu } 3216336Sgblack@eecs.umich.edu break; 3226336Sgblack@eecs.umich.edu case MISCREG_TSC: 3236336Sgblack@eecs.umich.edu regVal[MISCREG_TSC] = val - tc->getCpuPtr()->curCycle(); 3246336Sgblack@eecs.umich.edu return; 3256336Sgblack@eecs.umich.edu case MISCREG_DR0: 3266336Sgblack@eecs.umich.edu case MISCREG_DR1: 3276336Sgblack@eecs.umich.edu case MISCREG_DR2: 3286336Sgblack@eecs.umich.edu case MISCREG_DR3: 3296336Sgblack@eecs.umich.edu /* These should eventually set up breakpoints. */ 3306336Sgblack@eecs.umich.edu break; 3316336Sgblack@eecs.umich.edu case MISCREG_DR4: 3326336Sgblack@eecs.umich.edu miscReg = MISCREG_DR6; 3336336Sgblack@eecs.umich.edu /* Fall through to have the same effects as DR6. */ 3346336Sgblack@eecs.umich.edu case MISCREG_DR6: 3356336Sgblack@eecs.umich.edu { 3366336Sgblack@eecs.umich.edu DR6 dr6 = regVal[MISCREG_DR6]; 3376336Sgblack@eecs.umich.edu DR6 newDR6 = val; 3386336Sgblack@eecs.umich.edu dr6.b0 = newDR6.b0; 3396336Sgblack@eecs.umich.edu dr6.b1 = newDR6.b1; 3406336Sgblack@eecs.umich.edu dr6.b2 = newDR6.b2; 3416336Sgblack@eecs.umich.edu dr6.b3 = newDR6.b3; 3426336Sgblack@eecs.umich.edu dr6.bd = newDR6.bd; 3436336Sgblack@eecs.umich.edu dr6.bs = newDR6.bs; 3446336Sgblack@eecs.umich.edu dr6.bt = newDR6.bt; 3456336Sgblack@eecs.umich.edu newVal = dr6; 3466336Sgblack@eecs.umich.edu } 3476336Sgblack@eecs.umich.edu break; 3486336Sgblack@eecs.umich.edu case MISCREG_DR5: 3496336Sgblack@eecs.umich.edu miscReg = MISCREG_DR7; 3506336Sgblack@eecs.umich.edu /* Fall through to have the same effects as DR7. */ 3516336Sgblack@eecs.umich.edu case MISCREG_DR7: 3526336Sgblack@eecs.umich.edu { 3536336Sgblack@eecs.umich.edu DR7 dr7 = regVal[MISCREG_DR7]; 3546336Sgblack@eecs.umich.edu DR7 newDR7 = val; 3556336Sgblack@eecs.umich.edu dr7.l0 = newDR7.l0; 3566336Sgblack@eecs.umich.edu dr7.g0 = newDR7.g0; 3576336Sgblack@eecs.umich.edu if (dr7.l0 || dr7.g0) { 3586336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3596336Sgblack@eecs.umich.edu } else { 3606336Sgblack@eecs.umich.edu /* Disable breakpoint 0. */ 3616336Sgblack@eecs.umich.edu } 3626336Sgblack@eecs.umich.edu dr7.l1 = newDR7.l1; 3636336Sgblack@eecs.umich.edu dr7.g1 = newDR7.g1; 3646336Sgblack@eecs.umich.edu if (dr7.l1 || dr7.g1) { 3656336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3666336Sgblack@eecs.umich.edu } else { 3676336Sgblack@eecs.umich.edu /* Disable breakpoint 1. */ 3686336Sgblack@eecs.umich.edu } 3696336Sgblack@eecs.umich.edu dr7.l2 = newDR7.l2; 3706336Sgblack@eecs.umich.edu dr7.g2 = newDR7.g2; 3716336Sgblack@eecs.umich.edu if (dr7.l2 || dr7.g2) { 3726336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3736336Sgblack@eecs.umich.edu } else { 3746336Sgblack@eecs.umich.edu /* Disable breakpoint 2. */ 3756336Sgblack@eecs.umich.edu } 3766336Sgblack@eecs.umich.edu dr7.l3 = newDR7.l3; 3776336Sgblack@eecs.umich.edu dr7.g3 = newDR7.g3; 3786336Sgblack@eecs.umich.edu if (dr7.l3 || dr7.g3) { 3796336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3806336Sgblack@eecs.umich.edu } else { 3816336Sgblack@eecs.umich.edu /* Disable breakpoint 3. */ 3826336Sgblack@eecs.umich.edu } 3836336Sgblack@eecs.umich.edu dr7.gd = newDR7.gd; 3846336Sgblack@eecs.umich.edu dr7.rw0 = newDR7.rw0; 3856336Sgblack@eecs.umich.edu dr7.len0 = newDR7.len0; 3866336Sgblack@eecs.umich.edu dr7.rw1 = newDR7.rw1; 3876336Sgblack@eecs.umich.edu dr7.len1 = newDR7.len1; 3886336Sgblack@eecs.umich.edu dr7.rw2 = newDR7.rw2; 3896336Sgblack@eecs.umich.edu dr7.len2 = newDR7.len2; 3906336Sgblack@eecs.umich.edu dr7.rw3 = newDR7.rw3; 3916336Sgblack@eecs.umich.edu dr7.len3 = newDR7.len3; 3926336Sgblack@eecs.umich.edu } 3936336Sgblack@eecs.umich.edu break; 3946336Sgblack@eecs.umich.edu case MISCREG_M5_REG: 3956336Sgblack@eecs.umich.edu // Writing anything to the m5reg with side effects makes it update 3966336Sgblack@eecs.umich.edu // based on the current values of the relevant registers. The actual 3976336Sgblack@eecs.umich.edu // value written is discarded. 3986336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 3996336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 4006336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 4016336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 4029376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 4039376Sgblack@eecs.umich.edu tc); 4046336Sgblack@eecs.umich.edu return; 4056336Sgblack@eecs.umich.edu default: 4066336Sgblack@eecs.umich.edu break; 4076336Sgblack@eecs.umich.edu } 4086336Sgblack@eecs.umich.edu setMiscRegNoEffect(miscReg, newVal); 4096336Sgblack@eecs.umich.edu} 4106336Sgblack@eecs.umich.edu 4116336Sgblack@eecs.umich.eduvoid 41210905Sandreas.sandberg@arm.comISA::serialize(CheckpointOut &cp) const 4136336Sgblack@eecs.umich.edu{ 4146336Sgblack@eecs.umich.edu SERIALIZE_ARRAY(regVal, NumMiscRegs); 4156336Sgblack@eecs.umich.edu} 4166336Sgblack@eecs.umich.edu 4176336Sgblack@eecs.umich.eduvoid 41810905Sandreas.sandberg@arm.comISA::unserialize(CheckpointIn &cp) 4196336Sgblack@eecs.umich.edu{ 4206336Sgblack@eecs.umich.edu UNSERIALIZE_ARRAY(regVal, NumMiscRegs); 4217533Ssteve.reinhardt@amd.com updateHandyM5Reg(regVal[MISCREG_EFER], 4227533Ssteve.reinhardt@amd.com regVal[MISCREG_CR0], 4237533Ssteve.reinhardt@amd.com regVal[MISCREG_CS_ATTR], 4247533Ssteve.reinhardt@amd.com regVal[MISCREG_SS_ATTR], 4259376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 4269376Sgblack@eecs.umich.edu NULL); 4276313Sgblack@eecs.umich.edu} 4286313Sgblack@eecs.umich.edu 4299461Snilay@cs.wisc.eduvoid 4309461Snilay@cs.wisc.eduISA::startup(ThreadContext *tc) 4319461Snilay@cs.wisc.edu{ 4329461Snilay@cs.wisc.edu tc->getDecoderPtr()->setM5Reg(regVal[MISCREG_M5_REG]); 4339461Snilay@cs.wisc.edu} 4349461Snilay@cs.wisc.edu 4356313Sgblack@eecs.umich.edu} 4369384SAndreas.Sandberg@arm.com 4379384SAndreas.Sandberg@arm.comX86ISA::ISA * 4389384SAndreas.Sandberg@arm.comX86ISAParams::create() 4399384SAndreas.Sandberg@arm.com{ 4409384SAndreas.Sandberg@arm.com return new X86ISA::ISA(this); 4419384SAndreas.Sandberg@arm.com} 442