Changeset 106635 in vbox for trunk/src/VBox/HostDrivers/Support/SUPLibAll.cpp
- Timestamp:
- Oct 23, 2024 9:30:37 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPLibAll.cpp
r106061 r106635 49 49 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 50 50 # include <iprt/asm-amd64-x86.h> 51 #elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 52 # include <iprt/asm-arm.h> 51 53 #endif 52 54 #include <iprt/errcore.h> … … 57 59 58 60 59 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 61 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 60 62 /** 61 63 * The slow case for SUPReadTsc where we need to apply deltas. … … 83 85 * Read the TSC and get the corresponding aCPUs index. 84 86 */ 85 #ifdef IN_RING3 87 # ifdef IN_RING3 88 # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 86 89 if (pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS) 87 90 { … … 163 166 for (;;) 164 167 { 165 uint8_t idApic = ASMGetApicId();168 uint8_t const idApic = ASMGetApicId(); 166 169 uTsc = ASMReadTSC(); 167 170 if (RT_LIKELY(ASMGetApicId() == idApic)) … … 178 181 } 179 182 } 183 184 # else /* !AMD64 || !X86 */ 185 # if defined(RT_OS_WINDOWS) 186 /* Use TPIDRRO_EL0 (=cpu number) before and after reading the TSC. */ 187 uint32_t cTries = 0; 188 for (;;) 189 { 190 RTCCUINTREG const idApic = ASMGetThreadIdRoEL0(); 191 uTsc = ASMReadTSC(); 192 if (RT_LIKELY(ASMGetThreadIdRoEL0() == idApic)) 193 { 194 AssertBreakStmt(idApic < RT_ELEMENTS(pGip->aiCpuFromApicId), iGipCpu = UINT16_MAX); 195 iGipCpu = pGip->aiCpuFromApicId[idApic & 0xffff]; 196 break; 197 } 198 if (cTries >= 16) 199 { 200 iGipCpu = UINT16_MAX; 201 break; 202 } 203 cTries++; 204 } 205 # else 206 /* Use RTMpCpuId before and after reading the TSC. */ 207 uint32_t cTries = 0; 208 for (;;) 209 { 210 RTCPUID const idCpu = RTMpCpuId(); 211 uTsc = ASMReadTSC(); 212 if (RT_LIKELY(RTMpCpuId() == idCpu)) 213 { 214 int const iCpuSet = RTMpCpuIdToSetIndex(idCpu); 215 iGipCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet]; 216 break; 217 } 218 if (cTries >= 16) 219 { 220 iGipCpu = UINT16_MAX; 221 break; 222 } 223 cTries++; 224 } 225 # endif 226 # endif /* !AMD64 || !X86 */ 227 180 228 #elif defined(IN_RING0) 181 229 /* Ring-0: Use use RTMpCpuId(), no loops. */ … … 234 282 SUPR0_EXPORT_SYMBOL(SUPReadTscWithDelta); 235 283 # endif 236 #endif /* RT_ARCH_AMD64 || RT_ARCH_X86*/284 #endif /* defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) */ 237 285 238 286
Note:
See TracChangeset
for help on using the changeset viewer.