VirtualBox

Changeset 52465 in vbox


Ignore:
Timestamp:
Aug 22, 2014 11:39:08 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95680
Message:

VMM: Fix IEM FXSAVE implementation to match the logic in HM/raw-mode FPU handling.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/x86.h

    r51182 r52465  
    23442344    } aXMM[16]; /* 8 registers in 32 bits mode; 16 in long mode */
    23452345    /* - offset 416 - */
    2346     uint32_t    au32RsrvdRest[(512 - 416) / sizeof(uint32_t)];
     2346    uint32_t    au32RsrvdRest[(464 - 416) / sizeof(uint32_t)];
     2347    /* - offset 464 - Software usable reserved bits. */
     2348    uint32_t    au32RsrvdForSoftware[(512 - 464) / sizeof(uint32_t)];
    23472349} X86FXSTATE;
    23482350#pragma pack()
     
    23512353/** Pointer to a const FPU Extended state. */
    23522354typedef const X86FXSTATE *PCX86FXSTATE;
     2355
     2356/** Offset for software usable reserved bits (464:511) where we store a 32-bit
     2357 *  magic. Don't forget to update x86.mac if you change this! */
     2358#define X86_OFF_FXSTATE_RSVD            0x1d0
     2359/** The 32-bit magic used to recognize if this a 32-bit FPU state. Don't
     2360 *  forget to update x86.mac if you change this! */
     2361#define X86_FXSTATE_RSVD_32BIT_MAGIC    0x32b3232b
     2362AssertCompileSize(X86FXSTATE, 512);
     2363AssertCompileMemberOffset(X86FXSTATE, au32RsrvdForSoftware, 0x1d0);
    23532364
    23542365/** @name FPU status word flags.
  • trunk/include/iprt/x86.mac

    r50765 r52465  
    271271%define X86_DR7_RW_LEN_ALL_MASKS            0xffff0000
    272272%define X86_DR7_INIT_VAL                    0x400
     273%define X86_OFF_FXSTATE_RSVD                0x1d0
     274%define X86_FXSTATE_RSVD_32BIT_MAGIC        0x32b3232b
    273275%define MSR_P5_MC_ADDR                      0x00000000
    274276%define MSR_P5_MC_TYPE                      0x00000001
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h

    r52066 r52465  
    55055505
    55065506    /* FPU IP, CS, DP and DS. */
    5507     /** @todo FPU IP, CS, DP and DS cannot be implemented correctly without extra
    5508      * state information. :-/
    5509      * Storing zeros now to prevent any potential leakage of host info. */
    5510     pDst->FPUIP  = 0;
    5511     pDst->CS     = 0;
    5512     pDst->Rsrvd1 = 0;
    5513     pDst->FPUDP  = 0;
    5514     pDst->DS     = 0;
    5515     pDst->Rsrvd2 = 0;
     5507    pDst->FPUIP  = pCtx->fpu.FPUIP;
     5508    pDst->CS     = pCtx->fpu.CS;
     5509    pDst->FPUDP  = pCtx->fpu.FPUDP;
     5510    pDst->DS     = pCtx->fpu.DS;
     5511    if (enmEffOpSize == IEMMODE_64BIT)
     5512    {
     5513        /* Save upper 16-bits of FPUIP (IP:CS:Rsvd1) and FPUDP (DP:DS:Rsvd2). */
     5514        pDst->Rsrvd1 = pCtx->fpu.Rsrvd1;
     5515        pDst->Rsrvd2 = pCtx->fpu.Rsrvd2;
     5516        pDst->au32RsrvdForSoftware[0] = 0;
     5517    }
     5518    else
     5519    {
     5520        pDst->Rsrvd1 = 0;
     5521        pDst->Rsrvd2 = 0;
     5522        pDst->au32RsrvdForSoftware[0] = X86_FXSTATE_RSVD_32BIT_MAGIC;
     5523    }
    55165524
    55175525    /* XMM registers. */
  • trunk/src/VBox/VMM/VMMR0/CPUMR0A.asm

    r52419 r52465  
    3737; Use define because I'm too lazy to convert the struct.
    3838%define XMM_OFF_IN_X86FXSTATE   160
    39 %define RSVD_OFF_IN_X86FXSTATE  2ch     ; Reserved upper 32-bit part of ST(0)/MM0.
    4039%define IP_OFF_IN_X86FXSTATE    08h
    4140%define CS_OFF_IN_X86FXSTATE    0ch
    4241%define DS_OFF_IN_X86FXSTATE    14h
    43 
    44 ; Must fit into the dword (32-bits) at RSVD_OFF_IN_X86FXSTATE.
    45 %define FPUSTATE_32BIT_MAGIC    032b3232bh
    4642
    4743
     
    122118    mov         [rdx + CPUMCPU.Guest.fpu + DS_OFF_IN_X86FXSTATE], eax
    123119    add         rsp, 20h
    124     mov         dword [rdx + CPUMCPU.Guest.fpu + RSVD_OFF_IN_X86FXSTATE], FPUSTATE_32BIT_MAGIC
     120    mov         dword [rdx + CPUMCPU.Guest.fpu + X86_OFF_FXSTATE_RSVD], X86_FXSTATE_RSVD_32BIT_MAGIC
    125121%%save_done:
    126122%endmacro
     
    131127; @remarks Requires CPUMCPU pointer in RDX
    132128%macro RESTORE_32_OR_64_FPU 0
    133     cmp         dword [rdx + CPUMCPU.Guest.fpu + RSVD_OFF_IN_X86FXSTATE], FPUSTATE_32BIT_MAGIC
     129    cmp         dword [rdx + CPUMCPU.Guest.fpu + X86_OFF_FXSTATE_RSVD], X86_FXSTATE_RSVD_32BIT_MAGIC
    134130    jne         short %%restore_64bit_fpu
    135     ; We probably don't need to wipe out the reserved field - safer this way due to our limited testing
    136     mov         word [rdx + CPUMCPU.Guest.fpu + RSVD_OFF_IN_X86FXSTATE], 0
    137131    fxrstor     [rdx + CPUMCPU.Guest.fpu]
    138     mov         dword [rdx + CPUMCPU.Guest.fpu + RSVD_OFF_IN_X86FXSTATE], FPUSTATE_32BIT_MAGIC
    139132    jmp         short %%restore_fpu_done
    140133%%restore_64bit_fpu:
Note: See TracChangeset for help on using the changeset viewer.

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