VirtualBox

Ignore:
Timestamp:
Oct 23, 2024 9:30:37 PM (3 months ago)
Author:
vboxsync
Message:

SUPDrv: Making it build on win.arm64... jiraref:VBP-1253

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPLibAll.cpp

    r106061 r106635  
    4949#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    5050# include <iprt/asm-amd64-x86.h>
     51#elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)
     52# include <iprt/asm-arm.h>
    5153#endif
    5254#include <iprt/errcore.h>
     
    5759
    5860
    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)
    6062/**
    6163 * The slow case for SUPReadTsc where we need to apply deltas.
     
    8385     * Read the TSC and get the corresponding aCPUs index.
    8486     */
    85 #ifdef IN_RING3
     87# ifdef IN_RING3
     88#  if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    8689    if (pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS)
    8790    {
     
    163166        for (;;)
    164167        {
    165             uint8_t idApic = ASMGetApicId();
     168            uint8_t const idApic = ASMGetApicId();
    166169            uTsc = ASMReadTSC();
    167170            if (RT_LIKELY(ASMGetApicId() == idApic))
     
    178181        }
    179182    }
     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
    180228#elif defined(IN_RING0)
    181229    /* Ring-0: Use use RTMpCpuId(), no loops. */
     
    234282SUPR0_EXPORT_SYMBOL(SUPReadTscWithDelta);
    235283# 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) */
    237285
    238286
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette