VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp@ 52675

Last change on this file since 52675 was 52675, checked in by vboxsync, 11 years ago

VMM/GIM: Fix circular dependency between PDM and GIM init. routines.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: GIMMinimal.cpp 52675 2014-09-10 13:24:03Z vboxsync $ */
2/** @file
3 * GIM - Guest Interface Manager, Minimal implementation.
4 */
5
6/*
7 * Copyright (C) 2014 Oracle Corporation
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
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#define LOG_GROUP LOG_GROUP_GIM
22#include "GIMInternal.h"
23
24#include <iprt/assert.h>
25#include <iprt/err.h>
26#include <iprt/asm-amd64-x86.h>
27#include <iprt/string.h>
28
29#include <VBox/vmm/cpum.h>
30#include <VBox/vmm/vm.h>
31#include <VBox/vmm/tm.h>
32#include <VBox/vmm/pdmapi.h>
33
34/*******************************************************************************
35* Defined Constants And Macros *
36*******************************************************************************/
37
38VMMR3_INT_DECL(int) GIMR3MinimalInit(PVM pVM)
39{
40 AssertReturn(pVM, VERR_INVALID_PARAMETER);
41 AssertReturn(pVM->gim.s.enmProviderId == GIMPROVIDERID_MINIMAL, VERR_INTERNAL_ERROR_5);
42
43 /*
44 * Enable the Hypervisor Present.
45 */
46 CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
47
48 return VINF_SUCCESS;
49}
50
51
52VMMR3_INT_DECL(int) GIMR3MinimalInitFinalize(PVM pVM)
53{
54 /*
55 * Expose a generic hypervisor-agnostic leaf (originally defined VMware).
56 * The leaves range from 0x40000010 to 0x400000FF.
57 *
58 * This is done in the finalize routine as we need PDM to be
59 * initialized (otherwise PDMApicGetTimerFreq() would fail).
60 */
61 CPUMCPUIDLEAF HyperLeaf;
62 int rc = CPUMR3CpuIdGetLeaf(pVM, &HyperLeaf, 0x40000000, 0 /* uSubLeaf */);
63 if (RT_SUCCESS(rc))
64 {
65 HyperLeaf.uEax = UINT32_C(0x40000010); /* Maximum leaf we implement. */
66 rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
67 AssertLogRelRCReturn(rc, rc);
68
69 /*
70 * Add the timing information hypervisor leaf.
71 * MacOS X uses this to determine the TSC, bus frequency. See @bugref{7270}.
72 *
73 * EAX - TSC frequency in KHz.
74 * EBX - APIC frequency in KHz.
75 * ECX, EDX - Reserved.
76 */
77 uint64_t uApicFreq;
78 rc = PDMApicGetTimerFreq(pVM, &uApicFreq);
79 AssertLogRelRCReturn(rc, rc);
80
81 RT_ZERO(HyperLeaf);
82 HyperLeaf.uLeaf = UINT32_C(0x40000010);
83 HyperLeaf.uEax = TMCpuTicksPerSecond(pVM) / UINT64_C(1000);
84 HyperLeaf.uEbx = uApicFreq / UINT64_C(1000);
85 rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
86 AssertLogRelRCReturn(rc, rc);
87 }
88 else
89 LogRel(("GIM: Minimal: failed to get hypervisor leaf 0x40000000.\n"));
90
91 return VINF_SUCCESS;
92}
93
94VMMR3_INT_DECL(void) GIMR3MinimalRelocate(PVM pVM, RTGCINTPTR offDelta)
95{
96 NOREF(pVM); NOREF(offDelta);
97}
98
Note: See TracBrowser for help on using the repository browser.

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