Deleted Added
sdiff udiff text old ( 12577:5cafe57f87e5 ) new ( 12604:0cf3d5d3bd3e )
full compact
1/*
2 * Copyright (c) 2010-2016 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 696 unchanged lines hidden (view full) ---

705
706} // anonymous namespace
707
708void
709ISA::setMiscReg(int misc_reg, const MiscReg &val, ThreadContext *tc)
710{
711
712 MiscReg newVal = val;
713 int x;
714 bool secure_lookup;
715 bool hyp;
716 System *sys;
717 ThreadContext *oc;
718 uint8_t target_el;
719 uint16_t asid;
720 SCR scr;
721
722 if (misc_reg == MISCREG_CPSR) {
723 updateRegMap(val);
724
725

--- 298 unchanged lines hidden (view full) ---

1024
1025 // TLBI all entries, EL0&1 inner sharable (ignored)
1026 case MISCREG_TLBIALLIS:
1027 case MISCREG_TLBIALL: // TLBI all entries, EL0&1,
1028 assert32(tc);
1029 target_el = 1; // el 0 and 1 are handled together
1030 scr = readMiscReg(MISCREG_SCR, tc);
1031 secure_lookup = haveSecurity && !scr.ns;
1032 sys = tc->getSystemPtr();
1033 for (x = 0; x < sys->numContexts(); x++) {
1034 oc = sys->getThreadContext(x);
1035 getITBPtr(oc)->flushAllSecurity(secure_lookup, target_el);
1036 getDTBPtr(oc)->flushAllSecurity(secure_lookup, target_el);
1037
1038 // If CheckerCPU is connected, need to notify it of a flush
1039 CheckerCPU *checker = oc->getCheckerCpuPtr();
1040 if (checker) {
1041 getITBPtr(checker)->flushAllSecurity(secure_lookup,
1042 target_el);
1043 getDTBPtr(checker)->flushAllSecurity(secure_lookup,
1044 target_el);
1045 }
1046 }
1047 return;
1048 // TLBI all entries, EL0&1, instruction side
1049 case MISCREG_ITLBIALL:
1050 assert32(tc);
1051 target_el = 1; // el 0 and 1 are handled together
1052 scr = readMiscReg(MISCREG_SCR, tc);
1053 secure_lookup = haveSecurity && !scr.ns;
1054 getITBPtr(tc)->flushAllSecurity(secure_lookup, target_el);

--- 13 unchanged lines hidden (view full) ---

1068 // regardless of the level of lookup, since in gem5 we cache
1069 // in the tlb the last level of lookup only.
1070 case MISCREG_TLBIMVA:
1071 case MISCREG_TLBIMVAIS:
1072 assert32(tc);
1073 target_el = 1; // el 0 and 1 are handled together
1074 scr = readMiscReg(MISCREG_SCR, tc);
1075 secure_lookup = haveSecurity && !scr.ns;
1076 sys = tc->getSystemPtr();
1077 for (x = 0; x < sys->numContexts(); x++) {
1078 oc = sys->getThreadContext(x);
1079 getITBPtr(oc)->flushMvaAsid(mbits(newVal, 31, 12),
1080 bits(newVal, 7,0),
1081 secure_lookup, target_el);
1082 getDTBPtr(oc)->flushMvaAsid(mbits(newVal, 31, 12),
1083 bits(newVal, 7,0),
1084 secure_lookup, target_el);
1085
1086 CheckerCPU *checker = oc->getCheckerCpuPtr();
1087 if (checker) {
1088 getITBPtr(checker)->flushMvaAsid(mbits(newVal, 31, 12),
1089 bits(newVal, 7,0), secure_lookup, target_el);
1090 getDTBPtr(checker)->flushMvaAsid(mbits(newVal, 31, 12),
1091 bits(newVal, 7,0), secure_lookup, target_el);
1092 }
1093 }
1094 return;
1095 // TLBI by ASID, EL0&1, inner sharable
1096 case MISCREG_TLBIASIDIS:
1097 case MISCREG_TLBIASID:
1098 assert32(tc);
1099 target_el = 1; // el 0 and 1 are handled together
1100 scr = readMiscReg(MISCREG_SCR, tc);
1101 secure_lookup = haveSecurity && !scr.ns;
1102 sys = tc->getSystemPtr();
1103 for (x = 0; x < sys->numContexts(); x++) {
1104 oc = sys->getThreadContext(x);
1105 getITBPtr(oc)->flushAsid(bits(newVal, 7,0),
1106 secure_lookup, target_el);
1107 getDTBPtr(oc)->flushAsid(bits(newVal, 7,0),
1108 secure_lookup, target_el);
1109 CheckerCPU *checker = oc->getCheckerCpuPtr();
1110 if (checker) {
1111 getITBPtr(checker)->flushAsid(bits(newVal, 7,0),
1112 secure_lookup, target_el);
1113 getDTBPtr(checker)->flushAsid(bits(newVal, 7,0),
1114 secure_lookup, target_el);
1115 }
1116 }
1117 return;
1118 // TLBI by address, EL0&1, inner sharable (ignored)
1119 case MISCREG_TLBIMVAAL:
1120 case MISCREG_TLBIMVAALIS:
1121 // mcr tlbimvaal(is) is invalidating all matching entries
1122 // regardless of the level of lookup, since in gem5 we cache
1123 // in the tlb the last level of lookup only.
1124 case MISCREG_TLBIMVAA:
1125 case MISCREG_TLBIMVAAIS:
1126 assert32(tc);
1127 target_el = 1; // el 0 and 1 are handled together
1128 scr = readMiscReg(MISCREG_SCR, tc);
1129 secure_lookup = haveSecurity && !scr.ns;
1130 hyp = 0;
1131 tlbiMVA(tc, newVal, secure_lookup, hyp, target_el);
1132 return;
1133 // TLBI by address, EL2, hypervisor mode
1134 case MISCREG_TLBIMVALH:
1135 case MISCREG_TLBIMVALHIS:
1136 // mcr tlbimvalh(is) is invalidating all matching entries
1137 // regardless of the level of lookup, since in gem5 we cache
1138 // in the tlb the last level of lookup only.
1139 case MISCREG_TLBIMVAH:
1140 case MISCREG_TLBIMVAHIS:
1141 assert32(tc);
1142 target_el = 1; // aarch32, use hyp bit
1143 scr = readMiscReg(MISCREG_SCR, tc);
1144 secure_lookup = haveSecurity && !scr.ns;
1145 hyp = 1;
1146 tlbiMVA(tc, newVal, secure_lookup, hyp, target_el);
1147 return;
1148 case MISCREG_TLBIIPAS2L:
1149 case MISCREG_TLBIIPAS2LIS:
1150 // mcr tlbiipas2l(is) is invalidating all matching entries
1151 // regardless of the level of lookup, since in gem5 we cache
1152 // in the tlb the last level of lookup only.
1153 case MISCREG_TLBIIPAS2:
1154 case MISCREG_TLBIIPAS2IS:

--- 91 unchanged lines hidden (view full) ---

1246 case MISCREG_TLBI_VAE3_Xt:
1247 // TLBI by VA, EL3 regime stage 1, last level walk
1248 case MISCREG_TLBI_VALE3IS_Xt:
1249 case MISCREG_TLBI_VALE3_Xt:
1250 assert64(tc);
1251 target_el = 3;
1252 asid = 0xbeef; // does not matter, tlbi is global
1253 secure_lookup = true;
1254 tlbiVA(tc, newVal, asid, secure_lookup, target_el);
1255 return;
1256 // TLBI by VA, EL2
1257 case MISCREG_TLBI_VAE2IS_Xt:
1258 case MISCREG_TLBI_VAE2_Xt:
1259 // TLBI by VA, EL2, stage1 last level walk
1260 case MISCREG_TLBI_VALE2IS_Xt:
1261 case MISCREG_TLBI_VALE2_Xt:
1262 assert64(tc);
1263 target_el = 2;
1264 asid = 0xbeef; // does not matter, tlbi is global
1265 scr = readMiscReg(MISCREG_SCR, tc);
1266 secure_lookup = haveSecurity && !scr.ns;
1267 tlbiVA(tc, newVal, asid, secure_lookup, target_el);
1268 return;
1269 // TLBI by VA EL1 & 0, stage1, ASID, current VMID
1270 case MISCREG_TLBI_VAE1IS_Xt:
1271 case MISCREG_TLBI_VAE1_Xt:
1272 case MISCREG_TLBI_VALE1IS_Xt:
1273 case MISCREG_TLBI_VALE1_Xt:
1274 assert64(tc);
1275 asid = bits(newVal, 63, 48);
1276 target_el = 1; // el 0 and 1 are handled together
1277 scr = readMiscReg(MISCREG_SCR, tc);
1278 secure_lookup = haveSecurity && !scr.ns;
1279 tlbiVA(tc, newVal, asid, secure_lookup, target_el);
1280 return;
1281 // AArch64 TLBI: invalidate by ASID, stage 1, current VMID
1282 // @todo: handle VMID to enable Virtualization
1283 case MISCREG_TLBI_ASIDE1IS_Xt:
1284 case MISCREG_TLBI_ASIDE1_Xt:
1285 assert64(tc);
1286 target_el = 1; // el 0 and 1 are handled together
1287 scr = readMiscReg(MISCREG_SCR, tc);
1288 secure_lookup = haveSecurity && !scr.ns;
1289 sys = tc->getSystemPtr();
1290 for (x = 0; x < sys->numContexts(); x++) {
1291 oc = sys->getThreadContext(x);
1292 asid = bits(newVal, 63, 48);
1293 if (!haveLargeAsid64)
1294 asid &= mask(8);
1295 getITBPtr(oc)->flushAsid(asid, secure_lookup, target_el);
1296 getDTBPtr(oc)->flushAsid(asid, secure_lookup, target_el);
1297 CheckerCPU *checker = oc->getCheckerCpuPtr();
1298 if (checker) {
1299 getITBPtr(checker)->flushAsid(asid,
1300 secure_lookup, target_el);
1301 getDTBPtr(checker)->flushAsid(asid,
1302 secure_lookup, target_el);
1303 }
1304 }
1305 return;
1306 // AArch64 TLBI: invalidate by VA, ASID, stage 1, current VMID
1307 // VAAE1(IS) and VAALE1(IS) are the same because TLBs only store
1308 // entries from the last level of translation table walks
1309 // @todo: handle VMID to enable Virtualization
1310 case MISCREG_TLBI_VAAE1IS_Xt:
1311 case MISCREG_TLBI_VAAE1_Xt:
1312 case MISCREG_TLBI_VAALE1IS_Xt:
1313 case MISCREG_TLBI_VAALE1_Xt:
1314 assert64(tc);
1315 target_el = 1; // el 0 and 1 are handled together
1316 scr = readMiscReg(MISCREG_SCR, tc);
1317 secure_lookup = haveSecurity && !scr.ns;
1318 sys = tc->getSystemPtr();
1319 for (x = 0; x < sys->numContexts(); x++) {
1320 // @todo: extra controls on TLBI broadcast?
1321 oc = sys->getThreadContext(x);
1322 Addr va = ((Addr) bits(newVal, 43, 0)) << 12;
1323 getITBPtr(oc)->flushMva(va,
1324 secure_lookup, false, target_el);
1325 getDTBPtr(oc)->flushMva(va,
1326 secure_lookup, false, target_el);
1327
1328 CheckerCPU *checker = oc->getCheckerCpuPtr();
1329 if (checker) {
1330 getITBPtr(checker)->flushMva(va,
1331 secure_lookup, false, target_el);
1332 getDTBPtr(checker)->flushMva(va,
1333 secure_lookup, false, target_el);
1334 }
1335 }
1336 return;
1337 // AArch64 TLBI: invalidate by IPA, stage 2, current VMID
1338 case MISCREG_TLBI_IPAS2LE1IS_Xt:
1339 case MISCREG_TLBI_IPAS2LE1_Xt:
1340 case MISCREG_TLBI_IPAS2E1IS_Xt:
1341 case MISCREG_TLBI_IPAS2E1_Xt:
1342 assert64(tc);
1343 target_el = 1; // EL 0 and 1 are handled together

--- 442 unchanged lines hidden (view full) ---

1786 getGenericTimer(tc).setMiscReg(misc_reg, newVal);
1787 break;
1788 }
1789 }
1790 setMiscRegNoEffect(misc_reg, newVal);
1791}
1792
1793void
1794ISA::tlbiVA(ThreadContext *tc, MiscReg newVal, uint16_t asid,
1795 bool secure_lookup, uint8_t target_el)
1796{
1797 if (!haveLargeAsid64)
1798 asid &= mask(8);
1799 Addr va = ((Addr) bits(newVal, 43, 0)) << 12;
1800 System *sys = tc->getSystemPtr();
1801 for (int x = 0; x < sys->numContexts(); x++) {
1802 ThreadContext *oc = sys->getThreadContext(x);
1803 getITBPtr(oc)->flushMvaAsid(va, asid,
1804 secure_lookup, target_el);
1805 getDTBPtr(oc)->flushMvaAsid(va, asid,
1806 secure_lookup, target_el);
1807

--- 40 unchanged lines hidden (view full) ---

1848 if (checker) {
1849 getITBPtr(checker)->flushAllNs(hyp, target_el);
1850 getDTBPtr(checker)->flushAllNs(hyp, target_el);
1851 }
1852 }
1853}
1854
1855void
1856ISA::tlbiMVA(ThreadContext *tc, MiscReg newVal, bool secure_lookup, bool hyp,
1857 uint8_t target_el)
1858{
1859 System *sys = tc->getSystemPtr();
1860 for (int x = 0; x < sys->numContexts(); x++) {
1861 ThreadContext *oc = sys->getThreadContext(x);
1862 getITBPtr(oc)->flushMva(mbits(newVal, 31,12),
1863 secure_lookup, hyp, target_el);
1864 getDTBPtr(oc)->flushMva(mbits(newVal, 31,12),
1865 secure_lookup, hyp, target_el);
1866
1867 CheckerCPU *checker = oc->getCheckerCpuPtr();
1868 if (checker) {
1869 getITBPtr(checker)->flushMva(mbits(newVal, 31,12),
1870 secure_lookup, hyp, target_el);
1871 getDTBPtr(checker)->flushMva(mbits(newVal, 31,12),
1872 secure_lookup, hyp, target_el);
1873 }
1874 }
1875}
1876
1877void
1878ISA::tlbiIPA(ThreadContext *tc, MiscReg newVal, bool secure_lookup,
1879 uint8_t target_el)
1880{

--- 11 unchanged lines hidden (view full) ---

1892 getITBPtr(checker)->flushIpaVmid(ipa,
1893 secure_lookup, false, target_el);
1894 getDTBPtr(checker)->flushIpaVmid(ipa,
1895 secure_lookup, false, target_el);
1896 }
1897 }
1898}
1899
1900BaseISADevice &
1901ISA::getGenericTimer(ThreadContext *tc)
1902{
1903 // We only need to create an ISA interface the first time we try
1904 // to access the timer.
1905 if (timer)
1906 return *timer.get();
1907

--- 18 unchanged lines hidden ---