Changeset 14515 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Nov 24, 2008 12:33:00 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/Makefile.kmk
r14167 r14515 35 35 VMMR3_DEFS = IN_VMM_R3 IN_DIS IN_GMM_R3 IN_DBG 36 36 ## @todo eliminate IN_GMM_R3 37 ifdef VBOX_WITH_IDT_PATCHING38 VMMR3_DEFS += VBOX_WITH_IDT_PATCHING39 endif40 37 ifdef VBOX_WITH_PREALLOC_RAM_BY_DEFAULT 41 38 VMMR3_DEFS += VBOX_WITH_PREALLOC_RAM_BY_DEFAULT … … 302 299 PATM 303 300 VMMGC_DEFS = IN_VMM_RC IN_RT_GC IN_RT_RC IN_DIS DIS_CORE_ONLY 304 ifdef VBOX_WITH_IDT_PATCHING305 VMMGC_DEFS += VBOX_WITH_IDT_PATCHING306 endif307 301 ifdef VBOX_WITH_R0_LOGGING 308 302 VMMGC_DEFS += VBOX_WITH_R0_LOGGING … … 400 394 VMMR0_DEFS = IN_VMM_R0 IN_RT_R0 IN_DIS DIS_CORE_ONLY IN_GVMM_R0 IN_GMM_R0 IN_INTNET_R0 RTASSERT_HAVE_SHOULD_PANIC 401 395 ## @todo eliminate IN_GVMM_R0 IN_GMM_R0 402 ifdef VBOX_WITH_IDT_PATCHING403 VMMR0_DEFS += VBOX_WITH_IDT_PATCHING404 endif405 396 ifdef VBOX_WITH_R0_LOGGING 406 397 VMMR0_DEFS += VBOX_WITH_R0_LOGGING -
trunk/src/VBox/VMM/TRPMInternal.h
r14351 r14515 240 240 DECLASM(void) trpmR0DispatchHostInterruptSimple(RTUINT uActiveVector); 241 241 242 # ifdef VBOX_WITH_IDT_PATCHING243 /**244 * Code used for the dispatching of interrupts in R0 upon return from RC.245 * @internal246 */247 DECLASM(int) trpmR0InterruptDispatcher(void);248 # endif /* VBOX_WITH_IDT_PATCHING */249 250 242 #endif /* IN_RING0 */ 251 243 -
trunk/src/VBox/VMM/VMMR0/TRPMR0.cpp
r12989 r14515 101 101 } 102 102 103 104 #ifdef VBOX_WITH_IDT_PATCHING105 # ifdef VBOX_WITH_HYBIRD_32BIT_KERNEL106 # error "VBOX_WITH_HYBIRD_32BIT_KERNEL with VBOX_WITH_IDT_PATCHING isn't supported"107 # endif108 109 /**110 * Changes the VMMR0Entry() call frame and stack used by the IDT patch code111 * so that we'll dispatch an interrupt rather than returning directly to Ring-3112 * when VMMR0Entry() returns.113 *114 * @param pVM Pointer to the VM.115 * @param pvRet Pointer to the return address of VMMR0Entry() on the stack.116 */117 VMMR0DECL(void) TRPMR0SetupInterruptDispatcherFrame(PVM pVM, void *pvRet)118 {119 RTUINT uActiveVector = pVM->trpm.s.uActiveVector;120 pVM->trpm.s.uActiveVector = ~0;121 AssertMsgReturnVoid(uActiveVector < 256, ("uActiveVector=%#x is invalid! (More assertions to come, please enjoy!)\n", uActiveVector));122 123 #if HC_ARCH_BITS == 32124 /*125 * Get the handler pointer (16:32 ptr).126 */127 RTIDTR Idtr;128 ASMGetIDTR(&Idtr);129 PVBOXIDTE pIdte = &((PVBOXIDTE)Idtr.pIdt)[uActiveVector];130 AssertMsgReturnVoid(pIdte->Gen.u1Present, ("The IDT entry (%d) is not present!\n", uActiveVector));131 AssertMsgReturnVoid( pIdte->Gen.u3Type1 == VBOX_IDTE_TYPE1132 && pIdte->Gen.u5Type2 == VBOX_IDTE_TYPE2_INT_32,133 ("The IDT entry (%d) is not 32-bit int gate! type1=%#x type2=%#x\n",134 uActiveVector, pIdte->Gen.u3Type1, pIdte->Gen.u5Type2));135 136 RTFAR32 pfnHandler;137 pfnHandler.off = VBOXIDTE_OFFSET(*pIdte);138 pfnHandler.sel = pIdte->Gen.u16SegSel;139 140 /*141 * The stack frame is as follows:142 *143 * 1c iret frame144 * 18 fs145 * 14 ds146 * 10 es147 * c uArg148 * 8 uOperation149 * 4 pVM150 * 0 return address (pvRet points here)151 *152 * We'll change the stackframe so that we will not return153 * to the caller but to a interrupt dispatcher. We'll also154 * setup the frame so that ds and es are moved to give room155 * to a far return (to the handler).156 */157 unsigned *pau = (unsigned *)pvRet;158 pau[0] = (unsigned)trpmR0InterruptDispatcher; /* new return address */159 pau[3] = pau[6]; /* uArg = fs */160 pau[2] = pau[5]; /* uOperation = ds */161 pau[5] = pfnHandler.off; /* ds = retf off */162 pau[6] = pfnHandler.sel; /* fs = retf sel */163 164 #else /* 64-bit: */165 166 /*167 * Get the handler pointer (16:48 ptr).168 */169 RTIDTR Idtr;170 ASMGetIDTR(&Idtr);171 PVBOXIDTE pIdte = &((PVBOXIDTE)Idtr.pIdt)[uActiveVector * 2];172 173 AssertMsgReturnVoid(pIdte->Gen.u1Present, ("The IDT entry (%d) is not present!\n", uActiveVector));174 AssertMsgReturnVoid( pIdte->Gen.u3Type1 == VBOX_IDTE_TYPE1175 && pIdte->Gen.u5Type2 == VBOX_IDTE_TYPE2_INT_32, /* == 64 */176 ("The IDT entry (%d) is not 64-bit int gate! type1=%#x type2=%#x\n",177 uActiveVector, pIdte->Gen.u3Type1, pIdte->Gen.u5Type2));178 179 RTFAR64 pfnHandler;180 pfnHandler.off = VBOXIDTE_OFFSET(*pIdte);181 pfnHandler.off |= (uint64_t)(*(uint32_t *)(pIdte + 1)) << 32; //cleanup!182 pfnHandler.sel = pIdte->Gen.u16SegSel;183 184 if (pIdte->au32[1] & 0x7 /*IST*/)185 {186 /** @todo implement IST */187 }188 189 /*190 * The stack frame is as follows:191 *192 * 28 iret frame193 * 20 dummy194 * 14 uArg195 * 10 uOperation196 * 8 pVM197 * 0 return address (pvRet points here)198 *199 * We'll change the stackframe so that we will not return200 * to the caller but to a interrupt dispatcher. And we'll create201 * a 64-bit far return frame where dummy and uArg is.202 */203 uint64_t *pau = (uint64_t *)pvRet;204 Assert(pau[1] == (uint64_t)pVM);205 pau[0] = (uint64_t)trpmR0InterruptDispatcher; /* new return address */206 pau[3] = pfnHandler.off; /* retf off */207 pau[4] = pfnHandler.sel; /* retf sel */208 #endif209 }210 211 #endif /* VBOX_WITH_IDT_PATCHING */ -
trunk/src/VBox/VMM/VMMR0/TRPMR0A.asm
r8155 r14515 119 119 120 120 121 %ifdef VBOX_WITH_IDT_PATCHING122 123 align 16124 ;;125 ; This is the alternative return from VMMR0Entry() used when126 ; we need to dispatch an interrupt to the Host (we received it in GC).127 ;128 ; As seen in TRPMR0SetupInterruptDispatcherFrame() the stack is different129 ; than for the normal VMMR0Entry() return.130 ;131 ; 32-bit:132 ; 18 iret frame133 ; 14 retf selector (interrupt handler)134 ; 10 retf offset (interrupt handler)135 ; c es136 ; 8 fs137 ; 4 ds138 ; 0 pVM (esp here)139 ;140 ; 64-bit:141 ; 24 iret frame142 ; 18 retf selector (interrupt handler)143 ; 10 retf offset (interrupt handler)144 ; 8 uOperation145 ; 0 pVM (rsp here)146 ;147 BEGINPROC trpmR0InterruptDispatcher148 %ifdef RT_ARCH_AMD64149 lea rsp, [rsp + 10h] ; skip pVM and uOperation150 swapgs151 db 48h152 retf153 %else ; !RT_ARCH_AMD64154 add esp, byte 4 ; skip pVM155 pop ds156 pop fs157 pop es158 retf159 %endif ; !RT_ARCH_AMD64160 ENDPROC trpmR0InterruptDispatcher161 162 %endif ; VBOX_WITH_IDT_PATCHING163 164 165 121 ;; 166 122 ; Issues a software interrupt to the specified interrupt vector. -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r14500 r14515 475 475 476 476 /** 477 * The Ring 0 entry point, called by the interrupt gate. 477 * Unused ring-0 entry point that used to be called from the interrupt gate. 478 * 479 * Will be removed one of the next times we do a major SUPDrv version bump. 478 480 * 479 481 * @returns VBox status code. … … 487 489 switch (enmOperation) 488 490 { 489 #ifdef VBOX_WITH_IDT_PATCHING490 /*491 * Switch to GC.492 * These calls return whatever the GC returns.493 */494 case VMMR0_DO_RAW_RUN:495 {496 /* Safety precaution as VMX disables the switcher. */497 Assert(!pVM->vmm.s.fSwitcherDisabled);498 if (pVM->vmm.s.fSwitcherDisabled)499 return VERR_NOT_SUPPORTED;500 501 STAM_COUNTER_INC(&pVM->vmm.s.StatRunRC);502 register int rc;503 pVM->vmm.s.iLastGZRc = rc = pVM->vmm.s.pfnHostToGuestR0(pVM);504 505 #ifdef VBOX_WITH_STATISTICS506 vmmR0RecordRC(pVM, rc);507 #endif508 509 /*510 * We'll let TRPM change the stack frame so our return is different.511 * Just keep in mind that after the call, things have changed!512 */513 if ( rc == VINF_EM_RAW_INTERRUPT514 || rc == VINF_EM_RAW_INTERRUPT_HYPER)515 {516 /*517 * Don't trust the compiler to get this right.518 * gcc -fomit-frame-pointer screws up big time here. This works fine in 64-bit519 * mode too because we push the arguments on the stack in the IDT patch code.520 */521 # if defined(__GNUC__)522 void *pvRet = (uint8_t *)__builtin_frame_address(0) + sizeof(void *);523 # elif defined(_MSC_VER) && defined(RT_ARCH_AMD64) /** @todo check this with with VC7! */524 void *pvRet = (uint8_t *)_AddressOfReturnAddress();525 # elif defined(RT_ARCH_X86)526 void *pvRet = (uint8_t *)&pVM - sizeof(pVM);527 # else528 # error "huh?"529 # endif530 if ( ((uintptr_t *)pvRet)[1] == (uintptr_t)pVM531 && ((uintptr_t *)pvRet)[2] == (uintptr_t)enmOperation532 && ((uintptr_t *)pvRet)[3] == (uintptr_t)pvArg)533 TRPMR0SetupInterruptDispatcherFrame(pVM, pvRet);534 else535 {536 # if defined(DEBUG) || defined(LOG_ENABLED)537 static bool s_fHaveWarned = false;538 if (!s_fHaveWarned)539 {540 s_fHaveWarned = true;541 RTLogPrintf("VMMR0.r0: The compiler can't find the stack frame!\n");542 RTLogComPrintf("VMMR0.r0: The compiler can't find the stack frame!\n");543 }544 # endif545 TRPMR0DispatchHostInterrupt(pVM);546 }547 }548 return rc;549 }550 551 /*552 * Switch to GC to execute Hypervisor function.553 */554 case VMMR0_DO_CALL_HYPERVISOR:555 {556 /* Safety precaution as VMX disables the switcher. */557 Assert(!pVM->vmm.s.fSwitcherDisabled);558 if (pVM->vmm.s.fSwitcherDisabled)559 return VERR_NOT_SUPPORTED;560 561 RTCCUINTREG fFlags = ASMIntDisableFlags();562 int rc = pVM->vmm.s.pfnHostToGuestR0(pVM);563 /** @todo dispatch interrupts? */564 ASMSetFlags(fFlags);565 return rc;566 }567 568 /*569 * For profiling.570 */571 case VMMR0_DO_NOP:572 return VINF_SUCCESS;573 #endif /* VBOX_WITH_IDT_PATCHING */574 575 491 default: 576 492 /* -
trunk/src/VBox/VMM/testcase/Makefile.kmk
r14118 r14515 89 89 tstVMStructGC_TEMPLATE = VBOXGCEXE 90 90 tstVMStructGC_DEFS = IN_VMM_RC IN_DIS IN_RT_RC IN_RT_GC 91 ifdef VBOX_WITH_IDT_PATCHING92 tstVMStructGC_DEFS += VBOX_WITH_IDT_PATCHING93 endif94 91 ifdef VBOX_WITH_R0_LOGGING 95 92 tstVMStructGC_DEFS += VBOX_WITH_R0_LOGGING … … 103 100 tstVMStructSize_SOURCES = tstVMStructSize.cpp 104 101 tstVMStructSize.cpp_DEPS= $(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructGC.h 105 ifdef VBOX_WITH_IDT_PATCHING106 tstVMStructSize_DEFS += VBOX_WITH_IDT_PATCHING107 endif108 102 ifdef VBOX_WITH_R0_LOGGING 109 103 tstVMStructSize_DEFS += VBOX_WITH_R0_LOGGING … … 116 110 tstAsmStructs_TEMPLATE = VBOXR3AUTOTST 117 111 tstAsmStructs_DEFS = IN_VMM_R3 IN_DIS 118 ifdef VBOX_WITH_IDT_PATCHING119 tstAsmStructs_DEFS += VBOX_WITH_IDT_PATCHING120 endif121 112 ifdef VBOX_WITH_R0_LOGGING 122 113 tstAsmStructs_DEFS += VBOX_WITH_R0_LOGGING … … 127 118 tstAsmStructsGC_TEMPLATE= VBOXGCEXE 128 119 tstAsmStructsGC_DEFS = IN_VMM_RC IN_DIS IN_RT_RC IN_RT_GC 129 ifdef VBOX_WITH_IDT_PATCHING130 tstAsmStructsGC_DEFS += VBOX_WITH_IDT_PATCHING131 endif132 120 ifdef VBOX_WITH_R0_LOGGING 133 121 tstAsmStructsGC_DEFS += VBOX_WITH_R0_LOGGING
Note:
See TracChangeset
for help on using the changeset viewer.