VirtualBox

Changeset 8985 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 20, 2008 9:03:33 PM (17 years ago)
Author:
vboxsync
Message:

Added an extra argument to TRPMForwardTrap so the trpm profiling started in the trap handler assembly code are stopped correctly. Enabled the #UD forwarding for ring-0 traps (dtrace experiment).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/EM.cpp

    r8851 r8985  
    20562056                        EMR3CheckRawForcedActions(pVM);
    20572057
    2058                         rc = TRPMForwardTrap(pVM, CPUMCTX2CORE(pCtx), u8Interrupt, uErrorCode, enmError, TRPM_TRAP);
     2058                        rc = TRPMForwardTrap(pVM, CPUMCTX2CORE(pCtx), u8Interrupt, uErrorCode, enmError, TRPM_TRAP, -1);
    20592059                        if (rc == VINF_SUCCESS /* Don't use VBOX_SUCCESS */)
    20602060                        {
  • trunk/src/VBox/VMM/TRPM.cpp

    r8155 r8985  
    13851385
    13861386                /* There's a handler -> let's execute it in raw mode */
    1387                 rc = TRPMForwardTrap(pVM, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent);
     1387                rc = TRPMForwardTrap(pVM, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent, -1);
    13881388                if (rc == VINF_SUCCESS /* Don't use VBOX_SUCCESS */)
    13891389                {
  • trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp

    r8818 r8985  
     1#define VBOX_WITH_STATISTICS
    12/* $Id$ */
    23/** @file
     
    3031#include <VBox/patm.h>
    3132#include <VBox/selm.h>
     33#include <VBox/stam.h>
    3234#include "TRPMInternal.h"
    3335#include <VBox/vm.h>
     
    356358 * @param   enmError    TRPM_TRAP_HAS_ERRORCODE or TRPM_TRAP_NO_ERRORCODE.
    357359 * @param   enmType     TRPM event type
     360 * @param   iOrgTrap    The original trap.
    358361 * @internal
    359362 */
    360 TRPMDECL(int) TRPMForwardTrap(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t opsize, TRPMERRORCODE enmError, TRPMEVENT enmType)
     363TRPMDECL(int) TRPMForwardTrap(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t opsize, TRPMERRORCODE enmError, TRPMEVENT enmType, int32_t iOrgTrap)
    361364{
    362365#ifdef TRPM_FORWARD_TRAPS_IN_GC
     
    414417     * Well, only if the IF flag is set.
    415418     */
    416     /*
    417      * @todo if the trap handler was modified and marked invalid, then we should *now* go back to the host context and install a new patch.
    418      *
    419      */
     419    /** @todo if the trap handler was modified and marked invalid, then we should *now* go back to the host context and install a new patch. */
    420420    if (    pVM->trpm.s.aGuestTrapHandler[iGate]
    421421        && (eflags.Bits.u1IF)
    422422#ifndef VBOX_RAW_V86
    423         && !(eflags.Bits.u1VM) /* @todo implement when needed (illegal for same privilege level transfers). */
     423        && !(eflags.Bits.u1VM) /** @todo implement when needed (illegal for same privilege level transfers). */
    424424#endif
    425425        && !PATMIsPatchGCAddr(pVM, (RTGCPTR)pRegFrame->eip)
     
    456456        if (VBOX_FAILURE(rc))
    457457        {
    458             /* The page might be out of sync. (@todo might cross a page boundary) */
     458            /* The page might be out of sync. */ /** @todo might cross a page boundary) */
    459459            Log(("Page %VGv out of sync -> prefetch and try again\n", pIDTEntry));
    460460            rc = PGMPrefetchPage(pVM, pIDTEntry); /** @todo r=bird: rainy day: this isn't entirely safe because of access bit virtualiziation and CSAM. */
     
    516516                if (VBOX_FAILURE(rc))
    517517                {
    518                     /* The page might be out of sync. (@todo might cross a page boundary) */
     518                    /* The page might be out of sync. */ /** @todo might cross a page boundary) */
    519519                    Log(("Page %VGv out of sync -> prefetch and try again\n", pGdtEntry));
    520520                    rc = PGMPrefetchPage(pVM, pGdtEntry);  /** @todo r=bird: rainy day: this isn't entirely safe because of access bit virtualiziation and CSAM. */
     
    662662                        Log4(("Stack %VGv pos %02d: %08x\n", &pTrapStack[j], j, pTrapStack[j]));
    663663
    664                     const char *pszPrefix = "";
    665                     const char *szEFlags = "";
    666 
    667664                    Log4(("eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n"
    668665                          "eip=%08x esp=%08x ebp=%08x iopl=%d\n"
     
    695692                    STAM_COUNTER_INC(&pVM->trpm.s.CTXALLSUFF(paStatForwardedIRQ)[iGate]);
    696693                    STAM_PROFILE_ADV_STOP(CTXSUFF(&pVM->trpm.s.StatForwardProf), a);
     694                    if (iOrgTrap >= 0 && iOrgTrap < (int)RT_ELEMENTS(pVM->trpm.s.aStatGCTraps))
     695                        STAM_PROFILE_ADV_STOP(&pVM->trpm.s.aStatGCTraps[iOrgTrap], o);
    697696
    698697                    CPUMGCCallGuestTrapHandler(pRegFrame, GuestIdte.Gen.u16SegSel | 1, pVM->trpm.s.aGuestTrapHandler[iGate], eflags.u32, ss_r0, (RTGCPTR)esp_r0);
  • trunk/src/VBox/VMM/VMMGC/TRPMGCHandlers.cpp

    r8831 r8985  
    4848#include <iprt/assert.h>
    4949
     50/*******************************************************************************
     51*   Defined Constants And Macros                                               *
     52*******************************************************************************/
    5053/* still here. MODR/M byte parsing */
    5154#define X86_OPCODE_MODRM_MOD_MASK       0xc0
     
    5356#define X86_OPCODE_MODRM_RM_MASK        0x07
    5457
     58/** @todo fix/remove/permanent-enable this when DIS/PATM handles invalid lock sequences. */
     59#define DTRACE_EXPERIMENT
     60
     61
     62/*******************************************************************************
     63*   Structures and Typedefs                                                    *
     64*******************************************************************************/
    5565/** Pointer to a readonly hypervisor trap record. */
    5666typedef const struct TRPMGCHYPER *PCTRPMGCHYPER;
     
    193203            Log(("trpmGCExitTrap: u8Interrupt=%d (%#x) rc=%Vrc\n", u8Interrupt, u8Interrupt, rc));
    194204            AssertFatalMsgRC(rc, ("PDMGetInterrupt failed with %Vrc\n", rc));
    195             rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_HARDWARE_INT);
     205            rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_HARDWARE_INT, uOldActiveVector);
    196206            /* can't return if successful */
    197207            Assert(rc != VINF_SUCCESS);
     
    362372            return trpmGCExitTrap(pVM, VINF_EM_RAW_EMULATE_INSTR, pRegFrame);
    363373
    364         if (    PATMIsPatchGCAddr(pVM, (RTGCPTR)pRegFrame->eip)
    365             &&  Cpu.pCurInstr->opcode == OP_ILLUD2)
     374        /*
     375         * UD2 in a patch?
     376         */
     377        if (    Cpu.pCurInstr->opcode == OP_ILLUD2
     378            &&  PATMIsPatchGCAddr(pVM, (RTGCPTR)pRegFrame->eip))
    366379        {
    367380            rc = PATMGCHandleIllegalInstrTrap(pVM, pRegFrame);
    368             if (rc == VINF_SUCCESS || rc == VINF_EM_RAW_EMULATE_INSTR || rc == VINF_PATM_DUPLICATE_FUNCTION || rc == VINF_PATM_PENDING_IRQ_AFTER_IRET || rc == VINF_EM_RESCHEDULE)
     381            if (    rc == VINF_SUCCESS
     382                ||  rc == VINF_EM_RAW_EMULATE_INSTR
     383                ||  rc == VINF_PATM_DUPLICATE_FUNCTION
     384                ||  rc == VINF_PATM_PENDING_IRQ_AFTER_IRET
     385                ||  rc == VINF_EM_RESCHEDULE)
    369386                return trpmGCExitTrap(pVM, rc, pRegFrame);
    370387        }
    371         /* Note: monitor causes an #UD exception instead of #GP when not executed in ring 0. */
     388        /*
     389         * Speed up dtrace and don't entrust invalid lock sequences to the recompiler.
     390         */
     391        else if (Cpu.prefix & PREFIX_LOCK)
     392        {
     393            Log(("TRPMGCTrap06Handler: pc=%RGv op=%d\n", pRegFrame->eip, Cpu.pCurInstr->opcode));
     394#ifdef DTRACE_EXPERIMENT /** @todo fix/remove/permanent-enable this when DIS/PATM handles invalid lock sequences. */
     395            Assert(!PATMIsPatchGCAddr(pVM, (RTGCPTR)pRegFrame->eip));
     396            rc = TRPMForwardTrap(pVM, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP, 0x6);
     397            Assert(rc == VINF_EM_RAW_GUEST_TRAP);
     398#else
     399            rc = VINF_EM_RAW_EMULATE_INSTR;
     400#endif
     401        }
     402        /*
     403         * Handle MONITOR - it causes an #UD exception instead of #GP when not executed in ring 0.
     404         */
    372405        else if (Cpu.pCurInstr->opcode == OP_MONITOR)
    373406        {
     
    377410                pRegFrame->eip += Cpu.opsize;
    378411        }
    379         /* Speed up dtrace and don't entrust invalid lock sequences to the recompiler. */
    380         else if (Cpu.prefix & PREFIX_LOCK)
    381         {
    382             Log(("TRPMGCTrap06Handler: pc=%RGv op=%d\n", pRegFrame->eip, Cpu.pCurInstr->opcode));
    383             /** @todo Clear this with PATM - it gets upset when returning VINF_EM_RAW_GUEST_TRAP on a patch address. */
    384 #ifdef DTRACE_EXPERIMENT
    385             rc = TRPMForwardTrap(pVM, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP);
    386             Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    387 #else
    388             rc = VINF_EM_RAW_EMULATE_INSTR;
    389 #endif
    390         }
    391412        /* Never generate a raw trap here; it might be an instruction, that requires emulation. */
    392413        else
     
    395416    else
    396417    {
    397         rc = TRPMForwardTrap(pVM, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP);
     418        rc = TRPMForwardTrap(pVM, pRegFrame, 0x6, 0, TRPM_TRAP_NO_ERRORCODE, TRPM_TRAP, 0x6);
    398419        Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    399420    }
     
    560581                }
    561582            }
    562             rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT);
     583            rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT, 0xd);
    563584            if (VBOX_SUCCESS(rc) && rc != VINF_EM_RAW_GUEST_TRAP)
    564585                return trpmGCExitTrap(pVM, VINF_SUCCESS, pRegFrame);
     
    651672        {
    652673            Assert(pCpu->param1.flags & USE_IMMEDIATE8);
    653             rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT);
     674            rc = TRPMForwardTrap(pVM, pRegFrame, (uint32_t)pCpu->param1.parval, pCpu->opsize, TRPM_TRAP_NO_ERRORCODE, TRPM_SOFTWARE_INT, 0xd);
    654675            if (VBOX_SUCCESS(rc) && rc != VINF_EM_RAW_GUEST_TRAP)
    655676                return trpmGCExitTrap(pVM, VINF_SUCCESS, pRegFrame);
     
    834855        Assert(eflags.Bits.u2IOPL == 0);
    835856
    836         int rc = TRPMForwardTrap(pVM, pRegFrame, 0xD, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP);
     857        int rc = TRPMForwardTrap(pVM, pRegFrame, 0xD, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP, 0xd);
    837858        Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    838859        return trpmGCExitTrap(pVM, rc, pRegFrame);
     
    932953            return VINF_PATM_PATCH_TRAP_PF;
    933954
    934         rc = TRPMForwardTrap(pVM, pRegFrame, 0xE, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP);
     955        rc = TRPMForwardTrap(pVM, pRegFrame, 0xE, 0, TRPM_TRAP_HAS_ERRORCODE, TRPM_TRAP, 0xe);
    935956        Assert(rc == VINF_EM_RAW_GUEST_TRAP);
    936957        break;
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