VirtualBox

Changeset 55039 in vbox


Ignore:
Timestamp:
Mar 31, 2015 3:01:05 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99325
Message:

VMM: Fix hypercall patching.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/GIMAllKvm.cpp

    r55037 r55039  
    352352        if (Dis.pCurInstr->uOpcode == OP_VMCALL)
    353353        {
    354             Assert(cbInstr == 3);        /* paranoia. */
    355 
    356354            /*
    357355             * Patch the instruction to so we don't have to spend time disassembling it each time.
    358356             */
    359             static uint8_t s_abHypercall[3];
    360             size_t cbWritten;
    361             rc = HMPatchHypercall(pVM, &s_abHypercall, sizeof(s_abHypercall), &cbWritten);
    362             AssertRC(rc);
    363 
    364             if (RT_LIKELY(cbWritten == cbInstr))
    365                 rc = PGMPhysSimpleWriteGCPtr(pVCpu, pCtx->rip, &s_abHypercall, sizeof(s_abHypercall));
    366             if (RT_SUCCESS(rc))
    367                 return gimKvmHypercall(pVCpu, pCtx);
     357            static uint8_t s_abHypercall[3] = { 0x0F, 0x01, 0x00 };
     358            Assert(sizeof(s_abHypercall) == cbInstr);
     359            if (!s_abHypercall[2])
     360                s_abHypercall[2] = ASMIsAmdCpu() ? 0xD9 /* VMMCALL */ : 0xC1 /* VMCALL */;
     361            rc = PGMPhysSimpleWriteGCPtr(pVCpu, pCtx->rip, &s_abHypercall, sizeof(s_abHypercall));
     362            return VINF_SUCCESS;
    368363        }
    369364    }
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r55037 r55039  
    52275227    if (   pVM->hm.s.fTrapXcptUD
    52285228        && GIMAreHypercallsEnabled(pVCpu))
    5229     {
    5230         int rc = GIMXcptUD(pVCpu, pCtx);
    5231         if (RT_SUCCESS(rc))
    5232         {
    5233             /* If the exception handler changes anything other than guest general-purpose registers,
    5234                we would need to reload the guest changed bits on VM-reentry. */
    5235             hmR0SvmUpdateRip(pVCpu, pCtx, 3);
    5236             return VINF_SUCCESS;
    5237         }
    5238     }
    5239 
    5240     hmR0SvmSetPendingXcptUD(pVCpu);
     5229        GIMXcptUD(pVCpu, pCtx);
     5230    else
     5231        hmR0SvmSetPendingXcptUD(pVCpu);
     5232
    52415233    return VINF_SUCCESS;
    52425234}
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