1 | /* $Id: bs3-cmn-ExtCtxGetSize.c 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Bs3ExtCtxGetSize
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2020 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 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include "bs3kit-template-header.h"
|
---|
32 | #include <iprt/asm-amd64-x86.h>
|
---|
33 |
|
---|
34 |
|
---|
35 | #undef Bs3ExtCtxGetSize
|
---|
36 | BS3_CMN_DEF(uint16_t, Bs3ExtCtxGetSize,(uint64_t BS3_FAR *pfFlags))
|
---|
37 | {
|
---|
38 | uint32_t fEcx, fEdx;
|
---|
39 | *pfFlags = 0;
|
---|
40 |
|
---|
41 | ASMCpuIdExSlow(1, 0, 0, 0, NULL, NULL, &fEcx, &fEdx);
|
---|
42 | #if 1 /* To disable xsave/xrstor till IEM groks it... */
|
---|
43 | if (fEcx & X86_CPUID_FEATURE_ECX_XSAVE)
|
---|
44 | {
|
---|
45 | uint32_t fEax;
|
---|
46 | ASMCpuIdExSlow(13, 0, 0, 0, &fEax, NULL, &fEcx, &fEdx);
|
---|
47 | if ( fEcx >= sizeof(X86FXSTATE) + sizeof(X86XSAVEHDR)
|
---|
48 | && fEcx < _32K)
|
---|
49 | {
|
---|
50 | *pfFlags = fEax | ((uint64_t)fEdx << 32);
|
---|
51 | return RT_UOFFSETOF(BS3EXTCTX, Ctx) + RT_ALIGN(fEcx, 256);
|
---|
52 | }
|
---|
53 | }
|
---|
54 | #endif
|
---|
55 | if (fEdx & X86_CPUID_FEATURE_EDX_FXSR)
|
---|
56 | return RT_UOFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FXSTATE);
|
---|
57 | return RT_UOFFSETOF(BS3EXTCTX, Ctx) + sizeof(X86FPUSTATE);
|
---|
58 | }
|
---|
59 |
|
---|