VirtualBox

Changeset 988 in vbox


Ignore:
Timestamp:
Feb 19, 2007 6:19:14 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18802
Message:

Fixed the real cause of the tripple fault.

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

Legend:

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

    r960 r988  
    237237        VMMAll/TRPMAll.cpp \
    238238        VMMAll/VMAll.cpp \
     239        VMMAll/VMMAll.cpp \
    239240        PATM/VMMGC/CSAMGC.cpp \
    240241        PATM/VMMAll/CSAMAll.cpp \
  • trunk/src/VBox/VMM/VMM.cpp

    r914 r988  
    25952595            fDump = true;
    25962596    }
    2597     else if (    u8Trap != 8 /* double fault doesn't dare setting TrapNo. */
     2597    else if (    rcExpect != VINF_SUCCESS
     2598             &&  u8Trap != 8 /* double fault doesn't dare set TrapNo. */
    25982599             &&  u8Trap != 3 /* guest only, we're not in guest. */
    25992600             &&  u8Trap != 1 /* guest only, we're not in guest. */
     
    26152616        }
    26162617    }
    2617     else
     2618    else if (rcExpect != VINF_SUCCESS)
    26182619    {
    26192620        if (CPUMGetHyperSS(pVM) == SELMGetHyperDS(pVM))
     
    26932694        vmmR3DoTrapTest(pVM, 0xe, 0, VERR_TRPM_DONT_PANIC,  0x00000000, "vmmGCTestTrap0e_FaultEIP", "#PF (NULL)");
    26942695        vmmR3DoTrapTest(pVM, 0xe, 1, VERR_TRPM_DONT_PANIC,  0x00000000, "vmmGCTestTrap0e_FaultEIP", "#PF (NULL) WP");
     2696        vmmR3DoTrapTest(pVM, 0xe, 2, VINF_SUCCESS,          0x00000000, NULL,                       "#PF w/Tmp Handler");
     2697        vmmR3DoTrapTest(pVM, 0xe, 4, VINF_SUCCESS,          0x00000000, NULL,                       "#PF w/Tmp Handler and bad fs");
    26952698
    26962699        /*
  • trunk/src/VBox/VMM/VMMGC/TRPMGCHandlers.cpp

    r716 r988  
    3737#include "TRPMInternal.h"
    3838#include <VBox/vm.h>
     39#include <VBox/param.h>
    3940
    4041#include <VBox/err.h>
     
    978979    {
    979980        /*
    980          * Just zero the register in question.
    981          * We're ASSUMING that esp points to it.
     981         * Check that there is still some stack left, if not we'll flag
     982         * a guru meditation (the alternative is a triple fault).
    982983         */
     984        RTGCUINTPTR cbStackUsed = (RTGCUINTPTR)VMMGetStackGC(pVM) - pRegFrame->esp;
     985        if (cbStackUsed > VMM_STACK_SIZE - _1K)
     986        {
     987            LogRel(("trpmGCTrapInGeneric: ran out of stack: esp=#x cbStackUsed=%#x\n", pRegFrame->esp, cbStackUsed));
     988            return VERR_TRPM_DONT_PANIC;
     989        }
     990
     991        /*
     992         * Just zero the register containing the selector in question.
     993         * We'll deal with the actual stale or troublesome selector value in
     994         * the outermost trap frame.
     995         */
     996        PCPUMCTXCORE pCoreCtx = (PCPUMCTXCORE)pRegFrame->esp;
    983997        switch (uUser & TRPM_TRAP_IN_OP_MASK)
    984998        {
    985999            case TRPM_TRAP_IN_MOV_GS:
     1000                pRegFrame->eax = 0;
     1001                pRegFrame->gs = 0; /* prevent recursive trouble. */
     1002                break;
    9861003            case TRPM_TRAP_IN_MOV_FS:
    987                 *(PRTSEL)pRegFrame->esp = 0;
     1004                pRegFrame->eax = 0;
     1005                pRegFrame->fs = 0; /* prevent recursive trouble. */
    9881006                return VINF_SUCCESS;
    9891007
     
    10141032            case TRPM_TRAP_IN_MOV_DS:
    10151033            {
    1016                 PCPUMCTXCORE pTempGuestCtx = (PCPUMCTXCORE) pEsp;
     1034                PCPUMCTXCORE pTempGuestCtx = (PCPUMCTXCORE)pEsp;
    10171035
    10181036                /* Just copy the whole thing; several selector registers, eip (etc) and eax are not yet in pRegFrame. */
  • trunk/src/VBox/VMM/VMMGC/VMMGC.cpp

    r847 r988  
    2626#define LOG_GROUP LOG_GROUP_VMM
    2727#include <VBox/vmm.h>
     28#include <VBox/trpm.h>
    2829#include "VMMInternal.h"
    2930#include <VBox/vm.h>
     
    4748*******************************************************************************/
    4849static int vmmGCTest(PVM pVM, unsigned uOperation, unsigned uArg);
     50static DECLCALLBACK(int) vmmGCTestTmpPFHandler(PVM pVM, PCPUMCTXCORE pRegFrame);
     51static DECLCALLBACK(int) vmmGCTestTmpPFHandlerCorruptFS(PVM pVM, PCPUMCTXCORE pRegFrame);
    4952
    5053
     
    264267            if (uArg <= 1)
    265268                rc = vmmGCTestTrap0e();
     269            else if (uArg == 2 || uArg == 4)
     270            {
     271                /*
     272                 * Test the use of a temporary #PF handler.
     273                 */
     274                rc = TRPMGCSetTempHandler(pVM, X86_XCPT_PF, uArg != 4 ? vmmGCTestTmpPFHandler : vmmGCTestTmpPFHandlerCorruptFS);
     275                if (VBOX_SUCCESS(rc))
     276                {
     277                    rc = vmmGCTestTrap0e();
     278
     279                    /* in case it didn't fire. */
     280                    int rc2 = TRPMGCSetTempHandler(pVM, X86_XCPT_PF, NULL);
     281                    if (VBOX_FAILURE(rc2) && VBOX_SUCCESS(rc))
     282                        rc = rc2;
     283                }
     284            }
    266285            break;
    267286        }
     
    277296}
    278297
     298
     299/**
     300 * Temporary #PF trap handler for the #PF test case.
     301 *
     302 * @returns VBox status code (appropriate for GC return).
     303 *          In this context VBOX_SUCCESS means to restart the instruction.
     304 * @param   pVM         VM handle.
     305 * @param   pRegFrame   Trap register frame.
     306 */
     307static DECLCALLBACK(int) vmmGCTestTmpPFHandler(PVM pVM, PCPUMCTXCORE pRegFrame)
     308{
     309    if (pRegFrame->eip == (uintptr_t)vmmGCTestTrap0e_FaultEIP)
     310    {
     311        pRegFrame->eip = (uintptr_t)vmmGCTestTrap0e_ResumeEIP;
     312        return VINF_SUCCESS;
     313    }
     314    return VERR_INTERNAL_ERROR;
     315}
     316
     317
     318/**
     319 * Temporary #PF trap handler for the #PF test case, this one messes up the fs selector.
     320 *
     321 * @returns VBox status code (appropriate for GC return).
     322 *          In this context VBOX_SUCCESS means to restart the instruction.
     323 * @param   pVM         VM handle.
     324 * @param   pRegFrame   Trap register frame.
     325 */
     326static DECLCALLBACK(int) vmmGCTestTmpPFHandlerCorruptFS(PVM pVM, PCPUMCTXCORE pRegFrame)
     327{
     328    int rc = vmmGCTestTmpPFHandler(pVM, pRegFrame);
     329    pRegFrame->fs = 0x30;
     330    return rc;
     331}
     332
  • trunk/src/VBox/VMM/VMMGC/VMMGCA.asm

    r19 r988  
    210210    mov     eax, 0ffffffffh
    211211    ret
     212
     213EXPORTEDNAME vmmGCTestTrap0e_ResumeEIP
     214    RestoreAll
     215    xor     eax, eax
     216    ret
    212217ENDPROC vmmGCTestTrap0e
    213218
  • trunk/src/VBox/VMM/VMMInternal.h

    r914 r988  
    451451VMMGCDECL(int) vmmGCLoggerFlush(PRTLOGGERGC pLogger);
    452452
    453 /** @name Trap testcases
     453/** @name Trap testcases and related labels.
    454454 * @{ */
    455455DECLASM(void) vmmGCEnableWP(void);
     
    459459DECLASM(int) vmmGCTestTrap0d(void);
    460460DECLASM(int) vmmGCTestTrap0e(void);
     461DECLASM(int) vmmGCTestTrap0e_FaultEIP(void); /**< a label */
     462DECLASM(int) vmmGCTestTrap0e_ResumeEIP(void); /**< a label */
    461463/** @} */
    462464
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