isa.cc revision 12109
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]; 1489372Snilay@cs.wisc.edu return (fsw & (~(7ULL << 11))) + (top << 11); 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 16210899Snikos.nikoleris@gmail.com HandyM5Reg m5Reg = readMiscRegNoEffect(MISCREG_M5_REG); 16310899Snikos.nikoleris@gmail.com switch (miscReg) { 16410899Snikos.nikoleris@gmail.com case MISCREG_FSW: 16510899Snikos.nikoleris@gmail.com val &= (1ULL << 16) - 1; 16610899Snikos.nikoleris@gmail.com regVal[miscReg] = val; 16710899Snikos.nikoleris@gmail.com miscReg = MISCREG_X87_TOP; 16810899Snikos.nikoleris@gmail.com val <<= 11; 16910899Snikos.nikoleris@gmail.com case MISCREG_X87_TOP: 17010899Snikos.nikoleris@gmail.com val &= (1ULL << 3) - 1; 17110899Snikos.nikoleris@gmail.com break; 17210899Snikos.nikoleris@gmail.com case MISCREG_FTW: 17310899Snikos.nikoleris@gmail.com val &= (1ULL << 8) - 1; 17410899Snikos.nikoleris@gmail.com break; 17510899Snikos.nikoleris@gmail.com case MISCREG_FCW: 17610899Snikos.nikoleris@gmail.com case MISCREG_FOP: 17710899Snikos.nikoleris@gmail.com val &= (1ULL << 16) - 1; 17810899Snikos.nikoleris@gmail.com break; 17910899Snikos.nikoleris@gmail.com case MISCREG_MXCSR: 18010899Snikos.nikoleris@gmail.com val &= (1ULL << 32) - 1; 18110899Snikos.nikoleris@gmail.com break; 18210899Snikos.nikoleris@gmail.com case MISCREG_FISEG: 18310899Snikos.nikoleris@gmail.com case MISCREG_FOSEG: 18410899Snikos.nikoleris@gmail.com if (m5Reg.submode != SixtyFourBitMode) 18510899Snikos.nikoleris@gmail.com val &= (1ULL << 16) - 1; 18610899Snikos.nikoleris@gmail.com break; 18710899Snikos.nikoleris@gmail.com case MISCREG_FIOFF: 18810899Snikos.nikoleris@gmail.com case MISCREG_FOOFF: 18910899Snikos.nikoleris@gmail.com if (m5Reg.submode != SixtyFourBitMode) 19010899Snikos.nikoleris@gmail.com val &= (1ULL << 32) - 1; 19110899Snikos.nikoleris@gmail.com break; 19210899Snikos.nikoleris@gmail.com default: 19310899Snikos.nikoleris@gmail.com break; 19410899Snikos.nikoleris@gmail.com } 19510899Snikos.nikoleris@gmail.com 1966336Sgblack@eecs.umich.edu regVal[miscReg] = val; 1976313Sgblack@eecs.umich.edu} 1986313Sgblack@eecs.umich.edu 1996313Sgblack@eecs.umich.eduvoid 2006336Sgblack@eecs.umich.eduISA::setMiscReg(int miscReg, MiscReg val, ThreadContext * tc) 2016313Sgblack@eecs.umich.edu{ 2026336Sgblack@eecs.umich.edu MiscReg newVal = val; 2036336Sgblack@eecs.umich.edu switch(miscReg) 2046336Sgblack@eecs.umich.edu { 2056336Sgblack@eecs.umich.edu case MISCREG_CR0: 2066336Sgblack@eecs.umich.edu { 2076336Sgblack@eecs.umich.edu CR0 toggled = regVal[miscReg] ^ val; 2086336Sgblack@eecs.umich.edu CR0 newCR0 = val; 2096336Sgblack@eecs.umich.edu Efer efer = regVal[MISCREG_EFER]; 2106336Sgblack@eecs.umich.edu if (toggled.pg && efer.lme) { 2116336Sgblack@eecs.umich.edu if (newCR0.pg) { 2126336Sgblack@eecs.umich.edu //Turning on long mode 2136336Sgblack@eecs.umich.edu efer.lma = 1; 2146336Sgblack@eecs.umich.edu regVal[MISCREG_EFER] = efer; 2156336Sgblack@eecs.umich.edu } else { 2166336Sgblack@eecs.umich.edu //Turning off long mode 2176336Sgblack@eecs.umich.edu efer.lma = 0; 2186336Sgblack@eecs.umich.edu regVal[MISCREG_EFER] = efer; 2196336Sgblack@eecs.umich.edu } 2206336Sgblack@eecs.umich.edu } 2216336Sgblack@eecs.umich.edu if (toggled.pg) { 2229423SAndreas.Sandberg@arm.com tc->getITBPtr()->flushAll(); 2239423SAndreas.Sandberg@arm.com tc->getDTBPtr()->flushAll(); 2246336Sgblack@eecs.umich.edu } 2256336Sgblack@eecs.umich.edu //This must always be 1. 2266336Sgblack@eecs.umich.edu newCR0.et = 1; 2276336Sgblack@eecs.umich.edu newVal = newCR0; 2286336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2296336Sgblack@eecs.umich.edu newCR0, 2306336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 2316336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 2329376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2339376Sgblack@eecs.umich.edu tc); 2346336Sgblack@eecs.umich.edu } 2356336Sgblack@eecs.umich.edu break; 2366336Sgblack@eecs.umich.edu case MISCREG_CR2: 2376336Sgblack@eecs.umich.edu break; 2386336Sgblack@eecs.umich.edu case MISCREG_CR3: 2399423SAndreas.Sandberg@arm.com tc->getITBPtr()->flushNonGlobal(); 2409423SAndreas.Sandberg@arm.com tc->getDTBPtr()->flushNonGlobal(); 2416336Sgblack@eecs.umich.edu break; 2426336Sgblack@eecs.umich.edu case MISCREG_CR4: 2436336Sgblack@eecs.umich.edu { 2446336Sgblack@eecs.umich.edu CR4 toggled = regVal[miscReg] ^ val; 2456336Sgblack@eecs.umich.edu if (toggled.pae || toggled.pse || toggled.pge) { 2469423SAndreas.Sandberg@arm.com tc->getITBPtr()->flushAll(); 2479423SAndreas.Sandberg@arm.com tc->getDTBPtr()->flushAll(); 2486336Sgblack@eecs.umich.edu } 2496336Sgblack@eecs.umich.edu } 2506336Sgblack@eecs.umich.edu break; 2516336Sgblack@eecs.umich.edu case MISCREG_CR8: 2526336Sgblack@eecs.umich.edu break; 2536336Sgblack@eecs.umich.edu case MISCREG_CS_ATTR: 2546336Sgblack@eecs.umich.edu { 2556336Sgblack@eecs.umich.edu SegAttr toggled = regVal[miscReg] ^ val; 2566336Sgblack@eecs.umich.edu SegAttr newCSAttr = val; 2576336Sgblack@eecs.umich.edu if (toggled.longMode) { 2586336Sgblack@eecs.umich.edu if (newCSAttr.longMode) { 2596336Sgblack@eecs.umich.edu regVal[MISCREG_ES_EFF_BASE] = 0; 2606336Sgblack@eecs.umich.edu regVal[MISCREG_CS_EFF_BASE] = 0; 2616336Sgblack@eecs.umich.edu regVal[MISCREG_SS_EFF_BASE] = 0; 2626336Sgblack@eecs.umich.edu regVal[MISCREG_DS_EFF_BASE] = 0; 2636336Sgblack@eecs.umich.edu } else { 2646336Sgblack@eecs.umich.edu regVal[MISCREG_ES_EFF_BASE] = regVal[MISCREG_ES_BASE]; 2656336Sgblack@eecs.umich.edu regVal[MISCREG_CS_EFF_BASE] = regVal[MISCREG_CS_BASE]; 2666336Sgblack@eecs.umich.edu regVal[MISCREG_SS_EFF_BASE] = regVal[MISCREG_SS_BASE]; 2676336Sgblack@eecs.umich.edu regVal[MISCREG_DS_EFF_BASE] = regVal[MISCREG_DS_BASE]; 2686336Sgblack@eecs.umich.edu } 2696336Sgblack@eecs.umich.edu } 2706336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2716336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 2726336Sgblack@eecs.umich.edu newCSAttr, 2736336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 2749376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2759376Sgblack@eecs.umich.edu tc); 2766336Sgblack@eecs.umich.edu } 2776336Sgblack@eecs.umich.edu break; 2786336Sgblack@eecs.umich.edu case MISCREG_SS_ATTR: 2796336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 2806336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 2816336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 2826336Sgblack@eecs.umich.edu val, 2839376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 2849376Sgblack@eecs.umich.edu tc); 2856336Sgblack@eecs.umich.edu break; 2866336Sgblack@eecs.umich.edu // These segments always actually use their bases, or in other words 2876336Sgblack@eecs.umich.edu // their effective bases must stay equal to their actual bases. 2886336Sgblack@eecs.umich.edu case MISCREG_FS_BASE: 2896336Sgblack@eecs.umich.edu case MISCREG_GS_BASE: 2906336Sgblack@eecs.umich.edu case MISCREG_HS_BASE: 2916336Sgblack@eecs.umich.edu case MISCREG_TSL_BASE: 2926336Sgblack@eecs.umich.edu case MISCREG_TSG_BASE: 2936336Sgblack@eecs.umich.edu case MISCREG_TR_BASE: 2946336Sgblack@eecs.umich.edu case MISCREG_IDTR_BASE: 2956336Sgblack@eecs.umich.edu regVal[MISCREG_SEG_EFF_BASE(miscReg - MISCREG_SEG_BASE_BASE)] = val; 2966336Sgblack@eecs.umich.edu break; 2976336Sgblack@eecs.umich.edu // These segments ignore their bases in 64 bit mode. 2986336Sgblack@eecs.umich.edu // their effective bases must stay equal to their actual bases. 2996336Sgblack@eecs.umich.edu case MISCREG_ES_BASE: 3006336Sgblack@eecs.umich.edu case MISCREG_CS_BASE: 3016336Sgblack@eecs.umich.edu case MISCREG_SS_BASE: 3026336Sgblack@eecs.umich.edu case MISCREG_DS_BASE: 3036336Sgblack@eecs.umich.edu { 3046336Sgblack@eecs.umich.edu Efer efer = regVal[MISCREG_EFER]; 3056336Sgblack@eecs.umich.edu SegAttr csAttr = regVal[MISCREG_CS_ATTR]; 3066336Sgblack@eecs.umich.edu if (!efer.lma || !csAttr.longMode) // Check for non 64 bit mode. 3076336Sgblack@eecs.umich.edu regVal[MISCREG_SEG_EFF_BASE(miscReg - 3086336Sgblack@eecs.umich.edu MISCREG_SEG_BASE_BASE)] = val; 3096336Sgblack@eecs.umich.edu } 3106336Sgblack@eecs.umich.edu break; 3116336Sgblack@eecs.umich.edu case MISCREG_TSC: 3126336Sgblack@eecs.umich.edu regVal[MISCREG_TSC] = val - tc->getCpuPtr()->curCycle(); 3136336Sgblack@eecs.umich.edu return; 3146336Sgblack@eecs.umich.edu case MISCREG_DR0: 3156336Sgblack@eecs.umich.edu case MISCREG_DR1: 3166336Sgblack@eecs.umich.edu case MISCREG_DR2: 3176336Sgblack@eecs.umich.edu case MISCREG_DR3: 3186336Sgblack@eecs.umich.edu /* These should eventually set up breakpoints. */ 3196336Sgblack@eecs.umich.edu break; 3206336Sgblack@eecs.umich.edu case MISCREG_DR4: 3216336Sgblack@eecs.umich.edu miscReg = MISCREG_DR6; 3226336Sgblack@eecs.umich.edu /* Fall through to have the same effects as DR6. */ 3236336Sgblack@eecs.umich.edu case MISCREG_DR6: 3246336Sgblack@eecs.umich.edu { 3256336Sgblack@eecs.umich.edu DR6 dr6 = regVal[MISCREG_DR6]; 3266336Sgblack@eecs.umich.edu DR6 newDR6 = val; 3276336Sgblack@eecs.umich.edu dr6.b0 = newDR6.b0; 3286336Sgblack@eecs.umich.edu dr6.b1 = newDR6.b1; 3296336Sgblack@eecs.umich.edu dr6.b2 = newDR6.b2; 3306336Sgblack@eecs.umich.edu dr6.b3 = newDR6.b3; 3316336Sgblack@eecs.umich.edu dr6.bd = newDR6.bd; 3326336Sgblack@eecs.umich.edu dr6.bs = newDR6.bs; 3336336Sgblack@eecs.umich.edu dr6.bt = newDR6.bt; 3346336Sgblack@eecs.umich.edu newVal = dr6; 3356336Sgblack@eecs.umich.edu } 3366336Sgblack@eecs.umich.edu break; 3376336Sgblack@eecs.umich.edu case MISCREG_DR5: 3386336Sgblack@eecs.umich.edu miscReg = MISCREG_DR7; 3396336Sgblack@eecs.umich.edu /* Fall through to have the same effects as DR7. */ 3406336Sgblack@eecs.umich.edu case MISCREG_DR7: 3416336Sgblack@eecs.umich.edu { 3426336Sgblack@eecs.umich.edu DR7 dr7 = regVal[MISCREG_DR7]; 3436336Sgblack@eecs.umich.edu DR7 newDR7 = val; 3446336Sgblack@eecs.umich.edu dr7.l0 = newDR7.l0; 3456336Sgblack@eecs.umich.edu dr7.g0 = newDR7.g0; 3466336Sgblack@eecs.umich.edu if (dr7.l0 || dr7.g0) { 3476336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3486336Sgblack@eecs.umich.edu } else { 3496336Sgblack@eecs.umich.edu /* Disable breakpoint 0. */ 3506336Sgblack@eecs.umich.edu } 3516336Sgblack@eecs.umich.edu dr7.l1 = newDR7.l1; 3526336Sgblack@eecs.umich.edu dr7.g1 = newDR7.g1; 3536336Sgblack@eecs.umich.edu if (dr7.l1 || dr7.g1) { 3546336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3556336Sgblack@eecs.umich.edu } else { 3566336Sgblack@eecs.umich.edu /* Disable breakpoint 1. */ 3576336Sgblack@eecs.umich.edu } 3586336Sgblack@eecs.umich.edu dr7.l2 = newDR7.l2; 3596336Sgblack@eecs.umich.edu dr7.g2 = newDR7.g2; 3606336Sgblack@eecs.umich.edu if (dr7.l2 || dr7.g2) { 3616336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3626336Sgblack@eecs.umich.edu } else { 3636336Sgblack@eecs.umich.edu /* Disable breakpoint 2. */ 3646336Sgblack@eecs.umich.edu } 3656336Sgblack@eecs.umich.edu dr7.l3 = newDR7.l3; 3666336Sgblack@eecs.umich.edu dr7.g3 = newDR7.g3; 3676336Sgblack@eecs.umich.edu if (dr7.l3 || dr7.g3) { 3686336Sgblack@eecs.umich.edu panic("Debug register breakpoints not implemented.\n"); 3696336Sgblack@eecs.umich.edu } else { 3706336Sgblack@eecs.umich.edu /* Disable breakpoint 3. */ 3716336Sgblack@eecs.umich.edu } 3726336Sgblack@eecs.umich.edu dr7.gd = newDR7.gd; 3736336Sgblack@eecs.umich.edu dr7.rw0 = newDR7.rw0; 3746336Sgblack@eecs.umich.edu dr7.len0 = newDR7.len0; 3756336Sgblack@eecs.umich.edu dr7.rw1 = newDR7.rw1; 3766336Sgblack@eecs.umich.edu dr7.len1 = newDR7.len1; 3776336Sgblack@eecs.umich.edu dr7.rw2 = newDR7.rw2; 3786336Sgblack@eecs.umich.edu dr7.len2 = newDR7.len2; 3796336Sgblack@eecs.umich.edu dr7.rw3 = newDR7.rw3; 3806336Sgblack@eecs.umich.edu dr7.len3 = newDR7.len3; 3816336Sgblack@eecs.umich.edu } 3826336Sgblack@eecs.umich.edu break; 3836336Sgblack@eecs.umich.edu case MISCREG_M5_REG: 3846336Sgblack@eecs.umich.edu // Writing anything to the m5reg with side effects makes it update 3856336Sgblack@eecs.umich.edu // based on the current values of the relevant registers. The actual 3866336Sgblack@eecs.umich.edu // value written is discarded. 3876336Sgblack@eecs.umich.edu updateHandyM5Reg(regVal[MISCREG_EFER], 3886336Sgblack@eecs.umich.edu regVal[MISCREG_CR0], 3896336Sgblack@eecs.umich.edu regVal[MISCREG_CS_ATTR], 3906336Sgblack@eecs.umich.edu regVal[MISCREG_SS_ATTR], 3919376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 3929376Sgblack@eecs.umich.edu tc); 3936336Sgblack@eecs.umich.edu return; 3946336Sgblack@eecs.umich.edu default: 3956336Sgblack@eecs.umich.edu break; 3966336Sgblack@eecs.umich.edu } 3976336Sgblack@eecs.umich.edu setMiscRegNoEffect(miscReg, newVal); 3986336Sgblack@eecs.umich.edu} 3996336Sgblack@eecs.umich.edu 4006336Sgblack@eecs.umich.eduvoid 40110905Sandreas.sandberg@arm.comISA::serialize(CheckpointOut &cp) const 4026336Sgblack@eecs.umich.edu{ 4036336Sgblack@eecs.umich.edu SERIALIZE_ARRAY(regVal, NumMiscRegs); 4046336Sgblack@eecs.umich.edu} 4056336Sgblack@eecs.umich.edu 4066336Sgblack@eecs.umich.eduvoid 40710905Sandreas.sandberg@arm.comISA::unserialize(CheckpointIn &cp) 4086336Sgblack@eecs.umich.edu{ 4096336Sgblack@eecs.umich.edu UNSERIALIZE_ARRAY(regVal, NumMiscRegs); 4107533Ssteve.reinhardt@amd.com updateHandyM5Reg(regVal[MISCREG_EFER], 4117533Ssteve.reinhardt@amd.com regVal[MISCREG_CR0], 4127533Ssteve.reinhardt@amd.com regVal[MISCREG_CS_ATTR], 4137533Ssteve.reinhardt@amd.com regVal[MISCREG_SS_ATTR], 4149376Sgblack@eecs.umich.edu regVal[MISCREG_RFLAGS], 4159376Sgblack@eecs.umich.edu NULL); 4166313Sgblack@eecs.umich.edu} 4176313Sgblack@eecs.umich.edu 4189461Snilay@cs.wisc.eduvoid 4199461Snilay@cs.wisc.eduISA::startup(ThreadContext *tc) 4209461Snilay@cs.wisc.edu{ 4219461Snilay@cs.wisc.edu tc->getDecoderPtr()->setM5Reg(regVal[MISCREG_M5_REG]); 4229461Snilay@cs.wisc.edu} 4239461Snilay@cs.wisc.edu 4246313Sgblack@eecs.umich.edu} 4259384SAndreas.Sandberg@arm.com 4269384SAndreas.Sandberg@arm.comX86ISA::ISA * 4279384SAndreas.Sandberg@arm.comX86ISAParams::create() 4289384SAndreas.Sandberg@arm.com{ 4299384SAndreas.Sandberg@arm.com return new X86ISA::ISA(this); 4309384SAndreas.Sandberg@arm.com} 431