VirtualBox

Changeset 47309 in vbox for trunk/src/recompiler/target-i386


Ignore:
Timestamp:
Jul 22, 2013 2:42:08 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
87449
Message:

REM: Try set DESC_INTEL_UNUSED where applicable. Fixed values in DR6, mapped DR5 to DR7 and DR4 to DR6.

Location:
trunk/src/recompiler/target-i386
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler/target-i386/cpu.h

    r43394 r47309  
    116116
    117117#define DESC_TSS_BUSY_MASK (1 << 9)
     118#ifdef VBOX
     119# define DESC_INTEL_UNUSABLE    RT_BIT_32(16+8) /**< Internal VT-x bit for NULL sectors. */
     120#endif
    118121
    119122/* eflags masks */
     
    949952    if (flags & DESC_P_MASK)
    950953        flags |= DESC_A_MASK;           /* Make sure the A bit is set to avoid trouble. */
     954    if (selector < 4U && (env->hflags & HF_CS64_MASK))
     955        flags |= DESC_INTEL_UNUSABLE;
     956    else
     957        flags &= ~DESC_INTEL_UNUSABLE;
    951958    sc->flags = flags;
    952959    sc->newselector = 0;
  • trunk/src/recompiler/target-i386/op_helper.c

    r45494 r47309  
    274274    sc->flags = e2;
    275275#ifdef VBOX
     276    sc->flags &= ~DESC_INTEL_UNUSABLE;
    276277    sc->newselector = 0;
    277278    sc->fVBoxFlags  = CPUMSELREG_FLAGS_VALID;
     
    624625    env->ldt.flags = 0;
    625626#ifdef VBOX
     627    env->ldt.flags = DESC_INTEL_UNUSABLE;
    626628    env->ldt.fVBoxFlags  = CPUMSELREG_FLAGS_VALID;
    627629    env->ldt.newselector = 0;
     
    13261328    if (new_stack) {
    13271329        ss = 0 | dpl;
     1330#ifndef VBOX
    13281331        cpu_x86_load_seg_cache(env, R_SS, ss, 0, 0, 0);
     1332#else
     1333        cpu_x86_load_seg_cache(env, R_SS, ss, 0, 0, dpl << DESC_DPL_SHIFT);
     1334#endif
    13291335    }
    13301336    ESP = esp;
     
    25032509        env->ldt.limit = 0;
    25042510#ifdef VBOX
     2511        env->ldt.flags = DESC_INTEL_UNUSABLE;
    25052512        env->ldt.fVBoxFlags = CPUMSELREG_FLAGS_VALID;
    25062513        env->ldt.newselector = 0;
     
    25692576        env->tr.flags = 0;
    25702577#ifdef VBOX
     2578        env->tr.flags = DESC_INTEL_UNUSABLE;
    25712579        env->tr.fVBoxFlags  = CPUMSELREG_FLAGS_VALID;
    25722580        env->tr.newselector = 0;
     
    26452653    if ((selector & 0xfffc) == 0) {
    26462654        /* null selector case */
     2655#ifndef VBOX
    26472656        if (seg_reg == R_SS
    26482657#ifdef TARGET_X86_64
     
    26522661            raise_exception_err(EXCP0D_GPF, 0);
    26532662        cpu_x86_load_seg_cache(env, seg_reg, selector, 0, 0, 0);
     2663#else
     2664        if (seg_reg == R_SS) {
     2665            if (!(env->hflags & HF_CS64_MASK) || cpl == 3)
     2666                raise_exception_err(EXCP0D_GPF, 0);
     2667            e2 = (cpl << DESC_DPL_SHIFT) | DESC_INTEL_UNUSABLE;
     2668        } else {
     2669            e2 = DESC_INTEL_UNUSABLE;
     2670        }
     2671        cpu_x86_load_seg_cache(env, seg_reg, selector, 0, 0, e2);
     2672#endif
    26542673    } else {
    26552674
     
    33213340#endif
    33223341            {
     3342#if defined(VBOX) && defined(DEBUG)
     3343                Log(("NULL ss, rpl=%d\n", rpl));
     3344#endif
    33233345                raise_exception_err(EXCP0D_GPF, 0);
    33243346            }
    33253347        } else {
    33263348            if ((new_ss & 3) != rpl)
     3349            {
     3350#if defined(VBOX) && defined(DEBUG)
     3351                Log(("new_ss=%x != rpl=%d\n", new_ss, rpl));
     3352#endif
    33273353                raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
     3354            }
    33283355            if (load_segment(&ss_e1, &ss_e2, new_ss) != 0)
     3356            {
     3357#if defined(VBOX) && defined(DEBUG)
     3358                Log(("new_ss=%x load error\n", new_ss));
     3359#endif
    33293360                raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
     3361            }
    33303362            if (!(ss_e2 & DESC_S_MASK) ||
    33313363                (ss_e2 & DESC_CS_MASK) ||
    33323364                !(ss_e2 & DESC_W_MASK))
     3365            {
     3366#if defined(VBOX) && defined(DEBUG)
     3367                Log(("new_ss=%x ss_e2=%#x bad type\n", new_ss, ss_e2));
     3368#endif
    33333369                raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
     3370            }
    33343371            dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;
    33353372            if (dpl != rpl)
     3373            {
     3374#if defined(VBOX) && defined(DEBUG)
     3375                Log(("SS.dpl=%u  !=  rpl=%u\n", dpl, rpl));
     3376#endif
    33363377                raise_exception_err(EXCP0D_GPF, new_ss & 0xfffc);
     3378            }
    33373379            if (!(ss_e2 & DESC_P_MASK))
     3380            {
     3381#if defined(VBOX) && defined(DEBUG)
     3382                Log(("new_ss=%#x #NP\n", new_ss));
     3383#endif
    33383384                raise_exception_err(EXCP0B_NOSEG, new_ss & 0xfffc);
     3385            }
    33393386#ifdef VBOX
    33403387            if (!(e2 & DESC_A_MASK))
     
    34193466
    34203467#ifdef VBOX
     3468    Log(("iret (shift=%d new_eip=%#x)\n", shift, next_eip));
    34213469    e1 = e2 = 0; /** @todo Why do we do this? */
    34223470    remR3TrapClear(env->pVM);
     
    34273475#ifdef TARGET_X86_64
    34283476        if (env->hflags & HF_LMA_MASK)
     3477        {
     3478#if defined(VBOX) && defined(DEBUG)
     3479            Log(("eflags.NT=1 on iret in long mode\n"));
     3480#endif
    34293481            raise_exception_err(EXCP0D_GPF, 0);
     3482        }
    34303483#endif
    34313484        tss_selector = lduw_kernel(env->tr.base + 0);
     
    35973650        env->dr[reg] = t0;
    35983651        hw_breakpoint_insert(env, reg);
     3652# ifndef VBOX
    35993653    } else if (reg == 7) {
     3654# else
     3655    } else if (reg == 7 || reg == 5) {
     3656# endif
    36003657        for (i = 0; i < 4; i++)
    36013658            hw_breakpoint_remove(env, i);
     
    36043661            hw_breakpoint_insert(env, i);
    36053662    } else
     3663# ifndef VBOX
    36063664        env->dr[reg] = t0;
     3665# else
     3666        env->dr[6] = (t0 & ~RT_BIT_32(12)) | UINT32_C(0xffff0ff0); /* 4 is an alias for 6. */
     3667# endif
    36073668}
    36083669#endif
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