VirtualBox

Changeset 5285

Show
Ignore:
Timestamp:
10/14/07 01:55:58 (1 year ago)
Author:
vboxsync
Message:

deal with the centaur cpuid stuff.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/cpum.h

    r4208 r5285  
    291291CPUMDECL(GCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdStdGCPtr(PVM pVM); 
    292292CPUMDECL(GCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdExtGCPtr(PVM pVM); 
     293CPUMDECL(GCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdCentaurGCPtr(PVM pVM); 
    293294CPUMDECL(GCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdDefGCPtr(PVM pVM); 
    294295CPUMDECL(uint32_t)  CPUMGetGuestCpuIdStdMax(PVM pVM); 
    295296CPUMDECL(uint32_t)  CPUMGetGuestCpuIdExtMax(PVM pVM); 
     297CPUMDECL(uint32_t)  CPUMGetGuestCpuIdCentaurMax(PVM pVM); 
    296298CPUMDECL(CPUMSELREGHID *) CPUMGetGuestTRHid(PVM pVM); 
    297299/** @} */ 
  • trunk/include/VBox/vm.h

    r5211 r5285  
    357357#endif 
    358358#ifdef VBOX_WITH_HYBIRD_32BIT_KERNEL 
    359         char        padding[3584];                                  /* multiple of 32 */ 
     359        char        padding[3606];                                  /* multiple of 32 */ 
    360360#else 
    361         char        padding[HC_ARCH_BITS == 32 ? 3424 : 3552];      /* multiple of 32 */ 
     361        char        padding[HC_ARCH_BITS == 32 ? 3456 : 3584];      /* multiple of 32 */ 
    362362#endif 
    363363    } cpum; 
  • trunk/include/VBox/vm.mac

    r4958 r5285  
    66; 
    77;  Copyright (C) 2006-2007 innotek GmbH 
    8 ;  
     8; 
    99;  This file is part of VirtualBox Open Source Edition (OSE), as 
    1010;  available from http://www.virtualbox.org. This file is free software; 
     
    7979    alignb 32 
    8080%ifdef VBOX_WITH_HYBIRD_32BIT_KERNEL 
     81    .cpum                 resb 3106 
     82%elif HC_ARCH_BITS == 32 
     83    .cpum                 resb 3456 
     84%else 
    8185    .cpum                 resb 3584 
    82 %elif HC_ARCH_BITS == 32  
    83     .cpum                 resb 3424 
    84 %else 
    85     .cpum                 resb 3552 
    8686%endif 
    8787    .vmm                  resb 1024 
  • trunk/src/VBox/VMM/CPUM.cpp

    r5054 r5285  
    4646*******************************************************************************/ 
    4747/** The saved state version. */ 
    48 #define CPUM_SAVED_STATE_VERSION    3 
     48#define CPUM_SAVED_STATE_VERSION    4 
    4949 
    5050 
     
    194194     * Get the host CPUIDs. 
    195195     */ 
    196     for (i = 0; i < ELEMENTS(pVM->cpum.s.aGuestCpuIdStd); i++) 
     196    for (i = 0; i < RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdStd); i++) 
    197197        ASMCpuId(i, 
    198198                 &pCPUM->aGuestCpuIdStd[i].eax, &pCPUM->aGuestCpuIdStd[i].ebx, 
    199199                 &pCPUM->aGuestCpuIdStd[i].ecx, &pCPUM->aGuestCpuIdStd[i].edx); 
    200     for (i = 0; i < ELEMENTS(pCPUM->aGuestCpuIdExt); i++) 
     200    for (i = 0; i < RT_ELEMENTS(pCPUM->aGuestCpuIdExt); i++) 
    201201        ASMCpuId(0x80000000 + i, 
    202202                 &pCPUM->aGuestCpuIdExt[i].eax, &pCPUM->aGuestCpuIdExt[i].ebx, 
    203203                 &pCPUM->aGuestCpuIdExt[i].ecx, &pCPUM->aGuestCpuIdExt[i].edx); 
     204    for (i = 0; i < RT_ELEMENTS(pCPUM->aGuestCpuIdCentaur); i++) 
     205        ASMCpuId(0xc0000000 + i, 
     206                 &pCPUM->aGuestCpuIdCentaur[i].eax, &pCPUM->aGuestCpuIdCentaur[i].ebx, 
     207                 &pCPUM->aGuestCpuIdCentaur[i].ecx, &pCPUM->aGuestCpuIdCentaur[i].edx); 
     208 
    204209 
    205210    /* 
     
    246251                                       | 0; 
    247252 
    248 #if 1 /* we didn't used to do this, but I guess we should */ 
    249253    /* ASSUMES that this is ALWAYS the AMD define feature set if present. */ 
    250254    pCPUM->aGuestCpuIdExt[1].edx      &= X86_CPUID_AMD_FEATURE_EDX_FPU 
     
    270274                                       | X86_CPUID_AMD_FEATURE_EDX_FXSR 
    271275                                       | X86_CPUID_AMD_FEATURE_EDX_FFXSR 
    272                                        //| X86_CPUID_AMD_FEATURE_EDX_LONG_MODE - definitely not. 
     276                                       //| X86_CPUID_AMD_FEATURE_EDX_LONG_MODE - not yet. 
    273277                                       | X86_CPUID_AMD_FEATURE_EDX_3DNOW_EX 
    274278                                       | X86_CPUID_AMD_FEATURE_EDX_3DNOW 
     
    276280    pCPUM->aGuestCpuIdExt[1].ecx      &= 0//X86_CPUID_AMD_FEATURE_ECX_SVM    - not virtualized. 
    277281                                       | 0; 
    278 #endif 
    279  
    280 #if 0 /* this is what we used to do. */ 
    281     /* 
    282      * Set BrandIndex=0, CLFLUSH-line-size=0, Num-Logical-Cpus=0 and APIC-ID=0. 
    283      */ 
    284     pCPUM->aGuestCpuIdStd[1].ebx = 0; 
    285  
    286     /* 
    287      * Set the max standard index to 2. 
    288      */ 
    289     pCPUM->aGuestCpuIdStd[0].eax = 2; 
    290     pCPUM->GuestCpuIdDef = pCPUM->aGuestCpuIdStd[2]; /** @todo this default is *NOT* right for AMD, only Intel CPUs. (see tstInlineAsm) */ 
    291  
    292 #else /* this is what we probably should do */ 
     282 
    293283    /* 
    294284     * Hide HTT, multicode, SMP, whatever. 
     
    298288 
    299289    /* 
    300      * Determin the default value and limit it the number of entries. 
    301      * Intel returns values of the highest standard function, while AMD returns zeros. 
     290     * Determin the default. 
     291     * 
     292     * Intel returns values of the highest standard function, while AMD 
     293     * returns zeros. VIA on the other hand seems to returning nothing or 
     294     * perhaps some random garbage, we don't try duplicate this behavior. 
    302295     */ 
    303296    ASMCpuId(pCPUM->aGuestCpuIdStd[0].eax + 10, 
     
    305298             &pCPUM->GuestCpuIdDef.ecx, &pCPUM->GuestCpuIdDef.edx); 
    306299 
     300    /* 
     301     * Limit it the number of entries and fill the remaining with the defaults. 
     302     * 
     303     * The limits are masking off stuff about power saving and similar, this 
     304     * is perhaps a bit crudely done as there is probably some relatively harmless 
     305     * info too in these leaves (like words about having a constant TSC). 
     306     */ 
    307307    if (pCPUM->aGuestCpuIdStd[0].eax > 2) 
    308308        pCPUM->aGuestCpuIdStd[0].eax = 2; 
    309  
    310     if (pCPUM->aGuestCpuIdExt[0].eax > 0x80000004) 
    311         pCPUM->aGuestCpuIdExt[0].eax = 0x80000004; 
    312  
    313 #endif 
    314  
    315     /* 
    316      * Assign defaults to the entries we chopped off. 
    317      */ 
    318     for (i = pCPUM->aGuestCpuIdStd[0].eax + 1; i < ELEMENTS(pCPUM->aGuestCpuIdStd); i++) 
     309    for (i = pCPUM->aGuestCpuIdStd[0].eax + 1; i < RT_ELEMENTS(pCPUM->aGuestCpuIdStd); i++) 
    319310        pCPUM->aGuestCpuIdStd[i] = pCPUM->GuestCpuIdDef; 
    320     for (i = pCPUM->aGuestCpuIdExt[0].eax - 0x80000000 + 1; i < ELEMENTS(pCPUM->aGuestCpuIdExt); i++) 
     311 
     312    if (pCPUM->aGuestCpuIdExt[0].eax > UINT32_C(0x80000004)) 
     313        pCPUM->aGuestCpuIdExt[0].eax = UINT32_C(0x80000004); 
     314    for (i = pCPUM->aGuestCpuIdExt[0].eax >= UINT32_C(0x80000000) 
     315           ? pCPUM->aGuestCpuIdExt[0].eax - UINT32_C(0x80000000) + 1 
     316           : 0; 
     317         i < RT_ELEMENTS(pCPUM->aGuestCpuIdExt); i++) 
    321318        pCPUM->aGuestCpuIdExt[i] = pCPUM->GuestCpuIdDef; 
     319 
     320    /* 
     321     * Centaur stuff (VIA). 
     322     * 
     323     * The important part here (we think) is to make sure the 0xc0000000 
     324     * function returns 0xc0000001. As for the features, we don't currently 
     325     * let on about any of those... 
     326     */ 
     327    if (    pCPUM->aGuestCpuIdCentaur[0].eax >= UINT32_C(0xc0000000) 
     328        &&  pCPUM->aGuestCpuIdCentaur[0].eax <= UINT32_C(0xc0000004)) 
     329    { 
     330        pCPUM->aGuestCpuIdCentaur[0].eax = UINT32_C(0xc0000001); 
     331        pCPUM->aGuestCpuIdCentaur[1].edx = 0; /* all features hidden */ 
     332        for (i = 2; i < RT_ELEMENTS(pCPUM->aGuestCpuIdCentaur); i++) 
     333            pCPUM->aGuestCpuIdCentaur[i] = pCPUM->GuestCpuIdDef; 
     334    } 
     335    else 
     336        for (i = 0; i < RT_ELEMENTS(pCPUM->aGuestCpuIdCentaur); i++) 
     337            pCPUM->aGuestCpuIdCentaur[i] = pCPUM->GuestCpuIdDef; 
     338 
    322339 
    323340    /* 
     
    361378 
    362379        /* next */ 
    363         if (i & 0x80000000) 
     380        if ((i & UINT32_C(0xc0000000)) == 0) 
     381        { 
     382            pCpuId = &pCPUM->aGuestCpuIdExt[0]; 
     383            cElements = RT_ELEMENTS(pCPUM->aGuestCpuIdExt); 
     384            i = UINT32_C(0x80000000); 
     385        } 
     386        else if ((i & UINT32_C(0xc0000000)) == UINT32_C(0x80000000)) 
     387        { 
     388            pCpuId = &pCPUM->aGuestCpuIdCentaur[0]; 
     389            cElements = RT_ELEMENTS(pCPUM->aGuestCpuIdCentaur); 
     390            i = UINT32_C(0xc0000000); 
     391        } 
     392        else 
    364393            break; 
    365         pCpuId = &pCPUM->aGuestCpuIdExt[0]; 
    366         cElements = ELEMENTS(pCPUM->aGuestCpuIdExt); 
    367         i = 0x80000000; 
    368394    } 
    369395 
     
    536562    SSMR3PutMem(pSSM, &pVM->cpum.s.aGuestCpuIdExt[0], sizeof(pVM->cpum.s.aGuestCpuIdExt)); 
    537563 
     564    SSMR3PutU32(pSSM, ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur)); 
     565    SSMR3PutMem(pSSM, &pVM->cpum.s.aGuestCpuIdCentaur[0], sizeof(pVM->cpum.s.aGuestCpuIdCentaur)); 
     566 
    538567    SSMR3PutMem(pSSM, &pVM->cpum.s.GuestCpuIdDef, sizeof(pVM->cpum.s.GuestCpuIdDef)); 
    539568 
     
    587616        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED; 
    588617    SSMR3GetMem(pSSM, &pVM->cpum.s.aGuestCpuIdExt[0], sizeof(pVM->cpum.s.aGuestCpuIdExt)); 
     618 
     619    rc = SSMR3GetU32(pSSM, &cElements); AssertRCReturn(rc, rc); 
     620    if (cElements != RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur)) 
     621        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED; 
     622    SSMR3GetMem(pSSM, &pVM->cpum.s.aGuestCpuIdCentaur[0], sizeof(pVM->cpum.s.aGuestCpuIdCentaur)); 
    589623 
    590624    SSMR3GetMem(pSSM, &pVM->cpum.s.GuestCpuIdDef, sizeof(pVM->cpum.s.GuestCpuIdDef)); 
     
    14911525                        (uECX >> 0) & 0xff); 
    14921526    } 
     1527 
     1528 
     1529    /* 
     1530     * Centaur. 
     1531     */ 
     1532    unsigned cCentaurMax = pVM->cpum.s.aGuestCpuIdCentaur[0].eax & 0xffff; 
     1533 
     1534    pHlp->pfnPrintf(pHlp, 
     1535                    "\n" 
     1536                    "         RAW Centaur CPUIDs\n" 
     1537                    "     Function  eax      ebx      ecx      edx\n"); 
     1538    for (unsigned i = 0; i <= RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur); i++) 
     1539    { 
     1540        Guest = pVM->cpum.s.aGuestCpuIdCentaur[i]; 
     1541        ASMCpuId(0xc0000000 | i, &Host.eax, &Host.ebx, &Host.ecx, &Host.edx); 
     1542 
     1543        pHlp->pfnPrintf(pHlp, 
     1544                        "Gst: %08x  %08x %08x %08x %08x%s\n" 
     1545                        "Hst:           %08x %08x %08x %08x\n", 
     1546                        0xc0000000 | i, Guest.eax, Guest.ebx, Guest.ecx, Guest.edx, 
     1547                        i <= cCentaurMax ? "" : "*", 
     1548                        Host.eax, Host.ebx, Host.ecx, Host.edx); 
     1549    } 
     1550 
     1551    /* 
     1552     * Understandable output 
     1553     */ 
     1554    if (iVerbosity && cCentaurMax >= 0) 
     1555    { 
     1556        Guest = pVM->cpum.s.aGuestCpuIdCentaur[0]; 
     1557        pHlp->pfnPrintf(pHlp, 
     1558                        "Centaur Supports:                0xc0000000-%#010x\n", 
     1559                        Guest.eax); 
     1560    } 
     1561 
     1562    if (iVerbosity && cCentaurMax >= 1) 
     1563    { 
     1564        ASMCpuId(0xc0000001, &Host.eax, &Host.ebx, &Host.ecx, &Host.edx); 
     1565        uint32_t uEdxGst = pVM->cpum.s.aGuestCpuIdExt[1].edx; 
     1566        uint32_t uEdxHst = Host.edx; 
     1567 
     1568        if (iVerbosity == 1) 
     1569        { 
     1570            pHlp->pfnPrintf(pHlp, "Centaur Features EDX:           "); 
     1571            if (uEdxGst & RT_BIT(0))   pHlp->pfnPrintf(pHlp, " AIS"); 
     1572            if (uEdxGst & RT_BIT(1))   pHlp->pfnPrintf(pHlp, " AIS-E"); 
     1573            if (uEdxGst & RT_BIT(2))   pHlp->pfnPrintf(pHlp, " RNG"); 
     1574            if (uEdxGst & RT_BIT(3))   pHlp->pfnPrintf(pHlp, " RNG-E"); 
     1575            if (uEdxGst & RT_BIT(4))   pHlp->pfnPrintf(pHlp, " LH"); 
     1576            if (uEdxGst & RT_BIT(5))   pHlp->pfnPrintf(pHlp, " FEMMS"); 
     1577            if (uEdxGst & RT_BIT(6))   pHlp->pfnPrintf(pHlp, " ACE"); 
     1578            if (uEdxGst & RT_BIT(7))   pHlp->pfnPrintf(pHlp, " ACE-E"); 
     1579            /* possibly indicating MM/HE and MM/HE-E on older chips... */ 
     1580            if (uEdxGst & RT_BIT(8))   pHlp->pfnPrintf(pHlp, " ACE2"); 
     1581            if (uEdxGst & RT_BIT(9))   pHlp->pfnPrintf(pHlp, " ACE2-E"); 
     1582            if (uEdxGst & RT_BIT(10))  pHlp->pfnPrintf(pHlp, " PHE"); 
     1583            if (uEdxGst & RT_BIT(11))  pHlp->pfnPrintf(pHlp, " PHE-E"); 
     1584            if (uEdxGst & RT_BIT(12))  pHlp->pfnPrintf(pHlp, " PMM"); 
     1585            if (uEdxGst & RT_BIT(13))  pHlp->pfnPrintf(pHlp, " PMM-E"); 
     1586            for (unsigned iBit = 14; iBit < 32; iBit++) 
     1587                if (uEdxGst & RT_BIT(iBit)) 
     1588                    pHlp->pfnPrintf(pHlp, " %d", iBit); 
     1589            pHlp->pfnPrintf(pHlp, "\n"); 
     1590        } 
     1591        else 
     1592        { 
     1593            pHlp->pfnPrintf(pHlp, "Mnemonic - Description                 = guest (host)\n"); 
     1594            pHlp->pfnPrintf(pHlp, "AIS - Alternate Instruction Set        = %d (%d)\n",  !!(uEdxGst & RT_BIT( 0)),  !!(uEdxHst & RT_BIT( 0))); 
     1595            pHlp->pfnPrintf(pHlp, "AIS-E - AIS enabled                    = %d (%d)\n",  !!(uEdxGst & RT_BIT( 1)),  !!(uEdxHst & RT_BIT( 1))); 
     1596            pHlp->pfnPrintf(pHlp, "RNG - Random Number Generator          = %d (%d)\n",  !!(uEdxGst & RT_BIT( 2)),  !!(uEdxHst & RT_BIT( 2))); 
     1597            pHlp->pfnPrintf(pHlp, "RNG-E - RNG enabled                    = %d (%d)\n",  !!(uEdxGst & RT_BIT( 3)),  !!(uEdxHst & RT_BIT( 3))); 
     1598            pHlp->pfnPrintf(pHlp, "LH - LongHaul MSR 0000_110Ah           = %d (%d)\n",  !!(uEdxGst & RT_BIT( 4)),  !!(uEdxHst & RT_BIT( 4))); 
     1599            pHlp->pfnPrintf(pHlp, "FEMMS - FEMMS                          = %d (%d)\n",  !!(uEdxGst & RT_BIT( 5)),  !!(uEdxHst & RT_BIT( 5))); 
     1600            pHlp->pfnPrintf(pHlp, "ACE - Advanced Cryptography Engine     = %d (%d)\n",  !!(uEdxGst & RT_BIT( 6)),  !!(uEdxHst & RT_BIT( 6))); 
     1601            pHlp->pfnPrintf(pHlp, "ACE-E - ACE enabled                    = %d (%d)\n",  !!(uEdxGst & RT_BIT( 7)),  !!(uEdxHst & RT_BIT( 7))); 
     1602            /* possibly indicating MM/HE and MM/HE-E on older chips... */ 
     1603            pHlp->pfnPrintf(pHlp, "ACE2 - Advanced Cryptography Engine 2  = %d (%d)\n",  !!(uEdxGst & RT_BIT( 8)),  !!(uEdxHst & RT_BIT( 8))); 
     1604            pHlp->pfnPrintf(pHlp, "ACE2-E - ACE enabled                   = %d (%d)\n",  !!(uEdxGst & RT_BIT( 9)),  !!(uEdxHst & RT_BIT( 9))); 
     1605            pHlp->pfnPrintf(pHlp, "PHE - Hash Engine                      = %d (%d)\n",  !!(uEdxGst & RT_BIT(10)),  !!(uEdxHst & RT_BIT(10))); 
     1606            pHlp->pfnPrintf(pHlp, "PHE-E - PHE enabled                    = %d (%d)\n",  !!(uEdxGst & RT_BIT(11)),  !!(uEdxHst & RT_BIT(11))); 
     1607            pHlp->pfnPrintf(pHlp, "PMM - Montgomery Multiplier            = %d (%d)\n",  !!(uEdxGst & RT_BIT(12)),  !!(uEdxHst & RT_BIT(12))); 
     1608            pHlp->pfnPrintf(pHlp, "PMM-E - PMM enabled                    = %d (%d)\n",  !!(uEdxGst & RT_BIT(13)),  !!(uEdxHst & RT_BIT(13))); 
     1609            for (unsigned iBit = 14; iBit < 32; iBit++) 
     1610                if ((uEdxGst | uEdxHst) & RT_BIT(iBit)) 
     1611                    pHlp->pfnPrintf(pHlp, "Bit %d                                 = %d (%d)\n",  !!(uEdxGst & RT_BIT(iBit)),  !!(uEdxHst & RT_BIT(iBit))); 
     1612            pHlp->pfnPrintf(pHlp, "\n"); 
     1613        } 
     1614    } 
    14931615} 
    14941616 
  • trunk/src/VBox/VMM/CPUMInternal.h

    r4958 r5285  
    332332    /** The extended set of CpuId leafs. */ 
    333333    CPUMCPUID               aGuestCpuIdExt[10]; 
     334    /** The centaur set of CpuId leafs. */ 
     335    CPUMCPUID               aGuestCpuIdCentaur[2]; 
    334336    /** The default set of CpuId leafs. */ 
    335337    CPUMCPUID               GuestCpuIdDef; 
  • trunk/src/VBox/VMM/CPUMInternal.mac

    r4958 r5285  
    66; 
    77;  Copyright (C) 2006-2007 innotek GmbH 
    8 ;  
     8; 
    99;  This file is part of VirtualBox Open Source Edition (OSE), as 
    1010;  available from http://www.virtualbox.org. This file is free software; 
     
    382382    .aGuestCpuIdStd       resb    16*5 
    383383    .aGuestCpuIdExt       resb    16*10 
     384    .aGuestCpuIdCentaur   resb    16*2 
    384385    .GuestCpuIdDef        resb    16 
    385386 
  • trunk/src/VBox/VMM/PATM/PATMA.asm

    r4071 r5285  
    55 
    66;  Copyright (C) 2006-2007 innotek GmbH 
    7 ;  
     7; 
    88;  This file is part of VirtualBox Open Source Edition (OSE), as 
    99;  available from http://www.virtualbox.org. This file is free software; 
     
    15331533    cmp     eax, PATM_CPUID_EXT_MAX 
    15341534    jb      cpuid_ext 
     1535    cmp     eax, 0xc0000000 
     1536    jb      cpuid_def 
     1537    cmp     eax, PATM_CPUID_CENTAUR_MAX 
     1538    jb      cpuid_centaur 
    15351539 
    15361540cpuid_def: 
     
    15411545    mov     edx, PATM_CPUID_STD_PTR 
    15421546    jmp     cpuid_calc 
     1547 
    15431548cpuid_ext: 
    15441549    and     eax, 0ffh                   ; strictly speaking not necessary. 
    15451550    mov     edx, PATM_CPUID_EXT_PTR 
     1551    jmp     cpuid_calc 
     1552 
     1553cpuid_centaur: 
     1554    and     eax, 0ffh                   ; strictly speaking not necessary. 
     1555    mov     edx, PATM_CPUID_CENTAUR_PTR 
     1556 
    15461557cpuid_calc: 
    15471558    lea     eax, [ss:eax * 4]              ; 4 entries... 
  • trunk/src/VBox/VMM/PATM/PATMA.h

    r4071 r5285  
    5050#define PATM_CALL_PATCH_TARGET_ADDR             0xF1ABCD18 
    5151#define PATM_CALL_RETURN_ADDR                   0xF1ABCD19 
     52#define PATM_CPUID_CENTAUR_PTR                  0xF1ABCD1a 
    5253 
    5354/* Anything larger doesn't require a fixup */ 
     
    6465#define PATM_LOOKUP_AND_JUMP_FUNCTION           0xF1ABCE09    /** Relative address of global PATM lookup and jump function. */ 
    6566#define PATM_IRET_FUNCTION                      0xF1ABCE0A    /** Relative address of global PATM iret function. */ 
     67#define PATM_CPUID_CENTAUR_MAX                  0xF1ABCE0B 
    6668 
    6769// everything except IOPL, NT, IF, VM, VIF, VIP and RF 
  • trunk/src/VBox/VMM/PATM/PATMA.mac

    r4071 r5285  
    66; 
    77;  Copyright (C) 2006-2007 innotek GmbH 
    8 ;  
     8; 
    99;  This file is part of VirtualBox Open Source Edition (OSE), as 
    1010;  available from http://www.virtualbox.org. This file is free software; 
     
    4848%define PATM_CALL_PATCH_TARGET_ADDR             0xF1ABCD18 
    4949%define PATM_CALL_RETURN_ADDR                   0xF1ABCD19 
     50%define PATM_CPUID_CENTAUR_PTR                  0xF1ABCD1A 
    5051 
    5152;/* Anything larger doesn't require a fixup */ 
     
    6263%define PATM_LOOKUP_AND_JUMP_FUNCTION           0xF1ABCE09   ; /** Relative address of global PATM lookup and jump function. */ 
    6364%define PATM_IRET_FUNCTION                      0xF1ABCE0A   ; /** Relative address of global PATM iret function. */ 
     65%define PATM_CPUID_CENTAUR_MAX                  0xF1ABCE0B 
    6466 
    6567 
  • trunk/src/VBox/VMM/PATM/PATMPatch.cpp

    r4071 r5285  
    234234                    break; 
    235235 
     236                case PATM_CPUID_CENTAUR_PTR: 
     237                    dest = CPUMGetGuestCpuIdCentaurGCPtr(pVM); 
     238                    break; 
     239 
    236240                case PATM_CPUID_DEF_PTR: 
    237241                    dest = CPUMGetGuestCpuIdDefGCPtr(pVM); 
     
    244248                case PATM_CPUID_EXT_MAX: 
    245249                    dest = CPUMGetGuestCpuIdExtMax(pVM); 
     250                    break; 
     251 
     252                case PATM_CPUID_CENTAUR_MAX: 
     253                    dest = CPUMGetGuestCpuIdCentaurMax(pVM); 
    246254                    break; 
    247255 
     
    12821290 
    12831291    Log(("patmPatchGenMovFromSS %VGv\n", pCurInstrGC)); 
    1284      
     1292 
    12851293    Assert(pPatch->flags & PATMFL_CODE32); 
    12861294 
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r4958 r5285  
    801801    if (iLeaf < ELEMENTS(pVM->cpum.s.aGuestCpuIdStd)) 
    802802        pCpuId = &pVM->cpum.s.aGuestCpuIdStd[iLeaf]; 
    803     else if (iLeaf - UINT32_C(0x80000000) < ELEMENTS(pVM->cpum.s.aGuestCpuIdExt)) 
     803    else if (iLeaf - UINT32_C(0x80000000) < RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdExt)) 
    804804        pCpuId = &pVM->cpum.s.aGuestCpuIdExt[iLeaf - UINT32_C(0x80000000)]; 
     805    else if (iLeaf - UINT32_C(0xc0000000) < RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur)) 
     806        pCpuId = &pVM->cpum.s.aGuestCpuIdCentaur[iLeaf - UINT32_C(0xc0000000)]; 
    805807    else 
    806808        pCpuId = &pVM->cpum.s.GuestCpuIdDef; 
     
    842844 
    843845/** 
     846 * Gets a pointer to the array of centaur CPUID leafs. 
     847 * 
     848 * CPUMGetGuestCpuIdCentaurMax() give the size of the array. 
     849 * 
     850 * @returns Pointer to the centaur CPUID leafs (read-only). 
     851 * @param   pVM         The VM handle. 
     852 * @remark  Intended for PATM. 
     853 */ 
     854CPUMDECL(GCPTRTYPE(PCCPUMCPUID)) CPUMGetGuestCpuIdCentaurGCPtr(PVM pVM) 
     855{ 
     856    return GCPTRTYPE(PCCPUMCPUID)VM_GUEST_ADDR(pVM, &pVM->cpum.s.aGuestCpuIdCentaur[0]); 
     857} 
     858 
     859/** 
    844860 * Gets a pointer to the default CPUID leaf. 
    845861 * 
     
    860876 * @remark  Intended for PATM. 
    861877 */ 
    862 CPUMDECL(uint32_t) CPUMGetGuestCpuIdStdMax(PVM pVM) 
    863 { 
    864     return ELEMENTS(pVM->cpum.s.aGuestCpuIdStd); 
     878CPUMDECL(uint32_t) CPUMGetGuestCpuIdStdMax(PVM pVM) 
     879{ 
     880    return RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdStd); 
    865881} 
    866882 
     
    872888 * @remark  Intended for PATM. 
    873889 */ 
    874 CPUMDECL(uint32_t)  CPUMGetGuestCpuIdExtMax(PVM pVM) 
    875 
    876     return ELEMENTS(pVM->cpum.s.aGuestCpuIdStd); 
     890CPUMDECL(uint32_t) CPUMGetGuestCpuIdExtMax(PVM pVM) 
     891
     892    return RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdExt); 
     893
     894 
     895/** 
     896 * Gets a number of centaur CPUID leafs. 
     897 * 
     898 * @returns Number of leafs. 
     899 * @param   pVM         The VM handle. 
     900 * @remark  Intended for PATM. 
     901 */ 
     902CPUMDECL(uint32_t) CPUMGetGuestCpuIdCentaurMax(PVM pVM) 
     903
     904    return RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur); 
    877905} 
    878906 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy