Index: /trunk/src/VBox/Disassembler/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Disassembler/Makefile.kmk	(revision 26222)
+++ /trunk/src/VBox/Disassembler/Makefile.kmk	(revision 26223)
@@ -51,8 +51,8 @@
 
 ifdef VBOX_WITH_RAW_MODE
- LIBRARIES              += DisasmGC
- DisasmGC_TEMPLATE       = VBoxRc
- DisasmGC_DEFS           = IN_DIS IN_RT_GC IN_RT_RC DIS_CORE_ONLY
- DisasmGC_SOURCES        = \
+ LIBRARIES              += DisasmRC
+ DisasmRC_TEMPLATE       = VBoxRc
+ DisasmRC_DEFS           = IN_DIS IN_RT_GC IN_RT_RC DIS_CORE_ONLY
+ DisasmRC_SOURCES        = \
  	DisasmCore.cpp \
  	DisasmReg.cpp \
Index: /trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/Makefile.kmk	(revision 26222)
+++ /trunk/src/VBox/Runtime/Makefile.kmk	(revision 26223)
@@ -60,5 +60,5 @@
  LIBRARIES += RuntimeR3 RuntimeR0 RuntimeEFCPP RuntimeR3NoCRTGCC
  ifdef VBOX_WITH_RAW_MODE
-  LIBRARIES += RuntimeGC
+  LIBRARIES += RuntimeRC
  endif
  ifdef VBOX_WITH_VBOXDRV
@@ -1547,10 +1547,10 @@
 ifdef VBOX_WITH_RAW_MODE
  #
- # RuntimeGC - Guest context library.
+ # RuntimeRC - Raw-mode context library.
  #
- RuntimeGC_TEMPLATE      = VBoxRc
- RuntimeGC_DEFS          = IN_RT_GC RT_WITH_VBOX
- RuntimeGC_INCS          = include
- RuntimeGC_SOURCES       = \
+ RuntimeRC_TEMPLATE      = VBoxRc
+ RuntimeRC_DEFS          = IN_RT_GC RT_WITH_VBOX
+ RuntimeRC_INCS          = include
+ RuntimeRC_SOURCES       = \
  	common/log/log.cpp \
  	common/log/logellipsis.cpp \
@@ -1595,17 +1595,17 @@
 
  #if1of ($(KBUILD_TARGET_ARCH),amd64 x86)
- # RuntimeGC_SOURCES += common/time/timesupA.asm
+ # RuntimeRC_SOURCES += common/time/timesupA.asm
  #else
-  RuntimeGC_SOURCES += common/time/timesupref.cpp
+  RuntimeRC_SOURCES += common/time/timesupref.cpp
  #endif
 
- RuntimeGC_SOURCES.win.x86 = $(RuntimeWin32ASM_SOURCES)
+ RuntimeRC_SOURCES.win.x86 = $(RuntimeWin32ASM_SOURCES)
 
  ifeq ($(VBOX_LDR_FMT32),lx)
-  RuntimeGC_SOURCES += os2/sys0.asm
+  RuntimeRC_SOURCES += os2/sys0.asm
  endif
 
  if1of ($(KBUILD_TARGET), darwin solaris freebsd)
-  RuntimeGC_SOURCES += \
+  RuntimeRC_SOURCES += \
  	common/math/gcc/adddi3.c \
  	common/math/gcc/anddi3.c \
Index: /trunk/src/VBox/Runtime/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 26222)
+++ /trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 26223)
@@ -238,6 +238,6 @@
  endif
  tstLdrObj_LIBS = \
- 	$(PATH_LIB)/DisasmGC$(VBOX_SUFF_LIB) \
- 	$(PATH_LIB)/RuntimeGC$(VBOX_SUFF_LIB)
+ 	$(PATH_LIB)/DisasmRC$(VBOX_SUFF_LIB) \
+ 	$(PATH_LIB)/RuntimeRC$(VBOX_SUFF_LIB)
  ifeq ($(VBOX_LDR_FMT32),pe)
  tstLdrObj_LDFLAGS = -Entry:Entrypoint
Index: /trunk/src/VBox/VMM/Makefile.kmk
===================================================================
--- /trunk/src/VBox/VMM/Makefile.kmk	(revision 26222)
+++ /trunk/src/VBox/VMM/Makefile.kmk	(revision 26223)
@@ -351,6 +351,6 @@
 
  VMMGC_LIBS      = \
- 	$(PATH_LIB)/DisasmGC$(VBOX_SUFF_LIB) \
- 	$(PATH_LIB)/RuntimeGC$(VBOX_SUFF_LIB)
+ 	$(PATH_LIB)/DisasmRC$(VBOX_SUFF_LIB) \
+ 	$(PATH_LIB)/RuntimeRC$(VBOX_SUFF_LIB)
  ifneq ($(filter pe lx,$(VBOX_LDR_FMT32)),)
   VMMGC_LIBS    += \
Index: /trunk/src/VBox/VMM/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 26222)
+++ /trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 26223)
@@ -48,5 +48,5 @@
  ifdef VBOX_WITH_RAW_MODE
   PROGRAMS += tstMicro
-  SYSMODS  += tstMicroGC
+  SYSMODS  += tstMicroRC
  endif
  ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
@@ -228,21 +228,21 @@
  tstMicro_LIBS           = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
- tstMicroGC_TEMPLATE     = VBoxRc
- tstMicroGC_SOURCES      = tstMicroGC.cpp tstMicroGCA.asm
- tstMicroGC_DEFS         =
- tstMicroGC_INCS         = $(VBOX_PATH_VMM_SRC)/testcase
+ tstMicroRC_TEMPLATE     = VBoxRc
+ tstMicroRC_SOURCES      = tstMicroRC.cpp tstMicroRCA.asm
+ tstMicroRC_DEFS         =
+ tstMicroRC_INCS         = $(VBOX_PATH_VMM_SRC)/testcase
  ifeq ($(VBOX_LDR_FMT32),pe)
-  tstMicroGC_LDFLAGS     = -Entry:tstMicroGC
- endif
- tstMicroGC_SYSSUFF      = .gc
- tstMicroGC_LIBS         = \
- 	$(PATH_LIB)/DisasmGC$(VBOX_SUFF_LIB) \
- 	$(PATH_LIB)/RuntimeGC$(VBOX_SUFF_LIB)
+  tstMicroRC_LDFLAGS     = -Entry:tstMicroRC
+ endif
+ tstMicroRC_SYSSUFF      = .gc
+ tstMicroRC_LIBS         = \
+ 	$(PATH_LIB)/DisasmRC$(VBOX_SUFF_LIB) \
+ 	$(PATH_LIB)/RuntimeRC$(VBOX_SUFF_LIB)
  ifeq ($(filter-out pe lx,$(VBOX_LDR_FMT32)),)
-  tstMicroGC_LIBS        += \
+  tstMicroRC_LIBS        += \
   	$(PATH_LIB)/VMMGCBuiltin$(VBOX_SUFF_LIB) \
   	$(LIB_VMMGC)
  endif
- tstMicroGC_SOURCES.win = tstMicroGC.def
+ tstMicroRC_SOURCES.win = tstMicroRC.def
 
 endif # VBOX_WITH_RAW_MODE
Index: /trunk/src/VBox/VMM/testcase/tstMicro.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicro.cpp	(revision 26222)
+++ /trunk/src/VBox/VMM/testcase/tstMicro.cpp	(revision 26223)
@@ -203,29 +203,29 @@
      * Loading the module and resolve the entry point.
      */
-    int rc = PDMR3LdrLoadRC(pVM, NULL, "tstMicroGC.gc");
-    if (RT_FAILURE(rc))
-    {
-        RTPrintf(TESTCASE ": Failed to load tstMicroGC.gc, rc=%Rra\n", rc);
+    int rc = PDMR3LdrLoadRC(pVM, NULL, "tstMicroRC.gc");
+    if (RT_FAILURE(rc))
+    {
+        RTPrintf(TESTCASE ": Failed to load tstMicroRC.gc, rc=%Rra\n", rc);
         return rc;
     }
     RTRCPTR RCPtrEntry;
-    rc = PDMR3LdrGetSymbolRC(pVM, "tstMicroGC.gc", "tstMicroGC", &RCPtrEntry);
-    if (RT_FAILURE(rc))
-    {
-        RTPrintf(TESTCASE ": Failed to resolve the 'tstMicroGC' entry point in tstMicroGC.gc, rc=%Rra\n", rc);
+    rc = PDMR3LdrGetSymbolRC(pVM, "tstMicroRC.gc", "tstMicroRC", &RCPtrEntry);
+    if (RT_FAILURE(rc))
+    {
+        RTPrintf(TESTCASE ": Failed to resolve the 'tstMicroRC' entry point in tstMicroRC.gc, rc=%Rra\n", rc);
         return rc;
     }
     RTRCPTR RCPtrStart;
-    rc = PDMR3LdrGetSymbolRC(pVM, "tstMicroGC.gc", "tstMicroGCAsmStart", &RCPtrStart);
-    if (RT_FAILURE(rc))
-    {
-        RTPrintf(TESTCASE ": Failed to resolve the 'tstMicroGCAsmStart' entry point in tstMicroGC.gc, rc=%Rra\n", rc);
+    rc = PDMR3LdrGetSymbolRC(pVM, "tstMicroRC.gc", "tstMicroRCAsmStart", &RCPtrStart);
+    if (RT_FAILURE(rc))
+    {
+        RTPrintf(TESTCASE ": Failed to resolve the 'tstMicroRCAsmStart' entry point in tstMicroRC.gc, rc=%Rra\n", rc);
         return rc;
     }
     RTRCPTR RCPtrEnd;
-    rc = PDMR3LdrGetSymbolRC(pVM, "tstMicroGC.gc", "tstMicroGCAsmEnd", &RCPtrEnd);
-    if (RT_FAILURE(rc))
-    {
-        RTPrintf(TESTCASE ": Failed to resolve the 'tstMicroGCAsmEnd' entry point in tstMicroGC.gc, rc=%Rra\n", rc);
+    rc = PDMR3LdrGetSymbolRC(pVM, "tstMicroRC.gc", "tstMicroRCAsmEnd", &RCPtrEnd);
+    if (RT_FAILURE(rc))
+    {
+        RTPrintf(TESTCASE ": Failed to resolve the 'tstMicroRCAsmEnd' entry point in tstMicroRC.gc, rc=%Rra\n", rc);
         return rc;
     }
Index: unk/src/VBox/VMM/testcase/tstMicroGC.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicroGC.cpp	(revision 26222)
+++ 	(revision )
@@ -1,261 +1,0 @@
-/* $Id$ */
-/** @file
- * Micro Testcase, profiling special CPU operations - GC Code (hacks).
- */
-
-/*
- * Copyright (C) 2006-2007 Sun Microsystems, Inc.
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
- * Clara, CA 95054 USA or visit http://www.sun.com if you need
- * additional information or have any questions.
- */
-
-/*******************************************************************************
-*   Header Files                                                               *
-*******************************************************************************/
-#include <VBox/vm.h>
-#include <VBox/vmm.h>
-#include <VBox/selm.h>
-#include "tstMicro.h"
-
-#include <VBox/err.h>
-#include <iprt/asm.h>
-#include <VBox/log.h>
-#include <iprt/assert.h>
-#include <iprt/string.h>
-
-
-/*******************************************************************************
-*   Internal Functions                                                         *
-*******************************************************************************/
-RT_C_DECLS_BEGIN
-DECLEXPORT(int) tstMicroGC(PTSTMICRO pTst, unsigned uTestcase);
-RT_C_DECLS_END
-
-
-/**
- * Save and load our IDT.
- *
- * @param   pTst    Pointer to the instance data.
- * @param   iIDT    The index of the IDT entry which should be hooked.
- */
-void idtInstall(PTSTMICRO pTst, int iIDT)
-{
-    RTIDTR Idtr;
-    ASMGetIDTR(&Idtr);
-    if (Idtr.pIdt == (uintptr_t)&pTst->aIDT[0])
-        return;
-    pTst->OriginalIDTR.cbIdt = Idtr.cbIdt;
-    pTst->OriginalIDTR.pIdt  = Idtr.pIdt;
-
-    /*
-     * Copy the IDT.
-     */
-    if (Idtr.cbIdt >= sizeof(pTst->aIDT))
-        Idtr.cbIdt = sizeof(pTst->aIDT) - 1;
-    memcpy(&pTst->aIDT[0], (void *)Idtr.pIdt, Idtr.cbIdt + 1);
-
-
-    /* Hook up IDT entry. */
-    if (iIDT >= 0)
-    {
-        uintptr_t uHandler = (uintptr_t)tstTrapHandlerNoErr;
-        if (    iIDT == 8
-            ||  iIDT == 0xa
-            ||  iIDT == 0xb
-            ||  iIDT == 0xc
-            ||  iIDT == 0xd
-            ||  iIDT == 0xe
-            ||  iIDT == 0x11)
-            uHandler = (uintptr_t)tstTrapHandler;
-        pTst->aIDT[iIDT].Int.u16OffsetHigh  = uHandler >> 16;
-        pTst->aIDT[iIDT].Int.u16OffsetLow   = uHandler & 0xffff;
-        pTst->aIDT[iIDT].Int.u16SegSel      = SELMGetHyperCS(&g_VM);
-        pTst->aIDT[iIDT].Int.u2DPL          = 3;
-        pTst->aIDT[iIDT].Int.u1Present      = 1;
-        pTst->aIDT[iIDT].Int.u1Fixed0       = 0;
-        pTst->aIDT[iIDT].Int.u1Fixed1       = 0;
-        pTst->aIDT[iIDT].Int.u1Fixed2       = 0;
-        pTst->aIDT[iIDT].Int.u1Fixed3       = 0;
-        pTst->aIDT[iIDT].Int.u1Fixed4       = 1;
-        pTst->aIDT[iIDT].Int.u1Fixed5       = 1;
-        pTst->aIDT[iIDT].Int.u132BitGate    = 1;
-        pTst->aIDT[iIDT].Int.u1Fixed6       = 0;
-        pTst->aIDT[iIDT].Int.u5Reserved2    = 0;
-    }
-
-    /* Install int 42h, R3 gate */
-    pTst->aIDT[0x42].Int.u16OffsetHigh  = (uintptr_t)tstInterrupt42 >> 16;
-    pTst->aIDT[0x42].Int.u16OffsetLow   = (uintptr_t)tstInterrupt42 & 0xffff;
-    pTst->aIDT[0x42].Int.u16SegSel      = SELMGetHyperCS(&g_VM);
-    pTst->aIDT[0x42].Int.u2DPL          = 3;
-    pTst->aIDT[0x42].Int.u1Present      = 1;
-    pTst->aIDT[0x42].Int.u1Fixed0       = 0;
-    pTst->aIDT[0x42].Int.u1Fixed1       = 0;
-    pTst->aIDT[0x42].Int.u1Fixed2       = 0;
-    pTst->aIDT[0x42].Int.u1Fixed3       = 0;
-    pTst->aIDT[0x42].Int.u1Fixed4       = 1;
-    pTst->aIDT[0x42].Int.u1Fixed5       = 1;
-    pTst->aIDT[0x42].Int.u132BitGate    = 1;
-    pTst->aIDT[0x42].Int.u1Fixed6       = 0;
-    pTst->aIDT[0x42].Int.u5Reserved2    = 0;
-
-    /*
-     * Load our IDT.
-     */
-    Idtr.pIdt = (uintptr_t)&pTst->aIDT[0];
-    ASMSetIDTR(&Idtr);
-
-    RTIDTR Idtr2;
-    ASMGetIDTR(&Idtr2);
-    Assert(Idtr2.pIdt == (uintptr_t)&pTst->aIDT[0]);
-}
-
-
-/**
- * Removes all trap overrides except for gate 42.
- */
-DECLASM(void) idtOnly42(PTSTMICRO pTst)
-{
-    if (pTst->OriginalIDTR.pIdt)
-        memcpy(&pTst->aIDT[0], (void *)pTst->OriginalIDTR.pIdt, sizeof(VBOXIDTE) * 32);
-}
-
-
-
-DECLEXPORT(int) tstMicroGC(PTSTMICRO pTst, unsigned uTestcase)
-{
-    RTLogPrintf("pTst=%p uTestcase=%d\n", pTst, uTestcase);
-
-    /*
-     * Validate input.
-     */
-    if (uTestcase >= TSTMICROTEST_MAX)
-        return VERR_INVALID_PARAMETER;
-
-    /*
-     * Clear the results.
-     */
-    pTst->u64TSCR0Start = 0;
-    pTst->u64TSCRxStart = 0;
-    pTst->u64TSCR0Enter = 0;
-    pTst->u64TSCR0Exit = 0;
-    pTst->u64TSCRxEnd = 0;
-    pTst->u64TSCR0End = 0;
-    pTst->cHits = 0;
-    pTst->offEIPAdd = 0;
-    pTst->u32CR2 = 0;
-    pTst->u32EIP = 0;
-    pTst->u32ErrCd = 0;
-    PTSTMICRORESULT pRes = &pTst->aResults[uTestcase];
-    memset(&pTst->aResults[uTestcase], 0, sizeof(pTst->aResults[uTestcase]));
-
-
-    /*
-     * Do the testcase.
-     */
-    int rc = VINF_SUCCESS;
-    switch (uTestcase)
-    {
-        case TSTMICROTEST_OVERHEAD:
-        {
-            tstOverhead(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_INVLPG_0:
-        {
-            tstInvlpg0(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_INVLPG_EIP:
-        {
-            tstInvlpgEIP(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_INVLPG_ESP:
-        {
-            tstInvlpgESP(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_CR3_RELOAD:
-        {
-            tstCR3Reload(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_WP_DISABLE:
-        {
-            tstWPDisable(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_WP_ENABLE:
-        {
-            tstWPEnable(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_PF_R0:
-        {
-            idtInstall(pTst, 0xe);
-            pTst->offEIPAdd = 2;
-            rc = tstPFR0(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_PF_R1:
-        {
-            idtInstall(pTst, 0xe);
-            pTst->offEIPAdd = 2;
-            rc = tstPFR1(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_PF_R2:
-        {
-            idtInstall(pTst, 0xe);
-            pTst->offEIPAdd = 2;
-            rc = tstPFR2(pTst);
-            break;
-        }
-
-        case TSTMICROTEST_PF_R3:
-        {
-            idtInstall(pTst, 0xe);
-            pTst->offEIPAdd = 2;
-            rc = tstPFR3(pTst);
-            break;
-        }
-
-    }
-
-    /*
-     * Compute the results.
-     */
-    if (pTst->u64TSCR0End   && pTst->u64TSCR0Start)
-        pRes->cTotalTicks       = pTst->u64TSCR0End     - pTst->u64TSCR0Start   - pTst->u64Overhead;
-    if (pTst->u64TSCRxStart && pTst->u64TSCR0Start)
-        pRes->cToRxFirstTicks   = pTst->u64TSCRxStart   - pTst->u64TSCR0Start   - pTst->u64Overhead;
-    if (pTst->u64TSCR0Enter && pTst->u64TSCRxStart)
-        pRes->cTrapTicks        = pTst->u64TSCR0Enter   - pTst->u64TSCRxStart   - pTst->u64Overhead;
-    if (pTst->u64TSCRxEnd   && pTst->u64TSCR0Exit)
-        pRes->cToRxTrapTicks    = pTst->u64TSCRxEnd     - pTst->u64TSCR0Exit    - pTst->u64Overhead;
-    if (pTst->u64TSCR0End   && pTst->u64TSCRxEnd)
-        pRes->cToR0Ticks        = pTst->u64TSCR0End     - pTst->u64TSCRxEnd     - pTst->u64Overhead;
-
-    return rc;
-}
-
Index: unk/src/VBox/VMM/testcase/tstMicroGC.def
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicroGC.def	(revision 26222)
+++ 	(revision )
@@ -1,31 +1,0 @@
-;; @file
-;
-; VMM Guest Context Micro Benchmark - Definition file.
-
-; Copyright (C) 2006-2007 Sun Microsystems, Inc.
-;
-; This file is part of VirtualBox Open Source Edition (OSE), as
-; available from http://www.virtualbox.org. This file is free software;
-; you can redistribute it and/or modify it under the terms of the GNU
-; General Public License (GPL) as published by the Free Software
-; Foundation, in version 2 as it comes in the "COPYING" file of the
-; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
-; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
-;
-; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
-; Clara, CA 95054 USA or visit http://www.sun.com if you need
-; additional information or have any questions.
-;
-
-LIBRARY tstMicroGC.gc
-EXPORTS
-    ; data
-
-    ; code
-    tstMicroGCAsmStart
-    tstMicroGCAsmEnd
-    tstPFR1
-    tstPFR2
-    tstPFR3
-    tstTrapHandlerNoErr
-
Index: unk/src/VBox/VMM/testcase/tstMicroGCA.asm
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicroGCA.asm	(revision 26222)
+++ 	(revision )
@@ -1,560 +1,0 @@
-; $Id$
-;; @file
-; tstMicroGCA
-;
-
-;
-; Copyright (C) 2006-2007 Sun Microsystems, Inc.
-;
-; This file is part of VirtualBox Open Source Edition (OSE), as
-; available from http://www.virtualbox.org. This file is free software;
-; you can redistribute it and/or modify it under the terms of the GNU
-; General Public License (GPL) as published by the Free Software
-; Foundation, in version 2 as it comes in the "COPYING" file of the
-; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
-; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
-;
-; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
-; Clara, CA 95054 USA or visit http://www.sun.com if you need
-; additional information or have any questions.
-;
-
-;*******************************************************************************
-;*      Header Files                                                           *
-;*******************************************************************************
-%include "VBox/asmdefs.mac"
-%include "VBox/x86.mac"
-%include "VBox/cpum.mac"
-%include "VBox/err.mac"
-%include "VBox/vm.mac"
-%include "tstMicro.mac"
-
-
-;*******************************************************************************
-;*      Defined Constants And Macros                                           *
-;*******************************************************************************
-;;
-; Function prolog which saves everything and loads the first parameter into ebx.
-%macro PROLOG 0
-    push    ebp
-    mov     ebp, esp
-    push    ebx
-    push    esi
-    push    edi
-    mov     ebx, [ebp + 8]                      ; pTst
-%endm
-
-;;
-; Function epilog which saves everything and loads the first parameter into ebx.
-%macro EPILOG 0
-    pop     edi
-    pop     esi
-    pop     ebx
-    leave
-%endm
-
-;;
-; Does an rdtsc (trashing edx:eax) and move the result to edi:esi.
-%macro RDTSC_EDI_ESI 0
-    rdtsc
-    xchg    eax, esi
-    xchg    edx, edi
-%endm
-
-;;
-; Does an rdtsc (trashing edx:eax) and move the result to ecx:ebp.
-%macro RDTSC_ECX_EBP 0
-    rdtsc
-    xchg    eax, ebp
-    xchg    edx, ecx
-%endm
-
-;;
-; Saves the result of an instruction profiling operation.
-;
-; Input is in edi:esi (start) and [ebp + 8] points to TSTMICRO.
-; Trashes ebx.
-%macro STORE_INSTR_PRF_RESULT 0
-    mov     ebx, [ebp + 8]
-    mov     [ebx + TSTMICRO.u64TSCR0Start    ], esi
-    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edi
-    mov     [ebx + TSTMICRO.u64TSCR0End      ], eax
-    mov     [ebx + TSTMICRO.u64TSCR0End   + 4], edx
-%endm
-
-;;
-; Samples the end time of an instruction profiling operation and
-; Saves the result of an instruction profiling operation.
-;
-; Input is in edi:esi (start) and [ebp + 8] points to TSTMICRO.
-; Trashes ebx.
-%macro RDTSC_STORE_INSTR_PRF_RESULT 0
-    rdtsc
-    STORE_INSTR_PRF_RESULT
-%endm
-
-
-;;
-; copies the stack to gabStackCopy and saves ESP and EBP in gpESP and gpEBP.
-;
-; @param    %1      The resume label.
-; @param    ebx     TSTMICRO pointer.
-; @uses     ecx, edi, esi, flags.
-%macro COPY_STACK_ESP_EBP_RESUME 1
-    mov     [gpTst], ebx
-    mov     [gESPResume], esp
-    mov     [gEBPResume], ebp
-    mov     dword [gEIPResume], %1
-
-    mov     esi, esp
-    and     esi, ~0fffh
-    mov     edi, gabStackCopy
-    mov     ecx, 01000h / 4
-    rep     movsd
-
-%endm
-
-
-;*******************************************************************************
-;*  Global Variables                                                           *
-;*******************************************************************************
-BEGINDATA
-gpTst       dd 0
-
-gESPResume  dd 0
-gEBPResume  dd 0
-gEIPResume  dd 0
-
-BEGINBSS
-gabStackCopy resb  4096
-
-extern NAME(idtOnly42)
-extern IMPNAME(g_VM)
-
-BEGINCODE
-EXPORTEDNAME tstMicroGCAsmStart
-
-
-;;
-; Check the overhead of doing rdtsc + two xchg operations.
-;
-BEGINPROC tstOverhead
-    PROLOG
-
-    RDTSC_EDI_ESI
-    RDTSC_STORE_INSTR_PRF_RESULT
-
-    EPILOG
-    ret
-ENDPROC tstOverhead
-
-
-;;
-; Invalidate page 0.
-;
-BEGINPROC tstInvlpg0
-    PROLOG
-
-    RDTSC_EDI_ESI
-    invlpg  [0]
-    RDTSC_STORE_INSTR_PRF_RESULT
-
-    EPILOG
-    ret
-ENDPROC tstInvlpg0
-
-;;
-; Invalidate the current code page.
-;
-BEGINPROC tstInvlpgEIP
-    PROLOG
-
-    RDTSC_EDI_ESI
-    invlpg  [NAME(tstInvlpgEIP)]
-    RDTSC_STORE_INSTR_PRF_RESULT
-
-    EPILOG
-    ret
-ENDPROC tstInvlpgEIP
-
-
-;;
-; Invalidate page 0.
-;
-BEGINPROC tstInvlpgESP
-    PROLOG
-
-    RDTSC_EDI_ESI
-    invlpg  [esp]
-    RDTSC_STORE_INSTR_PRF_RESULT
-
-    EPILOG
-    ret
-ENDPROC tstInvlpgESP
-
-
-;;
-; cr3 reload sequence.
-;
-BEGINPROC tstCR3Reload
-    PROLOG
-
-    RDTSC_EDI_ESI
-    mov     ebx, cr3
-    mov     cr3, ebx
-    RDTSC_STORE_INSTR_PRF_RESULT
-
-    EPILOG
-    ret
-ENDPROC tstCR3Reload
-
-
-;;
-; Enable WP sequence.
-;
-BEGINPROC tstWPEnable
-    PROLOG
-
-    RDTSC_EDI_ESI
-    mov     ebx, cr0
-    or      ebx, X86_CR0_WRITE_PROTECT
-    mov     cr0, ebx
-    rdtsc
-    ; disabled it now or we'll die...
-    and     ebx, ~X86_CR0_WRITE_PROTECT
-    mov     cr0, ebx
-    STORE_INSTR_PRF_RESULT
-
-    EPILOG
-    ret
-ENDPROC tstWPEnable
-
-
-;;
-; Disable WP sequence.
-;
-BEGINPROC tstWPDisable
-    PROLOG
-
-    ;
-    mov     ebx, cr0
-    or      ebx, X86_CR0_WRITE_PROTECT
-    mov     cr0, ebx
-    ; just wast a bit of space and time to try avoid the enable bit tainting the results of the disable.
-    xor     ebx, ebx
-    rdtsc
-    add     ebx, eax
-    rdtsc
-    add     ebx, edx
-    rdtsc
-    sub     ebx, eax
-
-    RDTSC_EDI_ESI
-    mov     ebx, cr0
-    and     ebx, ~X86_CR0_WRITE_PROTECT
-    mov     cr0, ebx
-    RDTSC_STORE_INSTR_PRF_RESULT
-
-    EPILOG
-    ret
-ENDPROC tstWPDisable
-
-
-
-
-;;
-; Generate a #PF accessing page 0 in
-;
-BEGINPROC tstPFR0
-    PROLOG
-
-    COPY_STACK_ESP_EBP_RESUME tstPFR0_Resume
-
-    rdtsc
-    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
-    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
-    xor     ebx, ebx                    ; The NULL pointer.
-    xor     ecx, ecx
-    xor     ebp, ebp                    ; ebp:ecx - Rx enter time (0:0).
-    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
-    mov     [ebx], ebx                  ; traps - 2 bytes
-
-    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
-    int     42h                         ; we're done.
-
-tstPFR0_Resume:
-    EPILOG
-    ret
-ENDPROC tstPFR0
-
-
-
-;;
-; Generate a #PF accessing page 0 in ring-1
-;
-BEGINPROC_EXPORTED tstPFR1
-    PROLOG
-
-    COPY_STACK_ESP_EBP_RESUME tstPFR1_Resume
-
-    ; Setup iret to execute r1 code.
-    mov     eax, 02069h                 ; load ds and es with r3 selectors.
-    mov     es, eax
-    mov     ds, eax
-    push    dword 01069h                ; ss
-    push    dword [ebx + TSTMICRO.RCPtrStack] ; esp
-    push    dword 0000h                 ; eflags
-    push    dword 01061h                ; cs
-    push    tstPTR1_R1                  ; eip
-
-    rdtsc
-    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
-    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
-    iret
-
-    ; R3 code
-tstPTR1_R1:
-    RDTSC_ECX_EBP                       ; ebp:ecx - Rx enter time (0:0).
-    xor     ebx, ebx
-    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
-    mov     [ebx], ebx                  ; traps - 2 bytes
-
-    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
-    int     42h                         ; we're done.
-
-    ; Resume in R0
-tstPFR1_Resume:
-    EPILOG
-    ret
-ENDPROC tstPFR1
-
-
-;;
-; Generate a #PF accessing page 0 in ring-2
-;
-BEGINPROC_EXPORTED tstPFR2
-    PROLOG
-
-    COPY_STACK_ESP_EBP_RESUME tstPFR2_Resume
-
-    ; Setup iret to execute r2 code.
-    mov     eax, 0206ah                 ; load ds and es with r3 selectors.
-    mov     es, eax
-    mov     ds, eax
-    push    0206ah                      ; ss
-    push    dword [ebx + TSTMICRO.RCPtrStack] ; esp
-    push    dword 0000h                 ; eflags
-    push    02062h                      ; cs
-    push    tstPTR2_R2                  ; eip
-
-    rdtsc
-    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
-    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
-    iret
-
-    ; R3 code
-tstPTR2_R2:
-    RDTSC_ECX_EBP                       ; ebp:ecx - Rx enter time (0:0).
-    xor     ebx, ebx
-    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
-    mov     [ebx], ebx                  ; traps - 2 bytes
-
-    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
-    int     42h                         ; we're done.
-
-    ; Resume in R0
-tstPFR2_Resume:
-    EPILOG
-    ret
-ENDPROC tstPFR2
-
-
-;;
-; Generate a #PF accessing page 0 in ring-3
-;
-BEGINPROC_EXPORTED tstPFR3
-    PROLOG
-
-    COPY_STACK_ESP_EBP_RESUME tstPFR3_Resume
-
-    ; Setup iret to execute r3 code.
-    mov     eax, 0306bh                 ; load ds and es with r3 selectors.
-    mov     es, eax
-    mov     ds, eax
-    push    0306bh                      ; ss
-    push    dword [ebx + TSTMICRO.RCPtrStack] ; esp
-    push    dword 0000h                 ; eflags
-    push    03063h                      ; cs
-    push    tstPTR3_R3                  ; eip
-
-    rdtsc
-    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
-    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
-    iret
-
-    ; R3 code
-tstPTR3_R3:
-    RDTSC_ECX_EBP                       ; ebp:ecx - Rx enter time (0:0).
-    xor     ebx, ebx
-    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
-    mov     [ebx], ebx                  ; traps - 2 bytes
-
-    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
-    int     42h                         ; we're done.
-
-    ; Resume in R0
-tstPFR3_Resume:
-    EPILOG
-    ret
-ENDPROC tstPFR3
-
-
-
-;;
-; Trap handler with error code - share code with tstTrapHandler.
-align 8
-BEGINPROC_EXPORTED tstTrapHandlerNoErr
-    rdtsc
-    push    0ffffffffh
-    jmp     tstTrapHandler_Common
-
-;;
-; Trap handler with error code.
-;           14  SS          (only if ring transition.)
-;           10  ESP         (only if ring transition.)
-;            c  EFLAGS
-;            8  CS
-;            4  EIP
-;            0  Error code. (~0 for vectors which don't take an error code.)
-;; @todo This is a bit of a mess - clean up!
-align 8
-BEGINPROC tstTrapHandler
-    ; get the time
-    rdtsc
-
-tstTrapHandler_Common:
-    xchg    ecx, eax
-    mov     eax, -1                         ; return code
-
-    ; disable WP
-    mov     ebx, cr0
-    and     ebx, ~X86_CR0_WRITE_PROTECT
-    mov     cr0, ebx
-
-    ; first hit, or final hit?
-    mov     ebx, [gpTst]
-    inc     dword [ebx + TSTMICRO.cHits]
-    cmp     dword [ebx + TSTMICRO.cHits], byte 1
-    jne     near tstTrapHandler_Fault
-
-    ; save the results - edx:ecx == r0 enter time, edi:esi == before trap, ecx:ebp == Rx enter time.
-
-    mov     [ebx + TSTMICRO.u64TSCR0Enter    ], ecx
-    mov     [ebx + TSTMICRO.u64TSCR0Enter + 4], edx
-
-    ;mov     [ebx + TSTMICRO.u64TSCRxStart    ], ecx
-    ;mov     [ebx + TSTMICRO.u64TSCRxStart + 4], ebp
-
-    mov     [ebx + TSTMICRO.u64TSCRxStart    ], esi
-    mov     [ebx + TSTMICRO.u64TSCRxStart + 4], edi
-
-    mov     eax, cr2
-    mov     [ebx + TSTMICRO.u32CR2], eax
-    mov     eax, [esp + 0]
-    mov     [ebx + TSTMICRO.u32ErrCd], eax
-    mov     eax, [esp + 4]
-    mov     [ebx + TSTMICRO.u32EIP], eax
-
-    ;
-    ; Advance the EIP and resume.
-    ;
-    mov     ecx, [ebx + TSTMICRO.offEIPAdd]
-    add     [esp + 4], ecx              ; return eip + offEIPAdd
-
-    add     esp, byte 4                 ; skip the err code
-
-    ; take the timestamp before resuming.
-    rdtsc
-    mov     [ebx + TSTMICRO.u64TSCR0Exit    ], eax
-    mov     [ebx + TSTMICRO.u64TSCR0Exit + 4], edx
-    iret
-
-
-tstTrapHandler_Fault:
-    cld
-
-    ;
-    ; Setup CPUMCTXCORE frame
-    ;
-    push    dword [esp +  4h +  0h]     ; 3ch - eip
-    push    dword [esp + 0ch +  4h]     ; 38h - eflags
-    ;;;;push    dword [esp + 08h +  8h]     ; 34h - cs
-    push    cs;want disasm
-    push    ds                ; c       ; 30h
-    push    es                ;10       ; 2ch
-    push    fs                ;14       ; 28h
-    push    gs                ;18       ; 24h
-    push    dword [esp + 14h + 1ch]     ; 20h - ss
-    push    dword [esp + 10h + 20h]     ; 1ch - esp
-    push    ecx               ;24       ; 18h
-    push    edx               ;28       ; 14h
-    push    ebx               ;2c       ; 10h
-    push    eax               ;30       ;  ch
-    push    ebp               ;34       ;  8h
-    push    esi               ;38       ;  4h
-    push    edi               ;3c       ;  0h
-                              ;40
-
-    test    byte [esp + CPUMCTXCORE.cs], 3h ; check CPL of the cs selector
-    jmp short tstTrapHandler_Fault_Hyper ;; @todo
-    jz short tstTrapHandler_Fault_Hyper
-tstTrapHandler_Fault_Guest:
-    mov     ecx, esp
-    mov     edx, IMP(g_VM)
-    mov     eax, VERR_TRPM_DONT_PANIC
-    call    [edx + VM.pfnVMMGCGuestToHostAsmGuestCtx]
-    jmp short tstTrapHandler_Fault_Guest
-
-tstTrapHandler_Fault_Hyper:
-    ; fix ss:esp.
-    lea     ebx, [esp + 14h + 040h]     ; calc esp at trap
-    mov     [esp + CPUMCTXCORE.esp], ebx; update esp in register frame
-    mov     [esp + CPUMCTXCORE.ss], ss  ; update ss in register frame
-
-    mov     ecx, esp
-    mov     edx, IMP(g_VM)
-    mov     eax, VERR_TRPM_DONT_PANIC
-    call    [edx + VM.pfnVMMGCGuestToHostAsmHyperCtx]
-    jmp short tstTrapHandler_Fault_Hyper
-
-BEGINPROC tstInterrupt42
-    rdtsc
-    push    byte 0
-    mov     ecx, eax                    ; low ts
-    xor     eax, eax                    ; return code.
-
-    ; save the results - edx:ecx == r0 end time, edi:esi == Rx end time.
-    mov     [ebx + TSTMICRO.u64TSCR0End    ], ecx
-    mov     [ebx + TSTMICRO.u64TSCR0End + 4], edx
-
-    mov     [ebx + TSTMICRO.u64TSCRxEnd    ], esi
-    mov     [ebx + TSTMICRO.u64TSCRxEnd + 4], edi
-
-    ;
-    ; Restore the IDT and stack, and resume the testcase code.
-    ;
-    lidt    [ebx + TSTMICRO.OriginalIDTR]
-
-    mov     edi, esp
-    and     edi, ~0fffh
-    mov     esi, gabStackCopy
-    mov     ecx, 01000h / 4
-    mov     esp, [gESPResume]
-    mov     ebp, [gEBPResume]
-    rep movsd
-
-    jmp     [gEIPResume]
-
-ENDPROC tstTrapHandler
-
-EXPORTEDNAME tstMicroGCAsmEnd
Index: /trunk/src/VBox/VMM/testcase/tstMicroRC.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicroRC.cpp	(revision 26223)
+++ /trunk/src/VBox/VMM/testcase/tstMicroRC.cpp	(revision 26223)
@@ -0,0 +1,261 @@
+/* $Id$ */
+/** @file
+ * Micro Testcase, profiling special CPU operations - GC Code (hacks).
+ */
+
+/*
+ * Copyright (C) 2006-2007 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <VBox/vm.h>
+#include <VBox/vmm.h>
+#include <VBox/selm.h>
+#include "tstMicro.h"
+
+#include <VBox/err.h>
+#include <iprt/asm.h>
+#include <VBox/log.h>
+#include <iprt/assert.h>
+#include <iprt/string.h>
+
+
+/*******************************************************************************
+*   Internal Functions                                                         *
+*******************************************************************************/
+RT_C_DECLS_BEGIN
+DECLEXPORT(int) tstMicroRC(PTSTMICRO pTst, unsigned uTestcase);
+RT_C_DECLS_END
+
+
+/**
+ * Save and load our IDT.
+ *
+ * @param   pTst    Pointer to the instance data.
+ * @param   iIDT    The index of the IDT entry which should be hooked.
+ */
+void idtInstall(PTSTMICRO pTst, int iIDT)
+{
+    RTIDTR Idtr;
+    ASMGetIDTR(&Idtr);
+    if (Idtr.pIdt == (uintptr_t)&pTst->aIDT[0])
+        return;
+    pTst->OriginalIDTR.cbIdt = Idtr.cbIdt;
+    pTst->OriginalIDTR.pIdt  = Idtr.pIdt;
+
+    /*
+     * Copy the IDT.
+     */
+    if (Idtr.cbIdt >= sizeof(pTst->aIDT))
+        Idtr.cbIdt = sizeof(pTst->aIDT) - 1;
+    memcpy(&pTst->aIDT[0], (void *)Idtr.pIdt, Idtr.cbIdt + 1);
+
+
+    /* Hook up IDT entry. */
+    if (iIDT >= 0)
+    {
+        uintptr_t uHandler = (uintptr_t)tstTrapHandlerNoErr;
+        if (    iIDT == 8
+            ||  iIDT == 0xa
+            ||  iIDT == 0xb
+            ||  iIDT == 0xc
+            ||  iIDT == 0xd
+            ||  iIDT == 0xe
+            ||  iIDT == 0x11)
+            uHandler = (uintptr_t)tstTrapHandler;
+        pTst->aIDT[iIDT].Int.u16OffsetHigh  = uHandler >> 16;
+        pTst->aIDT[iIDT].Int.u16OffsetLow   = uHandler & 0xffff;
+        pTst->aIDT[iIDT].Int.u16SegSel      = SELMGetHyperCS(&g_VM);
+        pTst->aIDT[iIDT].Int.u2DPL          = 3;
+        pTst->aIDT[iIDT].Int.u1Present      = 1;
+        pTst->aIDT[iIDT].Int.u1Fixed0       = 0;
+        pTst->aIDT[iIDT].Int.u1Fixed1       = 0;
+        pTst->aIDT[iIDT].Int.u1Fixed2       = 0;
+        pTst->aIDT[iIDT].Int.u1Fixed3       = 0;
+        pTst->aIDT[iIDT].Int.u1Fixed4       = 1;
+        pTst->aIDT[iIDT].Int.u1Fixed5       = 1;
+        pTst->aIDT[iIDT].Int.u132BitGate    = 1;
+        pTst->aIDT[iIDT].Int.u1Fixed6       = 0;
+        pTst->aIDT[iIDT].Int.u5Reserved2    = 0;
+    }
+
+    /* Install int 42h, R3 gate */
+    pTst->aIDT[0x42].Int.u16OffsetHigh  = (uintptr_t)tstInterrupt42 >> 16;
+    pTst->aIDT[0x42].Int.u16OffsetLow   = (uintptr_t)tstInterrupt42 & 0xffff;
+    pTst->aIDT[0x42].Int.u16SegSel      = SELMGetHyperCS(&g_VM);
+    pTst->aIDT[0x42].Int.u2DPL          = 3;
+    pTst->aIDT[0x42].Int.u1Present      = 1;
+    pTst->aIDT[0x42].Int.u1Fixed0       = 0;
+    pTst->aIDT[0x42].Int.u1Fixed1       = 0;
+    pTst->aIDT[0x42].Int.u1Fixed2       = 0;
+    pTst->aIDT[0x42].Int.u1Fixed3       = 0;
+    pTst->aIDT[0x42].Int.u1Fixed4       = 1;
+    pTst->aIDT[0x42].Int.u1Fixed5       = 1;
+    pTst->aIDT[0x42].Int.u132BitGate    = 1;
+    pTst->aIDT[0x42].Int.u1Fixed6       = 0;
+    pTst->aIDT[0x42].Int.u5Reserved2    = 0;
+
+    /*
+     * Load our IDT.
+     */
+    Idtr.pIdt = (uintptr_t)&pTst->aIDT[0];
+    ASMSetIDTR(&Idtr);
+
+    RTIDTR Idtr2;
+    ASMGetIDTR(&Idtr2);
+    Assert(Idtr2.pIdt == (uintptr_t)&pTst->aIDT[0]);
+}
+
+
+/**
+ * Removes all trap overrides except for gate 42.
+ */
+DECLASM(void) idtOnly42(PTSTMICRO pTst)
+{
+    if (pTst->OriginalIDTR.pIdt)
+        memcpy(&pTst->aIDT[0], (void *)pTst->OriginalIDTR.pIdt, sizeof(VBOXIDTE) * 32);
+}
+
+
+
+DECLEXPORT(int) tstMicroRC(PTSTMICRO pTst, unsigned uTestcase)
+{
+    RTLogPrintf("pTst=%p uTestcase=%d\n", pTst, uTestcase);
+
+    /*
+     * Validate input.
+     */
+    if (uTestcase >= TSTMICROTEST_MAX)
+        return VERR_INVALID_PARAMETER;
+
+    /*
+     * Clear the results.
+     */
+    pTst->u64TSCR0Start = 0;
+    pTst->u64TSCRxStart = 0;
+    pTst->u64TSCR0Enter = 0;
+    pTst->u64TSCR0Exit = 0;
+    pTst->u64TSCRxEnd = 0;
+    pTst->u64TSCR0End = 0;
+    pTst->cHits = 0;
+    pTst->offEIPAdd = 0;
+    pTst->u32CR2 = 0;
+    pTst->u32EIP = 0;
+    pTst->u32ErrCd = 0;
+    PTSTMICRORESULT pRes = &pTst->aResults[uTestcase];
+    memset(&pTst->aResults[uTestcase], 0, sizeof(pTst->aResults[uTestcase]));
+
+
+    /*
+     * Do the testcase.
+     */
+    int rc = VINF_SUCCESS;
+    switch (uTestcase)
+    {
+        case TSTMICROTEST_OVERHEAD:
+        {
+            tstOverhead(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_INVLPG_0:
+        {
+            tstInvlpg0(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_INVLPG_EIP:
+        {
+            tstInvlpgEIP(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_INVLPG_ESP:
+        {
+            tstInvlpgESP(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_CR3_RELOAD:
+        {
+            tstCR3Reload(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_WP_DISABLE:
+        {
+            tstWPDisable(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_WP_ENABLE:
+        {
+            tstWPEnable(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_PF_R0:
+        {
+            idtInstall(pTst, 0xe);
+            pTst->offEIPAdd = 2;
+            rc = tstPFR0(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_PF_R1:
+        {
+            idtInstall(pTst, 0xe);
+            pTst->offEIPAdd = 2;
+            rc = tstPFR1(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_PF_R2:
+        {
+            idtInstall(pTst, 0xe);
+            pTst->offEIPAdd = 2;
+            rc = tstPFR2(pTst);
+            break;
+        }
+
+        case TSTMICROTEST_PF_R3:
+        {
+            idtInstall(pTst, 0xe);
+            pTst->offEIPAdd = 2;
+            rc = tstPFR3(pTst);
+            break;
+        }
+
+    }
+
+    /*
+     * Compute the results.
+     */
+    if (pTst->u64TSCR0End   && pTst->u64TSCR0Start)
+        pRes->cTotalTicks       = pTst->u64TSCR0End     - pTst->u64TSCR0Start   - pTst->u64Overhead;
+    if (pTst->u64TSCRxStart && pTst->u64TSCR0Start)
+        pRes->cToRxFirstTicks   = pTst->u64TSCRxStart   - pTst->u64TSCR0Start   - pTst->u64Overhead;
+    if (pTst->u64TSCR0Enter && pTst->u64TSCRxStart)
+        pRes->cTrapTicks        = pTst->u64TSCR0Enter   - pTst->u64TSCRxStart   - pTst->u64Overhead;
+    if (pTst->u64TSCRxEnd   && pTst->u64TSCR0Exit)
+        pRes->cToRxTrapTicks    = pTst->u64TSCRxEnd     - pTst->u64TSCR0Exit    - pTst->u64Overhead;
+    if (pTst->u64TSCR0End   && pTst->u64TSCRxEnd)
+        pRes->cToR0Ticks        = pTst->u64TSCR0End     - pTst->u64TSCRxEnd     - pTst->u64Overhead;
+
+    return rc;
+}
+
Index: /trunk/src/VBox/VMM/testcase/tstMicroRC.def
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicroRC.def	(revision 26223)
+++ /trunk/src/VBox/VMM/testcase/tstMicroRC.def	(revision 26223)
@@ -0,0 +1,31 @@
+;; @file
+;
+; VMM Guest Context Micro Benchmark - Definition file.
+
+; Copyright (C) 2006-2007 Sun Microsystems, Inc.
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+; Clara, CA 95054 USA or visit http://www.sun.com if you need
+; additional information or have any questions.
+;
+
+LIBRARY tstMicroRC.gc
+EXPORTS
+    ; data
+
+    ; code
+    tstMicroRCAsmStart
+    tstMicroRCAsmEnd
+    tstPFR1
+    tstPFR2
+    tstPFR3
+    tstTrapHandlerNoErr
+
Index: /trunk/src/VBox/VMM/testcase/tstMicroRCA.asm
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicroRCA.asm	(revision 26223)
+++ /trunk/src/VBox/VMM/testcase/tstMicroRCA.asm	(revision 26223)
@@ -0,0 +1,560 @@
+; $Id$
+;; @file
+; tstMicroRCA
+;
+
+;
+; Copyright (C) 2006-2007 Sun Microsystems, Inc.
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+; Clara, CA 95054 USA or visit http://www.sun.com if you need
+; additional information or have any questions.
+;
+
+;*******************************************************************************
+;*      Header Files                                                           *
+;*******************************************************************************
+%include "VBox/asmdefs.mac"
+%include "VBox/x86.mac"
+%include "VBox/cpum.mac"
+%include "VBox/err.mac"
+%include "VBox/vm.mac"
+%include "tstMicro.mac"
+
+
+;*******************************************************************************
+;*      Defined Constants And Macros                                           *
+;*******************************************************************************
+;;
+; Function prolog which saves everything and loads the first parameter into ebx.
+%macro PROLOG 0
+    push    ebp
+    mov     ebp, esp
+    push    ebx
+    push    esi
+    push    edi
+    mov     ebx, [ebp + 8]                      ; pTst
+%endm
+
+;;
+; Function epilog which saves everything and loads the first parameter into ebx.
+%macro EPILOG 0
+    pop     edi
+    pop     esi
+    pop     ebx
+    leave
+%endm
+
+;;
+; Does an rdtsc (trashing edx:eax) and move the result to edi:esi.
+%macro RDTSC_EDI_ESI 0
+    rdtsc
+    xchg    eax, esi
+    xchg    edx, edi
+%endm
+
+;;
+; Does an rdtsc (trashing edx:eax) and move the result to ecx:ebp.
+%macro RDTSC_ECX_EBP 0
+    rdtsc
+    xchg    eax, ebp
+    xchg    edx, ecx
+%endm
+
+;;
+; Saves the result of an instruction profiling operation.
+;
+; Input is in edi:esi (start) and [ebp + 8] points to TSTMICRO.
+; Trashes ebx.
+%macro STORE_INSTR_PRF_RESULT 0
+    mov     ebx, [ebp + 8]
+    mov     [ebx + TSTMICRO.u64TSCR0Start    ], esi
+    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edi
+    mov     [ebx + TSTMICRO.u64TSCR0End      ], eax
+    mov     [ebx + TSTMICRO.u64TSCR0End   + 4], edx
+%endm
+
+;;
+; Samples the end time of an instruction profiling operation and
+; Saves the result of an instruction profiling operation.
+;
+; Input is in edi:esi (start) and [ebp + 8] points to TSTMICRO.
+; Trashes ebx.
+%macro RDTSC_STORE_INSTR_PRF_RESULT 0
+    rdtsc
+    STORE_INSTR_PRF_RESULT
+%endm
+
+
+;;
+; copies the stack to gabStackCopy and saves ESP and EBP in gpESP and gpEBP.
+;
+; @param    %1      The resume label.
+; @param    ebx     TSTMICRO pointer.
+; @uses     ecx, edi, esi, flags.
+%macro COPY_STACK_ESP_EBP_RESUME 1
+    mov     [gpTst], ebx
+    mov     [gESPResume], esp
+    mov     [gEBPResume], ebp
+    mov     dword [gEIPResume], %1
+
+    mov     esi, esp
+    and     esi, ~0fffh
+    mov     edi, gabStackCopy
+    mov     ecx, 01000h / 4
+    rep     movsd
+
+%endm
+
+
+;*******************************************************************************
+;*  Global Variables                                                           *
+;*******************************************************************************
+BEGINDATA
+gpTst       dd 0
+
+gESPResume  dd 0
+gEBPResume  dd 0
+gEIPResume  dd 0
+
+BEGINBSS
+gabStackCopy resb  4096
+
+extern NAME(idtOnly42)
+extern IMPNAME(g_VM)
+
+BEGINCODE
+EXPORTEDNAME tstMicroRCAsmStart
+
+
+;;
+; Check the overhead of doing rdtsc + two xchg operations.
+;
+BEGINPROC tstOverhead
+    PROLOG
+
+    RDTSC_EDI_ESI
+    RDTSC_STORE_INSTR_PRF_RESULT
+
+    EPILOG
+    ret
+ENDPROC tstOverhead
+
+
+;;
+; Invalidate page 0.
+;
+BEGINPROC tstInvlpg0
+    PROLOG
+
+    RDTSC_EDI_ESI
+    invlpg  [0]
+    RDTSC_STORE_INSTR_PRF_RESULT
+
+    EPILOG
+    ret
+ENDPROC tstInvlpg0
+
+;;
+; Invalidate the current code page.
+;
+BEGINPROC tstInvlpgEIP
+    PROLOG
+
+    RDTSC_EDI_ESI
+    invlpg  [NAME(tstInvlpgEIP)]
+    RDTSC_STORE_INSTR_PRF_RESULT
+
+    EPILOG
+    ret
+ENDPROC tstInvlpgEIP
+
+
+;;
+; Invalidate page 0.
+;
+BEGINPROC tstInvlpgESP
+    PROLOG
+
+    RDTSC_EDI_ESI
+    invlpg  [esp]
+    RDTSC_STORE_INSTR_PRF_RESULT
+
+    EPILOG
+    ret
+ENDPROC tstInvlpgESP
+
+
+;;
+; cr3 reload sequence.
+;
+BEGINPROC tstCR3Reload
+    PROLOG
+
+    RDTSC_EDI_ESI
+    mov     ebx, cr3
+    mov     cr3, ebx
+    RDTSC_STORE_INSTR_PRF_RESULT
+
+    EPILOG
+    ret
+ENDPROC tstCR3Reload
+
+
+;;
+; Enable WP sequence.
+;
+BEGINPROC tstWPEnable
+    PROLOG
+
+    RDTSC_EDI_ESI
+    mov     ebx, cr0
+    or      ebx, X86_CR0_WRITE_PROTECT
+    mov     cr0, ebx
+    rdtsc
+    ; disabled it now or we'll die...
+    and     ebx, ~X86_CR0_WRITE_PROTECT
+    mov     cr0, ebx
+    STORE_INSTR_PRF_RESULT
+
+    EPILOG
+    ret
+ENDPROC tstWPEnable
+
+
+;;
+; Disable WP sequence.
+;
+BEGINPROC tstWPDisable
+    PROLOG
+
+    ;
+    mov     ebx, cr0
+    or      ebx, X86_CR0_WRITE_PROTECT
+    mov     cr0, ebx
+    ; just wast a bit of space and time to try avoid the enable bit tainting the results of the disable.
+    xor     ebx, ebx
+    rdtsc
+    add     ebx, eax
+    rdtsc
+    add     ebx, edx
+    rdtsc
+    sub     ebx, eax
+
+    RDTSC_EDI_ESI
+    mov     ebx, cr0
+    and     ebx, ~X86_CR0_WRITE_PROTECT
+    mov     cr0, ebx
+    RDTSC_STORE_INSTR_PRF_RESULT
+
+    EPILOG
+    ret
+ENDPROC tstWPDisable
+
+
+
+
+;;
+; Generate a #PF accessing page 0 in
+;
+BEGINPROC tstPFR0
+    PROLOG
+
+    COPY_STACK_ESP_EBP_RESUME tstPFR0_Resume
+
+    rdtsc
+    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
+    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
+    xor     ebx, ebx                    ; The NULL pointer.
+    xor     ecx, ecx
+    xor     ebp, ebp                    ; ebp:ecx - Rx enter time (0:0).
+    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
+    mov     [ebx], ebx                  ; traps - 2 bytes
+
+    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
+    int     42h                         ; we're done.
+
+tstPFR0_Resume:
+    EPILOG
+    ret
+ENDPROC tstPFR0
+
+
+
+;;
+; Generate a #PF accessing page 0 in ring-1
+;
+BEGINPROC_EXPORTED tstPFR1
+    PROLOG
+
+    COPY_STACK_ESP_EBP_RESUME tstPFR1_Resume
+
+    ; Setup iret to execute r1 code.
+    mov     eax, 02069h                 ; load ds and es with r3 selectors.
+    mov     es, eax
+    mov     ds, eax
+    push    dword 01069h                ; ss
+    push    dword [ebx + TSTMICRO.RCPtrStack] ; esp
+    push    dword 0000h                 ; eflags
+    push    dword 01061h                ; cs
+    push    tstPTR1_R1                  ; eip
+
+    rdtsc
+    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
+    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
+    iret
+
+    ; R3 code
+tstPTR1_R1:
+    RDTSC_ECX_EBP                       ; ebp:ecx - Rx enter time (0:0).
+    xor     ebx, ebx
+    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
+    mov     [ebx], ebx                  ; traps - 2 bytes
+
+    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
+    int     42h                         ; we're done.
+
+    ; Resume in R0
+tstPFR1_Resume:
+    EPILOG
+    ret
+ENDPROC tstPFR1
+
+
+;;
+; Generate a #PF accessing page 0 in ring-2
+;
+BEGINPROC_EXPORTED tstPFR2
+    PROLOG
+
+    COPY_STACK_ESP_EBP_RESUME tstPFR2_Resume
+
+    ; Setup iret to execute r2 code.
+    mov     eax, 0206ah                 ; load ds and es with r3 selectors.
+    mov     es, eax
+    mov     ds, eax
+    push    0206ah                      ; ss
+    push    dword [ebx + TSTMICRO.RCPtrStack] ; esp
+    push    dword 0000h                 ; eflags
+    push    02062h                      ; cs
+    push    tstPTR2_R2                  ; eip
+
+    rdtsc
+    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
+    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
+    iret
+
+    ; R3 code
+tstPTR2_R2:
+    RDTSC_ECX_EBP                       ; ebp:ecx - Rx enter time (0:0).
+    xor     ebx, ebx
+    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
+    mov     [ebx], ebx                  ; traps - 2 bytes
+
+    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
+    int     42h                         ; we're done.
+
+    ; Resume in R0
+tstPFR2_Resume:
+    EPILOG
+    ret
+ENDPROC tstPFR2
+
+
+;;
+; Generate a #PF accessing page 0 in ring-3
+;
+BEGINPROC_EXPORTED tstPFR3
+    PROLOG
+
+    COPY_STACK_ESP_EBP_RESUME tstPFR3_Resume
+
+    ; Setup iret to execute r3 code.
+    mov     eax, 0306bh                 ; load ds and es with r3 selectors.
+    mov     es, eax
+    mov     ds, eax
+    push    0306bh                      ; ss
+    push    dword [ebx + TSTMICRO.RCPtrStack] ; esp
+    push    dword 0000h                 ; eflags
+    push    03063h                      ; cs
+    push    tstPTR3_R3                  ; eip
+
+    rdtsc
+    mov     [ebx + TSTMICRO.u64TSCR0Start    ], eax
+    mov     [ebx + TSTMICRO.u64TSCR0Start + 4], edx
+    iret
+
+    ; R3 code
+tstPTR3_R3:
+    RDTSC_ECX_EBP                       ; ebp:ecx - Rx enter time (0:0).
+    xor     ebx, ebx
+    RDTSC_EDI_ESI                       ; edi:esi - Before trap.
+    mov     [ebx], ebx                  ; traps - 2 bytes
+
+    RDTSC_EDI_ESI                       ; edi:esi - Rx entry time.
+    int     42h                         ; we're done.
+
+    ; Resume in R0
+tstPFR3_Resume:
+    EPILOG
+    ret
+ENDPROC tstPFR3
+
+
+
+;;
+; Trap handler with error code - share code with tstTrapHandler.
+align 8
+BEGINPROC_EXPORTED tstTrapHandlerNoErr
+    rdtsc
+    push    0ffffffffh
+    jmp     tstTrapHandler_Common
+
+;;
+; Trap handler with error code.
+;           14  SS          (only if ring transition.)
+;           10  ESP         (only if ring transition.)
+;            c  EFLAGS
+;            8  CS
+;            4  EIP
+;            0  Error code. (~0 for vectors which don't take an error code.)
+;; @todo This is a bit of a mess - clean up!
+align 8
+BEGINPROC tstTrapHandler
+    ; get the time
+    rdtsc
+
+tstTrapHandler_Common:
+    xchg    ecx, eax
+    mov     eax, -1                         ; return code
+
+    ; disable WP
+    mov     ebx, cr0
+    and     ebx, ~X86_CR0_WRITE_PROTECT
+    mov     cr0, ebx
+
+    ; first hit, or final hit?
+    mov     ebx, [gpTst]
+    inc     dword [ebx + TSTMICRO.cHits]
+    cmp     dword [ebx + TSTMICRO.cHits], byte 1
+    jne     near tstTrapHandler_Fault
+
+    ; save the results - edx:ecx == r0 enter time, edi:esi == before trap, ecx:ebp == Rx enter time.
+
+    mov     [ebx + TSTMICRO.u64TSCR0Enter    ], ecx
+    mov     [ebx + TSTMICRO.u64TSCR0Enter + 4], edx
+
+    ;mov     [ebx + TSTMICRO.u64TSCRxStart    ], ecx
+    ;mov     [ebx + TSTMICRO.u64TSCRxStart + 4], ebp
+
+    mov     [ebx + TSTMICRO.u64TSCRxStart    ], esi
+    mov     [ebx + TSTMICRO.u64TSCRxStart + 4], edi
+
+    mov     eax, cr2
+    mov     [ebx + TSTMICRO.u32CR2], eax
+    mov     eax, [esp + 0]
+    mov     [ebx + TSTMICRO.u32ErrCd], eax
+    mov     eax, [esp + 4]
+    mov     [ebx + TSTMICRO.u32EIP], eax
+
+    ;
+    ; Advance the EIP and resume.
+    ;
+    mov     ecx, [ebx + TSTMICRO.offEIPAdd]
+    add     [esp + 4], ecx              ; return eip + offEIPAdd
+
+    add     esp, byte 4                 ; skip the err code
+
+    ; take the timestamp before resuming.
+    rdtsc
+    mov     [ebx + TSTMICRO.u64TSCR0Exit    ], eax
+    mov     [ebx + TSTMICRO.u64TSCR0Exit + 4], edx
+    iret
+
+
+tstTrapHandler_Fault:
+    cld
+
+    ;
+    ; Setup CPUMCTXCORE frame
+    ;
+    push    dword [esp +  4h +  0h]     ; 3ch - eip
+    push    dword [esp + 0ch +  4h]     ; 38h - eflags
+    ;;;;push    dword [esp + 08h +  8h]     ; 34h - cs
+    push    cs;want disasm
+    push    ds                ; c       ; 30h
+    push    es                ;10       ; 2ch
+    push    fs                ;14       ; 28h
+    push    gs                ;18       ; 24h
+    push    dword [esp + 14h + 1ch]     ; 20h - ss
+    push    dword [esp + 10h + 20h]     ; 1ch - esp
+    push    ecx               ;24       ; 18h
+    push    edx               ;28       ; 14h
+    push    ebx               ;2c       ; 10h
+    push    eax               ;30       ;  ch
+    push    ebp               ;34       ;  8h
+    push    esi               ;38       ;  4h
+    push    edi               ;3c       ;  0h
+                              ;40
+
+    test    byte [esp + CPUMCTXCORE.cs], 3h ; check CPL of the cs selector
+    jmp short tstTrapHandler_Fault_Hyper ;; @todo
+    jz short tstTrapHandler_Fault_Hyper
+tstTrapHandler_Fault_Guest:
+    mov     ecx, esp
+    mov     edx, IMP(g_VM)
+    mov     eax, VERR_TRPM_DONT_PANIC
+    call    [edx + VM.pfnVMMGCGuestToHostAsmGuestCtx]
+    jmp short tstTrapHandler_Fault_Guest
+
+tstTrapHandler_Fault_Hyper:
+    ; fix ss:esp.
+    lea     ebx, [esp + 14h + 040h]     ; calc esp at trap
+    mov     [esp + CPUMCTXCORE.esp], ebx; update esp in register frame
+    mov     [esp + CPUMCTXCORE.ss], ss  ; update ss in register frame
+
+    mov     ecx, esp
+    mov     edx, IMP(g_VM)
+    mov     eax, VERR_TRPM_DONT_PANIC
+    call    [edx + VM.pfnVMMGCGuestToHostAsmHyperCtx]
+    jmp short tstTrapHandler_Fault_Hyper
+
+BEGINPROC tstInterrupt42
+    rdtsc
+    push    byte 0
+    mov     ecx, eax                    ; low ts
+    xor     eax, eax                    ; return code.
+
+    ; save the results - edx:ecx == r0 end time, edi:esi == Rx end time.
+    mov     [ebx + TSTMICRO.u64TSCR0End    ], ecx
+    mov     [ebx + TSTMICRO.u64TSCR0End + 4], edx
+
+    mov     [ebx + TSTMICRO.u64TSCRxEnd    ], esi
+    mov     [ebx + TSTMICRO.u64TSCRxEnd + 4], edi
+
+    ;
+    ; Restore the IDT and stack, and resume the testcase code.
+    ;
+    lidt    [ebx + TSTMICRO.OriginalIDTR]
+
+    mov     edi, esp
+    and     edi, ~0fffh
+    mov     esi, gabStackCopy
+    mov     ecx, 01000h / 4
+    mov     esp, [gESPResume]
+    mov     ebp, [gEBPResume]
+    rep movsd
+
+    jmp     [gEIPResume]
+
+ENDPROC tstTrapHandler
+
+EXPORTEDNAME tstMicroRCAsmEnd
