VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/TRPMR0.cpp@ 19015

Last change on this file since 19015 was 19015, checked in by vboxsync, 15 years ago

Split up TRPM. (guest SMP)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1/* $Id: TRPMR0.cpp 19015 2009-04-20 07:54:29Z vboxsync $ */
2/** @file
3 * TRPM - The Trap Monitor - HC Ring 0
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_TRPM
27#include <VBox/trpm.h>
28#include "TRPMInternal.h"
29#include <VBox/vm.h>
30#include <VBox/vmm.h>
31#include <VBox/err.h>
32#include <VBox/log.h>
33#include <iprt/assert.h>
34#include <iprt/asm.h>
35
36
37/**
38 * Dispatches an interrupt that arrived while we were in the guest context.
39 *
40 * @param pVM The VM handle.
41 * @remark Must be called with interrupts disabled.
42 */
43VMMR0DECL(void) TRPMR0DispatchHostInterrupt(PVM pVM)
44{
45 PVMCPU pVCpu = VMMGetCpu0(pVM);
46 RTUINT uActiveVector = pVCpu->trpm.s.uActiveVector;
47
48 pVCpu->trpm.s.uActiveVector = ~0;
49 AssertMsgReturnVoid(uActiveVector < 256, ("uActiveVector=%#x is invalid! (More assertions to come, please enjoy!)\n", uActiveVector));
50
51#ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
52 /*
53 * Check if we're in long mode or not.
54 */
55 if ( (ASMCpuId_EDX(0x80000001) & X86_CPUID_AMD_FEATURE_EDX_LONG_MODE)
56 && (ASMRdMsr(MSR_K6_EFER) & MSR_K6_EFER_LMA))
57 {
58 trpmR0DispatchHostInterruptSimple(uActiveVector);
59 return;
60 }
61#endif
62
63 /*
64 * Get the handler pointer (16:32 ptr) / (16:48 ptr).
65 */
66 RTIDTR Idtr;
67 ASMGetIDTR(&Idtr);
68#if HC_ARCH_BITS == 32
69 PVBOXIDTE pIdte = &((PVBOXIDTE)Idtr.pIdt)[uActiveVector];
70#else
71 PVBOXIDTE pIdte = &((PVBOXIDTE)Idtr.pIdt)[uActiveVector * 2];
72#endif
73 AssertMsgReturnVoid(pIdte->Gen.u1Present, ("The IDT entry (%d) is not present!\n", uActiveVector));
74 AssertMsgReturnVoid( pIdte->Gen.u3Type1 == VBOX_IDTE_TYPE1
75 || pIdte->Gen.u5Type2 == VBOX_IDTE_TYPE2_INT_32,
76 ("The IDT entry (%d) is not 32-bit int gate! type1=%#x type2=%#x\n",
77 uActiveVector, pIdte->Gen.u3Type1, pIdte->Gen.u5Type2));
78#if HC_ARCH_BITS == 32
79 RTFAR32 pfnHandler;
80 pfnHandler.off = VBOXIDTE_OFFSET(*pIdte);
81 pfnHandler.sel = pIdte->Gen.u16SegSel;
82
83 const RTR0UINTREG uRSP = ~(RTR0UINTREG)0;
84
85#else /* 64-bit: */
86 RTFAR64 pfnHandler;
87 pfnHandler.off = VBOXIDTE_OFFSET(*pIdte);
88 pfnHandler.off |= (uint64_t)(*(uint32_t *)(pIdte + 1)) << 32; //cleanup!
89 pfnHandler.sel = pIdte->Gen.u16SegSel;
90
91 RTR0UINTREG uRSP = ~(RTR0UINTREG)0;
92 if (pIdte->au32[1] & 0x7 /*IST*/)
93 {
94 trpmR0DispatchHostInterruptSimple(uActiveVector);
95 return;
96 }
97
98#endif
99
100 /*
101 * Dispatch it.
102 */
103 trpmR0DispatchHostInterrupt(pfnHandler.off, pfnHandler.sel, uRSP);
104}
105
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette