VirtualBox

Changeset 107227 in vbox for trunk/src/VBox/VMM/VMMR3/EM.cpp


Ignore:
Timestamp:
Dec 4, 2024 3:20:14 PM (6 weeks ago)
Author:
vboxsync
Message:

VMM: Cleaning up ARMv8 / x86 split. jiraref:VBP-1470

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r107194 r107227  
    116116
    117117    int rc = CFGMR3QueryBoolDef(pCfgEM, "IemExecutesAll", &pVM->em.s.fIemExecutesAll,
    118 #if defined(RT_ARCH_ARM64) && defined(RT_OS_DARWIN) && !defined(VBOX_VMM_TARGET_ARMV8)
     118#if (defined(VBOX_VMM_TARGET_X86)   && !defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) \
     119 || (defined(VBOX_VMM_TARGET_ARMV8) && !defined(RT_ARCH_ARM64)) /** @todo not main exec engine = iem/recomp would be better... */
    119120                                true
    120121#else
     
    706707#endif /* LOG_ENABLED || VBOX_STRICT */
    707708
    708 #if !defined(VBOX_VMM_TARGET_ARMV8)
     709#ifdef VBOX_VMM_TARGET_X86
    709710
    710711/**
     
    852853}
    853854
    854 #endif /* VBOX_VMM_TARGET_ARMV8 */
     855#endif /* VBOX_VMM_TARGET_X86 */
    855856
    856857/**
     
    885886                    rc = EMR3HmSingleInstruction(pVM, pVCpu, 0 /*fFlags*/);
    886887#endif
    887 #if !defined(VBOX_VMM_TARGET_ARMV8)
    888888                else if (pVCpu->em.s.enmState == EMSTATE_DEBUG_GUEST_NEM)
    889889                    rc = VBOXSTRICTRC_TODO(emR3NemSingleInstruction(pVM, pVCpu, 0 /*fFlags*/));
    890890                else
    891891                {
     892#if defined(VBOX_VMM_TARGET_X86) /** @todo IEM/arm64 */
    892893                    rc = IEMExecOne(pVCpu); /** @todo add dedicated interface... */
    893894                    if (rc == VINF_SUCCESS || rc == VINF_EM_RESCHEDULE)
    894895                        rc = VINF_EM_DBG_STEPPED;
     896#else
     897                    AssertFailed();
     898                    rc = VBOXSTRICTRC_TODO(emR3NemSingleInstruction(pVM, pVCpu, 0 /*fFlags*/));
     899#endif
    895900                }
    896901
     902#ifdef VBOX_VMM_TARGET_X86
    897903                if (rc != VINF_EM_EMULATE_SPLIT_LOCK)
    898904                { /* likely */ }
     
    903909                        rc = VINF_EM_DBG_STEPPED;
    904910                }
    905 #else
    906                 AssertMsg(pVCpu->em.s.enmState == EMSTATE_DEBUG_GUEST_NEM,
    907                           ("%u\n", pVCpu->em.s.enmState));
    908                 rc = VBOXSTRICTRC_TODO(emR3NemSingleInstruction(pVM, pVCpu, 0 /*fFlags*/));
    909911#endif
    910912                break;
     
    10721074#ifdef VBOX_VMM_TARGET_ARMV8
    10731075    LogFlow(("emR3RecompilerExecute/%u: (pc=%RGv)\n", pVCpu->idCpu, (RTGCPTR)pVCpu->cpum.GstCtx.Pc.u64));
     1076#elif defined(VBOX_VMM_TARGET_X86)
     1077    LogFlow(("emR3RecompilerExecute/%u: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip));
    10741078#else
    1075     LogFlow(("emR3RecompilerExecute/%u: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip));
     1079# error "port me"
    10761080#endif
    10771081
     
    10851089#ifdef LOG_ENABLED
    10861090# if defined(VBOX_VMM_TARGET_ARMV8)
    1087         Log3(("EM: pc=%08x\n", CPUMGetGuestFlatPC(pVCpu)));
    1088 # else
     1091        Log3(("EM: pc=%08RX64\n", CPUMGetGuestFlatPC(pVCpu)));
     1092# elif defined(VBOX_VMM_TARGET_X86)
    10891093        if (!pVCpu->cpum.GstCtx.eflags.Bits.u1VM)
    10901094            Log(("EMR%d: %04X:%08RX64 RSP=%08RX64 IF=%d CR0=%x eflags=%x\n", CPUMGetGuestCPL(pVCpu), pVCpu->cpum.GstCtx.cs.Sel,
     
    10931097        else
    10941098            Log(("EMV86: %04X:%08X IF=%d\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF));
     1099# else
     1100#  error "port me"
    10951101# endif
    10961102#endif
     
    11741180         * Check if we can switch back to the main execution engine now.
    11751181         */
    1176 #if !defined(VBOX_VMM_TARGET_ARMV8)
     1182#ifdef VBOX_WITH_HWVIRT
    11771183        if (VM_IS_HM_ENABLED(pVM))
    11781184        {
     
    12741280        PDMCritSectBothFF(pVM, pVCpu);
    12751281
    1276 #if !defined(VBOX_VMM_TARGET_ARMV8)
     1282#ifdef VBOX_VMM_TARGET_X86
    12771283    /* Update CR3 (Nested Paging case for HM). */
    12781284    if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_HM_UPDATE_CR3))
     
    13121318}
    13131319
    1314 
    1315 #if !defined(VBOX_VMM_TARGET_ARMV8)
     1320#ifdef VBOX_VMM_TARGET_X86
     1321
    13161322/**
    13171323 * Helper for emR3ForcedActions() for VMX external interrupt VM-exit.
     
    13231329static int emR3VmxNstGstIntrIntercept(PVMCPU pVCpu)
    13241330{
    1325 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     1331# ifdef VBOX_WITH_NESTED_HWVIRT_VMX
    13261332    /* Handle the "external interrupt" VM-exit intercept. */
    13271333    if (    CPUMIsGuestVmxPinCtlsSet(&pVCpu->cpum.GstCtx, VMX_PIN_CTLS_EXT_INT_EXIT)
     
    13341340        return VBOXSTRICTRC_VAL(rcStrict);
    13351341    }
    1336 #else
     1342# else
    13371343    RT_NOREF(pVCpu);
    1338 #endif
     1344# endif
    13391345    return VINF_NO_CHANGE;
    13401346}
     
    13501356static int emR3SvmNstGstIntrIntercept(PVMCPU pVCpu)
    13511357{
    1352 #ifdef VBOX_WITH_NESTED_HWVIRT_SVM
     1358# ifdef VBOX_WITH_NESTED_HWVIRT_SVM
    13531359    /* Handle the physical interrupt intercept (can be masked by the nested hypervisor). */
    13541360    if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, &pVCpu->cpum.GstCtx, SVM_CTRL_INTERCEPT_INTR))
     
    13661372        return VINF_EM_TRIPLE_FAULT;
    13671373    }
    1368 #else
     1374# else
    13691375    NOREF(pVCpu);
    1370 #endif
     1376# endif
    13711377    return VINF_NO_CHANGE;
    13721378}
     
    13821388static int emR3SvmNstGstVirtIntrIntercept(PVMCPU pVCpu)
    13831389{
    1384 #ifdef VBOX_WITH_NESTED_HWVIRT_SVM
     1390# ifdef VBOX_WITH_NESTED_HWVIRT_SVM
    13851391    if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, &pVCpu->cpum.GstCtx, SVM_CTRL_INTERCEPT_VINTR))
    13861392    {
     
    13951401        return VINF_EM_TRIPLE_FAULT;
    13961402    }
    1397 #else
     1403# else
    13981404    NOREF(pVCpu);
    1399 #endif
     1405# endif
    14001406    return VINF_NO_CHANGE;
    14011407}
    1402 #endif
    1403 
     1408
     1409#endif /* VBOX_VMM_TARGET_X86 */
    14041410
    14051411/**
     
    16581664            TMR3TimerQueuesDo(pVM);
    16591665
    1660 #if !defined(VBOX_VMM_TARGET_ARMV8)
     1666#ifdef VBOX_VMM_TARGET_X86
    16611667        /*
    16621668         * Pick up asynchronously posted interrupts into the APIC.
     
    18031809            Assert(!VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_VMX_APIC_WRITE | VMCPU_FF_VMX_MTF | VMCPU_FF_VMX_PREEMPT_TIMER));
    18041810        }
    1805 # endif
     1811# endif /* VBOX_WITH_NESTED_HWVIRT_VMX */
    18061812
    18071813        /*
     
    19591965        }
    19601966
    1961 #else /* VBOX_VMM_TARGET_ARMV8 */
     1967#else  /* VBOX_VMM_TARGET_ARMV8 */
    19621968        bool fWakeupPending = false;
    1963 
    19641969        if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_VTIMER_ACTIVATED))
    19651970        {
     
    20812086        /* check that we got them all  */
    20822087        AssertCompile(VM_FF_HIGH_PRIORITY_PRE_MASK == (VM_FF_TM_VIRTUAL_SYNC | VM_FF_DBGF | VM_FF_CHECK_VM_STATE | VM_FF_DEBUG_SUSPEND | VM_FF_PGM_NEED_HANDY_PAGES | VM_FF_PGM_NO_MEMORY | VM_FF_EMT_RENDEZVOUS));
    2083 #if defined(VBOX_VMM_TARGET_ARMV8)
     2088#ifdef VBOX_VMM_TARGET_ARMV8
    20842089        AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_IRQ | VMCPU_FF_INTERRUPT_FIQ | VMCPU_FF_DBGF));
     2090#elif defined(VBOX_VMM_TARGET_X86)
     2091        AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL | VMCPU_FF_DBGF | VMCPU_FF_INTERRUPT_NESTED_GUEST | VMCPU_FF_VMX_MTF | VMCPU_FF_VMX_APIC_WRITE | VMCPU_FF_VMX_PREEMPT_TIMER | VMCPU_FF_VMX_INT_WINDOW | VMCPU_FF_VMX_NMI_WINDOW));
    20852092#else
    2086         AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL | VMCPU_FF_DBGF | VMCPU_FF_INTERRUPT_NESTED_GUEST | VMCPU_FF_VMX_MTF | VMCPU_FF_VMX_APIC_WRITE | VMCPU_FF_VMX_PREEMPT_TIMER | VMCPU_FF_VMX_INT_WINDOW | VMCPU_FF_VMX_NMI_WINDOW));
     2093# error "port me"
    20872094#endif
    20882095    }
     
    22092216                fFFDone = false;
    22102217
    2211 #if defined(VBOX_STRICT) && !defined(VBOX_VMM_TARGET_ARMV8)
     2218#if defined(VBOX_STRICT) && defined(VBOX_VMM_TARGET_X86)
    22122219            CPUMAssertGuestRFlagsCookie(pVM, pVCpu);
    22132220#endif
     
    22332240                    if (!pVM->em.s.fIemExecutesAll)
    22342241                    {
    2235 #if !defined(VBOX_VMM_TARGET_ARMV8)
     2242#ifdef VBOX_WITH_HWVIRT
    22362243                        if (VM_IS_HM_ENABLED(pVM))
    22372244                        {
     
    25972604                    else if (rc == VINF_SUCCESS)
    25982605                        rc = VINF_EM_RESCHEDULE; /* Need to check whether we can run in HM or NEM again. */
    2599 #ifndef VBOX_VMM_TARGET_ARMV8
     2606#ifdef VBOX_VMM_TARGET_X86
    26002607                    if (rc != VINF_EM_EMULATE_SPLIT_LOCK)
    26012608                    { /* likely */ }
     
    26242631                    if (TRPMHasTrap(pVCpu))
    26252632                        rc = VINF_EM_RESCHEDULE;
    2626 #if !defined(VBOX_VMM_TARGET_ARMV8)
     2633#ifdef VBOX_VMM_TARGET_X86
    26272634                    /* MWAIT has a special extension where it's woken up when
    26282635                       an interrupt is pending even when IF=0. */
     
    26492656                    else
    26502657                    {
    2651 #if defined(VBOX_VMM_TARGET_ARMV8)
     2658#ifdef VBOX_VMM_TARGET_ARMV8
    26522659                        const uint32_t fWaitHalted = 0; /* WFI/WFE always return when an interrupt happens. */
    2653 #else
     2660#elif defined(VBOX_VMM_TARGET_X86)
    26542661                        const uint32_t fWaitHalted = (CPUMGetGuestEFlags(pVCpu) & X86_EFL_IF) ? 0 : VMWAITHALTED_F_IGNORE_IRQS;
    26552662#endif
    26562663                        rc = VMR3WaitHalted(pVM, pVCpu, fWaitHalted);
     2664
    26572665                        /* We're only interested in NMI/SMIs here which have their own FFs, so we don't need to
    26582666                           check VMCPU_FF_UPDATE_APIC here. */
    26592667                        if (   rc == VINF_SUCCESS
    2660 #if defined(VBOX_VMM_TARGET_ARMV8)
    2661                             && VMCPU_FF_IS_ANY_SET(pVCpu,   VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI | VMCPU_FF_VTIMER_ACTIVATED
    2662                                                           | VMCPU_FF_INTERRUPT_FIQ | VMCPU_FF_INTERRUPT_IRQ)
     2668#ifdef VBOX_VMM_TARGET_ARMV8
     2669                            && VMCPU_FF_IS_ANY_SET(pVCpu,   VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI
     2670                                                          | VMCPU_FF_INTERRUPT_FIQ | VMCPU_FF_INTERRUPT_IRQ
     2671                                                          | VMCPU_FF_VTIMER_ACTIVATED)
     2672#elif defined(VBOX_VMM_TARGET_X86)
     2673                            && VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI | VMCPU_FF_UNHALT)
    26632674#else
    2664                             && VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI | VMCPU_FF_UNHALT)
     2675# error "port me"
    26652676#endif
    26662677                            )
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