VirtualBox

Changeset 102549 in vbox


Ignore:
Timestamp:
Dec 8, 2023 3:57:39 PM (10 months ago)
Author:
vboxsync
Message:

VMM/IEM: Must truncate constant variable values according to the type size, since we're not getting any help from the C compiler here. bugref:10371

Location:
trunk/src/VBox/VMM
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/Makefile.kmk

    r102471 r102549  
    233233        $(if-expr !defined(IEM_WITHOUT_ASSEMBLY),VMMAll/IEMAllAImpl.asm,) \
    234234        VMMAll/VMMAllA.asm
     235VBoxVMM_SOURCES.arm64 += \
     236        VMMAll/IEMAllAImpl-arm64.S
    235237ifdef VBOX_WITH_VUSB
    236238 VBoxVMM_SOURCES += VMMR3/PDMUsb.cpp
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp

    r102510 r102549  
    33813381{
    33823382    Assert(enmGstReg < kIemNativeGstReg_End && g_aGstShadowInfo[enmGstReg].cb != 0);
    3383 #ifdef LOG_ENABLED
     3383#if defined(LOG_ENABLED) || defined(VBOX_STRICT)
    33843384    static const char * const s_pszIntendedUse[] = { "fetch", "update", "full write", "destructive calc" };
    33853385#endif
     
    61046104
    61056105    pReNative->Core.aVars[idxVar].u.uValue = uValue;
     6106    AssertMsg(   pReNative->Core.aVars[idxVar].cbVar >= sizeof(uint64_t)
     6107              || pReNative->Core.aVars[idxVar].u.uValue < RT_BIT_64(pReNative->Core.aVars[idxVar].cbVar * 8),
     6108              ("idxVar=%d cbVar=%u uValue=%#RX64\n", idxVar, pReNative->Core.aVars[idxVar].cbVar, uValue));
    61066109}
    61076110
     
    61836186{
    61846187    uint8_t const idxVar = iemNativeArgAllocInt(pReNative, iArgNo, cbType);
     6188
     6189    /* Since we're using a generic uint64_t value type, we must truncate it if
     6190       the variable is smaller otherwise we may end up with too large value when
     6191       scaling up a imm8 w/ sign-extension.
     6192
     6193       This caused trouble with a "add bx, 0xffff" instruction (around f000:ac60
     6194       in the bios, bx=1) when running on arm, because clang expect 16-bit
     6195       register parameters to have bits 16 and up set to zero.  Instead of
     6196       setting x1 = 0xffff we ended up with x1 = 0xffffffffffffff and the wrong
     6197       CF value in the result.  */
     6198    switch (cbType)
     6199    {
     6200        case sizeof(uint8_t):   uValue &= UINT64_C(0xff); break;
     6201        case sizeof(uint16_t):  uValue &= UINT64_C(0xffff); break;
     6202        case sizeof(uint32_t):  uValue &= UINT64_C(0xffffffff); break;
     6203    }
    61856204    iemNativeVarSetKindToConst(pReNative, idxVar, uValue);
    61866205    return idxVar;
     
    62136232{
    62146233    uint8_t const idxVar = iemNativeVarAllocInt(pReNative, cbType);
     6234
     6235    /* Since we're using a generic uint64_t value type, we must truncate it if
     6236       the variable is smaller otherwise we may end up with too large value when
     6237       scaling up a imm8 w/ sign-extension. */
     6238    switch (cbType)
     6239    {
     6240        case sizeof(uint8_t):   uValue &= UINT64_C(0xff); break;
     6241        case sizeof(uint16_t):  uValue &= UINT64_C(0xffff); break;
     6242        case sizeof(uint32_t):  uValue &= UINT64_C(0xffffffff); break;
     6243    }
    62156244    iemNativeVarSetKindToConst(pReNative, idxVar, uValue);
    62166245    return idxVar;
     
    1111211141    }
    1111311142#endif
     11143    /*iemNativeDisassembleTb(pTb, DBGFR3InfoLogRelHlp());*/
    1111411144
    1111511145    STAM_REL_PROFILE_STOP(&pVCpu->iem.s.StatNativeRecompilation, a);
  • trunk/src/VBox/VMM/testcase/Makefile.kmk

    r99040 r102549  
    349349        $(TSTIEMAIMPL_TEST_DATA_DEPS)
    350350
    351 tstIEMAImpl_SOURCES.arm64 += tstIEMAImplDataSseBinary.S
     351tstIEMAImpl_SOURCES.arm64  = \
     352        tstIEMAImplDataSseBinary.S \
     353        ../VMMAll/IEMAllAImpl-arm64.S
    352354tstIEMAImplDataSseBinary.S_DEPS   = \
    353355        $(TSTIEMAIMPL_TEST_DATA_DEPS)
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