VirtualBox

Changeset 19141 in vbox for trunk/src/VBox/VMM/PATM


Ignore:
Timestamp:
Apr 23, 2009 1:52:18 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46372
Message:

Action flags breakup.
Fixed PGM saved state loading of 2.2.2 images.
Reduced hacks in PATM state loading (fixups).

Location:
trunk/src/VBox/VMM/PATM
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PATM/CSAM.cpp

    r18992 r19141  
    228228    pVM->csam.s.fScanningStarted = false;
    229229
    230     VM_FF_CLEAR(pVM, VM_FF_CSAM_PENDING_ACTION);
     230    PVMCPU pVCpu = &pVM->aCpus[0];  /* raw mode implies 1 VPCU */
     231    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_CSAM_PENDING_ACTION);
    231232    pVM->csam.s.cDirtyPages = 0;
    232233    /* not necessary */
     
    22632264 * @returns VBox status code.
    22642265 * @param   pVM         The VM to operate on.
    2265  */
    2266 VMMR3DECL(int) CSAMR3DoPendingAction(PVM pVM)
     2266 * @param   pVCpu       The VMCPU to operate on.
     2267 */
     2268VMMR3DECL(int) CSAMR3DoPendingAction(PVM pVM, PVMCPU pVCpu)
    22672269{
    22682270    csamR3FlushDirtyPages(pVM);
    22692271    csamR3FlushCodePages(pVM);
    22702272
    2271     VM_FF_CLEAR(pVM, VM_FF_CSAM_PENDING_ACTION);
     2273    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_CSAM_PENDING_ACTION);
    22722274    return VINF_SUCCESS;
    22732275}
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r18988 r19141  
    112112    Log(("PATMR3Init: Patch record size %d\n", sizeof(PATCHINFO)));
    113113
    114     AssertReleaseMsg(PATMInterruptFlag == (VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST),
    115                      ("Interrupt flags out of sync!! PATMInterruptFlag=%#x expected %#x. broken assembler?\n", PATMInterruptFlag, VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST));
     114    /* These values can't change as they are hardcoded in patch code (old saved states!) */
     115    AssertCompile(VM_FF_TIMER   == VMCPU_FF_TIMER);
     116    AssertCompile(VM_FF_REQUEST == VMCPU_FF_REQUEST);
     117    AssertCompile(VMCPU_FF_INTERRUPT_APIC == RT_BIT_32(0));
     118    AssertCompile(VMCPU_FF_INTERRUPT_PIC == RT_BIT_32(1));
     119
     120    AssertReleaseMsg(PATMInterruptFlag == (VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST),
     121                     ("Interrupt flags out of sync!! PATMInterruptFlag=%#x expected %#x. broken assembler?\n", PATMInterruptFlag, VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST));
    116122
    117123    /* Allocate patch memory and GC patch state memory. */
     
    62336239        }
    62346240#endif
    6235         EMSetInhibitInterruptsPC(pVM, pVCpu, pNewEip);
     6241        EMSetInhibitInterruptsPC(pVCpu, pNewEip);
    62366242        pVM->patm.s.pGCStateHC->GCPtrInhibitInterrupts = 0;
    62376243    }
  • trunk/src/VBox/VMM/PATM/PATMA.asm

    r11979 r19141  
    146146
    147147    ; if interrupts are pending, then we must go back to the host context to handle them!
    148     test    dword [ss:PATM_VM_FORCEDACTIONS], VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST
     148    test    dword [ss:PATM_VM_FORCEDACTIONS], VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST
    149149    jz      PATMClearInhibitIRQFaultIF0_Continue
    150150
     
    221221
    222222    ; if interrupts are pending, then we must go back to the host context to handle them!
    223     test    dword [ss:PATM_VM_FORCEDACTIONS], VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST
     223    test    dword [ss:PATM_VM_FORCEDACTIONS], VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST
    224224    jz      PATMClearInhibitIRQContIF0_Continue
    225225
     
    744744
    745745    ; if interrupts are pending, then we must go back to the host context to handle them!
    746     test    dword [ss:PATM_VM_FORCEDACTIONS], VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST
     746    test    dword [ss:PATM_VM_FORCEDACTIONS], VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST
    747747    jz      PATMPopf32_Continue
    748748
     
    834834
    835835    ; if interrupts are pending, then we must go back to the host context to handle them!
    836     test    dword [ss:PATM_VM_FORCEDACTIONS], VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST
     836    test    dword [ss:PATM_VM_FORCEDACTIONS], VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST
    837837    jz      PATMPopf32_NoExit_Continue
    838838
     
    922922    ; if interrupts are pending, then we must go back to the host context to handle them!
    923923    ; @note we destroy the flags here, but that should really not matter (PATM_INT3 case)
    924     test    dword [ss:PATM_VM_FORCEDACTIONS], VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST
     924    test    dword [ss:PATM_VM_FORCEDACTIONS], VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST
    925925    jz      PATMPopf16_Continue
    926926    mov     dword [ss:PATM_INTERRUPTFLAG], 1
     
    987987    ; if interrupts are pending, then we must go back to the host context to handle them!
    988988    ; @note we destroy the flags here, but that should really not matter (PATM_INT3 case)
    989     test    dword [ss:PATM_VM_FORCEDACTIONS], VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST
     989    test    dword [ss:PATM_VM_FORCEDACTIONS], VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST
    990990    jz      PATMPopf16_Continue_NoExit
    991991    mov     dword [ss:PATM_INTERRUPTFLAG], 1
     
    12381238; Note: This is very important as pending pic interrupts can be overriden by apic interrupts if we don't check early enough (Fedora 5 boot)
    12391239; @@todo fix this properly, so we can dispatch pending interrupts in GC
    1240     test    dword [ss:PATM_VM_FORCEDACTIONS], VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC
     1240    test    dword [ss:PATM_VM_FORCEDACTIONS], VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC
    12411241    jz      iret_continue
    12421242
     
    25822582; For assertion during init (to make absolutely sure the flags are in sync in vm.mac & vm.h)
    25832583GLOBALNAME PATMInterruptFlag
    2584     DD      VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_REQUEST
    2585 
     2584    DD      VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_TIMER | VMCPU_FF_REQUEST
     2585
  • trunk/src/VBox/VMM/PATM/PATMInternal.h

    r18927 r19141  
    4141#else
    4242# define PATM_SSM_VERSION                    54
     43# define PATM_SSM_VERSION_FIXUP_HACK         54
    4344# define PATM_SSM_VERSION_VER16              53
    4445#endif
     
    134135#define PATM_STAT_MEMSIZE                   (PATM_STAT_MAX_COUNTERS*sizeof(STAMRATIOU32))
    135136
     137/** aCpus[0].fLocalForcedActions fixup (must be uneven to avoid theoretical clashes with valid pointers) */
     138#define PATM_FIXUP_CPU_FF_ACTION            0xffffff01
     139/** default cpuid pointer fixup */
     140#define PATM_FIXUP_CPUID_DEFAULT            0xffffff03
     141/** standard cpuid pointer fixup */
     142#define PATM_FIXUP_CPUID_STANDARD           0xffffff05
     143/** extended cpuid pointer fixup */
     144#define PATM_FIXUP_CPUID_EXTENDED           0xffffff07
     145/** centaur cpuid pointer fixup */
     146#define PATM_FIXUP_CPUID_CENTAUR            0xffffff09
    136147
    137148typedef struct
  • trunk/src/VBox/VMM/PATM/PATMPatch.cpp

    r19075 r19141  
    287287                case PATM_VM_FORCEDACTIONS:
    288288                    /* @todo dirty assumptions when correcting this fixup during saved state loading. */
    289                     dest = pVM->pVMRC + RT_OFFSETOF(VM, fForcedActions);
     289                    dest = pVM->pVMRC + RT_OFFSETOF(VM, aCpus[0].fLocalForcedActions);
    290290                    break;
    291291
  • trunk/src/VBox/VMM/PATM/PATMSSM.cpp

    r19075 r19141  
    142142    PSSMHANDLE          pSSM = pVM->patm.s.savedstate.pSSM;
    143143    RELOCREC            rec  = *(PRELOCREC)pNode;
     144    RTRCPTR            *pFixup = (RTRCPTR *)rec.pRelocPos;
    144145
    145146    Assert(rec.pRelocPos);
     147    /* Convert pointer to an offset into patch memory. */
    146148    PATM_SUBTRACT_PTR(rec.pRelocPos, pVM->patm.s.pPatchMemHC);
     149
     150    if (rec.uType == FIXUP_ABSOLUTE)
     151    {
     152        /* Core.Key abused to store the fixup type. */
     153        if (*pFixup == pVM->pVMRC + RT_OFFSETOF(VM, aCpus[0].fLocalForcedActions))
     154            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPU_FF_ACTION;
     155        else
     156        if (*pFixup == CPUMR3GetGuestCpuIdDefRCPtr(pVM))
     157            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_DEFAULT;
     158        else
     159        if (*pFixup == CPUMR3GetGuestCpuIdStdRCPtr(pVM))
     160            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_STANDARD;
     161        else
     162        if (*pFixup == CPUMR3GetGuestCpuIdExtRCPtr(pVM))
     163            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_EXTENDED;
     164        else
     165        if (*pFixup == CPUMR3GetGuestCpuIdCentaurRCPtr(pVM))
     166            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_CENTAUR;
     167    }
    147168
    148169    /* Save the lookup record. */
     
    286307
    287308    if (    u32Version != PATM_SSM_VERSION
     309        &&  u32Version != PATM_SSM_VERSION_FIXUP_HACK
    288310        &&  u32Version != PATM_SSM_VERSION_VER16
    289311#ifdef PATM_WITH_NEW_SSM
     
    874896        }
    875897        else
    876         /* Note: rather assumptive! */
    877         if (    *pFixup >= pVM->pVMRC
     898        if (    ulSSMVersion <= PATM_SSM_VERSION_FIXUP_HACK
     899            &&  *pFixup >= pVM->pVMRC
    878900            &&  *pFixup < pVM->pVMRC + 32)
    879901        {
    880             LogFlow(("Changing fForcedActions fixup from %x to %x\n", *pFixup, pVM->pVMRC + RT_OFFSETOF(VM, fForcedActions)));
    881             *pFixup = pVM->pVMRC + RT_OFFSETOF(VM, fForcedActions);
     902            LogFlow(("Changing fLocalForcedActions fixup from %x to %x\n", *pFixup, pVM->pVMRC + RT_OFFSETOF(VM, aCpus[0].fLocalForcedActions)));
     903            *pFixup = pVM->pVMRC + RT_OFFSETOF(VM, aCpus[0].fLocalForcedActions);
    882904        }
    883905        else
    884         if (    *pFixup >= pVM->pVMRC
     906        if (    ulSSMVersion <= PATM_SSM_VERSION_FIXUP_HACK
     907            &&  *pFixup >= pVM->pVMRC
    885908            &&  *pFixup < pVM->pVMRC + 8192)
    886909        {
     
    909932        }
    910933        else
    911             AssertMsgFailed(("Unexpected fixup value %x\n", *pFixup));
     934        if (ulSSMVersion >= PATM_SSM_VERSION)
     935        {
     936#ifdef LOG_ENABLED
     937            RTRCPTR oldFixup = *pFixup;
     938#endif
     939            /* Core.Key abused to store the type of fixup */
     940            switch ((uint32_t)pRec->Core.Key)
     941            {
     942            case PATM_FIXUP_CPU_FF_ACTION:
     943                *pFixup = pVM->pVMRC + RT_OFFSETOF(VM, aCpus[0].fLocalForcedActions);
     944                LogFlow(("Changing cpu ff action fixup from %x to %x\n", oldFixup, *pFixup));
     945                break;
     946            case PATM_FIXUP_CPUID_DEFAULT:
     947                *pFixup = CPUMR3GetGuestCpuIdDefRCPtr(pVM);
     948                LogFlow(("Changing cpuid def fixup from %x to %x\n", oldFixup, *pFixup));
     949                break;
     950            case PATM_FIXUP_CPUID_STANDARD:
     951                *pFixup = CPUMR3GetGuestCpuIdStdRCPtr(pVM);
     952                LogFlow(("Changing cpuid std fixup from %x to %x\n", oldFixup, *pFixup));
     953                break;
     954            case PATM_FIXUP_CPUID_EXTENDED:
     955                *pFixup = CPUMR3GetGuestCpuIdExtRCPtr(pVM);
     956                LogFlow(("Changing cpuid ext fixup from %x to %x\n", oldFixup, *pFixup));
     957                break;
     958            case PATM_FIXUP_CPUID_CENTAUR:
     959                *pFixup = CPUMR3GetGuestCpuIdCentaurRCPtr(pVM);
     960                LogFlow(("Changing cpuid centaur fixup from %x to %x\n", oldFixup, *pFixup));
     961                break;
     962            default:
     963                AssertMsgFailed(("Unexpected fixup value %x\n", *pFixup));
     964                break;
     965            }
     966        }
    912967
    913968#ifdef RT_OS_WINDOWS
    914         AssertCompile(RT_OFFSETOF(VM, fForcedActions) < 32);
     969        AssertCompile(RT_OFFSETOF(VM, fGlobalForcedActions) < 32);
    915970#endif
    916971        break;
  • trunk/src/VBox/VMM/PATM/VMMAll/CSAMAll.cpp

    r14299 r19141  
    3737#include "CSAMInternal.h"
    3838#include <VBox/vm.h>
     39#include <VBox/vmm.h>
    3940#include <VBox/dbg.h>
    4041#include <VBox/err.h>
     
    6869
    6970    STAM_COUNTER_ADD(&pVM->csam.s.StatNrTraps, 1);
    70     VM_FF_SET(pVM, VM_FF_CSAM_SCAN_PAGE);
     71    VMCPU_FF_SET(VMMGetCpu0(pVM), VMCPU_FF_CSAM_SCAN_PAGE);
    7172    return VINF_CSAM_PENDING_ACTION;
    7273}
     
    205206    {
    206207        pVM->csam.s.pvPossibleCodePage[pVM->csam.s.cPossibleCodePages++] = (RTRCPTR)GCPtr;
    207         VM_FF_SET(pVM, VM_FF_CSAM_PENDING_ACTION);
     208        VMCPU_FF_SET(VMMGetCpu0(pVM), VMCPU_FF_CSAM_PENDING_ACTION);
    208209    }
    209210    return;
  • trunk/src/VBox/VMM/PATM/VMMAll/PATMAll.cpp

    r18927 r19141  
    191191        if (CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts == (RTRCPTR)pCtxCore->eip)
    192192        {
    193             EMSetInhibitInterruptsPC(pVM, VMMGetCpu0(pVM), pCtxCore->eip);
     193            EMSetInhibitInterruptsPC(VMMGetCpu0(pVM), pCtxCore->eip);
    194194        }
    195195        CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts = 0;
  • trunk/src/VBox/VMM/PATM/VMMGC/CSAMGC.cpp

    r18988 r19141  
    117117    }
    118118
    119     VM_FF_SET(pVM, VM_FF_CSAM_PENDING_ACTION);
     119    VMCPU_FF_SET(pVCpu, VMCPU_FF_CSAM_PENDING_ACTION);
    120120
    121121    /* Note that pvFault might be a different address in case of aliases. So use pvRange + offset instead!. */
Note: See TracChangeset for help on using the changeset viewer.

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