1 | /* $Id: CPUMR3Host-x86.cpp 109210 2025-05-08 22:09:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * CPUM - X86 Host Specific code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2024 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 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP LOG_GROUP_CPUM
|
---|
33 | #include <VBox/vmm/cpum.h>
|
---|
34 | #include "CPUMInternal.h"
|
---|
35 | #include <VBox/vmm/vmcc.h>
|
---|
36 |
|
---|
37 | #include <iprt/asm-amd64-x86.h>
|
---|
38 | #include <iprt/string.h>
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Determins the host CPU MXCSR mask.
|
---|
44 | *
|
---|
45 | * @returns MXCSR mask.
|
---|
46 | */
|
---|
47 | VMMR3DECL(uint32_t) CPUMR3DeterminHostMxCsrMask(void)
|
---|
48 | {
|
---|
49 | if ( ASMHasCpuId()
|
---|
50 | && RTX86IsValidStdRange(ASMCpuId_EAX(0))
|
---|
51 | && ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_FXSR)
|
---|
52 | {
|
---|
53 | uint8_t volatile abBuf[sizeof(X86FXSTATE) + 64];
|
---|
54 | PX86FXSTATE pState = (PX86FXSTATE)&abBuf[64 - ((uintptr_t)&abBuf[0] & 63)];
|
---|
55 | RT_ZERO(*pState);
|
---|
56 | ASMFxSave(pState);
|
---|
57 | if (pState->MXCSR_MASK == 0)
|
---|
58 | return 0xffbf;
|
---|
59 | return pState->MXCSR_MASK;
|
---|
60 | }
|
---|
61 | return 0;
|
---|
62 | }
|
---|
63 |
|
---|