VirtualBox

Changeset 66404 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Apr 3, 2017 3:21:56 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114357
Message:

IEM: Implemented ldmxcsr Md.

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r66392 r66404  
    395395    /* [BS3CG1DST_OZ_R14] = */  BS3CG1DSTSIZE_OPERAND_SIZE_GRP,
    396396    /* [BS3CG1DST_OZ_R15] = */  BS3CG1DSTSIZE_OPERAND_SIZE_GRP,
     397
     398    /* [BS3CG1DST_CR0] = */     4,
     399    /* [BS3CG1DST_CR4] = */     4,
    397400
    398401    /* [BS3CG1DST_FCW] = */         2,
     
    623626    /* [BS3CG1DST_OZ_R15] = */      RT_OFFSETOF(BS3REGCTX, r15),
    624627
     628    /* [BS3CG1DST_CR0] = */         RT_OFFSETOF(BS3REGCTX, cr0),
     629    /* [BS3CG1DST_CR4] = */         RT_OFFSETOF(BS3REGCTX, cr4),
     630
    625631    /* [BS3CG1DST_FCW] = */         sizeof(BS3REGCTX) + RT_OFFSETOF(BS3EXTCTX, Ctx.x87.FCW),
    626632    /* [BS3CG1DST_FSW] = */         sizeof(BS3REGCTX) + RT_OFFSETOF(BS3EXTCTX, Ctx.x87.FSW),
     
    852858    { "OZ_R15" },
    853859
     860    { "CR0" },
     861    { "CR4" },
     862
    854863    { "FCW" },
    855864    { "FSW" },
     
    861870    { "FPUDS" },
    862871    { "MXCSR" },
    863     { "MXCSR_M" },
    864872    { "ST0" },
    865873    { "ST1" },
     
    977985    { "VALXCPT" },
    978986};
     987AssertCompile(RT_ELEMENTS(g_aszBs3Cg1DstFields) >= BS3CG1DST_END);
    979988AssertCompile(RT_ELEMENTS(g_aszBs3Cg1DstFields) == BS3CG1DST_END);
    980989
     
    15561565            break;
    15571566
     1567        case BS3CG1ENC_MODRM_MdRO:
     1568            if (iEncoding == 0)
     1569            {
     1570                off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 0)) - 1;
     1571                off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off,
     1572                                               (pThis->abCurInstr[off] & X86_MODRM_REG_MASK) >> X86_MODRM_REG_SHIFT,
     1573                                               4, 0, BS3CG1OPLOC_MEM);
     1574            }
     1575            else
     1576                break;
     1577            pThis->cbCurInstr = off;
     1578            iEncoding++;
     1579            break;
     1580
    15581581        case BS3CG1ENC_MODRM_MdWO:
    15591582            if (iEncoding == 0)
     
    18361859            pThis->iRmOp             = 0;
    18371860            pThis->aOperands[0].cbOp = 1;
     1861            pThis->aOperands[0].enmLocation = BS3CG1OPLOC_MEM;
     1862            break;
     1863
     1864        case BS3CG1ENC_MODRM_MdRO:
     1865            pThis->iRmOp             = 0;
     1866            pThis->aOperands[0].cbOp = 4;
    18381867            pThis->aOperands[0].enmLocation = BS3CG1OPLOC_MEM;
    18391868            break;
     
    21662195        case BS3CG1_CTXOP_AND:      return "&=";
    21672196        case BS3CG1_CTXOP_AND_INV:  return "&~=";
     2197        default:                    return "?WTF?";
    21682198    }
    21692199}
     
    32843314#if 0
    32853315    /* (for debugging) */
    3286     if (!BS3_MODE_IS_RM_OR_V86(bMode))
     3316    if (bMode != BS3_MODE_PPV86)
    32873317        return BS3TESTDOMODE_SKIPPED;
    32883318#endif
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h

    r66391 r66404  
    7070    BS3CG1OP_Ma,
    7171    BS3CG1OP_MbRO,
     72    BS3CG1OP_MdRO,
    7273    BS3CG1OP_MdWO,
    7374    BS3CG1OP_Mq,
     
    104105    BS3CG1ENC_MODRM_Vdq_Wdq,
    105106    BS3CG1ENC_MODRM_MbRO,
     107    BS3CG1ENC_MODRM_MdRO,
    106108    BS3CG1ENC_MODRM_MdWO,
    107109
     
    410412    BS3CG1DST_OZ_R14,
    411413    BS3CG1DST_OZ_R15,
     414
     415    /* Control registers.*/
     416    BS3CG1DST_CR0,
     417    BS3CG1DST_CR4,
    412418
    413419    /* FPU registers. */
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxRestore.asm

    r60774 r66404  
    309309        je      .skip_control_regs
    310310%endif
     311        test    byte [xBX + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_TR_LDTR
     312        jnz     .skip_control_regs
    311313
    312314        ; LDTR
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-RegCtxSaveEx.asm

    r66199 r66404  
    3333;*********************************************************************************************************************************
    3434BS3_EXTERN_DATA16   g_bBs3CurrentMode
     35%if ARCH_BITS != 64
     36BS3_EXTERN_DATA16   g_uBs3CpuDetected
     37%endif
    3538
    3639TMPL_BEGIN_TEXT
     
    97100        push    xBP
    98101        mov     xBP, xSP
     102%if ARCH_BITS == 64
     103        push    rcx                     ; Save pRegCtx
     104%endif
    99105
    100106        ;
     
    151157        BS3_CALL_CONV_EPILOG 3
    152158        BS3_HYBRID_RET
    153 
    154159
    155160        ;
     
    218223%endif
    219224        BS3_SET_BITS TMPL_BITS
    220         jmp     .return
     225        jmp     .supplement_and_return
    221226        TMPL_BEGIN_TEXT
    222227
     
    256261        call    _Bs3SwitchTo%[TMPL_BITS]Bit_c16
    257262        BS3_SET_BITS TMPL_BITS
    258         jmp     .return
     263        jmp     .supplement_and_return
    259264TMPL_BEGIN_TEXT
    260265%endif
     
    292297        call    _Bs3SwitchTo16Bit_c32
    293298        BS3_SET_BITS TMPL_BITS
    294         jmp     .return
     299        jmp     .supplement_and_return
    295300.code_32_back_to_v86:
    296301        BS3_SET_BITS 32
    297302        call    _Bs3SwitchTo16BitV86_c32
     303        BS3_SET_BITS TMPL_BITS
     304        jmp     .return
    298305 %else
    299306        call    _Bs3SwitchTo64Bit_c32
    300  %endif
    301         BS3_SET_BITS TMPL_BITS
    302         jmp     .return
     307        BS3_SET_BITS TMPL_BITS
     308        jmp     .supplement_and_return
     309 %endif
    303310%endif
    304311
     
    334341        jmp     .return
    335342%endif
     343
     344
     345        ;
     346        ; Supplement the state out of the current context and then return.
     347        ;
     348.supplement_and_return:
     349%if ARCH_BITS == 16
     350        CPU 8086
     351        ; Skip 286 and older.  Also make 101% sure we not in real mode or v8086 mode.
     352        cmp     byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80386
     353        jb      .return                 ; Just skip if 286 or older.
     354        test    byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_CODE_V86
     355        jnz     .return
     356        cmp     byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_RM
     357        jne     .return                 ; paranoia
     358        CPU 386
     359%endif
     360
     361        ; Load the context pointer into a suitable register.
     362%if ARCH_BITS == 64
     363 %define pRegCtx rcx
     364        mov     rcx, [xBP - xCB]
     365%elif ARCH_BITS == 32
     366 %define pRegCtx ecx
     367        mov     ecx, [xBP + xCB + cbCurRetAddr]
     368%else
     369 %define pRegCtx es:bx
     370        push    es
     371        push    bx
     372        les     bx, [xBP + xCB + cbCurRetAddr]
     373%endif
     374%if ARCH_BITS == 64
     375        ; If we're in 64-bit mode we can capture and restore the high bits.
     376        test    byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_AMD64
     377        jz      .supplemented_64bit_registers
     378        mov     [pRegCtx + BS3REGCTX.r8], r8
     379        mov     [pRegCtx + BS3REGCTX.r9], r9
     380        mov     [pRegCtx + BS3REGCTX.r10], r10
     381        mov     [pRegCtx + BS3REGCTX.r11], r11
     382        mov     [pRegCtx + BS3REGCTX.r12], r12
     383        mov     [pRegCtx + BS3REGCTX.r13], r13
     384        mov     [pRegCtx + BS3REGCTX.r14], r14
     385        mov     [pRegCtx + BS3REGCTX.r15], r15
     386        shr     rax, 32
     387        mov     [pRegCtx + BS3REGCTX.rax + 4], eax
     388        mov     rax, rbx
     389        shr     rax, 32
     390        mov     [pRegCtx + BS3REGCTX.rbx + 4], eax
     391        mov     rax, rcx
     392        shr     rax, 32
     393        mov     [pRegCtx + BS3REGCTX.rcx + 4], eax
     394        mov     rax, rdx
     395        shr     rax, 32
     396        mov     [pRegCtx + BS3REGCTX.rdx + 4], eax
     397        mov     rax, rsp
     398        shr     rax, 32
     399        mov     [pRegCtx + BS3REGCTX.rsp + 4], eax
     400        mov     rax, rbp
     401        shr     rax, 32
     402        mov     [pRegCtx + BS3REGCTX.rbp + 4], eax
     403        mov     rax, rsi
     404        shr     rax, 32
     405        mov     [pRegCtx + BS3REGCTX.rsi + 4], eax
     406        mov     rax, rdi
     407        shr     rax, 32
     408        mov     [pRegCtx + BS3REGCTX.rdi + 4], eax
     409        ;and     byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_AMD64 - enable later.
     410.supplemented_64bit_registers:
     411%endif
     412        ; The rest requires ring-0 (at least during restore).
     413        mov     ax, ss
     414        test    ax, 3
     415        jnz     .done_supplementing
     416
     417        ; Do control registers.
     418        test    byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR4
     419        jz      .supplemented_control_registers
     420        mov     sAX, cr0
     421        mov     [pRegCtx + BS3REGCTX.cr0], sAX
     422        mov     sAX, cr2
     423        mov     [pRegCtx + BS3REGCTX.cr2], sAX
     424        mov     sAX, cr3
     425        mov     [pRegCtx + BS3REGCTX.cr3], sAX
     426        and     byte [pRegCtx + BS3REGCTX.fbFlags], ~(BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR0_IS_MSW)
     427
     428%if ARCH_BITS != 64
     429        test    byte [1 + BS3_DATA16_WRT(g_uBs3CpuDetected)], (BS3CPU_F_CPUID >> 8)
     430        jz      .supplemented_control_registers
     431%endif
     432        mov     sAX, cr4
     433        mov     [pRegCtx + BS3REGCTX.cr4], sAX
     434        and     byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_CR4
     435.supplemented_control_registers:
     436
     437        ; Supply tr and ldtr if necessary
     438        test    byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_TR_LDTR
     439        jz      .done_supplementing
     440        str     [pRegCtx + BS3REGCTX.tr]
     441        sldt    [pRegCtx + BS3REGCTX.ldtr]
     442        and     byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_TR_LDTR
     443
     444.done_supplementing:
     445TONLY16 pop     bx
     446TONLY16 pop     es
     447        jmp     .return
     448%undef pRegCtx
    336449BS3_PROC_END_CMN   Bs3RegCtxSaveEx
    337450
    338 
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