VirtualBox

Changeset 5394 in vbox


Ignore:
Timestamp:
Oct 21, 2007 1:49:38 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25505
Message:

/TRPM/SafeToDropGuestIDTMonitoring

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

Legend:

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

    r4071 r5394  
    394394
    395395
    396 /**
    397  * Enable or disable tracking of Guest's IDT.
    398  * @{
    399  */
     396/** Enable or disable tracking of Guest's IDT. */
    400397#define TRPM_TRACK_GUEST_IDT_CHANGES
    401 /** @} */
    402 
    403 /**
    404  * Enable or disable tracking of Shadow IDT.
    405  * @{
    406  */
     398
     399/** Enable or disable tracking of Shadow IDT. */
    407400#define TRPM_TRACK_SHADOW_IDT_CHANGES
    408 /** @} */
    409401
    410402/** TRPM saved state version. */
     
    445437    pVM->trpm.s.GCPtrIdt           = ~0;
    446438    pVM->trpm.s.fDisableMonitoring = false;
     439    pVM->trpm.s.fSafeToDropGuestIDTMonitoring = false;
     440
     441    /*
     442     * Read the configuration (if any).
     443     */
     444    PCFGMNODE pTRPMNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "TRPM");
     445    if (pTRPMNode)
     446    {
     447        bool f;
     448        int rc = CFGMR3QueryBool(pTRPMNode, "SafeToDropGuestIDTMonitoring", &f);
     449        if (RT_SUCCESS(rc))
     450            pVM->trpm.s.fSafeToDropGuestIDTMonitoring = f;
     451    }
     452
     453    /* write config summary to log */
     454    if (pVM->trpm.s.fSafeToDropGuestIDTMonitoring)
     455        LogRel(("TRPM: Dropping Guest IDT Monitoring.\n"));
    447456
    448457    /*
     
    557566     * Iterate the idt and set the addresses.
    558567     */
    559     PVBOXIDTE   pIdte        = &pVM->trpm.s.aIdt[0];
    560     PVBOXIDTE_GENERIC   pIdteTemplate = &g_aIdt[0];
     568    PVBOXIDTE pIdte = &pVM->trpm.s.aIdt[0];
     569    PVBOXIDTE_GENERIC pIdteTemplate = &g_aIdt[0];
    561570    for (unsigned i = 0; i < ELEMENTS(pVM->trpm.s.aIdt); i++, pIdte++, pIdteTemplate++)
    562571    {
     
    673682    if (pVM->trpm.s.GuestIdtr.pIdt != ~0U)
    674683    {
    675         int rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
    676         AssertRC(rc);
     684        if (!pVM->trpm.s.fSafeToDropGuestIDTMonitoring)
     685        {
     686            int rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
     687            AssertRC(rc);
     688        }
    677689        pVM->trpm.s.GuestIdtr.pIdt = ~0U;
    678690    }
     
    719731    SSMR3PutGCUIntPtr(pSSM, pTrpm->uSavedCR2);
    720732    SSMR3PutGCUInt(pSSM,    pTrpm->uPrevVector);
     733#if 0  /** @todo Enable this (+ load change) on the next version change. */
     734    SSMR3PutBool(pSSM,      pTrpm->fDisableMonitoring);
     735#else
    721736    SSMR3PutGCUInt(pSSM,    pTrpm->fDisableMonitoring);
     737#endif
    722738    SSMR3PutUInt(pSSM,      VM_FF_ISSET(pVM, VM_FF_TRPM_SYNC_IDT));
    723739    SSMR3PutMem(pSSM,       &pTrpm->au32IdtPatched[0], sizeof(pTrpm->au32IdtPatched));
     
    780796    SSMR3GetGCUIntPtr(pSSM, &pTrpm->uSavedCR2);
    781797    SSMR3GetGCUInt(pSSM,    &pTrpm->uPrevVector);
    782     SSMR3GetGCUInt(pSSM,    &pTrpm->fDisableMonitoring);
     798#if 0 /** @todo Enable this + the corresponding save code on the next version change. */
     799    SSMR3GetBool(pSSM,      &pTrpm->fDisableMonitoring);
     800#else
     801    RTGCUINT fDisableMonitoring;
     802    SSMR3GetGCUInt(pSSM,    &fDisableMonitoring);
     803    pTrpm->fDisableMonitoring = !!fDisableMonitoring;
     804#endif
    783805
    784806    RTUINT fSyncIDT;
     
    892914    {
    893915        Log(("TRPMR3UpdateFromCPUM: Guest's IDT is changed to pIdt=%08X cbIdt=%08X\n", IDTR.pIdt, IDTR.cbIdt));
    894 
    895         /*
    896          * [Re]Register write virtual handler for guest's IDT.
    897          */
    898         if (pVM->trpm.s.GuestIdtr.pIdt != ~0U)
    899         {
    900             rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
    901             AssertRCReturn(rc, rc);
    902         }
    903         /* limit is including */
    904         rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_WRITE, IDTR.pIdt, IDTR.pIdt + IDTR.cbIdt /* already inclusive */,
    905                                          0, trpmGuestIDTWriteHandler, "trpmgcGuestIDTWriteHandler", 0, "Guest IDT write access handler");
    906 
    907         if (rc == VERR_PGM_HANDLER_VIRTUAL_CONFLICT)
    908         {
    909             /* Could be a conflict with CSAM */
    910             CSAMR3RemovePage(pVM, IDTR.pIdt);
    911             if (PAGE_ADDRESS(IDTR.pIdt) != PAGE_ADDRESS(IDTR.pIdt + IDTR.cbIdt))
    912                 CSAMR3RemovePage(pVM, IDTR.pIdt + IDTR.cbIdt);
    913 
     916        if (!pVM->trpm.s.fSafeToDropGuestIDTMonitoring)
     917        {
     918            /*
     919             * [Re]Register write virtual handler for guest's IDT.
     920             */
     921            if (pVM->trpm.s.GuestIdtr.pIdt != ~0U)
     922            {
     923                rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
     924                AssertRCReturn(rc, rc);
     925            }
     926            /* limit is including */
    914927            rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_WRITE, IDTR.pIdt, IDTR.pIdt + IDTR.cbIdt /* already inclusive */,
    915928                                             0, trpmGuestIDTWriteHandler, "trpmgcGuestIDTWriteHandler", 0, "Guest IDT write access handler");
    916         }
    917 
    918         AssertRCReturn(rc, rc);
     929
     930            if (rc == VERR_PGM_HANDLER_VIRTUAL_CONFLICT)
     931            {
     932                /* Could be a conflict with CSAM */
     933                CSAMR3RemovePage(pVM, IDTR.pIdt);
     934                if (PAGE_ADDRESS(IDTR.pIdt) != PAGE_ADDRESS(IDTR.pIdt + IDTR.cbIdt))
     935                    CSAMR3RemovePage(pVM, IDTR.pIdt + IDTR.cbIdt);
     936
     937                rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_WRITE, IDTR.pIdt, IDTR.pIdt + IDTR.cbIdt /* already inclusive */,
     938                                                 0, trpmGuestIDTWriteHandler, "trpmgcGuestIDTWriteHandler", 0, "Guest IDT write access handler");
     939            }
     940
     941            AssertRCReturn(rc, rc);
     942        }
    919943
    920944        /* Update saved Guest IDTR. */
     
    962986    if (pVM->trpm.s.GuestIdtr.pIdt != ~0U)
    963987    {
    964         int rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
    965         AssertRC(rc);
     988        if (!pVM->trpm.s.fSafeToDropGuestIDTMonitoring)
     989        {
     990            int rc = PGMHandlerVirtualDeregister(pVM, pVM->trpm.s.GuestIdtr.pIdt);
     991            AssertRC(rc);
     992        }
    966993        pVM->trpm.s.GuestIdtr.pIdt = ~0U;
    967994    }
  • trunk/src/VBox/VMM/TRPMInternal.h

    r4829 r5394  
    117117    RTGCUINT        uPrevVector;
    118118
    119     /** IDT monitoring and sync flag */
    120     RTUINT          fDisableMonitoring; /** @todo r=bird: bool and 7 byte achPadding1. */
     119    /** IDT monitoring and sync flag (HWACC). */
     120    bool            fDisableMonitoring; /** @todo r=bird: bool and 7 byte achPadding1. */
     121
     122    /** Whether monitoring of the guest IDT is enabled or not.
     123     *
     124     * This configuration option is provided for speeding up guest like Solaris
     125     * that put the IDT on the same page as a whole lot of other data that is
     126     * freqently updated. The updates will cause #PFs and have to be interpreted
     127     * by PGMInterpretInstruction which is slow compared to raw execution.
     128     *
     129     * If the guest is well behaved and doesn't change the IDT after loading it,
     130     * there is no problem with dropping the IDT monitoring.
     131     *
     132     * @cfgm    /TRPM/SafeToDropGuestIDTMonitoring   boolean     defaults to false.
     133     */
     134    bool            fSafeToDropGuestIDTMonitoring;
    121135
    122136    /** Padding to get the IDTs at a 16 byte alignement. */
    123     char            achPadding1[4];
     137    uint8_t         abPadding1[6];
    124138
    125139    /** IDTs. Aligned at 16 byte offset for speed. */
  • trunk/src/VBox/VMM/TRPMInternal.mac

    r4071 r5394  
    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;
     
    3838    .uSavedCR2          resd 1
    3939    .uPrevVector        resd 1
    40     .fDisableMonitoring resd 1
    41     .achPadding1        resb 4
     40    .fDisableMonitoring resb 1
     41    .fSafeToDropGuestIDTMonitoring resb 1
     42    .abPadding1         resb 6
    4243    .aIdt               resd 512
    4344    .au32IdtPatched     resd 8
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