VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/GVMMR0Internal.h@ 103131

Last change on this file since 103131 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.8 KB
Line 
1/* $Id: GVMMR0Internal.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * GVMM - The Global VM Manager, Internal header.
4 */
5
6/*
7 * Copyright (C) 2007-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
29#define VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <iprt/mem.h>
35#include <iprt/timer.h>
36
37
38/**
39 * The GVMM per VM data.
40 */
41typedef struct GVMMPERVCPU
42{
43 /** The time the halted EMT thread expires.
44 * 0 if the EMT thread is blocked here. */
45 uint64_t volatile u64HaltExpire;
46 /** The event semaphore the EMT thread is blocking on. */
47 RTSEMEVENTMULTI HaltEventMulti;
48 /** High resolution wake-up timer, NIL_RTTIMER if not used. */
49 PRTTIMER hHrWakeUpTimer;
50 /** The ID of the CPU we ran on when halting (debug only). */
51 RTCPUID idHaltedOnCpu;
52 /** Set if hHrWakeUpTimer is armed. */
53 bool volatile fHrWakeUptimerArmed;
54 uint8_t abPadding[1];
55 /** The EMT hash table index for this VCpu. */
56 uint16_t idxEmtHash;
57 /** The ring-3 mapping of the VMCPU structure. */
58 RTR0MEMOBJ VMCpuMapObj;
59 /** Statistics. */
60 GVMMSTATSVMCPU Stats;
61} GVMMPERVCPU;
62/** Pointer to the GVMM per VCPU data. */
63typedef GVMMPERVCPU *PGVMMPERVCPU;
64
65
66/**
67 * EMT hash table entry.
68 */
69typedef struct GVMMEMTHASHENTRY
70{
71 /** The key. */
72 RTNATIVETHREAD hNativeEmt;
73 /** The VCpu index. */
74 VMCPUID idVCpu;
75#if HC_ARCH_BITS == 64
76 uint32_t u32Padding;
77#endif
78} GVMMEMTHASHENTRY;
79AssertCompileSize(GVMMEMTHASHENTRY, sizeof(void *) * 2);
80
81/** The EMT hash table size. */
82#define GVMM_EMT_HASH_SIZE (VMM_MAX_CPU_COUNT * 4)
83/** Primary EMT hash table hash function, sans range limit.
84 * @note We assume the native ring-0 thread handle is a pointer to a pretty big
85 * structure of at least 1 KiB.
86 * - NT AMD64 6.0 ETHREAD: 0x450. See
87 * https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/ps/ethread/index.htm
88 * for more details.
89 * - Solaris kthread_t is at least 0x370 in Solaris 10.
90 * - Linux task_struct looks pretty big too.
91 * - As does struct thread in xnu.
92 * @todo Make platform specific adjustment as needed. */
93#define GVMM_EMT_HASH_CORE(a_hNativeSelf) ( (uintptr_t)(a_hNativeSelf) >> 10 )
94/** Primary EMT hash table function. */
95#define GVMM_EMT_HASH_1(a_hNativeSelf) ( GVMM_EMT_HASH_CORE(a_hNativeSelf) % GVMM_EMT_HASH_SIZE )
96/** Secondary EMT hash table function, added to the primary one on collision.
97 * This uses the bits above the primary hash.
98 * @note It is always odd, which guarantees that we'll visit all hash table
99 * entries in case of a collision. */
100#define GVMM_EMT_HASH_2(a_hNativeSelf) ( ((GVMM_EMT_HASH_CORE(a_hNativeSelf) / GVMM_EMT_HASH_SIZE) | 1) % GVMM_EMT_HASH_SIZE )
101
102/**
103 * The GVMM per VM data.
104 */
105typedef struct GVMMPERVM
106{
107 /** The shared VM data structure allocation object (PVMR0). */
108 RTR0MEMOBJ VMMemObj;
109 /** The Ring-3 mapping of the shared VM data structure (PVMR3). */
110 RTR0MEMOBJ VMMapObj;
111 /** The allocation object for the VM pages. */
112 RTR0MEMOBJ VMPagesMemObj;
113 /** The ring-3 mapping of the VM pages. */
114 RTR0MEMOBJ VMPagesMapObj;
115
116 /** The scheduler statistics. */
117 GVMMSTATSSCHED StatsSched;
118
119 /** Whether the per-VM ring-0 initialization has been performed. */
120 bool fDoneVMMR0Init;
121 /** Whether the per-VM ring-0 termination is being or has been performed. */
122 bool fDoneVMMR0Term;
123 bool afPadding[6];
124
125 /** Worker thread registrations. */
126 struct
127 {
128 /** The native ring-0 thread handle. */
129 RTNATIVETHREAD hNativeThread;
130 /** The native ring-3 thread handle. */
131 RTNATIVETHREAD hNativeThreadR3;
132 } aWorkerThreads[GVMMWORKERTHREAD_END];
133
134 /** EMT lookup hash table. */
135 GVMMEMTHASHENTRY aEmtHash[GVMM_EMT_HASH_SIZE];
136} GVMMPERVM;
137/** Pointer to the GVMM per VM data. */
138typedef GVMMPERVM *PGVMMPERVM;
139
140
141#endif /* !VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h */
142
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