VirtualBox

source: vbox/trunk/include/VBox/vmm/cpum-common.h

Last change on this file was 98970, checked in by vboxsync, 14 months ago

VMM: More ARMv8 x86/amd64 separation work, bugref:10385

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/** @file
2 * CPUM - CPU Monitor(/ Manager).
3 */
4
5/*
6 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_cpum_common_h
37#define VBOX_INCLUDED_vmm_cpum_common_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/types.h>
43#include <VBox/vmm/cpumctx.h>
44#include <VBox/vmm/vmapi.h>
45
46RT_C_DECLS_BEGIN
47
48/** @defgroup grp_cpum The CPU Monitor / Manager API
49 * @ingroup grp_vmm
50 * @{
51 */
52
53#ifndef VBOX_FOR_DTRACE_LIB
54
55/** @name Externalized State Helpers.
56 * @{ */
57/** @def CPUM_ASSERT_NOT_EXTRN
58 * Macro for asserting that @a a_fNotExtrn are present.
59 *
60 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
61 * @param a_fNotExtrn Mask of CPUMCTX_EXTRN_XXX bits to check.
62 *
63 * @remarks Requires VMCPU_INCL_CPUM_GST_CTX to be defined.
64 */
65#define CPUM_ASSERT_NOT_EXTRN(a_pVCpu, a_fNotExtrn) \
66 AssertMsg(!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fNotExtrn)), \
67 ("%#RX64; a_fNotExtrn=%#RX64\n", (a_pVCpu)->cpum.GstCtx.fExtrn, (a_fNotExtrn)))
68
69/** @def CPUMCTX_ASSERT_NOT_EXTRN
70 * Macro for asserting that @a a_fNotExtrn are present in @a a_pCtx.
71 *
72 * @param a_pCtx The CPU context of the calling EMT.
73 * @param a_fNotExtrn Mask of CPUMCTX_EXTRN_XXX bits to check.
74 */
75#define CPUMCTX_ASSERT_NOT_EXTRN(a_pCtx, a_fNotExtrn) \
76 AssertMsg(!((a_pCtx)->fExtrn & (a_fNotExtrn)), \
77 ("%#RX64; a_fNotExtrn=%#RX64\n", (a_pCtx)->fExtrn, (a_fNotExtrn)))
78
79/** @def CPUM_IMPORT_EXTRN_RET
80 * Macro for making sure the state specified by @a fExtrnImport is present,
81 * calling CPUMImportGuestStateOnDemand() to get it if necessary.
82 *
83 * Will return if CPUMImportGuestStateOnDemand() fails.
84 *
85 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
86 * @param a_fExtrnImport Mask of CPUMCTX_EXTRN_XXX bits to get.
87 * @thread EMT(a_pVCpu)
88 *
89 * @remarks Requires VMCPU_INCL_CPUM_GST_CTX to be defined.
90 */
91#define CPUM_IMPORT_EXTRN_RET(a_pVCpu, a_fExtrnImport) \
92 do { \
93 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
94 { /* already present, consider this likely */ } \
95 else \
96 { \
97 int rcCpumImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
98 AssertRCReturn(rcCpumImport, rcCpumImport); \
99 } \
100 } while (0)
101
102/** @def CPUM_IMPORT_EXTRN_RCSTRICT
103 * Macro for making sure the state specified by @a fExtrnImport is present,
104 * calling CPUMImportGuestStateOnDemand() to get it if necessary.
105 *
106 * Will update a_rcStrict if CPUMImportGuestStateOnDemand() fails.
107 *
108 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
109 * @param a_fExtrnImport Mask of CPUMCTX_EXTRN_XXX bits to get.
110 * @param a_rcStrict Strict status code variable to update on failure.
111 * @thread EMT(a_pVCpu)
112 *
113 * @remarks Requires VMCPU_INCL_CPUM_GST_CTX to be defined.
114 */
115#define CPUM_IMPORT_EXTRN_RCSTRICT(a_pVCpu, a_fExtrnImport, a_rcStrict) \
116 do { \
117 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
118 { /* already present, consider this likely */ } \
119 else \
120 { \
121 int rcCpumImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
122 AssertStmt(RT_SUCCESS(rcCpumImport) || RT_FAILURE_NP(a_rcStrict), a_rcStrict = rcCpumImport); \
123 } \
124 } while (0)
125
126VMM_INT_DECL(int) CPUMImportGuestStateOnDemand(PVMCPUCC pVCpu, uint64_t fExtrnImport);
127/** @} */
128
129#endif /* !VBOX_FOR_DTRACE_LIB */
130/** @} */
131RT_C_DECLS_END
132
133
134#endif /* !VBOX_INCLUDED_vmm_cpum_common_h */
135
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use