VirtualBox

Changeset 95372 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 26, 2022 12:27:49 AM (3 years ago)
Author:
vboxsync
Message:

ValKit/bs3kit: Some more work on extended CPU/FPU state management. bugref:9898

Location:
trunk/src/VBox/ValidationKit/bootsectors/bs3kit
Files:
4 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r95371 r95372  
    139139       bs3-cmn-RegSetLdtr.asm \
    140140       bs3-cmn-RegGetXcr0.asm \
    141        bs3-cmn-RegGetXcr0Asm.asm \
    142141       bs3-cmn-RegSetXcr0.asm \
    143142       bs3-cmn-ExtCtxInit.c \
     
    148147       bs3-cmn-ExtCtxFree.c \
    149148       bs3-cmn-ExtCtxCopy.c \
     149       bs3-cmn-ExtCtxGetMxCsr.c \
     150       bs3-cmn-ExtCtxSetMxCsr.c \
     151       bs3-cmn-ExtCtxGetYmm.c \
     152       bs3-cmn-ExtCtxSetYmm.c \
    150153       bs3-cmn-SelFar32ToFlat32.c \
    151154       bs3-cmn-SelFar32ToFlat32NoClobber.asm \
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxSave.asm

    r95371 r95372  
    2828
    2929extern BS3_CMN_NM(Bs3RegSetXcr0)
    30 extern BS3_CMN_NM(Bs3RegGetXcr0Asm)
    3130
    3231;;
     
    6463
    6564.do_16_xsave:
    66         call    BS3_CMN_NM(Bs3RegGetXcr0Asm)
     65        ; xgetbv can be used in any ring!
     66        xor     ecx, ecx
     67        xgetbv
    6768        mov     [es:bx + BS3EXTCTX.fXcr0Saved], eax
    6869        mov     [es:bx + BS3EXTCTX.fXcr0Saved + 4], edx
     
    106107
    107108.do_xsave:
    108         call    BS3_CMN_NM(Bs3RegGetXcr0Asm)
     109        xor     ecx, ecx
     110        xgetbv
    109111        mov     [xBX + BS3EXTCTX.fXcr0Saved], eax
    110112        mov     [xBX + BS3EXTCTX.fXcr0Saved + 4], edx
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegGetXcr0.asm

    r95371 r95372  
    2828
    2929
    30 BS3_EXTERN_CMN Bs3Syscall
    31 %if TMPL_BITS == 16
    32 BS3_EXTERN_DATA16 g_bBs3CurrentMode
    33 %endif
    34 TMPL_BEGIN_TEXT
    35 
    36 
    3730;;
    3831; @cproto   BS3_CMN_PROTO_STUB(uint64_t, Bs3RegGetXcr0,(void));
     
    4134; @remarks  Does not require 20h of parameter scratch space in 64-bit mode.
    4235;
    43 ; @uses     No GPRs, though 16-bit mode the upper 48-bits of rax and rdx are cleared.
     36; @uses     No GPRs, though 16-bit mode the upper 48-bits of RAX, RDX and RCX are cleared.
    4437;
    4538BS3_PROC_BEGIN_CMN Bs3RegGetXcr0, BS3_PBC_HYBRID_SAFE
    46         BS3_CALL_CONV_PROLOG 0
    4739        push    xBP
    4840        mov     xBP, xSP
    4941TONLY64 push    rdx
    5042
    51 %if TMPL_BITS == 16
    52         ; If V8086 mode we have to go thru a syscall.
    53         test    byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_CODE_V86
    54         jnz     .via_system_call
    55         cmp     byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_RM
    56         je      .direct_access
    57 %endif
    58         ; If not in ring-0, we have to make a system call.
    59         mov     ax, ss
    60         and     ax, X86_SEL_RPL
    61         jnz     .via_system_call
    62 
    63 .direct_access:
     43        ; Read the value.
    6444TNOT16  push    sCX
    6545        xor     ecx, ecx
    6646        xgetbv
    6747TNOT16  pop     sCX
    68         jmp     .return
    6948
    70 .via_system_call:
    71         mov     xAX, BS3_SYSCALL_GET_XCR0
    72         call    Bs3Syscall
    73 
    74 .return:
     49        ; Move the edx:eax value into the appropriate return register(s).
    7550%if TMPL_BITS == 16
    7651        ; value [dx cx bx ax]
     
    8459        shr     rdx, 32
    8560        or      rax, rdx
    86         pop     rdx
    8761%endif
     62
     63TONLY64 pop     rdx
    8864        pop     xBP
    89         BS3_CALL_CONV_EPILOG 0
    9065        BS3_HYBRID_RET
    9166BS3_PROC_END_CMN   Bs3RegGetXcr0
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegSetXcr0.asm

    r95371 r95372  
    4040; @param    uValue      The value to set.
    4141
    42 ; @remarks  Does not require 20h of parameter scratch space in 64-bit mode,
    43 ;           only 8 bytes for dumping rcx.
     42; @remarks  Does not require 20h of parameter scratch space in 64-bit mode.
    4443;
    4544; @uses     No GPRs.
    4645;
    4746BS3_PROC_BEGIN_CMN Bs3RegSetXcr0, BS3_PBC_HYBRID_SAFE
    48         BS3_CALL_CONV_PROLOG 1
    4947        push    xBP
    5048        mov     xBP, xSP
     
    5452
    5553        ; Load the value
     54%if TMPL_BITS == 64
     55        mov     eax, ecx
     56        mov     rdx, rcx
     57        shr     rdx, 32
     58%else
    5659        mov     sAX, [xBP + xCB + cbCurRetAddr]
    5760        mov     sDX, [xBP + xCB + cbCurRetAddr + 4]
     61%endif
    5862
    5963%if TMPL_BITS == 16
     
    8690        pop     sSI
    8791        pop     xBP
    88         BS3_CALL_CONV_EPILOG 1
    8992        BS3_HYBRID_RET
    9093BS3_PROC_END_CMN   Bs3RegSetXcr0
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk

    r95371 r95372  
    3737$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelFar32ToFlat32NoClobber,6)
    3838$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3RegCtxSaveEx,8)
     39$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxSetYmm)
    3940$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestCheckRegCtxEx)
    4041$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestFailed)
     
    6061$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxInit)
    6162$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetHandler)
     63$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxGetYmm)
    6264$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3Printf)
    6365$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3PrintfV)
     
    7173$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabFree)
    7274$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TestSubErrorCount)
     75$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxGetMxCsr)
    7376$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SelFar32ToFlat32)
    7477$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SelProtFar32ToFlat32)
     
    7881$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3TrapSetDpl)
    7982$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxFree)
     83$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxSetMxCsr)
    8084$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemAlloc)
    8185$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemAllocZ)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-define.h

    r95371 r95372  
    3434#define Bs3ExtCtxCopy BS3_CMN_MANGLER(Bs3ExtCtxCopy)
    3535#define Bs3ExtCtxFree BS3_CMN_MANGLER(Bs3ExtCtxFree)
     36#define Bs3ExtCtxGetMxCsr BS3_CMN_MANGLER(Bs3ExtCtxGetMxCsr)
    3637#define Bs3ExtCtxGetSize BS3_CMN_MANGLER(Bs3ExtCtxGetSize)
     38#define Bs3ExtCtxGetYmm BS3_CMN_MANGLER(Bs3ExtCtxGetYmm)
    3739#define Bs3ExtCtxInit BS3_CMN_MANGLER(Bs3ExtCtxInit)
    3840#define Bs3ExtCtxRestore BS3_CMN_MANGLER(Bs3ExtCtxRestore)
    3941#define Bs3ExtCtxSave BS3_CMN_MANGLER(Bs3ExtCtxSave)
     42#define Bs3ExtCtxSetMxCsr BS3_CMN_MANGLER(Bs3ExtCtxSetMxCsr)
     43#define Bs3ExtCtxSetYmm BS3_CMN_MANGLER(Bs3ExtCtxSetYmm)
    4044#define Bs3GetCpuVendor BS3_CMN_MANGLER(Bs3GetCpuVendor)
    4145#define Bs3GetModeName BS3_CMN_MANGLER(Bs3GetModeName)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-mangling-code-undef.h

    r95371 r95372  
    3434#undef Bs3ExtCtxCopy
    3535#undef Bs3ExtCtxFree
     36#undef Bs3ExtCtxGetMxCsr
    3637#undef Bs3ExtCtxGetSize
     38#undef Bs3ExtCtxGetYmm
    3739#undef Bs3ExtCtxInit
    3840#undef Bs3ExtCtxRestore
    3941#undef Bs3ExtCtxSave
     42#undef Bs3ExtCtxSetMxCsr
     43#undef Bs3ExtCtxSetYmm
    4044#undef Bs3GetCpuVendor
    4145#undef Bs3GetModeName
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r95371 r95372  
    28802880BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxCopy,(PBS3EXTCTX pDst, PCBS3EXTCTX pSrc));
    28812881
     2882/**
     2883 * Gets the MXCSR register value from @a pExtCtx.
     2884 *
     2885 * @returns MXCSR value, 0 if not part of context.
     2886 * @param   pExtCtx         The extended CPU context.
     2887 */
     2888BS3_CMN_PROTO_STUB(uint32_t, Bs3ExtCtxGetMxCsr,(PCBS3EXTCTX pExtCtx));
     2889
     2890/**
     2891 * Sets the MXCSR register value in @a pExtCtx.
     2892 *
     2893 * @param   pExtCtx         The extended CPU context.
     2894 * @param   uValue          The new MXCSR value.
     2895 */
     2896BS3_CMN_PROTO_STUB(void, Bs3ExtCtxSetMxCsr,(PBS3EXTCTX pExtCtx, uint32_t uValue));
     2897
     2898/**
     2899 * Gets the value of YMM register number @a iReg from @a pExtCtx.
     2900 *
     2901 * @returns MXCSR value, 0 if not part of context.
     2902 * @param   pExtCtx         The extended CPU context.
     2903 * @param   iReg            The register to get.
     2904 * @param   pValue          Where to return the value.  Parts not in the
     2905 *                          extended state are zeroed.  For absent or invalid
     2906 *                          @a iReg values this is set to zero.
     2907 */
     2908BS3_CMN_PROTO_STUB(PRTUINT256U, Bs3ExtCtxGetYmm,(PCBS3EXTCTX pExtCtx, uint8_t iReg, PRTUINT256U pValue));
     2909
     2910/**
     2911 * Sets the value of YMM register number @a iReg in @a pExtCtx to @a pValue.
     2912 *
     2913 * @returns true if set (even if only partially). False if not set (not
     2914 *          supported by state format, unsupported/invalid iReg).
     2915 * @param   pExtCtx         The extended CPU context.
     2916 * @param   iReg            The register to set.
     2917 * @param   pValue          The new register value.
     2918 * @param   f128Bit         A little peculiarity grown from mixing SSE and AVX
     2919 *                          tests:  When set to true only the lower 128 bits of
     2920 *                          the YMM register will be set. The upper bits are
     2921 *                          untouched.  When false, the whole 256-bits value
     2922 *                          will be set.
     2923 */
     2924BS3_CMN_PROTO_STUB(bool, Bs3ExtCtxSetYmm,(PBS3EXTCTX pExtCtx, uint8_t iReg, PCRTUINT256U pValue, bool f128Bit));
     2925
    28822926
    28832927/** @name Debug register accessors for V8086 mode (works everwhere).
Note: See TracChangeset for help on using the changeset viewer.

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