VirtualBox

Changeset 72419 in vbox


Ignore:
Timestamp:
Jun 3, 2018 12:49:33 PM (6 years ago)
Author:
vboxsync
Message:

NEM/win: Modify the APIC and firmware configuration to disable X2APIC. Turns out we cannot expose X2APIC to guests when using NEM/win. bugref:9044

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r72415 r72419  
    10841084
    10851085/**
     1086 * Makes sure APIC and firmware will not allow X2APIC mode.
     1087 *
     1088 * This is rather ugly.
     1089 *
     1090 * @returns VBox status code
     1091 * @param   pVM             The cross context VM structure.
     1092 */
     1093static int nemR3WinDisableX2Apic(PVM pVM)
     1094{
     1095    /*
     1096     * First make sure the 'Mode' config value of the APIC isn't set to X2APIC.
     1097     * This defaults to APIC, so no need to change unless it's X2APIC.
     1098     */
     1099    // /Devices/apic/0/Config/
     1100    PCFGMNODE pCfg = CFGMR3GetChild(CFGMR3GetRoot(pVM), "/Devices/apic/0/Config");
     1101    if (pCfg)
     1102    {
     1103        uint8_t bMode = 0;
     1104        int rc = CFGMR3QueryU8(pCfg, "Mode", &bMode);
     1105        AssertLogRelMsgReturn(RT_SUCCESS(rc) || rc == VERR_CFGM_VALUE_NOT_FOUND, ("%Rrc\n", rc), rc);
     1106        if (RT_SUCCESS(rc) && bMode == PDMAPICMODE_X2APIC)
     1107        {
     1108            LogRel(("NEM: Adjusting APIC configuration from X2APIC to APIC max mode.  X2APIC is not supported by the WinHvPlatform API!\n"));
     1109            LogRel(("NEM: Disable Hyper-V if you need X2APIC for your guests!\n"));
     1110            rc = CFGMR3RemoveValue(pCfg, "Mode");
     1111            rc = CFGMR3InsertInteger(pCfg, "Mode", PDMAPICMODE_APIC);
     1112            AssertLogRelRCReturn(rc, rc);
     1113        }
     1114    }
     1115
     1116    /*
     1117     * Now the firmwares.
     1118     * These also defaults to APIC and only needs adjusting if configured to X2APIC (2).
     1119     */
     1120    static const char * const s_apszFirmwareConfigs[] =
     1121    {
     1122        "/Devices/efi/0/Config",
     1123        "/Devices/pcbios/0/Config",
     1124    };
     1125    for (unsigned i = 0; i < RT_ELEMENTS(s_apszFirmwareConfigs); i++)
     1126    {
     1127        pCfg = CFGMR3GetChild(CFGMR3GetRoot(pVM), "/Devices/APIC/0/Config");
     1128        if (pCfg)
     1129        {
     1130            uint8_t bMode = 0;
     1131            int rc = CFGMR3QueryU8(pCfg, "APIC", &bMode);
     1132            AssertLogRelMsgReturn(RT_SUCCESS(rc) || rc == VERR_CFGM_VALUE_NOT_FOUND, ("%Rrc\n", rc), rc);
     1133            if (RT_SUCCESS(rc) && bMode == 2)
     1134            {
     1135                LogRel(("NEM: Adjusting %s/Mode from 2 (X2APIC) to 1 (APIC).\n", s_apszFirmwareConfigs[i]));
     1136                rc = CFGMR3RemoveValue(pCfg, "APIC");
     1137                rc = CFGMR3InsertInteger(pCfg, "APIC", 1);
     1138                AssertLogRelRCReturn(rc, rc);
     1139            }
     1140        }
     1141    }
     1142
     1143    return VINF_SUCCESS;
     1144}
     1145
     1146
     1147/**
    10861148 * Try initialize the native API.
    10871149 *
     
    11441206                        VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_NATIVE_API);
    11451207                        Log(("NEM: Marked active!\n"));
     1208                        nemR3WinDisableX2Apic(pVM);
    11461209
    11471210                        /* Register release statistics */
     
    13571420        /*
    13581421         * Adjust features.
     1422         * Note! We've already disabled X2APIC via CFGM during the first init call.
    13591423         */
    1360         /** @todo Figure out how to get X2APIC working on AMD (and possible
    1361          * intel), but first figure how to disable it dynamically. */
    1362         /*CPUMR3ClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_X2APIC);*/
    1363 
    13641424        return VINF_SUCCESS;
    13651425    }
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