VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMRZ/CPUMRZ.cpp@ 80268

Last change on this file since 80268 was 80064, checked in by vboxsync, 6 years ago

VMM: Kicking out raw-mode and 32-bit hosts - CPUM. bugref:9517 bugref:9511

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: CPUMRZ.cpp 80064 2019-07-31 10:31:36Z vboxsync $ */
2/** @file
3 * CPUM - Raw-mode and ring-0 context.
4 */
5
6/*
7 * Copyright (C) 2016-2019 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/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_CPUM
23#include <VBox/vmm/cpum.h>
24#include "CPUMInternal.h"
25#include <VBox/vmm/vm.h>
26#include <VBox/err.h>
27#include <VBox/log.h>
28#include <VBox/vmm/hm.h>
29#include <iprt/assert.h>
30#include <iprt/x86.h>
31
32
33
34
35/**
36 * Prepares the host FPU/SSE/AVX stuff for IEM action.
37 *
38 * This will make sure the FPU/SSE/AVX guest state is _not_ loaded in the CPU.
39 * This will make sure the FPU/SSE/AVX host state is saved.
40 * Finally, it will make sure the FPU/SSE/AVX host features can be safely
41 * accessed.
42 *
43 * @param pVCpu The cross context virtual CPU structure.
44 */
45VMMRZ_INT_DECL(void) CPUMRZFpuStatePrepareHostCpuForUse(PVMCPU pVCpu)
46{
47 pVCpu->cpum.s.fChanged |= CPUM_CHANGED_FPU_REM;
48 switch (pVCpu->cpum.s.fUseFlags & (CPUM_USED_FPU_GUEST | CPUM_USED_FPU_HOST))
49 {
50 case 0:
51 if (cpumRZSaveHostFPUState(&pVCpu->cpum.s) == VINF_CPUM_HOST_CR0_MODIFIED)
52 HMR0NotifyCpumModifiedHostCr0(pVCpu);
53 Log6(("CPUMRZFpuStatePrepareHostCpuForUse: #0 - %#x\n", ASMGetCR0()));
54 break;
55
56 case CPUM_USED_FPU_HOST:
57 Log6(("CPUMRZFpuStatePrepareHostCpuForUse: #1 - %#x\n", ASMGetCR0()));
58 break;
59
60 case CPUM_USED_FPU_GUEST | CPUM_USED_FPU_HOST:
61 cpumRZSaveGuestFpuState(&pVCpu->cpum.s, true /*fLeaveFpuAccessible*/);
62#ifdef IN_RING0
63 HMR0NotifyCpumUnloadedGuestFpuState(pVCpu);
64#endif
65 Log6(("CPUMRZFpuStatePrepareHostCpuForUse: #2 - %#x\n", ASMGetCR0()));
66 break;
67
68 default:
69 AssertFailed();
70 }
71
72}
73
74
75/**
76 * Makes sure the FPU/SSE/AVX guest state is saved in CPUMCPU::Guest and will be
77 * reloaded before direct use.
78 *
79 * No promisses about the FPU/SSE/AVX host features are made.
80 *
81 * @param pVCpu The cross context virtual CPU structure.
82 */
83VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeForChange(PVMCPU pVCpu)
84{
85 CPUMRZFpuStatePrepareHostCpuForUse(pVCpu);
86}
87
88
89/**
90 * Makes sure the FPU/SSE/AVX state in CPUMCPU::Guest is up to date.
91 *
92 * This will not cause CPUM_USED_FPU_GUEST to change.
93 *
94 * @param pVCpu The cross context virtual CPU structure.
95 */
96VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeForRead(PVMCPU pVCpu)
97{
98 if (pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST)
99 {
100 cpumRZSaveGuestFpuState(&pVCpu->cpum.s, false /*fLeaveFpuAccessible*/);
101 pVCpu->cpum.s.fUseFlags |= CPUM_USED_FPU_GUEST;
102 Log7(("CPUMRZFpuStateActualizeForRead\n"));
103 }
104}
105
106
107/**
108 * Makes sure the XMM0..XMM15 and MXCSR state in CPUMCPU::Guest is up to date.
109 *
110 * This will not cause CPUM_USED_FPU_GUEST to change.
111 *
112 * @param pVCpu The cross context virtual CPU structure.
113 */
114VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeSseForRead(PVMCPU pVCpu)
115{
116#if defined(VBOX_WITH_KERNEL_USING_XMM) && HC_ARCH_BITS == 64
117 NOREF(pVCpu);
118#else
119 if (pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST)
120 {
121 cpumRZSaveGuestSseRegisters(&pVCpu->cpum.s);
122 Log7(("CPUMRZFpuStateActualizeSseForRead\n"));
123 }
124#endif
125}
126
127
128/**
129 * Makes sure the YMM0..YMM15 and MXCSR state in CPUMCPU::Guest is up to date.
130 *
131 * This will not cause CPUM_USED_FPU_GUEST to change.
132 *
133 * @param pVCpu The cross context virtual CPU structure.
134 */
135VMMRZ_INT_DECL(void) CPUMRZFpuStateActualizeAvxForRead(PVMCPU pVCpu)
136{
137 if (pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST)
138 {
139 cpumRZSaveGuestAvxRegisters(&pVCpu->cpum.s);
140 Log7(("CPUMRZFpuStateActualizeAvxForRead\n"));
141 }
142}
143
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