VirtualBox

Changeset 41906 in vbox for trunk


Ignore:
Timestamp:
Jun 24, 2012 3:44:03 PM (13 years ago)
Author:
vboxsync
Message:

CPUM: Combined the visible and hidden selector register data into one structure. Preparing for lazily resolving+caching of hidden registers in raw-mode.

Location:
trunk
Files:
52 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/types.h

    r41901 r41906  
    384384typedef const struct CPUMCTXCORE *PCCPUMCTXCORE;
    385385
    386 /** Pointer to selector hidden registers. */
    387 typedef struct CPUMSELREGHID *PCPUMSELREGHID;
    388 /** Pointer to const selector hidden registers. */
    389 typedef const struct CPUMSELREGHID *PCCPUMSELREGHID;
     386/** Pointer to a selector register. */
     387typedef struct CPUMSELREG *PCPUMSELREG;
     388/** Pointer to a const selector register. */
     389typedef const struct CPUMSELREG *PCCPUMSELREG;
     390
     391/** Pointer to selector hidden registers.
     392 * @deprecated Replaced by PCPUMSELREG  */
     393typedef struct CPUMSELREG *PCPUMSELREGHID;
     394/** Pointer to const selector hidden registers.
     395 * @deprecated Replaced by PCCPUMSELREG  */
     396typedef const struct CPUMSELREG *PCCPUMSELREGHID;
    390397
    391398/** @} */
  • trunk/include/VBox/vmm/cpum.h

    r41904 r41906  
    248248        return false;
    249249
    250     return pCtx->csHid.Attr.n.u1Long;
     250    return pCtx->cs.Attr.n.u1Long;
    251251}
    252252
     
    263263        return false;
    264264
    265     return pCtx->csHid.Attr.n.u1Long;
     265    return pCtx->cs.Attr.n.u1Long;
    266266}
    267267
  • trunk/include/VBox/vmm/cpum.mac

    r41905 r41906  
    4848    .r14                resq    1
    4949    .r15                resq    1
    50     .es                 resw    1
    51     .esPadding          resw    3
    52     .esHid.u64Base      resq    1
    53     .esHid.u32Limit     resd    1
    54     .esHid.Attr         resd    1
    55     .cs                 resw    1
    56     .csPadding          resw    3
    57     .csHid.u64Base      resq    1
    58     .csHid.u32Limit     resd    1
    59     .csHid.Attr         resd    1
    60     .ss                 resw    1
    61     .ssPadding          resw    3
    62     .ssHid.u64Base      resq    1
    63     .ssHid.u32Limit     resd    1
    64     .ssHid.Attr         resd    1
    65     .ds                 resw    1
    66     .dsPadding          resw    3
    67     .dsHid.u64Base      resq    1
    68     .dsHid.u32Limit     resd    1
    69     .dsHid.Attr         resd    1
    70     .fs                 resw    1
    71     .fsPadding          resw    3
    72     .fsHid.u64Base      resq    1
    73     .fsHid.u32Limit     resd    1
    74     .fsHid.Attr         resd    1
    75     .gs                 resw    1
    76     .gsPadding          resw    3
    77     .gsHid.u64Base      resq    1
    78     .gsHid.u32Limit     resd    1
    79     .gsHid.Attr         resd    1
     50    .es.Sel             resw    1
     51    .es.PaddingSel      resw    1
     52    .es.ValidSel        resw    1
     53    .es.fFlags          resw    1
     54    .es.u64Base         resq    1
     55    .es.u32Limit        resd    1
     56    .es.Attr            resd    1
     57    .cs.Sel             resw    1
     58    .cs.PaddingSel      resw    1
     59    .cs.ValidSel        resw    1
     60    .cs.fFlags          resw    1
     61    .cs.u64Base         resq    1
     62    .cs.u32Limit        resd    1
     63    .cs.Attr            resd    1
     64    .ss.Sel             resw    1
     65    .ss.PaddingSel      resw    1
     66    .ss.ValidSel        resw    1
     67    .ss.fFlags          resw    1
     68    .ss.u64Base         resq    1
     69    .ss.u32Limit        resd    1
     70    .ss.Attr            resd    1
     71    .ds.Sel             resw    1
     72    .ds.PaddingSel      resw    1
     73    .ds.ValidSel        resw    1
     74    .ds.fFlags          resw    1
     75    .ds.u64Base         resq    1
     76    .ds.u32Limit        resd    1
     77    .ds.Attr            resd    1
     78    .fs.Sel             resw    1
     79    .fs.PaddingSel      resw    1
     80    .fs.ValidSel        resw    1
     81    .fs.fFlags          resw    1
     82    .fs.u64Base         resq    1
     83    .fs.u32Limit        resd    1
     84    .fs.Attr            resd    1
     85    .gs.Sel             resw    1
     86    .gs.PaddingSel      resw    1
     87    .gs.ValidSel        resw    1
     88    .gs.fFlags          resw    1
     89    .gs.u64Base         resq    1
     90    .gs.u32Limit        resd    1
     91    .gs.Attr            resd    1
    8092    .eip                resq    1
    8193    .eflags             resq    1
     
    101113    .r14                resq    1
    102114    .r15                resq    1
    103     .es                 resw    1
    104     .esPadding          resw    3
    105     .esHid.u64Base      resq    1
    106     .esHid.u32Limit     resd    1
    107     .esHid.Attr         resd    1
    108     .cs                 resw    1
    109     .csPadding          resw    3
    110     .csHid.u64Base      resq    1
    111     .csHid.u32Limit     resd    1
    112     .csHid.Attr         resd    1
    113     .ss                 resw    1
    114     .ssPadding          resw    3
    115     .ssHid.u64Base      resq    1
    116     .ssHid.u32Limit     resd    1
    117     .ssHid.Attr         resd    1
    118     .ds                 resw    1
    119     .dsPadding          resw    3
    120     .dsHid.u64Base      resq    1
    121     .dsHid.u32Limit     resd    1
    122     .dsHid.Attr         resd    1
    123     .fs                 resw    1
    124     .fsPadding          resw    3
    125     .fsHid.u64Base      resq    1
    126     .fsHid.u32Limit     resd    1
    127     .fsHid.Attr         resd    1
    128     .gs                 resw    1
    129     .gsPadding          resw    3
    130     .gsHid.u64Base      resq    1
    131     .gsHid.u32Limit     resd    1
    132     .gsHid.Attr         resd    1
     115    .es.Sel             resw    1
     116    .es.PaddingSel      resw    1
     117    .es.ValidSel        resw    1
     118    .es.fFlags          resw    1
     119    .es.u64Base         resq    1
     120    .es.u32Limit        resd    1
     121    .es.Attr            resd    1
     122    .cs.Sel             resw    1
     123    .cs.PaddingSel      resw    1
     124    .cs.ValidSel        resw    1
     125    .cs.fFlags          resw    1
     126    .cs.u64Base         resq    1
     127    .cs.u32Limit        resd    1
     128    .cs.Attr            resd    1
     129    .ss.Sel             resw    1
     130    .ss.PaddingSel      resw    1
     131    .ss.ValidSel        resw    1
     132    .ss.fFlags          resw    1
     133    .ss.u64Base         resq    1
     134    .ss.u32Limit        resd    1
     135    .ss.Attr            resd    1
     136    .ds.Sel             resw    1
     137    .ds.PaddingSel      resw    1
     138    .ds.ValidSel        resw    1
     139    .ds.fFlags          resw    1
     140    .ds.u64Base         resq    1
     141    .ds.u32Limit        resd    1
     142    .ds.Attr            resd    1
     143    .fs.Sel             resw    1
     144    .fs.PaddingSel      resw    1
     145    .fs.ValidSel        resw    1
     146    .fs.fFlags          resw    1
     147    .fs.u64Base         resq    1
     148    .fs.u32Limit        resd    1
     149    .fs.Attr            resd    1
     150    .gs.Sel             resw    1
     151    .gs.PaddingSel      resw    1
     152    .gs.ValidSel        resw    1
     153    .gs.fFlags          resw    1
     154    .gs.u64Base         resq    1
     155    .gs.u32Limit        resd    1
     156    .gs.Attr            resd    1
    133157    .eip                resq    1
    134158    .eflags             resq    1
     
    146170    .idtr.cbIdt         resw    1
    147171    .idtr.pIdt          resq    1
    148     .ldtr               resw    1
    149     .ldtrPadding        resw    3
    150     .ldtrHid.u64Base    resq    1
    151     .ldtrHid.u32Limit   resd    1
    152     .ldtrHid.Attr       resd    1
    153     .tr                 resw    1
    154     .trPadding          resw    3
    155     .trHid.u64Base      resq    1
    156     .trHid.u32Limit     resd    1
    157     .trHid.Attr         resd    1
     172    .ldtr.Sel           resw    1
     173    .ldtr.PaddingSel    resw    1
     174    .ldtr.ValidSel      resw    1
     175    .ldtr.fFlags        resw    1
     176    .ldtr.u64Base       resq    1
     177    .ldtr.u32Limit      resd    1
     178    .ldtr.Attr          resd    1
     179    .tr.Sel             resw    1
     180    .tr.PaddingSel      resw    1
     181    .tr.ValidSel        resw    1
     182    .tr.fFlags          resw    1
     183    .tr.u64Base         resq    1
     184    .tr.u32Limit        resd    1
     185    .tr.Attr            resd    1
    158186    .SysEnter.cs        resb    8
    159187    .SysEnter.eip       resb    8
  • trunk/include/VBox/vmm/cpumctx.h

    r41905 r41906  
    2929#ifndef VBOX_FOR_DTRACE_LIB
    3030# include <iprt/x86.h>
     31# include <VBox/types.h>
    3132#else
    3233# pragma D depends_on library x86.d
     
    4445 * Selector hidden registers.
    4546 */
    46 typedef struct CPUMSELREGHID
    47 {
     47typedef struct CPUMSELREG
     48{
     49    /** The selector register. */
     50    RTSEL       Sel;
     51    /** Padding, don't use. */
     52    RTSEL       PaddingSel;
     53    /** The selector which info resides in u64Base, u32Limit and Attr, provided
     54     * that CPUMSELREG_FLAGS_VALID is set. */
     55    RTSEL       ValidSel;
     56    /** Flags, see CPUMSELREG_FLAGS_XXX. */
     57    uint16_t    fFlags;
     58
    4859    /** Base register.
    4960     *
    50      *  Long mode remarks:
     61     * Long mode remarks:
    5162     *  - Unused in long mode for CS, DS, ES, SS
    5263     *  - 32 bits for FS & GS; FS(GS)_BASE msr used for the base address
     
    6071     * Only the flags, dpl and type are used. */
    6172    X86DESCATTR Attr;
    62 } CPUMSELREGHID;
    63 
     73} CPUMSELREG;
     74
     75/** @name CPUMSELREG_FLAGS_XXX - CPUMSELREG::fFlags values.
     76 * @{ */
     77#define CPUMSELREG_FLAGS_VALID      UINT16_C(0x0001)
     78#define CPUMSELREG_FLAGS_STALE      UINT16_C(0x0002)
     79/** @} */
     80
     81/** Old type used for the hidden register part.
     82 * @deprecated  */
     83typedef CPUMSELREG CPUMSELREGHID;
    6484
    6585/**
     
    172192     * @note These follow the encoding order (X86_SREG_XXX) and can be accessed as
    173193     *       an array starting a es.
    174      * @todo Combine the selector and hidden bits, effectively expanding the hidden
    175      *       register structure by 64-bit.
    176      *
    177194     * @{  */
    178     RTSEL               es;
    179     RTSEL               esPadding[3];
    180     CPUMSELREGHID       esHid;
    181 
    182     RTSEL               cs;
    183     RTSEL               csPadding[3];
    184     CPUMSELREGHID       csHid;
    185 
    186     RTSEL               ss;
    187     RTSEL               ssPadding[3];
    188     CPUMSELREGHID       ssHid;
    189 
    190     RTSEL               ds;
    191     RTSEL               dsPadding[3];
    192     CPUMSELREGHID       dsHid;
    193 
    194     RTSEL               fs;
    195     RTSEL               fsPadding[3];
    196     CPUMSELREGHID       fsHid;
    197 
    198     RTSEL               gs;
    199     RTSEL               gsPadding[3];
    200     CPUMSELREGHID       gsHid;
     195    CPUMSELREG          es;
     196    CPUMSELREG          cs;
     197    CPUMSELREG          ss;
     198    CPUMSELREG          ds;
     199    CPUMSELREG          fs;
     200    CPUMSELREG          gs;
    201201    /** @} */
    202202
     
    305305     * @note These follow the encoding order (X86_SREG_XXX) and can be accessed as
    306306     *       an array starting a es.
    307      * @todo Combine the selector and hidden bits, effectively expanding the hidden
    308      *       register structure by 64-bit.
    309      *
    310307     * @{  */
    311     RTSEL               es;
    312     RTSEL               esPadding[3];
    313     CPUMSELREGHID       esHid;
    314 
    315     RTSEL               cs;
    316     RTSEL               csPadding[3];
    317     CPUMSELREGHID       csHid;
    318 
    319     RTSEL               ss;
    320     RTSEL               ssPadding[3];
    321     CPUMSELREGHID       ssHid;
    322 
    323     RTSEL               ds;
    324     RTSEL               dsPadding[3];
    325     CPUMSELREGHID       dsHid;
    326 
    327     RTSEL               fs;
    328     RTSEL               fsPadding[3];
    329     CPUMSELREGHID       fsHid;
    330 
    331     RTSEL               gs;
    332     RTSEL               gsPadding[3];
    333     CPUMSELREGHID       gsHid;
     308    CPUMSELREG          es;
     309    CPUMSELREG          cs;
     310    CPUMSELREG          ss;
     311    CPUMSELREG          ds;
     312    CPUMSELREG          fs;
     313    CPUMSELREG          gs;
    334314    /** @} */
    335315
     
    382362    /** The task register.
    383363     * Only the guest context uses all the members. */
    384     RTSEL           ldtr;
    385     RTSEL           ldtrPadding[3];
    386     CPUMSELREGHID   ldtrHid;
     364    CPUMSELREG      ldtr;
    387365    /** The task register.
    388366     * Only the guest context uses all the members. */
    389     RTSEL           tr;
    390     RTSEL           trPadding[3];
    391     CPUMSELREGHID   trHid;
     367    CPUMSELREG      tr;
    392368
    393369    /** The sysenter msr registers.
  • trunk/src/VBox/Disassembler/DisasmReg.cpp

    r41790 r41906  
    185185static const unsigned g_aRegHidSegIndex[] =
    186186{
    187     RT_OFFSETOF(CPUMCTXCORE, esHid),         /* DISSELREG_ES */
    188     RT_OFFSETOF(CPUMCTXCORE, csHid),         /* DISSELREG_CS */
    189     RT_OFFSETOF(CPUMCTXCORE, ssHid),         /* DISSELREG_SS */
    190     RT_OFFSETOF(CPUMCTXCORE, dsHid),         /* DISSELREG_DS */
    191     RT_OFFSETOF(CPUMCTXCORE, fsHid),         /* DISSELREG_FS */
    192     RT_OFFSETOF(CPUMCTXCORE, gsHid)          /* DISSELREG_GS */
     187    RT_OFFSETOF(CPUMCTXCORE, es),         /* DISSELREG_ES */
     188    RT_OFFSETOF(CPUMCTXCORE, cs),         /* DISSELREG_CS */
     189    RT_OFFSETOF(CPUMCTXCORE, ss),         /* DISSELREG_SS */
     190    RT_OFFSETOF(CPUMCTXCORE, ds),         /* DISSELREG_DS */
     191    RT_OFFSETOF(CPUMCTXCORE, fs),         /* DISSELREG_FS */
     192    RT_OFFSETOF(CPUMCTXCORE, gs)          /* DISSELREG_GS */
    193193};
    194194
  • trunk/src/VBox/VMM/Makefile.kmk

    r41831 r41906  
    683683IEMAllCImplStrInstr.cpp.o IEMAllCImplStrInstr.cpp.obj: IEMAll.o
    684684
     685# Alias the switcher templates.
     686PAEand32Bit.o PAEand32Bit.obj:                 PAETo32Bit.o   PAEToPAE.o   32BitTo32Bit.o PAETo32Bit.o
     687LegacyandAMD64.o LegacyandAMD64.obj:           32BitToAMD64.o PAEToAMD64.o
     688AMD64andLegacy.o AMD64andLegacy.obj:           AMD64To32Bit.o AMD64ToPAE.o
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r41905 r41906  
    142142VMMDECL(void) CPUMSetHyperCS(PVMCPU pVCpu, RTSEL SelCS)
    143143{
    144     pVCpu->cpum.s.CTX_SUFF(pHyperCore)->cs = SelCS;
     144    pVCpu->cpum.s.CTX_SUFF(pHyperCore)->cs.Sel = SelCS;
    145145}
    146146
     
    148148VMMDECL(void) CPUMSetHyperDS(PVMCPU pVCpu, RTSEL SelDS)
    149149{
    150     pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ds = SelDS;
     150    pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ds.Sel = SelDS;
    151151}
    152152
     
    154154VMMDECL(void) CPUMSetHyperES(PVMCPU pVCpu, RTSEL SelES)
    155155{
    156     pVCpu->cpum.s.CTX_SUFF(pHyperCore)->es = SelES;
     156    pVCpu->cpum.s.CTX_SUFF(pHyperCore)->es.Sel = SelES;
    157157}
    158158
     
    160160VMMDECL(void) CPUMSetHyperFS(PVMCPU pVCpu, RTSEL SelFS)
    161161{
    162     pVCpu->cpum.s.CTX_SUFF(pHyperCore)->fs = SelFS;
     162    pVCpu->cpum.s.CTX_SUFF(pHyperCore)->fs.Sel = SelFS;
    163163}
    164164
     
    166166VMMDECL(void) CPUMSetHyperGS(PVMCPU pVCpu, RTSEL SelGS)
    167167{
    168     pVCpu->cpum.s.CTX_SUFF(pHyperCore)->gs = SelGS;
     168    pVCpu->cpum.s.CTX_SUFF(pHyperCore)->gs.Sel = SelGS;
    169169}
    170170
     
    172172VMMDECL(void) CPUMSetHyperSS(PVMCPU pVCpu, RTSEL SelSS)
    173173{
    174     pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ss = SelSS;
     174    pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ss.Sel = SelSS;
    175175}
    176176
     
    197197VMMDECL(void) CPUMSetHyperTR(PVMCPU pVCpu, RTSEL SelTR)
    198198{
    199     pVCpu->cpum.s.Hyper.tr = SelTR;
     199    pVCpu->cpum.s.Hyper.tr.Sel = SelTR;
    200200}
    201201
     
    203203VMMDECL(void) CPUMSetHyperLDTR(PVMCPU pVCpu, RTSEL SelLDTR)
    204204{
    205     pVCpu->cpum.s.Hyper.ldtr = SelLDTR;
     205    pVCpu->cpum.s.Hyper.ldtr.Sel = SelLDTR;
    206206}
    207207
     
    251251VMMDECL(RTSEL) CPUMGetHyperCS(PVMCPU pVCpu)
    252252{
    253     return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->cs;
     253    return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->cs.Sel;
    254254}
    255255
     
    257257VMMDECL(RTSEL) CPUMGetHyperDS(PVMCPU pVCpu)
    258258{
    259     return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ds;
     259    return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ds.Sel;
    260260}
    261261
     
    263263VMMDECL(RTSEL) CPUMGetHyperES(PVMCPU pVCpu)
    264264{
    265     return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->es;
     265    return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->es.Sel;
    266266}
    267267
     
    269269VMMDECL(RTSEL) CPUMGetHyperFS(PVMCPU pVCpu)
    270270{
    271     return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->fs;
     271    return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->fs.Sel;
    272272}
    273273
     
    275275VMMDECL(RTSEL) CPUMGetHyperGS(PVMCPU pVCpu)
    276276{
    277     return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->gs;
     277    return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->gs.Sel;
    278278}
    279279
     
    281281VMMDECL(RTSEL) CPUMGetHyperSS(PVMCPU pVCpu)
    282282{
    283     return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ss;
     283    return pVCpu->cpum.s.CTX_SUFF(pHyperCore)->ss.Sel;
    284284}
    285285
     
    369369VMMDECL(RTSEL) CPUMGetHyperLDTR(PVMCPU pVCpu)
    370370{
    371     return pVCpu->cpum.s.Hyper.ldtr;
     371    return pVCpu->cpum.s.Hyper.ldtr.Sel;
    372372}
    373373
     
    491491VMMDECL(int) CPUMSetGuestTR(PVMCPU pVCpu, uint16_t tr)
    492492{
    493     pVCpu->cpum.s.Guest.tr  = tr;
     493    pVCpu->cpum.s.Guest.tr.Sel  = tr;
    494494    pVCpu->cpum.s.fChanged |= CPUM_CHANGED_TR;
    495495    return VINF_SUCCESS;
     
    498498VMMDECL(int) CPUMSetGuestLDTR(PVMCPU pVCpu, uint16_t ldtr)
    499499{
    500     pVCpu->cpum.s.Guest.ldtr = ldtr;
     500    pVCpu->cpum.s.Guest.ldtr.Sel = ldtr;
    501501    pVCpu->cpum.s.fChanged  |= CPUM_CHANGED_LDTR;
    502502    return VINF_SUCCESS;
     
    682682VMMDECL(int) CPUMSetGuestSS(PVMCPU pVCpu, uint16_t ss)
    683683{
    684     pVCpu->cpum.s.Guest.ss = ss;
     684    pVCpu->cpum.s.Guest.ss.Sel = ss;
    685685    return VINF_SUCCESS;
    686686}
     
    689689VMMDECL(int) CPUMSetGuestCS(PVMCPU pVCpu, uint16_t cs)
    690690{
    691     pVCpu->cpum.s.Guest.cs = cs;
     691    pVCpu->cpum.s.Guest.cs.Sel = cs;
    692692    return VINF_SUCCESS;
    693693}
     
    696696VMMDECL(int) CPUMSetGuestDS(PVMCPU pVCpu, uint16_t ds)
    697697{
    698     pVCpu->cpum.s.Guest.ds = ds;
     698    pVCpu->cpum.s.Guest.ds.Sel = ds;
    699699    return VINF_SUCCESS;
    700700}
     
    703703VMMDECL(int) CPUMSetGuestES(PVMCPU pVCpu, uint16_t es)
    704704{
    705     pVCpu->cpum.s.Guest.es = es;
     705    pVCpu->cpum.s.Guest.es.Sel = es;
    706706    return VINF_SUCCESS;
    707707}
     
    710710VMMDECL(int) CPUMSetGuestFS(PVMCPU pVCpu, uint16_t fs)
    711711{
    712     pVCpu->cpum.s.Guest.fs = fs;
     712    pVCpu->cpum.s.Guest.fs.Sel = fs;
    713713    return VINF_SUCCESS;
    714714}
     
    717717VMMDECL(int) CPUMSetGuestGS(PVMCPU pVCpu, uint16_t gs)
    718718{
    719     pVCpu->cpum.s.Guest.gs = gs;
     719    pVCpu->cpum.s.Guest.gs.Sel = gs;
    720720    return VINF_SUCCESS;
    721721}
     
    864864
    865865        case MSR_K8_FS_BASE:
    866             *puValue = pVCpu->cpum.s.Guest.fsHid.u64Base;
     866            *puValue = pVCpu->cpum.s.Guest.fs.u64Base;
    867867            break;
    868868
    869869        case MSR_K8_GS_BASE:
    870             *puValue = pVCpu->cpum.s.Guest.gsHid.u64Base;
     870            *puValue = pVCpu->cpum.s.Guest.gs.u64Base;
    871871            break;
    872872
     
    11421142
    11431143        case MSR_K8_FS_BASE:
    1144             pVCpu->cpum.s.Guest.fsHid.u64Base   = uValue;
     1144            pVCpu->cpum.s.Guest.fs.u64Base      = uValue;
    11451145            break;
    11461146
    11471147        case MSR_K8_GS_BASE:
    1148             pVCpu->cpum.s.Guest.gsHid.u64Base   = uValue;
     1148            pVCpu->cpum.s.Guest.gs.u64Base      = uValue;
    11491149            break;
    11501150
     
    11891189{
    11901190    if (pHidden)
    1191         *pHidden = pVCpu->cpum.s.Guest.trHid;
    1192     return pVCpu->cpum.s.Guest.tr;
     1191        *pHidden = pVCpu->cpum.s.Guest.tr;
     1192    return pVCpu->cpum.s.Guest.tr.Sel;
    11931193}
    11941194
     
    11961196VMMDECL(RTSEL) CPUMGetGuestCS(PVMCPU pVCpu)
    11971197{
    1198     return pVCpu->cpum.s.Guest.cs;
     1198    return pVCpu->cpum.s.Guest.cs.Sel;
    11991199}
    12001200
     
    12021202VMMDECL(RTSEL) CPUMGetGuestDS(PVMCPU pVCpu)
    12031203{
    1204     return pVCpu->cpum.s.Guest.ds;
     1204    return pVCpu->cpum.s.Guest.ds.Sel;
    12051205}
    12061206
     
    12081208VMMDECL(RTSEL) CPUMGetGuestES(PVMCPU pVCpu)
    12091209{
    1210     return pVCpu->cpum.s.Guest.es;
     1210    return pVCpu->cpum.s.Guest.es.Sel;
    12111211}
    12121212
     
    12141214VMMDECL(RTSEL) CPUMGetGuestFS(PVMCPU pVCpu)
    12151215{
    1216     return pVCpu->cpum.s.Guest.fs;
     1216    return pVCpu->cpum.s.Guest.fs.Sel;
    12171217}
    12181218
     
    12201220VMMDECL(RTSEL) CPUMGetGuestGS(PVMCPU pVCpu)
    12211221{
    1222     return pVCpu->cpum.s.Guest.gs;
     1222    return pVCpu->cpum.s.Guest.gs.Sel;
    12231223}
    12241224
     
    12261226VMMDECL(RTSEL) CPUMGetGuestSS(PVMCPU pVCpu)
    12271227{
    1228     return pVCpu->cpum.s.Guest.ss;
     1228    return pVCpu->cpum.s.Guest.ss.Sel;
    12291229}
    12301230
     
    12321232VMMDECL(RTSEL) CPUMGetGuestLDTR(PVMCPU pVCpu)
    12331233{
    1234     return pVCpu->cpum.s.Guest.ldtr;
     1234    return pVCpu->cpum.s.Guest.ldtr.Sel;
    12351235}
    12361236
     
    24542454        {
    24552455            if (!pCtxCore->eflags.Bits.u1VM)
    2456                 cpl = pCtxCore->ssHid.Attr.n.u2Dpl;
     2456                cpl = pCtxCore->ss.Attr.n.u2Dpl;
    24572457            else
    24582458                cpl = 3; /* REM doesn't set DPL=3 in V8086 mode. See @bugref{5130}. */
     
    24702470             * See section 4.11.1 in the AMD manual.
    24712471             */
    2472             cpl = (pCtxCore->ss & X86_SEL_RPL);
     2472            cpl = (pCtxCore->ss.Sel & X86_SEL_RPL);
    24732473#ifndef IN_RING0
    24742474            if (cpl == 1)
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r41830 r41906  
    384384#else
    385385/** @todo Get the CPU mode as well while we're at it! */
    386     int rc = SELMValidateAndConvertCSAddr(pVCpu, pCtxCore->eflags, pCtxCore->ss, pCtxCore->cs,
    387                                           &pCtxCore->csHid, pCtxCore->rip, &GCPtrInstr);
     386    int rc = SELMValidateAndConvertCSAddr(pVCpu, pCtxCore->eflags, pCtxCore->ss.Sel, pCtxCore->cs.Sel,
     387                                          &pCtxCore->cs, pCtxCore->rip, &GCPtrInstr);
    388388#endif
    389389    if (RT_FAILURE(rc))
    390390    {
    391391        Log(("EMInterpretDisasOne: Failed to convert %RTsel:%RGv (cpl=%d) - rc=%Rrc !!\n",
    392              pCtxCore->cs, (RTGCPTR)pCtxCore->rip, pCtxCore->ss & X86_SEL_RPL, rc));
     392             pCtxCore->cs.Sel, (RTGCPTR)pCtxCore->rip, pCtxCore->ss.Sel & X86_SEL_RPL, rc));
    393393        return rc;
    394394    }
     
    415415                                   PDISCPUSTATE pDis, unsigned *pcbInstr)
    416416{
    417     DISCPUMODE enmCpuMode = SELMGetCpuModeFromSelector(pVCpu, pCtxCore->eflags, pCtxCore->cs, (PCPUMSELREGHID)&pCtxCore->csHid);
     417    DISCPUMODE enmCpuMode = SELMGetCpuModeFromSelector(pVCpu, pCtxCore->eflags, pCtxCore->cs.Sel, (PCPUMSELREGHID)&pCtxCore->cs);
    418418    /** @todo Deal with too long instruction (=> \#GP), opcode read errors (=>
    419419     *        \#PF, \#GP, \#??), undefined opcodes (=> \#UD), and such. */
     
    461461        uint32_t     cbOp;
    462462        PDISCPUSTATE pDis = &pVCpu->em.s.DisState;
    463         pDis->uCpuMode = SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->cs, &pRegFrame->csHid);
     463        pDis->uCpuMode = SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->cs.Sel, &pRegFrame->cs);
    464464        rc = emDisCoreOne(pVCpu->CTX_SUFF(pVM), pVCpu, pDis, (RTGCUINTPTR)pbCode, &cbOp);
    465465        if (RT_SUCCESS(rc))
     
    515515        uint32_t     cbOp;
    516516        PDISCPUSTATE pDis = &pVCpu->em.s.DisState;
    517         pDis->uCpuMode = SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->cs, &pRegFrame->csHid);
     517        pDis->uCpuMode = SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->cs.Sel, &pRegFrame->cs);
    518518        rc = emDisCoreOne(pVCpu->CTX_SUFF(pVM), pVCpu, pDis, (RTGCUINTPTR)pbCode, &cbOp);
    519519        if (RT_SUCCESS(rc))
     
    625625    AssertRCReturn(rc, VERR_EM_INTERPRETER);
    626626
    627     pRegFrame->eip = eip & 0xffff;
    628     pRegFrame->cs  = cs;
     627    pRegFrame->eip    = eip & 0xffff;
     628    pRegFrame->cs.Sel = cs;
    629629
    630630    /* Mask away all reserved bits */
     
    635635    Assert((pRegFrame->eflags.u32 & (X86_EFL_IF|X86_EFL_IOPL)) == X86_EFL_IF);
    636636
    637     pRegFrame->esp = esp;
    638     pRegFrame->ss  = ss;
    639     pRegFrame->ds  = ds;
    640     pRegFrame->es  = es;
    641     pRegFrame->fs  = fs;
    642     pRegFrame->gs  = gs;
     637    pRegFrame->esp      = esp;
     638    pRegFrame->ss.Sel   = ss;
     639    pRegFrame->ds.Sel   = ds;
     640    pRegFrame->es.Sel   = es;
     641    pRegFrame->fs.Sel   = fs;
     642    pRegFrame->gs.Sel   = gs;
    643643
    644644    return VINF_SUCCESS;
     
    926926            {
    927927                /* Illegal to have an active 64 bits CS selector (AMD Arch. Programmer's Manual Volume 2: Table 14-5) */
    928                 if (pRegFrame->csHid.Attr.n.u1Long)
     928                if (pRegFrame->cs.Attr.n.u1Long)
    929929                {
    930930                    AssertMsgFailed(("Illegal enabling of paging with CS.u1Long = 1!!\n"));
     
    15351535
    15361536            /* Read stack value first */
    1537             if (SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->ss, &pRegFrame->ssHid) == DISCPUMODE_16BIT)
     1537            if (SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->ss.Sel, &pRegFrame->ss) == DISCPUMODE_16BIT)
    15381538                return VERR_EM_INTERPRETER; /* No legacy 16 bits stuff here, please. */
    15391539
     
    22022202    if (!(pDis->fPrefix & DISPREFIX_REP))
    22032203    {
    2204         LogFlow(("emInterpretStosWD dest=%04X:%RGv (%RGv) cbSize=%d\n", pRegFrame->es, GCOffset, GCDest, cbSize));
     2204        LogFlow(("emInterpretStosWD dest=%04X:%RGv (%RGv) cbSize=%d\n", pRegFrame->es.Sel, GCOffset, GCDest, cbSize));
    22052205
    22062206        rc = emRamWrite(pVM, pVCpu, pRegFrame, GCDest, &pRegFrame->rax, cbSize);
     
    22472247        }
    22482248
    2249         LogFlow(("emInterpretStosWD dest=%04X:%RGv (%RGv) cbSize=%d cTransfers=%x DF=%d\n", pRegFrame->es, GCOffset, GCDest, cbSize, cTransfers, pRegFrame->eflags.Bits.u1DF));
     2249        LogFlow(("emInterpretStosWD dest=%04X:%RGv (%RGv) cbSize=%d cTransfers=%x DF=%d\n", pRegFrame->es.Sel, GCOffset, GCDest, cbSize, cTransfers, pRegFrame->eflags.Bits.u1DF));
    22502250        /* Access verification first; we currently can't recover properly from traps inside this instruction */
    22512251        rc = PGMVerifyAccess(pVCpu, GCDest - ((offIncrement > 0) ? 0 : ((cTransfers-1) * cbSize)),
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r41838 r41906  
    632632    IEMMODE enmMode = CPUMIsGuestIn64BitCodeEx(pCtx)
    633633                    ? IEMMODE_64BIT
    634                     : pCtx->csHid.Attr.n.u1DefBig /** @todo check if this is correct... */
     634                    : pCtx->cs.Attr.n.u1DefBig /** @todo check if this is correct... */
    635635                    ? IEMMODE_32BIT
    636636                    : IEMMODE_16BIT;
     
    684684    {
    685685        uint32_t GCPtrPC32 = pCtx->eip;
    686         AssertMsg(!(GCPtrPC32 & ~(uint32_t)UINT16_MAX) || pIemCpu->enmCpuMode == IEMMODE_32BIT, ("%04x:%RX64\n", pCtx->cs, pCtx->rip));
    687         if (GCPtrPC32 > pCtx->csHid.u32Limit)
     686        AssertMsg(!(GCPtrPC32 & ~(uint32_t)UINT16_MAX) || pIemCpu->enmCpuMode == IEMMODE_32BIT, ("%04x:%RX64\n", pCtx->cs.Sel, pCtx->rip));
     687        if (GCPtrPC32 > pCtx->cs.u32Limit)
    688688            return iemRaiseSelectorBounds(pIemCpu, X86_SREG_CS, IEM_ACCESS_INSTRUCTION);
    689         cbToTryRead = pCtx->csHid.u32Limit - GCPtrPC32 + 1;
    690         GCPtrPC = pCtx->csHid.u64Base + GCPtrPC32;
     689        cbToTryRead = pCtx->cs.u32Limit - GCPtrPC32 + 1;
     690        GCPtrPC = pCtx->cs.u64Base + GCPtrPC32;
    691691    }
    692692
     
    789789        Assert(!(GCPtrNext32 & ~(uint32_t)UINT16_MAX) || pIemCpu->enmCpuMode == IEMMODE_32BIT);
    790790        GCPtrNext32 += pIemCpu->cbOpcode;
    791         if (GCPtrNext32 > pCtx->csHid.u32Limit)
     791        if (GCPtrNext32 > pCtx->cs.u32Limit)
    792792            return iemRaiseSelectorBounds(pIemCpu, X86_SREG_CS, IEM_ACCESS_INSTRUCTION);
    793         cbToTryRead = pCtx->csHid.u32Limit - GCPtrNext32 + 1;
     793        cbToTryRead = pCtx->cs.u32Limit - GCPtrNext32 + 1;
    794794        if (cbToTryRead < cbMin - cbLeft)
    795795            return iemRaiseSelectorBounds(pIemCpu, X86_SREG_CS, IEM_ACCESS_INSTRUCTION);
    796         GCPtrNext = pCtx->csHid.u64Base + GCPtrNext32;
     796        GCPtrNext = pCtx->cs.u64Base + GCPtrNext32;
    797797    }
    798798
     
    15901590    *pSelSS = 0; /* make gcc happy */
    15911591
    1592     switch (pCtx->trHid.Attr.n.u4Type)
     1592    switch (pCtx->tr.Attr.n.u4Type)
    15931593    {
    15941594        /*
     
    15991599        {
    16001600            uint32_t off = uCpl * 4 + 2;
    1601             if (off + 4 > pCtx->trHid.u32Limit)
     1601            if (off + 4 > pCtx->tr.u32Limit)
    16021602            {
    1603                 Log(("LoadStackFromTss32Or16: out of bounds! uCpl=%d, u32Limit=%#x TSS16\n", uCpl, pCtx->trHid.u32Limit));
     1603                Log(("LoadStackFromTss32Or16: out of bounds! uCpl=%d, u32Limit=%#x TSS16\n", uCpl, pCtx->tr.u32Limit));
    16041604                return iemRaiseTaskSwitchFaultCurrentTSS(pIemCpu);
    16051605            }
    16061606
    16071607            uint32_t u32Tmp = 0; /* gcc maybe... */
    1608             rcStrict = iemMemFetchSysU32(pIemCpu, &u32Tmp, UINT8_MAX, pCtx->trHid.u64Base + off);
     1608            rcStrict = iemMemFetchSysU32(pIemCpu, &u32Tmp, UINT8_MAX, pCtx->tr.u64Base + off);
    16091609            if (rcStrict == VINF_SUCCESS)
    16101610            {
     
    16231623        {
    16241624            uint32_t off = uCpl * 8 + 4;
    1625             if (off + 7 > pCtx->trHid.u32Limit)
     1625            if (off + 7 > pCtx->tr.u32Limit)
    16261626            {
    1627                 Log(("LoadStackFromTss32Or16: out of bounds! uCpl=%d, u32Limit=%#x TSS16\n", uCpl, pCtx->trHid.u32Limit));
     1627                Log(("LoadStackFromTss32Or16: out of bounds! uCpl=%d, u32Limit=%#x TSS16\n", uCpl, pCtx->tr.u32Limit));
    16281628                return iemRaiseTaskSwitchFaultCurrentTSS(pIemCpu);
    16291629            }
    16301630
    16311631            uint64_t u64Tmp;
    1632             rcStrict = iemMemFetchSysU64(pIemCpu, &u64Tmp, UINT8_MAX, pCtx->trHid.u64Base + off);
     1632            rcStrict = iemMemFetchSysU64(pIemCpu, &u64Tmp, UINT8_MAX, pCtx->tr.u64Base + off);
    16331633            if (rcStrict == VINF_SUCCESS)
    16341634            {
     
    17141714
    17151715    pu16Frame[2] = (uint16_t)pCtx->eflags.u;
    1716     pu16Frame[1] = (uint16_t)pCtx->cs;
     1716    pu16Frame[1] = (uint16_t)pCtx->cs.Sel;
    17171717    pu16Frame[0] = pCtx->ip + cbInstr;
    17181718    rcStrict = iemMemStackPushCommitSpecial(pIemCpu, pu16Frame, uNewRsp);
     
    17241724     * adjustments.
    17251725     */
    1726     pCtx->cs               = Idte.sel;
    1727     pCtx->csHid.u64Base    = (uint32_t)Idte.sel << 4;
     1726    pCtx->cs.Sel           = Idte.sel;
     1727    pCtx->cs.ValidSel      = Idte.sel;
     1728    pCtx->cs.fFlags        = CPUMSELREG_FLAGS_VALID;
     1729    pCtx->cs.u64Base       = (uint32_t)Idte.sel << 4;
    17281730    /** @todo do we load attribs and limit as well? Should we check against limit like far jump? */
    17291731    pCtx->rip              = Idte.off;
     
    19561958        uStackFrame.pu32[0] = (fFlags & (IEM_XCPT_FLAGS_T_SOFT_INT | IEM_XCPT_FLAGS_BP_INSTR)) == IEM_XCPT_FLAGS_T_SOFT_INT
    19571959                            ? pCtx->eip + cbInstr : pCtx->eip;
    1958         uStackFrame.pu32[1] = (pCtx->cs & ~X86_SEL_RPL) | pIemCpu->uCpl;
     1960        uStackFrame.pu32[1] = (pCtx->cs.Sel & ~X86_SEL_RPL) | pIemCpu->uCpl;
    19591961        uStackFrame.pu32[2] = pCtx->eflags.u;
    19601962        uStackFrame.pu32[3] = pCtx->esp;
    1961         uStackFrame.pu32[4] = pCtx->ss;
     1963        uStackFrame.pu32[4] = pCtx->ss.Sel;
    19621964        rcStrict = iemMemCommitAndUnmap(pIemCpu, pvStackFrame, IEM_ACCESS_STACK_W | IEM_ACCESS_WHAT_SYS);
    19631965        if (rcStrict != VINF_SUCCESS)
     
    19851987
    19861988        /*
    1987          * Start commint the register changes (joins with the DPL=CPL branch).
     1989         * Start comitting the register changes (joins with the DPL=CPL branch).
    19881990         */
    1989         pCtx->ss                = NewSS;
    1990         pCtx->ssHid.u32Limit    = cbLimitSS;
    1991         pCtx->ssHid.u64Base     = X86DESC_BASE(DescSS.Legacy);
    1992         pCtx->ssHid.Attr.u      = X86DESC_GET_HID_ATTR(DescSS.Legacy);
     1991        pCtx->ss.Sel            = NewSS;
     1992        pCtx->ss.ValidSel       = NewSS;
     1993        pCtx->ss.fFlags         = CPUMSELREG_FLAGS_VALID;
     1994        pCtx->ss.u32Limit       = cbLimitSS;
     1995        pCtx->ss.u64Base        = X86DESC_BASE(DescSS.Legacy);
     1996        pCtx->ss.Attr.u         = X86DESC_GET_HID_ATTR(DescSS.Legacy);
    19931997        pCtx->rsp               = uNewEsp - cbStackFrame; /** @todo Is the high word cleared for 16-bit stacks and/or interrupt handlers? */
    19941998        pIemCpu->uCpl           = uNewCpl;
     
    20112015        uStackFrame.pu32[0] = (fFlags & (IEM_XCPT_FLAGS_T_SOFT_INT | IEM_XCPT_FLAGS_BP_INSTR)) == IEM_XCPT_FLAGS_T_SOFT_INT
    20122016                            ? pCtx->eip + cbInstr : pCtx->eip;
    2013         uStackFrame.pu32[1] = (pCtx->cs & ~X86_SEL_RPL) | pIemCpu->uCpl;
     2017        uStackFrame.pu32[1] = (pCtx->cs.Sel & ~X86_SEL_RPL) | pIemCpu->uCpl;
    20142018        uStackFrame.pu32[2] = pCtx->eflags.u;
    20152019        rcStrict = iemMemCommitAndUnmap(pIemCpu, pvStackFrame, IEM_ACCESS_STACK_W); /* don't use the commit here */
     
    20332037
    20342038    /* ... register committing continues. */
    2035     pCtx->cs                = (NewCS & ~X86_SEL_RPL) | uNewCpl;
    2036     pCtx->csHid.u32Limit    = cbLimitCS;
    2037     pCtx->csHid.u64Base     = X86DESC_BASE(DescCS.Legacy);
    2038     pCtx->csHid.Attr.u      = X86DESC_GET_HID_ATTR(DescCS.Legacy);
     2039    pCtx->cs.Sel            = (NewCS & ~X86_SEL_RPL) | uNewCpl;
     2040    pCtx->cs.ValidSel       = (NewCS & ~X86_SEL_RPL) | uNewCpl;
     2041    pCtx->cs.fFlags         = CPUMSELREG_FLAGS_VALID;
     2042    pCtx->cs.u32Limit       = cbLimitCS;
     2043    pCtx->cs.u64Base        = X86DESC_BASE(DescCS.Legacy);
     2044    pCtx->cs.Attr.u         = X86DESC_GET_HID_ATTR(DescCS.Legacy);
    20392045
    20402046    pCtx->rip               = uNewEip;
     
    21382144    if (pIemCpu->cXcptRecursions == 0)
    21392145        Log(("iemRaiseXcptOrInt: %#x at %04x:%RGv cbInstr=%#x fFlags=%#x uErr=%#x uCr2=%llx\n",
    2140              u8Vector, pCtx->cs, pCtx->rip, cbInstr, fFlags, uErr, uCr2));
     2146             u8Vector, pCtx->cs.Sel, pCtx->rip, cbInstr, fFlags, uErr, uCr2));
    21412147    else
    21422148    {
    21432149        Log(("iemRaiseXcptOrInt: %#x at %04x:%RGv cbInstr=%#x fFlags=%#x uErr=%#x uCr2=%llx; prev=%#x depth=%d flags=%#x\n",
    2144              u8Vector, pCtx->cs, pCtx->rip, cbInstr, fFlags, uErr, uCr2, pIemCpu->uCurXcpt, pIemCpu->cXcptRecursions + 1, fPrevXcpt));
     2150             u8Vector, pCtx->cs.Sel, pCtx->rip, cbInstr, fFlags, uErr, uCr2, pIemCpu->uCurXcpt, pIemCpu->cXcptRecursions + 1, fPrevXcpt));
    21452151
    21462152        /** @todo double and tripple faults. */
     
    22212227    pIemCpu->fCurXcpt = fPrevXcpt;
    22222228    LogFlow(("iemRaiseXcptOrInt: returns %Rrc (vec=%#x); cs:rip=%04x:%RGv ss:rsp=%04x:%RGv\n",
    2223              VBOXSTRICTRC_VAL(rcStrict), u8Vector, pCtx->cs, pCtx->rip, pCtx->ss, pCtx->esp));
     2229             VBOXSTRICTRC_VAL(rcStrict), u8Vector, pCtx->cs.Sel, pCtx->rip, pCtx->ss.Sel, pCtx->esp));
    22242230    return rcStrict;
    22252231}
     
    22682274{
    22692275    return iemRaiseXcptOrInt(pIemCpu, 0, X86_XCPT_TS, IEM_XCPT_FLAGS_T_CPU_XCPT | IEM_XCPT_FLAGS_ERR,
    2270                              pIemCpu->CTX_SUFF(pCtx)->tr, 0);
     2276                             pIemCpu->CTX_SUFF(pCtx)->tr.Sel, 0);
    22712277}
    22722278
     
    26422648    switch (iSegReg)
    26432649    {
    2644         case X86_SREG_ES: return &pCtx->esHid;
    2645         case X86_SREG_CS: return &pCtx->csHid;
    2646         case X86_SREG_SS: return &pCtx->ssHid;
    2647         case X86_SREG_DS: return &pCtx->dsHid;
    2648         case X86_SREG_FS: return &pCtx->fsHid;
    2649         case X86_SREG_GS: return &pCtx->gsHid;
    2650     }
    2651     AssertFailedReturn(NULL);
    2652 }
    2653 
    2654 
    2655 /**
    2656  * Gets a reference (pointer) to the specified segment register (the selector
    2657  * value).
    2658  *
    2659  * @returns Pointer to the selector variable.
    2660  * @param   pIemCpu             The per CPU data.
    2661  * @param   iSegReg             The segment register.
    2662  */
    2663 static uint16_t *iemSRegRef(PIEMCPU pIemCpu, uint8_t iSegReg)
    2664 {
    2665     PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
    2666     switch (iSegReg)
    2667     {
    26682650        case X86_SREG_ES: return &pCtx->es;
    26692651        case X86_SREG_CS: return &pCtx->cs;
     
    26782660
    26792661/**
     2662 * Gets a reference (pointer) to the specified segment register (the selector
     2663 * value).
     2664 *
     2665 * @returns Pointer to the selector variable.
     2666 * @param   pIemCpu             The per CPU data.
     2667 * @param   iSegReg             The segment register.
     2668 */
     2669static uint16_t *iemSRegRef(PIEMCPU pIemCpu, uint8_t iSegReg)
     2670{
     2671    PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
     2672    switch (iSegReg)
     2673    {
     2674        case X86_SREG_ES: return &pCtx->es.Sel;
     2675        case X86_SREG_CS: return &pCtx->cs.Sel;
     2676        case X86_SREG_SS: return &pCtx->ss.Sel;
     2677        case X86_SREG_DS: return &pCtx->ds.Sel;
     2678        case X86_SREG_FS: return &pCtx->fs.Sel;
     2679        case X86_SREG_GS: return &pCtx->gs.Sel;
     2680    }
     2681    AssertFailedReturn(NULL);
     2682}
     2683
     2684
     2685/**
    26802686 * Fetches the selector value of a segment register.
    26812687 *
     
    26892695    switch (iSegReg)
    26902696    {
    2691         case X86_SREG_ES: return pCtx->es;
    2692         case X86_SREG_CS: return pCtx->cs;
    2693         case X86_SREG_SS: return pCtx->ss;
    2694         case X86_SREG_DS: return pCtx->ds;
    2695         case X86_SREG_FS: return pCtx->fs;
    2696         case X86_SREG_GS: return pCtx->gs;
     2697        case X86_SREG_ES: return pCtx->es.Sel;
     2698        case X86_SREG_CS: return pCtx->cs.Sel;
     2699        case X86_SREG_SS: return pCtx->ss.Sel;
     2700        case X86_SREG_DS: return pCtx->ds.Sel;
     2701        case X86_SREG_FS: return pCtx->fs.Sel;
     2702        case X86_SREG_GS: return pCtx->gs.Sel;
    26972703    }
    26982704    AssertFailedReturn(0xffff);
     
    28422848        {
    28432849            uint16_t uNewIp = pCtx->ip + offNextInstr + pIemCpu->offOpcode;
    2844             if (   uNewIp > pCtx->csHid.u32Limit
     2850            if (   uNewIp > pCtx->cs.u32Limit
    28452851                && pIemCpu->enmCpuMode != IEMMODE_64BIT) /* no need to check for non-canonical. */
    28462852                return iemRaiseGeneralProtectionFault0(pIemCpu);
     
    28552861
    28562862            uint32_t uNewEip = pCtx->eip + offNextInstr + pIemCpu->offOpcode;
    2857             if (uNewEip > pCtx->csHid.u32Limit)
     2863            if (uNewEip > pCtx->cs.u32Limit)
    28582864                return iemRaiseGeneralProtectionFault0(pIemCpu);
    28592865            pCtx->rip = uNewEip;
     
    28952901
    28962902    uint16_t uNewIp = pCtx->ip + offNextInstr + pIemCpu->offOpcode;
    2897     if (   uNewIp > pCtx->csHid.u32Limit
     2903    if (   uNewIp > pCtx->cs.u32Limit
    28982904        && pIemCpu->enmCpuMode != IEMMODE_64BIT) /* no need to check for non-canonical. */
    28992905        return iemRaiseGeneralProtectionFault0(pIemCpu);
     
    29252931
    29262932        uint32_t uNewEip = pCtx->eip + offNextInstr + pIemCpu->offOpcode;
    2927         if (uNewEip > pCtx->csHid.u32Limit)
     2933        if (uNewEip > pCtx->cs.u32Limit)
    29282934            return iemRaiseGeneralProtectionFault0(pIemCpu);
    29292935        pCtx->rip = uNewEip;
     
    29592965        {
    29602966            Assert(uNewRip <= UINT16_MAX);
    2961             if (   uNewRip > pCtx->csHid.u32Limit
     2967            if (   uNewRip > pCtx->cs.u32Limit
    29622968                && pIemCpu->enmCpuMode != IEMMODE_64BIT) /* no need to check for non-canonical. */
    29632969                return iemRaiseGeneralProtectionFault0(pIemCpu);
     
    29732979            Assert(pIemCpu->enmCpuMode != IEMMODE_64BIT);
    29742980
    2975             if (uNewRip > pCtx->csHid.u32Limit)
     2981            if (uNewRip > pCtx->cs.u32Limit)
    29762982                return iemRaiseGeneralProtectionFault0(pIemCpu);
    29772983            pCtx->rip = uNewRip;
     
    30043010DECLINLINE(RTGCPTR) iemRegGetEffRsp(PCCPUMCTX pCtx)
    30053011{
    3006     if (pCtx->ssHid.Attr.n.u1Long)
     3012    if (pCtx->ss.Attr.n.u1Long)
    30073013        return pCtx->rsp;
    3008     if (pCtx->ssHid.Attr.n.u1DefBig)
     3014    if (pCtx->ss.Attr.n.u1DefBig)
    30093015        return pCtx->esp;
    30103016    return pCtx->sp;
     
    30623068DECLINLINE(void) iemRegAddToRsp(PCPUMCTX pCtx, uint8_t cbToAdd)
    30633069{
    3064     if (pCtx->ssHid.Attr.n.u1Long)
     3070    if (pCtx->ss.Attr.n.u1Long)
    30653071        pCtx->rsp += cbToAdd;
    3066     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3072    else if (pCtx->ss.Attr.n.u1DefBig)
    30673073        pCtx->esp += cbToAdd;
    30683074    else
     
    30803086DECLINLINE(void) iemRegSubFromRsp(PCPUMCTX pCtx, uint8_t cbToSub)
    30813087{
    3082     if (pCtx->ssHid.Attr.n.u1Long)
     3088    if (pCtx->ss.Attr.n.u1Long)
    30833089        pCtx->rsp -= cbToSub;
    3084     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3090    else if (pCtx->ss.Attr.n.u1DefBig)
    30853091        pCtx->esp -= cbToSub;
    30863092    else
     
    30983104DECLINLINE(void) iemRegAddToRspEx(PRTUINT64U pTmpRsp, uint8_t cbToAdd, PCCPUMCTX pCtx)
    30993105{
    3100     if (pCtx->ssHid.Attr.n.u1Long)
     3106    if (pCtx->ss.Attr.n.u1Long)
    31013107        pTmpRsp->u           += cbToAdd;
    3102     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3108    else if (pCtx->ss.Attr.n.u1DefBig)
    31033109        pTmpRsp->DWords.dw0  += cbToAdd;
    31043110    else
     
    31163122DECLINLINE(void) iemRegSubFromRspEx(PRTUINT64U pTmpRsp, uint8_t cbToSub, PCCPUMCTX pCtx)
    31173123{
    3118     if (pCtx->ssHid.Attr.n.u1Long)
     3124    if (pCtx->ss.Attr.n.u1Long)
    31193125        pTmpRsp->u          -= cbToSub;
    3120     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3126    else if (pCtx->ss.Attr.n.u1DefBig)
    31213127        pTmpRsp->DWords.dw0 -= cbToSub;
    31223128    else
     
    31403146    uTmpRsp.u = pCtx->rsp;
    31413147
    3142     if (pCtx->ssHid.Attr.n.u1Long)
     3148    if (pCtx->ss.Attr.n.u1Long)
    31433149        GCPtrTop = uTmpRsp.u            -= cbItem;
    3144     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3150    else if (pCtx->ss.Attr.n.u1DefBig)
    31453151        GCPtrTop = uTmpRsp.DWords.dw0   -= cbItem;
    31463152    else
     
    31663172    uTmpRsp.u = pCtx->rsp;
    31673173
    3168     if (pCtx->ssHid.Attr.n.u1Long)
     3174    if (pCtx->ss.Attr.n.u1Long)
    31693175    {
    31703176        GCPtrTop = uTmpRsp.u;
    31713177        uTmpRsp.u += cbItem;
    31723178    }
    3173     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3179    else if (pCtx->ss.Attr.n.u1DefBig)
    31743180    {
    31753181        GCPtrTop = uTmpRsp.DWords.dw0;
     
    31993205    RTGCPTR GCPtrTop;
    32003206
    3201     if (pCtx->ssHid.Attr.n.u1Long)
     3207    if (pCtx->ss.Attr.n.u1Long)
    32023208        GCPtrTop = pTmpRsp->u          -= cbItem;
    3203     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3209    else if (pCtx->ss.Attr.n.u1DefBig)
    32043210        GCPtrTop = pTmpRsp->DWords.dw0 -= cbItem;
    32053211    else
     
    32213227{
    32223228    RTGCPTR GCPtrTop;
    3223     if (pCtx->ssHid.Attr.n.u1Long)
     3229    if (pCtx->ss.Attr.n.u1Long)
    32243230    {
    32253231        GCPtrTop = pTmpRsp->u;
    32263232        pTmpRsp->u          += cbItem;
    32273233    }
    3228     else if (pCtx->ssHid.Attr.n.u1DefBig)
     3234    else if (pCtx->ss.Attr.n.u1DefBig)
    32293235    {
    32303236        GCPtrTop = pTmpRsp->DWords.dw0;
     
    33353341         *        happens in real mode here based on the fnsave and fnstenv images. */
    33363342        pCtx->fpu.CS    = 0;
    3337         pCtx->fpu.FPUIP = pCtx->eip | ((uint32_t)pCtx->cs << 4);
     3343        pCtx->fpu.FPUIP = pCtx->eip | ((uint32_t)pCtx->cs.Sel << 4);
    33383344    }
    33393345    else
    33403346    {
    3341         pCtx->fpu.CS    = pCtx->cs;
     3347        pCtx->fpu.CS    = pCtx->cs.Sel;
    33423348        pCtx->fpu.FPUIP = pCtx->rip;
    33433349    }
     
    33583364    switch (iEffSeg)
    33593365    {
    3360         case X86_SREG_DS: sel = pCtx->ds; break;
    3361         case X86_SREG_SS: sel = pCtx->ss; break;
    3362         case X86_SREG_CS: sel = pCtx->cs; break;
    3363         case X86_SREG_ES: sel = pCtx->es; break;
    3364         case X86_SREG_FS: sel = pCtx->fs; break;
    3365         case X86_SREG_GS: sel = pCtx->gs; break;
     3366        case X86_SREG_DS: sel = pCtx->ds.Sel; break;
     3367        case X86_SREG_SS: sel = pCtx->ss.Sel; break;
     3368        case X86_SREG_CS: sel = pCtx->cs.Sel; break;
     3369        case X86_SREG_ES: sel = pCtx->es.Sel; break;
     3370        case X86_SREG_FS: sel = pCtx->fs.Sel; break;
     3371        case X86_SREG_GS: sel = pCtx->gs.Sel; break;
    33663372        default:
    33673373            AssertMsgFailed(("%d\n", iEffSeg));
    3368             sel = pCtx->ds;
     3374            sel = pCtx->ds.Sel;
    33693375    }
    33703376    /** @todo FPU.DS and FPUDP needs to be kept seperately. */
     
    57775783    if (uSel & X86_SEL_LDT)
    57785784    {
    5779         if (   !pCtx->ldtrHid.Attr.n.u1Present
    5780             || (uSel | 0x7U) > pCtx->ldtrHid.u32Limit )
     5785        if (   !pCtx->ldtr.Attr.n.u1Present
     5786            || (uSel | 0x7U) > pCtx->ldtr.u32Limit )
    57815787        {
    57825788            Log(("iemMemFetchSelDesc: LDT selector %#x is out of bounds (%3x) or ldtr is NP (%#x)\n",
    5783                  uSel, pCtx->ldtrHid.u32Limit, pCtx->ldtr));
     5789                 uSel, pCtx->ldtr.u32Limit, pCtx->ldtr.Sel));
    57845790            /** @todo is this the right exception? */
    57855791            return iemRaiseGeneralProtectionFaultBySelector(pIemCpu, uSel);
    57865792        }
    57875793
    5788         Assert(pCtx->ldtrHid.Attr.n.u1Present);
    5789         GCPtrBase = pCtx->ldtrHid.u64Base;
     5794        Assert(pCtx->ldtr.Attr.n.u1Present);
     5795        GCPtrBase = pCtx->ldtr.u64Base;
    57905796    }
    57915797    else
     
    58105816            || pDesc->Legacy.Gen.u1DescType)
    58115817            pDesc->Long.au64[1] = 0;
    5812         else if ((uint32_t)(uSel & X86_SEL_MASK) + 15 < (uSel & X86_SEL_LDT ? pCtx->ldtrHid.u32Limit : pCtx->gdtr.cbGdt))
     5818        else if ((uint32_t)(uSel & X86_SEL_MASK) + 15 < (uSel & X86_SEL_LDT ? pCtx->ldtr.u32Limit : pCtx->gdtr.cbGdt))
    58135819            rcStrict = iemMemFetchSysU64(pIemCpu, &pDesc->Legacy.u, UINT8_MAX, GCPtrBase + (uSel & X86_SEL_MASK));
    58145820        else
     
    58595865     */
    58605866    RTGCPTR GCPtr = uSel & X86_SEL_LDT
    5861                   ? pCtx->ldtrHid.u64Base
     5867                  ? pCtx->ldtr.u64Base
    58625868                  : pCtx->gdtr.pGdt;
    58635869    GCPtr += uSel & X86_SEL_MASK;
     
    66056611#ifdef DEBUG
    66066612# define IEMOP_MNEMONIC(a_szMnemonic) \
    6607     Log4(("decode - %04x:%RGv %s%s [#%u]\n", pIemCpu->CTX_SUFF(pCtx)->cs, pIemCpu->CTX_SUFF(pCtx)->rip, \
     6613    Log4(("decode - %04x:%RGv %s%s [#%u]\n", pIemCpu->CTX_SUFF(pCtx)->cs.Sel, pIemCpu->CTX_SUFF(pCtx)->rip, \
    66086614          pIemCpu->fPrefixes & IEM_OP_PRF_LOCK ? "lock " : "", a_szMnemonic, pIemCpu->cInstructions))
    66096615# define IEMOP_MNEMONIC2(a_szMnemonic, a_szOps) \
    6610     Log4(("decode - %04x:%RGv %s%s %s [#%u]\n", pIemCpu->CTX_SUFF(pCtx)->cs, pIemCpu->CTX_SUFF(pCtx)->rip, \
     6616    Log4(("decode - %04x:%RGv %s%s %s [#%u]\n", pIemCpu->CTX_SUFF(pCtx)->cs.Sel, pIemCpu->CTX_SUFF(pCtx)->rip, \
    66116617          pIemCpu->fPrefixes & IEM_OP_PRF_LOCK ? "lock " : "", a_szMnemonic, a_szOps, pIemCpu->cInstructions))
    66126618#else
     
    78727878              pCtx->eax, pCtx->ebx, pCtx->ecx, pCtx->edx, pCtx->esi, pCtx->edi,
    78737879              pCtx->eip, pCtx->esp, pCtx->ebp, pCtx->eflags.Bits.u2IOPL,
    7874               (RTSEL)pCtx->cs, (RTSEL)pCtx->ss, (RTSEL)pCtx->ds, (RTSEL)pCtx->es,
    7875               (RTSEL)pCtx->fs, (RTSEL)pCtx->gs, pCtx->eflags.u,
     7880              pCtx->cs.Sel, pCtx->ss.Sel, pCtx->ds.Sel, pCtx->es.Sel,
     7881              pCtx->fs.Sel, pCtx->gs.Sel, pCtx->eflags.u,
    78767882              pCtx->fpu.FSW, pCtx->fpu.FCW, pCtx->fpu.FTW, pCtx->fpu.MXCSR, pCtx->fpu.MXCSR_MASK,
    78777883              szInstr));
     
    78837889# endif
    78847890        LogFlow(("IEMExecOne: cs:rip=%04x:%08RX64 ss:rsp=%04x:%08RX64 EFL=%06x\n",
    7885                  pCtx->cs, pCtx->rip, pCtx->ss, pCtx->rsp, pCtx->eflags.u));
     7891                 pCtx->cs.Sel, pCtx->rip, pCtx->ss.Sel, pCtx->rsp, pCtx->eflags.u));
    78867892#endif
    78877893
     
    79017907    if (rcStrict != VINF_SUCCESS)
    79027908        LogFlow(("IEMExecOne: cs:rip=%04x:%08RX64 ss:rsp=%04x:%08RX64 EFL=%06x - rcStrict=%Rrc\n",
    7903                  pCtx->cs, pCtx->rip, pCtx->ss, pCtx->rsp, pCtx->eflags.u, VBOXSTRICTRC_VAL(rcStrict)));
     7909                 pCtx->cs.Sel, pCtx->rip, pCtx->ss.Sel, pCtx->rsp, pCtx->eflags.u, VBOXSTRICTRC_VAL(rcStrict)));
    79047910    return rcStrict;
    79057911}
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h

    r41783 r41906  
    103103 * visible parts, in protected mode.
    104104 *
    105  * @param   puSel               The selector register.
    106  * @param   pHid                The hidden register part.
    107  */
    108 static void iemHlpLoadNullDataSelectorProt(PRTSEL puSel, PCPUMSELREGHID pHid)
     105 * @param   pSReg               Pointer to the segment register.
     106 */
     107static void iemHlpLoadNullDataSelectorProt(PCPUMSELREG pSReg)
    109108{
    110109    /** @todo Testcase: write a testcase checking what happends when loading a NULL
    111110     *        data selector in protected mode. */
    112     pHid->u64Base  = 0;
    113     pHid->u32Limit = 0;
    114     pHid->Attr.u   = 0;
    115     *puSel = 0;
     111    pSReg->Sel      = 0;
     112    pSReg->ValidSel = 0;
     113    pSReg->fFlags   = CPUMSELREG_FLAGS_VALID;
     114    pSReg->u64Base  = 0;
     115    pSReg->u32Limit = 0;
     116    pSReg->Attr.u   = 0;
    116117}
    117118
     
    121122 *
    122123 * @param   uCpl                The new CPL.
    123  * @param   puSel               The selector register.
    124  * @param   pHid                The corresponding hidden register.
    125  */
    126 static void iemHlpAdjustSelectorForNewCpl(uint8_t uCpl, PRTSEL puSel, PCPUMSELREGHID pHid)
    127 {
    128     if (   uCpl > pHid->Attr.n.u2Dpl
    129         && pHid->Attr.n.u1DescType /* code or data, not system */
    130         &&    (pHid->Attr.n.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_CONF))
    131            !=                        (X86_SEL_TYPE_CODE | X86_SEL_TYPE_CONF)) /* not conforming code */
    132         iemHlpLoadNullDataSelectorProt(puSel, pHid);
     124 * @param   pSReg               Pointer to the segment register.
     125 */
     126static void iemHlpAdjustSelectorForNewCpl(uint8_t uCpl, PCPUMSELREG pSReg)
     127{
     128    if (   uCpl > pSReg->Attr.n.u2Dpl
     129        && pSReg->Attr.n.u1DescType /* code or data, not system */
     130        &&    (pSReg->Attr.n.u4Type & (X86_SEL_TYPE_CODE | X86_SEL_TYPE_CONF))
     131           !=                         (X86_SEL_TYPE_CODE | X86_SEL_TYPE_CONF)) /* not conforming code */
     132        iemHlpLoadNullDataSelectorProt(pSReg);
    133133}
    134134
     
    158158    /** @todo do popa boundary / wrap-around checks.  */
    159159    if (RT_UNLIKELY(   IEM_IS_REAL_OR_V86_MODE(pIemCpu)
    160                     && (pCtx->csHid.u32Limit < GCPtrLast)) ) /* ASSUMES 64-bit RTGCPTR */
     160                    && (pCtx->cs.u32Limit < GCPtrLast)) ) /* ASSUMES 64-bit RTGCPTR */
    161161    {
    162162        /* word-by-word */
     
    230230    /** @todo do popa boundary / wrap-around checks.  */
    231231    if (RT_UNLIKELY(   IEM_IS_REAL_OR_V86_MODE(pIemCpu)
    232                     && (pCtx->csHid.u32Limit < GCPtrLast)) ) /* ASSUMES 64-bit RTGCPTR */
     232                    && (pCtx->cs.u32Limit < GCPtrLast)) ) /* ASSUMES 64-bit RTGCPTR */
    233233    {
    234234        /* word-by-word */
     
    632632    PCPUMCTX pCtx   = pIemCpu->CTX_SUFF(pCtx);
    633633    uint16_t uOldPC = pCtx->ip + cbInstr;
    634     if (uNewPC > pCtx->csHid.u32Limit)
     634    if (uNewPC > pCtx->cs.u32Limit)
    635635        return iemRaiseGeneralProtectionFault0(pIemCpu);
    636636
     
    655655    uint16_t uOldPC = pCtx->ip + cbInstr;
    656656    uint16_t uNewPC = uOldPC + offDisp;
    657     if (uNewPC > pCtx->csHid.u32Limit)
     657    if (uNewPC > pCtx->cs.u32Limit)
    658658        return iemRaiseGeneralProtectionFault0(pIemCpu);
    659659
     
    678678    PCPUMCTX pCtx   = pIemCpu->CTX_SUFF(pCtx);
    679679    uint32_t uOldPC = pCtx->eip + cbInstr;
    680     if (uNewPC > pCtx->csHid.u32Limit)
     680    if (uNewPC > pCtx->cs.u32Limit)
    681681        return iemRaiseGeneralProtectionFault0(pIemCpu);
    682682
     
    701701    uint32_t uOldPC = pCtx->eip + cbInstr;
    702702    uint32_t uNewPC = uOldPC + offDisp;
    703     if (uNewPC > pCtx->csHid.u32Limit)
     703    if (uNewPC > pCtx->cs.u32Limit)
    704704        return iemRaiseGeneralProtectionFault0(pIemCpu);
    705705
     
    891891        && IEM_IS_REAL_OR_V86_MODE(pIemCpu))
    892892    {
    893         if (offSeg > pCtx->csHid.u32Limit)
     893        if (offSeg > pCtx->cs.u32Limit)
    894894            return iemRaiseGeneralProtectionFault0(pIemCpu);
    895895
     
    898898        else
    899899            pCtx->rip       = offSeg & UINT16_MAX;
    900         pCtx->cs            = uSel;
    901         pCtx->csHid.u64Base = (uint32_t)uSel << 4;
     900        pCtx->cs.Sel        = uSel;
     901        pCtx->cs.ValidSel   = uSel;
     902        pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     903        pCtx->cs.u64Base    = (uint32_t)uSel << 4;
    902904        /** @todo REM reset the accessed bit (see on jmp far16 after disabling
    903905         *        PE.  Check with VT-x and AMD-V. */
    904906#ifdef IEM_VERIFICATION_MODE
    905         pCtx->csHid.Attr.u  &= ~X86_SEL_TYPE_ACCESSED;
     907        pCtx->cs.Attr.u    &= ~X86_SEL_TYPE_ACCESSED;
    906908#endif
    907909        return VINF_SUCCESS;
     
    10151017    /* commit */
    10161018    pCtx->rip = offSeg;
    1017     pCtx->cs  = uSel & (X86_SEL_MASK | X86_SEL_LDT);
    1018     pCtx->cs |= pIemCpu->uCpl; /** @todo is this right for conforming segs? or in general? */
    1019     pCtx->csHid.Attr.u   = X86DESC_GET_HID_ATTR(Desc.Legacy);
    1020     pCtx->csHid.u32Limit = cbLimit;
    1021     pCtx->csHid.u64Base  = u64Base;
     1019    pCtx->cs.Sel         = uSel & (X86_SEL_MASK | X86_SEL_LDT);
     1020    pCtx->cs.Sel        |= pIemCpu->uCpl; /** @todo is this right for conforming segs? or in general? */
     1021    pCtx->cs.ValidSel    = pCtx->cs.Sel;
     1022    pCtx->cs.fFlags      = CPUMSELREG_FLAGS_VALID;
     1023    pCtx->cs.Attr.u      = X86DESC_GET_HID_ATTR(Desc.Legacy);
     1024    pCtx->cs.u32Limit    = cbLimit;
     1025    pCtx->cs.u64Base     = u64Base;
    10221026    /** @todo check if the hidden bits are loaded correctly for 64-bit
    10231027     *        mode.  */
     
    10661070        {
    10671071            uPtrRet.pu16[0] = pCtx->ip + cbInstr;
    1068             uPtrRet.pu16[1] = pCtx->cs;
     1072            uPtrRet.pu16[1] = pCtx->cs.Sel;
    10691073        }
    10701074        else
    10711075        {
    10721076            uPtrRet.pu32[0] = pCtx->eip + cbInstr;
    1073             uPtrRet.pu16[3] = pCtx->cs;
     1077            uPtrRet.pu16[3] = pCtx->cs.Sel;
    10741078        }
    10751079        rcStrict = iemMemStackPushCommitSpecial(pIemCpu, uPtrRet.pv, uNewRsp);
     
    10791083        /* Branch. */
    10801084        pCtx->rip           = offSeg;
    1081         pCtx->cs            = uSel;
    1082         pCtx->csHid.u64Base = (uint32_t)uSel << 4;
     1085        pCtx->cs.Sel        = uSel;
     1086        pCtx->cs.ValidSel   = uSel;
     1087        pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     1088        pCtx->cs.u64Base    = (uint32_t)uSel << 4;
    10831089        /** @todo Does REM reset the accessed bit here too? (See on jmp far16
    10841090         *        after disabling PE.) Check with VT-x and AMD-V. */
    10851091#ifdef IEM_VERIFICATION_MODE
    1086         pCtx->csHid.Attr.u  &= ~X86_SEL_TYPE_ACCESSED;
     1092        pCtx->cs.Attr.u    &= ~X86_SEL_TYPE_ACCESSED;
    10871093#endif
    10881094        return VINF_SUCCESS;
     
    12171223    {
    12181224        uPtrRet.pu16[0] = pCtx->ip + cbInstr;
    1219         uPtrRet.pu16[1] = pCtx->cs;
     1225        uPtrRet.pu16[1] = pCtx->cs.Sel;
    12201226    }
    12211227    else if (enmEffOpSize == IEMMODE_32BIT)
    12221228    {
    12231229        uPtrRet.pu32[0] = pCtx->eip + cbInstr;
    1224         uPtrRet.pu32[1] = pCtx->cs; /** @todo Testcase: What is written to the high word when callf is pushing CS? */
     1230        uPtrRet.pu32[1] = pCtx->cs.Sel; /** @todo Testcase: What is written to the high word when callf is pushing CS? */
    12251231    }
    12261232    else
    12271233    {
    12281234        uPtrRet.pu64[0] = pCtx->rip + cbInstr;
    1229         uPtrRet.pu64[1] = pCtx->cs; /** @todo Testcase: What is written to the high words when callf is pushing CS? */
     1235        uPtrRet.pu64[1] = pCtx->cs.Sel; /** @todo Testcase: What is written to the high words when callf is pushing CS? */
    12301236    }
    12311237    rcStrict = iemMemStackPushCommitSpecial(pIemCpu, uPtrRet.pv, uNewRsp);
     
    12351241    /* commit */
    12361242    pCtx->rip = offSeg;
    1237     pCtx->cs  = uSel & (X86_SEL_MASK | X86_SEL_LDT);
    1238     pCtx->cs |= pIemCpu->uCpl;
    1239     pCtx->csHid.Attr.u   = X86DESC_GET_HID_ATTR(Desc.Legacy);
    1240     pCtx->csHid.u32Limit = cbLimit;
    1241     pCtx->csHid.u64Base  = u64Base;
     1243    pCtx->cs.Sel         = uSel & (X86_SEL_MASK | X86_SEL_LDT);
     1244    pCtx->cs.Sel        |= pIemCpu->uCpl;
     1245    pCtx->cs.ValidSel    = pCtx->cs.Sel;
     1246    pCtx->cs.fFlags      = CPUMSELREG_FLAGS_VALID;
     1247    pCtx->cs.Attr.u      = X86DESC_GET_HID_ATTR(Desc.Legacy);
     1248    pCtx->cs.u32Limit    = cbLimit;
     1249    pCtx->cs.u64Base     = u64Base;
    12421250    /** @todo check if the hidden bits are loaded correctly for 64-bit
    12431251     *        mode.  */
     
    12991307        /** @todo Intel pseudo code only does the limit check for 16-bit
    13001308         *        operands, AMD does not make any distinction. What is right? */
    1301         if (uNewRip > pCtx->csHid.u32Limit)
     1309        if (uNewRip > pCtx->cs.u32Limit)
    13021310            return iemRaiseSelectorBounds(pIemCpu, X86_SREG_CS, IEM_ACCESS_INSTRUCTION);
    13031311
     
    13071315            return rcStrict;
    13081316        pCtx->rip           = uNewRip;
    1309         pCtx->cs            = uNewCs;
    1310         pCtx->csHid.u64Base = (uint32_t)uNewCs << 4;
     1317        pCtx->cs.Sel        = uNewCs;
     1318        pCtx->cs.ValidSel   = uNewCs;
     1319        pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     1320        pCtx->cs.u64Base    = (uint32_t)uNewCs << 4;
    13111321        /** @todo do we load attribs and limit as well? */
    13121322        if (cbPop)
     
    15401550        else
    15411551            pCtx->rip           = uNewRip;
    1542         pCtx->cs                = uNewCs;
    1543         pCtx->csHid.Attr.u      = X86DESC_GET_HID_ATTR(DescCs.Legacy);
    1544         pCtx->csHid.u32Limit    = cbLimitCs;
    1545         pCtx->csHid.u64Base     = u64Base;
     1552        pCtx->cs.Sel            = uNewCs;
     1553        pCtx->cs.ValidSel       = uNewCs;
     1554        pCtx->cs.fFlags         = CPUMSELREG_FLAGS_VALID;
     1555        pCtx->cs.Attr.u         = X86DESC_GET_HID_ATTR(DescCs.Legacy);
     1556        pCtx->cs.u32Limit       = cbLimitCs;
     1557        pCtx->cs.u64Base        = u64Base;
    15461558        pCtx->rsp               = uNewRsp;
    1547         pCtx->ss                = uNewCs;
    1548         pCtx->ssHid.Attr.u      = X86DESC_GET_HID_ATTR(DescSs.Legacy);
    1549         pCtx->ssHid.u32Limit    = cbLimitSs;
     1559        pCtx->ss.Sel            = uNewOuterSs;
     1560        pCtx->ss.ValidSel       = uNewOuterSs;
     1561        pCtx->ss.fFlags         = CPUMSELREG_FLAGS_VALID;
     1562        pCtx->ss.Attr.u         = X86DESC_GET_HID_ATTR(DescSs.Legacy);
     1563        pCtx->ss.u32Limit       = cbLimitSs;
    15501564        if (pIemCpu->enmCpuMode == IEMMODE_64BIT)
    1551             pCtx->ssHid.u64Base = 0;
     1565            pCtx->ss.u64Base    = 0;
    15521566        else
    1553             pCtx->ssHid.u64Base = X86DESC_BASE(DescSs.Legacy);
     1567            pCtx->ss.u64Base    = X86DESC_BASE(DescSs.Legacy);
    15541568
    15551569        pIemCpu->uCpl           = (uNewCs & X86_SEL_RPL);
    1556         iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->ds, &pCtx->dsHid);
    1557         iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->es, &pCtx->esHid);
    1558         iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->fs, &pCtx->fsHid);
    1559         iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->gs, &pCtx->gsHid);
     1570        iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->ds);
     1571        iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->es);
     1572        iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->fs);
     1573        iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->gs);
    15601574
    15611575        /** @todo check if the hidden bits are loaded correctly for 64-bit
     
    16181632            return rcStrict;
    16191633        if (enmEffOpSize == IEMMODE_16BIT)
    1620             pCtx->rip           = uNewRip & UINT16_MAX; /** @todo Testcase: When exactly does this occur? With call it happens prior to the limit check according to Intel... */
     1634            pCtx->rip       = uNewRip & UINT16_MAX; /** @todo Testcase: When exactly does this occur? With call it happens prior to the limit check according to Intel... */
    16211635        else
    1622             pCtx->rip           = uNewRip;
    1623         pCtx->cs                = uNewCs;
    1624         pCtx->csHid.Attr.u      = X86DESC_GET_HID_ATTR(DescCs.Legacy);
    1625         pCtx->csHid.u32Limit    = cbLimitCs;
    1626         pCtx->csHid.u64Base     = u64Base;
     1636            pCtx->rip       = uNewRip;
     1637        pCtx->cs.Sel        = uNewCs;
     1638        pCtx->cs.ValidSel   = uNewCs;
     1639        pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     1640        pCtx->cs.Attr.u     = X86DESC_GET_HID_ATTR(DescCs.Legacy);
     1641        pCtx->cs.u32Limit   = cbLimitCs;
     1642        pCtx->cs.u64Base    = u64Base;
    16271643        /** @todo check if the hidden bits are loaded correctly for 64-bit
    16281644         *        mode.  */
     
    16771693    if (enmEffOpSize != IEMMODE_64BIT)
    16781694    {
    1679         if (NewRip.DWords.dw0 > pCtx->csHid.u32Limit)
    1680         {
    1681             Log(("retn newrip=%llx - out of bounds (%x) -> #GP\n", NewRip.u, pCtx->csHid.u32Limit));
     1695        if (NewRip.DWords.dw0 > pCtx->cs.u32Limit)
     1696        {
     1697            Log(("retn newrip=%llx - out of bounds (%x) -> #GP\n", NewRip.u, pCtx->cs.u32Limit));
    16821698            return iemRaiseSelectorBounds(pIemCpu, X86_SREG_CS, IEM_ACCESS_INSTRUCTION);
    16831699        }
     
    17161732    /* Calculate the intermediate RSP from RBP and the stack attributes. */
    17171733    RTUINT64U       NewRsp;
    1718     if (pCtx->ssHid.Attr.n.u1Long)
     1734    if (pCtx->ss.Attr.n.u1Long)
    17191735    {
    17201736        /** @todo Check that LEAVE actually preserve the high EBP bits. */
     
    17221738        NewRsp.Words.w0 = pCtx->bp;
    17231739    }
    1724     else if (pCtx->ssHid.Attr.n.u1DefBig)
     1740    else if (pCtx->ss.Attr.n.u1DefBig)
    17251741        NewRsp.u = pCtx->ebp;
    17261742    else
     
    18391855    /** @todo Only the AMD pseudo code check the limit here, what's
    18401856     *        right? */
    1841     if (uNewEip > pCtx->csHid.u32Limit)
     1857    if (uNewEip > pCtx->cs.u32Limit)
    18421858        return iemRaiseSelectorBounds(pIemCpu, X86_SREG_CS, IEM_ACCESS_INSTRUCTION);
    18431859
     
    18751891        return rcStrict;
    18761892    pCtx->rip           = uNewEip;
    1877     pCtx->cs            = uNewCs;
    1878     pCtx->csHid.u64Base = (uint32_t)uNewCs << 4;
     1893    pCtx->cs.Sel        = uNewCs;
     1894    pCtx->cs.ValidSel   = uNewCs;
     1895    pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     1896    pCtx->cs.u64Base    = (uint32_t)uNewCs << 4;
    18791897    /** @todo do we load attribs and limit as well? */
    18801898    Assert(uNewFlags & X86_EFL_1);
     
    21132131                }
    21142132
    2115                 pCtx->rip               = uNewEip;
    2116                 pCtx->cs                = uNewCs;
    2117                 pCtx->csHid.Attr.u      = X86DESC_GET_HID_ATTR(DescCS.Legacy);
    2118                 pCtx->csHid.u32Limit    = cbLimitCS;
    2119                 pCtx->csHid.u64Base     = X86DESC_BASE(DescCS.Legacy);
    2120                 pCtx->rsp               = uNewESP;
    2121                 pCtx->ss                = uNewSS;
    2122                 pCtx->ssHid.Attr.u      = X86DESC_GET_HID_ATTR(DescSS.Legacy);
    2123                 pCtx->ssHid.u32Limit    = cbLimitSs;
    2124                 pCtx->ssHid.u64Base     = X86DESC_BASE(DescSS.Legacy);
     2133                pCtx->rip           = uNewEip;
     2134                pCtx->cs.Sel        = uNewCs;
     2135                pCtx->cs.ValidSel   = uNewCs;
     2136                pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     2137                pCtx->cs.Attr.u     = X86DESC_GET_HID_ATTR(DescCS.Legacy);
     2138                pCtx->cs.u32Limit   = cbLimitCS;
     2139                pCtx->cs.u64Base    = X86DESC_BASE(DescCS.Legacy);
     2140                pCtx->rsp           = uNewESP;
     2141                pCtx->ss.Sel        = uNewSS;
     2142                pCtx->ss.ValidSel   = uNewSS;
     2143                pCtx->ss.fFlags     = CPUMSELREG_FLAGS_VALID;
     2144                pCtx->ss.Attr.u     = X86DESC_GET_HID_ATTR(DescSS.Legacy);
     2145                pCtx->ss.u32Limit   = cbLimitSs;
     2146                pCtx->ss.u64Base    = X86DESC_BASE(DescSS.Legacy);
    21252147
    21262148                uint32_t fEFlagsMask = X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF  | X86_EFL_SF
     
    21322154                else if (pIemCpu->uCpl <= pCtx->eflags.Bits.u2IOPL)
    21332155                    fEFlagsMask |= X86_EFL_IF;
    2134                 pCtx->eflags.u         &= ~fEFlagsMask;
    2135                 pCtx->eflags.u         |= fEFlagsMask & uNewFlags;
    2136 
    2137                 pIemCpu->uCpl           = uNewCs & X86_SEL_RPL;
    2138                 iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->ds, &pCtx->dsHid);
    2139                 iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->es, &pCtx->esHid);
    2140                 iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->fs, &pCtx->fsHid);
    2141                 iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->gs, &pCtx->gsHid);
     2156                pCtx->eflags.u     &= ~fEFlagsMask;
     2157                pCtx->eflags.u     |= fEFlagsMask & uNewFlags;
     2158
     2159                pIemCpu->uCpl       = uNewCs & X86_SEL_RPL;
     2160                iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->ds);
     2161                iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->es);
     2162                iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->fs);
     2163                iemHlpAdjustSelectorForNewCpl(uNewCs & X86_SEL_RPL, &pCtx->gs);
    21422164
    21432165                /* Done! */
     
    21672189                }
    21682190
    2169                 pCtx->rip               = uNewEip;
    2170                 pCtx->cs                = uNewCs;
    2171                 pCtx->csHid.Attr.u      = X86DESC_GET_HID_ATTR(DescCS.Legacy);
    2172                 pCtx->csHid.u32Limit    = cbLimitCS;
    2173                 pCtx->csHid.u64Base     = X86DESC_BASE(DescCS.Legacy);
    2174                 pCtx->rsp               = uNewRsp;
     2191                pCtx->rip           = uNewEip;
     2192                pCtx->cs.Sel        = uNewCs;
     2193                pCtx->cs.ValidSel   = uNewCs;
     2194                pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     2195                pCtx->cs.Attr.u     = X86DESC_GET_HID_ATTR(DescCS.Legacy);
     2196                pCtx->cs.u32Limit   = cbLimitCS;
     2197                pCtx->cs.u64Base    = X86DESC_BASE(DescCS.Legacy);
     2198                pCtx->rsp           = uNewRsp;
    21752199
    21762200                uint32_t fEFlagsMask = X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF  | X86_EFL_SF
     
    26672691            CPUMSetGuestLDTR(IEMCPU_TO_VMCPU(pIemCpu), 0);
    26682692        else
    2669             pCtx->ldtr = 0;
    2670         pCtx->ldtrHid.Attr.u   = 0;
    2671         pCtx->ldtrHid.u64Base  = 0;
    2672         pCtx->ldtrHid.u32Limit = 0;
     2693            pCtx->ldtr.Sel = 0;
     2694        pCtx->ldtr.ValidSel = 0;
     2695        pCtx->ldtr.fFlags   = CPUMSELREG_FLAGS_VALID;
     2696        pCtx->ldtr.Attr.u   = 0;
     2697        pCtx->ldtr.u64Base  = 0;
     2698        pCtx->ldtr.u32Limit = 0;
    26732699
    26742700        iemRegAddToRip(pIemCpu, cbInstr);
     
    27282754        CPUMSetGuestLDTR(IEMCPU_TO_VMCPU(pIemCpu), uNewLdt & X86_SEL_MASK);
    27292755    else
    2730         pCtx->ldtr = uNewLdt & X86_SEL_MASK;
    2731     pCtx->ldtrHid.Attr.u   = X86DESC_GET_HID_ATTR(Desc.Legacy);
    2732     pCtx->ldtrHid.u32Limit = X86DESC_LIMIT(Desc.Legacy);
    2733     pCtx->ldtrHid.u64Base  = u64Base;
     2756        pCtx->ldtr.Sel  = uNewLdt & X86_SEL_MASK;
     2757    pCtx->ldtr.ValidSel = uNewLdt & X86_SEL_MASK;
     2758    pCtx->ldtr.fFlags   = CPUMSELREG_FLAGS_VALID;
     2759    pCtx->ldtr.Attr.u   = X86DESC_GET_HID_ATTR(Desc.Legacy);
     2760    pCtx->ldtr.u32Limit = X86DESC_LIMIT(Desc.Legacy);
     2761    pCtx->ldtr.u64Base  = u64Base;
    27342762
    27352763    iemRegAddToRip(pIemCpu, cbInstr);
     
    28472875        CPUMSetGuestTR(IEMCPU_TO_VMCPU(pIemCpu), uNewTr & X86_SEL_MASK);
    28482876    else
    2849         pCtx->tr = uNewTr & X86_SEL_MASK;
    2850     pCtx->trHid.Attr.u   = X86DESC_GET_HID_ATTR(Desc.Legacy);
    2851     pCtx->trHid.u32Limit = X86DESC_LIMIT(Desc.Legacy);
    2852     pCtx->trHid.u64Base  = u64Base;
     2877        pCtx->tr.Sel  = uNewTr & X86_SEL_MASK;
     2878    pCtx->tr.ValidSel = uNewTr & X86_SEL_MASK;
     2879    pCtx->tr.fFlags   = CPUMSELREG_FLAGS_VALID;
     2880    pCtx->tr.Attr.u   = X86DESC_GET_HID_ATTR(Desc.Legacy);
     2881    pCtx->tr.u32Limit = X86DESC_LIMIT(Desc.Legacy);
     2882    pCtx->tr.u64Base  = u64Base;
    28532883
    28542884    iemRegAddToRip(pIemCpu, cbInstr);
     
    29602990                    return iemRaiseGeneralProtectionFault0(pIemCpu);
    29612991                }
    2962                 if (pCtx->csHid.Attr.n.u1Long)
     2992                if (pCtx->cs.Attr.n.u1Long)
    29632993                {
    29642994                    Log(("Trying to enabled long mode paging with a long CS descriptor loaded.\n"));
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplStrInstr.cpp.h

    r39970 r41906  
    7676        return rcStrict;
    7777
    78     rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->esHid, X86_SREG_ES);
     78    rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->es, X86_SREG_ES);
    7979    if (rcStrict != VINF_SUCCESS)
    8080        return rcStrict;
     
    9494         */
    9595#if ADDR_SIZE != 64
    96         ADDR2_TYPE  uVirtSrc1Addr = (uint32_t)pSrc1Hid->u64Base   + uSrc1AddrReg;
    97         ADDR2_TYPE  uVirtSrc2Addr = (uint32_t)pCtx->esHid.u64Base + uSrc2AddrReg;
     96        ADDR2_TYPE  uVirtSrc1Addr = (uint32_t)pSrc1Hid->u64Base + uSrc1AddrReg;
     97        ADDR2_TYPE  uVirtSrc2Addr = (uint32_t)pCtx->es.u64Base + uSrc2AddrReg;
    9898#else
    9999        uint64_t    uVirtSrc1Addr = uSrc1AddrReg;
     
    111111            && uSrc1AddrReg < pSrc1Hid->u32Limit
    112112            && uSrc1AddrReg + (cLeftPage * (OP_SIZE / 8)) <= pSrc1Hid->u32Limit
    113             && uSrc2AddrReg < pCtx->esHid.u32Limit
    114             && uSrc2AddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->esHid.u32Limit
     113            && uSrc2AddrReg < pCtx->es.u32Limit
     114            && uSrc2AddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->es.u32Limit
    115115#endif
    116116           )
     
    233233        return rcStrict;
    234234
    235     rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->esHid, X86_SREG_ES);
     235    rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->es, X86_SREG_ES);
    236236    if (rcStrict != VINF_SUCCESS)
    237237        return rcStrict;
     
    251251         */
    252252#if ADDR_SIZE != 64
    253         ADDR2_TYPE  uVirtSrc1Addr = (uint32_t)pSrc1Hid->u64Base   + uSrc1AddrReg;
    254         ADDR2_TYPE  uVirtSrc2Addr = (uint32_t)pCtx->esHid.u64Base + uSrc2AddrReg;
     253        ADDR2_TYPE  uVirtSrc1Addr = (uint32_t)pSrc1Hid->u64Base + uSrc1AddrReg;
     254        ADDR2_TYPE  uVirtSrc2Addr = (uint32_t)pCtx->es.u64Base + uSrc2AddrReg;
    255255#else
    256256        uint64_t    uVirtSrc1Addr = uSrc1AddrReg;
     
    268268            && uSrc1AddrReg < pSrc1Hid->u32Limit
    269269            && uSrc1AddrReg + (cLeftPage * (OP_SIZE / 8)) <= pSrc1Hid->u32Limit
    270             && uSrc2AddrReg < pCtx->esHid.u32Limit
    271             && uSrc2AddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->esHid.u32Limit
     270            && uSrc2AddrReg < pCtx->es.u32Limit
     271            && uSrc2AddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->es.u32Limit
    272272#endif
    273273           )
     
    385385    }
    386386
    387     VBOXSTRICTRC rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->esHid, X86_SREG_ES);
     387    VBOXSTRICTRC rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->es, X86_SREG_ES);
    388388    if (rcStrict != VINF_SUCCESS)
    389389        return rcStrict;
     
    403403         */
    404404#if ADDR_SIZE != 64
    405         ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->esHid.u64Base + uAddrReg;
     405        ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->es.u64Base + uAddrReg;
    406406#else
    407407        uint64_t    uVirtAddr = uAddrReg;
     
    413413            && cbIncr > 0    /** @todo Implement reverse direction string ops. */
    414414#if ADDR_SIZE != 64
    415             && uAddrReg < pCtx->esHid.u32Limit
    416             && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->esHid.u32Limit
     415            && uAddrReg < pCtx->es.u32Limit
     416            && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->es.u32Limit
    417417#endif
    418418           )
     
    509509    }
    510510
    511     VBOXSTRICTRC rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->esHid, X86_SREG_ES);
     511    VBOXSTRICTRC rcStrict = iemMemSegCheckReadAccessEx(pIemCpu, &pCtx->es, X86_SREG_ES);
    512512    if (rcStrict != VINF_SUCCESS)
    513513        return rcStrict;
     
    527527         */
    528528#if ADDR_SIZE != 64
    529         ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->esHid.u64Base + uAddrReg;
     529        ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->es.u64Base + uAddrReg;
    530530#else
    531531        uint64_t    uVirtAddr = uAddrReg;
     
    537537            && cbIncr > 0    /** @todo Implement reverse direction string ops. */
    538538#if ADDR_SIZE != 64
    539             && uAddrReg < pCtx->esHid.u32Limit
    540             && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->esHid.u32Limit
     539            && uAddrReg < pCtx->es.u32Limit
     540            && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->es.u32Limit
    541541#endif
    542542           )
     
    640640        return rcStrict;
    641641
    642     rcStrict = iemMemSegCheckWriteAccessEx(pIemCpu, &pCtx->esHid, X86_SREG_ES);
     642    rcStrict = iemMemSegCheckWriteAccessEx(pIemCpu, &pCtx->es, X86_SREG_ES);
    643643    if (rcStrict != VINF_SUCCESS)
    644644        return rcStrict;
     
    657657         */
    658658#if ADDR_SIZE != 64
    659         ADDR2_TYPE  uVirtSrcAddr = (uint32_t)pSrcHid->u64Base    + uSrcAddrReg;
    660         ADDR2_TYPE  uVirtDstAddr = (uint32_t)pCtx->esHid.u64Base + uDstAddrReg;
     659        ADDR2_TYPE  uVirtSrcAddr = (uint32_t)pSrcHid->u64Base + uSrcAddrReg;
     660        ADDR2_TYPE  uVirtDstAddr = (uint32_t)pCtx->es.u64Base + uDstAddrReg;
    661661#else
    662662        uint64_t    uVirtSrcAddr = uSrcAddrReg;
     
    674674            && uSrcAddrReg < pSrcHid->u32Limit
    675675            && uSrcAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pSrcHid->u32Limit
    676             && uDstAddrReg < pCtx->esHid.u32Limit
    677             && uDstAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->esHid.u32Limit
     676            && uDstAddrReg < pCtx->es.u32Limit
     677            && uDstAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->es.u32Limit
    678678#endif
    679679           )
     
    764764    }
    765765
    766     VBOXSTRICTRC rcStrict = iemMemSegCheckWriteAccessEx(pIemCpu, &pCtx->esHid, X86_SREG_ES);
     766    VBOXSTRICTRC rcStrict = iemMemSegCheckWriteAccessEx(pIemCpu, &pCtx->es, X86_SREG_ES);
    767767    if (rcStrict != VINF_SUCCESS)
    768768        return rcStrict;
     
    781781         */
    782782#if ADDR_SIZE != 64
    783         ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->esHid.u64Base + uAddrReg;
     783        ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->es.u64Base + uAddrReg;
    784784#else
    785785        uint64_t    uVirtAddr = uAddrReg;
     
    791791            && cbIncr > 0    /** @todo Implement reverse direction string ops. */
    792792#if ADDR_SIZE != 64
    793             && uAddrReg < pCtx->esHid.u32Limit
    794             && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->esHid.u32Limit
     793            && uAddrReg < pCtx->es.u32Limit
     794            && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->es.u32Limit
    795795#endif
    796796           )
     
    10481048    }
    10491049
    1050     rcStrict = iemMemSegCheckWriteAccessEx(pIemCpu, &pCtx->esHid, X86_SREG_ES);
     1050    rcStrict = iemMemSegCheckWriteAccessEx(pIemCpu, &pCtx->es, X86_SREG_ES);
    10511051    if (rcStrict != VINF_SUCCESS)
    10521052        return rcStrict;
     
    10641064         */
    10651065#if ADDR_SIZE != 64
    1066         ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->esHid.u64Base + uAddrReg;
     1066        ADDR2_TYPE  uVirtAddr = (uint32_t)pCtx->es.u64Base + uAddrReg;
    10671067#else
    10681068        uint64_t    uVirtAddr = uAddrReg;
     
    10741074            && cbIncr > 0    /** @todo Implement reverse direction string ops. */
    10751075#if ADDR_SIZE != 64
    1076             && uAddrReg < pCtx->esHid.u32Limit
    1077             && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->esHid.u32Limit
     1076            && uAddrReg < pCtx->es.u32Limit
     1077            && uAddrReg + (cLeftPage * (OP_SIZE / 8)) <= pCtx->es.u32Limit
    10781078#endif
    10791079           )
  • trunk/src/VBox/VMM/VMMAll/PATMAll.cpp

    r41801 r41906  
    385385        if (    pCtx->SysEnter.cs == 0
    386386            ||  pRegFrame->eflags.Bits.u1VM
    387             ||  (pRegFrame->cs & X86_SEL_RPL) != 3
     387            ||  (pRegFrame->cs.Sel & X86_SEL_RPL) != 3
    388388            ||  pVM->patm.s.pfnSysEnterPatchGC == 0
    389389            ||  pVM->patm.s.pfnSysEnterGC != (RTRCPTR)(RTRCUINTPTR)pCtx->SysEnter.eip
     
    394394        /** @todo the base and limit are forced to 0 & 4G-1 resp. We assume the selector is wide open here. */
    395395        /** @note The Intel manual suggests that the OS is responsible for this. */
    396         pRegFrame->cs          = (pCtx->SysEnter.cs & ~X86_SEL_RPL) | 1;
     396        pRegFrame->cs.Sel      = (pCtx->SysEnter.cs & ~X86_SEL_RPL) | 1;
    397397        pRegFrame->eip         = /** @todo ugly conversion! */(uint32_t)pVM->patm.s.pfnSysEnterPatchGC;
    398         pRegFrame->ss          = pRegFrame->cs + 8;     /* SysEnter.cs + 8 */
     398        pRegFrame->ss.Sel      = pRegFrame->cs.Sel + 8;     /* SysEnter.cs + 8 */
    399399        pRegFrame->esp         = pCtx->SysEnter.esp;
    400         pRegFrame->eflags.u32 &= ~(X86_EFL_VM|X86_EFL_RF);
     400        pRegFrame->eflags.u32 &= ~(X86_EFL_VM | X86_EFL_RF);
    401401        pRegFrame->eflags.u32 |= X86_EFL_IF;
    402402
     
    408408        return VINF_SUCCESS;
    409409    }
    410     else
    411410    if (pCpu->pCurInstr->uOpcode == OP_SYSEXIT)
    412411    {
    413412        if (    pCtx->SysEnter.cs == 0
    414             ||  (pRegFrame->cs & X86_SEL_RPL) != 1
     413            ||  (pRegFrame->cs.Sel & X86_SEL_RPL) != 1
    415414            ||  pRegFrame->eflags.Bits.u1VM
    416415            ||  !(PATMRawGetEFlags(pVM, pRegFrame) & X86_EFL_IF))
     
    419418        Log2(("PATMSysCall: sysexit from %RRv to %RRv\n", pRegFrame->eip, pRegFrame->edx));
    420419
    421         pRegFrame->cs          = ((pCtx->SysEnter.cs + 16) & ~X86_SEL_RPL) | 3;
     420        pRegFrame->cs.Sel      = ((pCtx->SysEnter.cs + 16) & ~X86_SEL_RPL) | 3;
    422421        pRegFrame->eip         = pRegFrame->edx;
    423         pRegFrame->ss          = pRegFrame->cs + 8;  /* SysEnter.cs + 24 */
     422        pRegFrame->ss.Sel      = pRegFrame->cs.Sel + 8;  /* SysEnter.cs + 24 */
    424423        pRegFrame->esp         = pRegFrame->ecx;
    425424
     
    428427        return VINF_SUCCESS;
    429428    }
    430     else
    431429    if (pCpu->pCurInstr->uOpcode == OP_SYSCALL)
    432430    {
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r41802 r41906  
    407407    PVM pVM = pVCpu->CTX_SUFF(pVM);
    408408
    409     Log(("PGMTrap0eHandler: uErr=%RGx pvFault=%RGv eip=%04x:%RGv cr3=%RGp\n", uErr, pvFault, pRegFrame->cs, (RTGCPTR)pRegFrame->rip, (RTGCPHYS)CPUMGetGuestCR3(pVCpu)));
     409    Log(("PGMTrap0eHandler: uErr=%RGx pvFault=%RGv eip=%04x:%RGv cr3=%RGp\n", uErr, pvFault, pRegFrame->cs.Sel, (RTGCPTR)pRegFrame->rip, (RTGCPHYS)CPUMGetGuestCR3(pVCpu)));
    410410    STAM_PROFILE_START(&pVCpu->pgm.s.CTX_SUFF(pStats)->StatRZTrap0e, a);
    411411    STAM_STATS({ pVCpu->pgm.s.CTX_SUFF(pStatTrap0eAttribution) = NULL; } );
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r41836 r41906  
    10791079     */
    10801080    LogRel(("%s: returns rc=%Rrc pvFault=%RGv uErr=%RX64 cs:rip=%04x:%08RX64\n",
    1081             __PRETTY_FUNCTION__, rc, pvFault, (uint64_t)uErr, pRegFrame->cs, pRegFrame->rip));
     1081            __PRETTY_FUNCTION__, rc, pvFault, (uint64_t)uErr, pRegFrame->cs.Sel, pRegFrame->rip));
    10821082    return rc;
    10831083
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r41803 r41906  
    853853        {
    854854            LogFlow(("pgmPoolAccessHandlerPTWorker: Interpretation failed for patch code %04x:%RGv, ignoring.\n",
    855                      pRegFrame->cs, (RTGCPTR)pRegFrame->eip));
     855                     pRegFrame->cs.Sel, (RTGCPTR)pRegFrame->eip));
    856856            rc = VINF_SUCCESS;
    857857            STAM_COUNTER_INC(&pPool->StatMonitorRZIntrFailPatch2);
     
    990990    {
    991991        LogFlow(("pgmPoolAccessHandlerPTWorker: Interpretation failed for %04x:%RGv - opcode=%d\n",
    992                   pRegFrame->cs, (RTGCPTR)pRegFrame->rip, pDis->pCurInstr->uOpcode));
     992                  pRegFrame->cs.Sel, (RTGCPTR)pRegFrame->rip, pDis->pCurInstr->uOpcode));
    993993        rc = VINF_EM_RAW_EMULATE_INSTR;
    994994        STAM_COUNTER_INC(&pPool->CTX_MID_Z(StatMonitor,EmulateInstr));
  • trunk/src/VBox/VMM/VMMAll/SELMAll.cpp

    r41803 r41906  
    114114
    115115    /* 64 bits mode: CS, DS, ES and SS are treated as if each segment base is 0 (Intel® 64 and IA-32 Architectures Software Developer's Manual: 3.4.2.1). */
    116     if (    pCtxCore->csHid.Attr.n.u1Long
     116    if (    pCtxCore->cs.Attr.n.u1Long
    117117        &&  CPUMIsGuestInLongMode(pVCpu))
    118118    {
     
    196196
    197197        /* 64 bits mode: CS, DS, ES and SS are treated as if each segment base is 0 (Intel® 64 and IA-32 Architectures Software Developer's Manual: 3.4.2.1). */
    198         if (    pCtxCore->csHid.Attr.n.u1Long
     198        if (    pCtxCore->cs.Attr.n.u1Long
    199199            &&  CPUMIsGuestInLongMode(pVCpu))
    200200        {
  • trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp

    r41802 r41906  
    370370# if defined(VBOX_STRICT) || defined(LOG_ENABLED)
    371371    if (pRegFrame->eflags.Bits.u1VM)
    372         Log(("TRPMForwardTrap-VM: eip=%04X:%04X iGate=%d\n", pRegFrame->cs, pRegFrame->eip, iGate));
     372        Log(("TRPMForwardTrap-VM: eip=%04X:%04X iGate=%d\n", pRegFrame->cs.Sel, pRegFrame->eip, iGate));
    373373    else
    374         Log(("TRPMForwardTrap: eip=%04X:%08X iGate=%d\n", pRegFrame->cs, pRegFrame->eip, iGate));
     374        Log(("TRPMForwardTrap: eip=%04X:%08X iGate=%d\n", pRegFrame->cs.Sel, pRegFrame->eip, iGate));
    375375
    376376    switch (iGate) {
     
    564564                if (fConforming || dpl == cpl)  /* to the same privilege level */
    565565                {
    566                     ss_r0  = pRegFrame->ss;
     566                    ss_r0  = pRegFrame->ss.Sel;
    567567                    esp_r0 = pRegFrame->esp;
    568568
     
    584584                uint32_t *pTrapStack;
    585585#ifdef IN_RC
    586                 Assert(eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 0);
     586                Assert(eflags.Bits.u1VM || (pRegFrame->ss.Sel & X86_SEL_RPL) != 0);
    587587                /* Check maximum amount we need (10 when executing in V86 mode) */
    588588                rc = PGMVerifyAccess(pVCpu, (RTGCUINTPTR)pTrapStackGC - 10*sizeof(uint32_t), 10 * sizeof(uint32_t), X86_PTE_RW);
    589589                pTrapStack = (uint32_t *)(uintptr_t)pTrapStackGC;
    590590#else
    591                 Assert(eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) == 0 || (pRegFrame->ss & X86_SEL_RPL) == 3);
     591                Assert(eflags.Bits.u1VM || (pRegFrame->ss.Sel & X86_SEL_RPL) == 0 || (pRegFrame->ss.Sel & X86_SEL_RPL) == 3);
    592592                /* Check maximum amount we need (10 when executing in V86 mode) */
    593593                if ((pTrapStackGC >> PAGE_SHIFT) != ((pTrapStackGC - 10*sizeof(uint32_t)) >> PAGE_SHIFT)) /* fail if we cross a page boundary */
     
    606606                    if (eflags.Bits.u1VM)
    607607                    {
    608                         Log(("TRAP%02X: (VM) Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss & X86_SEL_RPL), pVCpu->trpm.s.uActiveCR2));
    609                         pTrapStack[--idx] = pRegFrame->gs;
    610                         pTrapStack[--idx] = pRegFrame->fs;
    611                         pTrapStack[--idx] = pRegFrame->ds;
    612                         pTrapStack[--idx] = pRegFrame->es;
     608                        Log(("TRAP%02X: (VM) Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss.Sel & X86_SEL_RPL), pVCpu->trpm.s.uActiveCR2));
     609                        pTrapStack[--idx] = pRegFrame->gs.Sel;
     610                        pTrapStack[--idx] = pRegFrame->fs.Sel;
     611                        pTrapStack[--idx] = pRegFrame->ds.Sel;
     612                        pTrapStack[--idx] = pRegFrame->es.Sel;
    613613
    614614                        /* clear ds, es, fs & gs in current context */
    615                         pRegFrame->ds = pRegFrame->es = pRegFrame->fs = pRegFrame->gs = 0;
     615                        pRegFrame->ds.Sel = pRegFrame->es.Sel = pRegFrame->fs.Sel = pRegFrame->gs.Sel = 0;
    616616                    }
    617617                    else
    618                         Log(("TRAP%02X: Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss & X86_SEL_RPL), pVCpu->trpm.s.uActiveCR2));
     618                        Log(("TRAP%02X: Handler %04X:%RGv Stack %04X:%08X RPL=%d CR2=%08X\n", iGate, GuestIdte.Gen.u16SegSel, pHandler, ss_r0, esp_r0, (pRegFrame->ss.Sel & X86_SEL_RPL), pVCpu->trpm.s.uActiveCR2));
    619619
    620620                    if (!fConforming && dpl < cpl)
    621621                    {
    622                         if ((pRegFrame->ss & X86_SEL_RPL) == 1 && !eflags.Bits.u1VM)
    623                             pTrapStack[--idx] = pRegFrame->ss & ~1;    /* Mask away traces of raw ring execution (ring 1). */
     622                        if ((pRegFrame->ss.Sel & X86_SEL_RPL) == 1 && !eflags.Bits.u1VM)
     623                            pTrapStack[--idx] = pRegFrame->ss.Sel & ~1;    /* Mask away traces of raw ring execution (ring 1). */
    624624                        else
    625                             pTrapStack[--idx] = pRegFrame->ss;
     625                            pTrapStack[--idx] = pRegFrame->ss.Sel;
    626626
    627627                        pTrapStack[--idx] = pRegFrame->esp;
     
    632632                    pTrapStack[--idx] = eflags.u32;
    633633
    634                     if ((pRegFrame->cs & X86_SEL_RPL) == 1 && !eflags.Bits.u1VM)
    635                         pTrapStack[--idx] = pRegFrame->cs & ~1;    /* Mask away traces of raw ring execution (ring 1). */
     634                    if ((pRegFrame->cs.Sel & X86_SEL_RPL) == 1 && !eflags.Bits.u1VM)
     635                        pTrapStack[--idx] = pRegFrame->cs.Sel & ~1;    /* Mask away traces of raw ring execution (ring 1). */
    636636                    else
    637                         pTrapStack[--idx] = pRegFrame->cs;
     637                        pTrapStack[--idx] = pRegFrame->cs.Sel;
    638638
    639639                    if (enmType == TRPM_SOFTWARE_INT)
     
    665665                          pRegFrame->eax, pRegFrame->ebx, pRegFrame->ecx, pRegFrame->edx, pRegFrame->esi, pRegFrame->edi,
    666666                          pRegFrame->eip, pRegFrame->esp, pRegFrame->ebp, eflags.Bits.u2IOPL,
    667                           (RTSEL)pRegFrame->cs, (RTSEL)pRegFrame->ds, (RTSEL)pRegFrame->es,
    668                           (RTSEL)pRegFrame->fs, (RTSEL)pRegFrame->gs, eflags.u32));
     667                          pRegFrame->cs.Sel, pRegFrame->ds.Sel, pRegFrame->es.Sel,
     668                          pRegFrame->fs.Sel, pRegFrame->gs.Sel, eflags.u32));
    669669#endif
    670670
     
    705705
    706706                    pRegFrame->eip        = pVM->trpm.s.aGuestTrapHandler[iGate];
    707                     pRegFrame->cs         = GuestIdte.Gen.u16SegSel;
     707                    pRegFrame->cs.Sel     = GuestIdte.Gen.u16SegSel;
    708708                    pRegFrame->esp        = esp_r0;
    709                     pRegFrame->ss         = ss_r0 & ~X86_SEL_RPL;     /* set rpl to ring 0 */
     709                    pRegFrame->ss.Sel     = ss_r0 & ~X86_SEL_RPL;     /* set rpl to ring 0 */
    710710                    STAM_PROFILE_ADV_STOP(&pVM->trpm.s.CTX_SUFF_Z(StatForwardProf), a);
    711711                    PGMPhysReleasePageMappingLock(pVM, &PageMappingLock);
     
    737737    STAM_PROFILE_ADV_STOP(&pVM->trpm.s.CTX_SUFF_Z(StatForwardProf), a);
    738738
    739     Log(("TRAP%02X: forwarding to REM (ss rpl=%d eflags=%08X VMIF=%d handler=%08X\n", iGate, pRegFrame->ss & X86_SEL_RPL, pRegFrame->eflags.u32, PATMAreInterruptsEnabledByCtxCore(pVM, pRegFrame), pVM->trpm.s.aGuestTrapHandler[iGate]));
     739    Log(("TRAP%02X: forwarding to REM (ss rpl=%d eflags=%08X VMIF=%d handler=%08X\n", iGate, pRegFrame->ss.Sel & X86_SEL_RPL, pRegFrame->eflags.u32, PATMAreInterruptsEnabledByCtxCore(pVM, pRegFrame), pVM->trpm.s.aGuestTrapHandler[iGate]));
    740740#endif
    741741    return VINF_EM_RAW_GUEST_TRAP;
     
    760760VMMDECL(int) TRPMRaiseXcpt(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt)
    761761{
    762     LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x\n", pCtxCore->cs, pCtxCore->eip, enmXcpt));
     762    LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x\n", pCtxCore->cs.Sel, pCtxCore->eip, enmXcpt));
    763763/** @todo dispatch the trap. */
    764764    pVCpu->trpm.s.uActiveVector            = enmXcpt;
     
    787787VMMDECL(int) TRPMRaiseXcptErr(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr)
    788788{
    789     LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x uErr=%RX32\n", pCtxCore->cs, pCtxCore->eip, enmXcpt, uErr));
     789    LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x uErr=%RX32\n", pCtxCore->cs.Sel, pCtxCore->eip, enmXcpt, uErr));
    790790/** @todo dispatch the trap. */
    791791    pVCpu->trpm.s.uActiveVector            = enmXcpt;
     
    815815VMMDECL(int) TRPMRaiseXcptErrCR2(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr, RTGCUINTPTR uCR2)
    816816{
    817     LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x uErr=%RX32 uCR2=%RGv\n", pCtxCore->cs, pCtxCore->eip, enmXcpt, uErr, uCR2));
     817    LogFlow(("TRPMRaiseXcptErr: cs:eip=%RTsel:%RX32 enmXcpt=%#x uErr=%RX32 uCR2=%RGv\n", pCtxCore->cs.Sel, pCtxCore->eip, enmXcpt, uErr, uCR2));
    818818/** @todo dispatch the trap. */
    819819    pVCpu->trpm.s.uActiveVector            = enmXcpt;
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r41836 r41906  
    19311931    {
    19321932        Log(("rax=%016RX64 rbx=%016RX64 rcx=%016RX64 rdx=%016RX64\n"
    1933             "rsi=%016RX64 rdi=%016RX64 r8 =%016RX64 r9 =%016RX64\n"
    1934             "r10=%016RX64 r11=%016RX64 r12=%016RX64 r13=%016RX64\n"
    1935             "r14=%016RX64 r15=%016RX64\n"
    1936             "rip=%016RX64 rsp=%016RX64 rbp=%016RX64 iopl=%d %*s\n"
    1937             "cs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
    1938             "ds={%04x base=%016RX64 limit=%08x flags=%08x}\n"
    1939             "es={%04x base=%016RX64 limit=%08x flags=%08x}\n"
    1940             "fs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
    1941             "gs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
    1942             "ss={%04x base=%016RX64 limit=%08x flags=%08x}\n"
    1943             "cr0=%016RX64 cr2=%016RX64 cr3=%016RX64 cr4=%016RX64\n"
    1944             "dr0=%016RX64 dr1=%016RX64 dr2=%016RX64 dr3=%016RX64\n"
    1945             "dr4=%016RX64 dr5=%016RX64 dr6=%016RX64 dr7=%016RX64\n"
    1946             "gdtr=%016RX64:%04x  idtr=%016RX64:%04x  eflags=%08x\n"
    1947             "ldtr={%04x base=%08RX64 limit=%08x flags=%08x}\n"
    1948             "tr  ={%04x base=%08RX64 limit=%08x flags=%08x}\n"
    1949             "SysEnter={cs=%04llx eip=%08llx esp=%08llx}\n"
    1950             ,
    1951             pCtx->rax, pCtx->rbx, pCtx->rcx, pCtx->rdx, pCtx->rsi, pCtx->rdi,
    1952             pCtx->r8, pCtx->r9, pCtx->r10, pCtx->r11, pCtx->r12, pCtx->r13,
    1953             pCtx->r14, pCtx->r15,
    1954             pCtx->rip, pCtx->rsp, pCtx->rbp, X86_EFL_GET_IOPL(efl), 31, szEFlags,
    1955             (RTSEL)pCtx->cs, pCtx->csHid.u64Base, pCtx->csHid.u32Limit, pCtx->csHid.Attr.u,
    1956             (RTSEL)pCtx->ds, pCtx->dsHid.u64Base, pCtx->dsHid.u32Limit, pCtx->dsHid.Attr.u,
    1957             (RTSEL)pCtx->es, pCtx->esHid.u64Base, pCtx->esHid.u32Limit, pCtx->esHid.Attr.u,
    1958             (RTSEL)pCtx->fs, pCtx->fsHid.u64Base, pCtx->fsHid.u32Limit, pCtx->fsHid.Attr.u,
    1959             (RTSEL)pCtx->gs, pCtx->gsHid.u64Base, pCtx->gsHid.u32Limit, pCtx->gsHid.Attr.u,
    1960             (RTSEL)pCtx->ss, pCtx->ssHid.u64Base, pCtx->ssHid.u32Limit, pCtx->ssHid.Attr.u,
    1961             pCtx->cr0,  pCtx->cr2, pCtx->cr3,  pCtx->cr4,
    1962             pCtx->dr[0],  pCtx->dr[1], pCtx->dr[2],  pCtx->dr[3],
    1963             pCtx->dr[4],  pCtx->dr[5], pCtx->dr[6],  pCtx->dr[7],
    1964             pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, efl,
    1965             (RTSEL)pCtx->ldtr, pCtx->ldtrHid.u64Base, pCtx->ldtrHid.u32Limit, pCtx->ldtrHid.Attr.u,
    1966             (RTSEL)pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u,
    1967             pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp));
     1933             "rsi=%016RX64 rdi=%016RX64 r8 =%016RX64 r9 =%016RX64\n"
     1934             "r10=%016RX64 r11=%016RX64 r12=%016RX64 r13=%016RX64\n"
     1935             "r14=%016RX64 r15=%016RX64\n"
     1936             "rip=%016RX64 rsp=%016RX64 rbp=%016RX64 iopl=%d %*s\n"
     1937             "cs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
     1938             "ds={%04x base=%016RX64 limit=%08x flags=%08x}\n"
     1939             "es={%04x base=%016RX64 limit=%08x flags=%08x}\n"
     1940             "fs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
     1941             "gs={%04x base=%016RX64 limit=%08x flags=%08x}\n"
     1942             "ss={%04x base=%016RX64 limit=%08x flags=%08x}\n"
     1943             "cr0=%016RX64 cr2=%016RX64 cr3=%016RX64 cr4=%016RX64\n"
     1944             "dr0=%016RX64 dr1=%016RX64 dr2=%016RX64 dr3=%016RX64\n"
     1945             "dr4=%016RX64 dr5=%016RX64 dr6=%016RX64 dr7=%016RX64\n"
     1946             "gdtr=%016RX64:%04x  idtr=%016RX64:%04x  eflags=%08x\n"
     1947             "ldtr={%04x base=%08RX64 limit=%08x flags=%08x}\n"
     1948             "tr  ={%04x base=%08RX64 limit=%08x flags=%08x}\n"
     1949             "SysEnter={cs=%04llx eip=%08llx esp=%08llx}\n"
     1950             ,
     1951             pCtx->rax, pCtx->rbx, pCtx->rcx, pCtx->rdx, pCtx->rsi, pCtx->rdi,
     1952             pCtx->r8, pCtx->r9, pCtx->r10, pCtx->r11, pCtx->r12, pCtx->r13,
     1953             pCtx->r14, pCtx->r15,
     1954             pCtx->rip, pCtx->rsp, pCtx->rbp, X86_EFL_GET_IOPL(efl), 31, szEFlags,
     1955             pCtx->cs.Sel, pCtx->cs.u64Base, pCtx->cs.u32Limit, pCtx->cs.Attr.u,
     1956             pCtx->ds.Sel, pCtx->ds.u64Base, pCtx->ds.u32Limit, pCtx->ds.Attr.u,
     1957             pCtx->es.Sel, pCtx->es.u64Base, pCtx->es.u32Limit, pCtx->es.Attr.u,
     1958             pCtx->fs.Sel, pCtx->fs.u64Base, pCtx->fs.u32Limit, pCtx->fs.Attr.u,
     1959             pCtx->gs.Sel, pCtx->gs.u64Base, pCtx->gs.u32Limit, pCtx->gs.Attr.u,
     1960             pCtx->ss.Sel, pCtx->ss.u64Base, pCtx->ss.u32Limit, pCtx->ss.Attr.u,
     1961             pCtx->cr0,  pCtx->cr2, pCtx->cr3,  pCtx->cr4,
     1962             pCtx->dr[0],  pCtx->dr[1], pCtx->dr[2],  pCtx->dr[3],
     1963             pCtx->dr[4],  pCtx->dr[5], pCtx->dr[6],  pCtx->dr[7],
     1964             pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, efl,
     1965             pCtx->ldtr.Sel, pCtx->ldtr.u64Base, pCtx->ldtr.u32Limit, pCtx->ldtr.Attr.u,
     1966             pCtx->tr.Sel, pCtx->tr.u64Base, pCtx->tr.u32Limit, pCtx->tr.Attr.u,
     1967             pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp));
    19681968    }
    19691969    else
    19701970        Log(("eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n"
    1971             "eip=%08x esp=%08x ebp=%08x iopl=%d %*s\n"
    1972             "cs={%04x base=%016RX64 limit=%08x flags=%08x} dr0=%08RX64 dr1=%08RX64\n"
    1973             "ds={%04x base=%016RX64 limit=%08x flags=%08x} dr2=%08RX64 dr3=%08RX64\n"
    1974             "es={%04x base=%016RX64 limit=%08x flags=%08x} dr4=%08RX64 dr5=%08RX64\n"
    1975             "fs={%04x base=%016RX64 limit=%08x flags=%08x} dr6=%08RX64 dr7=%08RX64\n"
    1976             "gs={%04x base=%016RX64 limit=%08x flags=%08x} cr0=%08RX64 cr2=%08RX64\n"
    1977             "ss={%04x base=%016RX64 limit=%08x flags=%08x} cr3=%08RX64 cr4=%08RX64\n"
    1978             "gdtr=%016RX64:%04x  idtr=%016RX64:%04x  eflags=%08x\n"
    1979             "ldtr={%04x base=%08RX64 limit=%08x flags=%08x}\n"
    1980             "tr  ={%04x base=%08RX64 limit=%08x flags=%08x}\n"
    1981             "SysEnter={cs=%04llx eip=%08llx esp=%08llx}\n"
    1982             ,
    1983             pCtx->eax, pCtx->ebx, pCtx->ecx, pCtx->edx, pCtx->esi, pCtx->edi,
    1984             pCtx->eip, pCtx->esp, pCtx->ebp, X86_EFL_GET_IOPL(efl), 31, szEFlags,
    1985             (RTSEL)pCtx->cs, pCtx->csHid.u64Base, pCtx->csHid.u32Limit, pCtx->csHid.Attr.u, pCtx->dr[0],  pCtx->dr[1],
    1986             (RTSEL)pCtx->ds, pCtx->dsHid.u64Base, pCtx->dsHid.u32Limit, pCtx->dsHid.Attr.u, pCtx->dr[2],  pCtx->dr[3],
    1987             (RTSEL)pCtx->es, pCtx->esHid.u64Base, pCtx->esHid.u32Limit, pCtx->esHid.Attr.u, pCtx->dr[4],  pCtx->dr[5],
    1988             (RTSEL)pCtx->fs, pCtx->fsHid.u64Base, pCtx->fsHid.u32Limit, pCtx->fsHid.Attr.u, pCtx->dr[6],  pCtx->dr[7],
    1989             (RTSEL)pCtx->gs, pCtx->gsHid.u64Base, pCtx->gsHid.u32Limit, pCtx->gsHid.Attr.u, pCtx->cr0,  pCtx->cr2,
    1990             (RTSEL)pCtx->ss, pCtx->ssHid.u64Base, pCtx->ssHid.u32Limit, pCtx->ssHid.Attr.u, pCtx->cr3,  pCtx->cr4,
    1991             pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, efl,
    1992             (RTSEL)pCtx->ldtr, pCtx->ldtrHid.u64Base, pCtx->ldtrHid.u32Limit, pCtx->ldtrHid.Attr.u,
    1993             (RTSEL)pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u,
    1994             pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp));
     1971             "eip=%08x esp=%08x ebp=%08x iopl=%d %*s\n"
     1972             "cs={%04x base=%016RX64 limit=%08x flags=%08x} dr0=%08RX64 dr1=%08RX64\n"
     1973             "ds={%04x base=%016RX64 limit=%08x flags=%08x} dr2=%08RX64 dr3=%08RX64\n"
     1974             "es={%04x base=%016RX64 limit=%08x flags=%08x} dr4=%08RX64 dr5=%08RX64\n"
     1975             "fs={%04x base=%016RX64 limit=%08x flags=%08x} dr6=%08RX64 dr7=%08RX64\n"
     1976             "gs={%04x base=%016RX64 limit=%08x flags=%08x} cr0=%08RX64 cr2=%08RX64\n"
     1977             "ss={%04x base=%016RX64 limit=%08x flags=%08x} cr3=%08RX64 cr4=%08RX64\n"
     1978             "gdtr=%016RX64:%04x  idtr=%016RX64:%04x  eflags=%08x\n"
     1979             "ldtr={%04x base=%08RX64 limit=%08x flags=%08x}\n"
     1980             "tr  ={%04x base=%08RX64 limit=%08x flags=%08x}\n"
     1981             "SysEnter={cs=%04llx eip=%08llx esp=%08llx}\n"
     1982             ,
     1983             pCtx->eax, pCtx->ebx, pCtx->ecx, pCtx->edx, pCtx->esi, pCtx->edi,
     1984             pCtx->eip, pCtx->esp, pCtx->ebp, X86_EFL_GET_IOPL(efl), 31, szEFlags,
     1985             pCtx->cs.Sel, pCtx->cs.u64Base, pCtx->cs.u32Limit, pCtx->cs.Attr.u, pCtx->dr[0],  pCtx->dr[1],
     1986             pCtx->ds.Sel, pCtx->ds.u64Base, pCtx->ds.u32Limit, pCtx->ds.Attr.u, pCtx->dr[2],  pCtx->dr[3],
     1987             pCtx->es.Sel, pCtx->es.u64Base, pCtx->es.u32Limit, pCtx->es.Attr.u, pCtx->dr[4],  pCtx->dr[5],
     1988             pCtx->fs.Sel, pCtx->fs.u64Base, pCtx->fs.u32Limit, pCtx->fs.Attr.u, pCtx->dr[6],  pCtx->dr[7],
     1989             pCtx->gs.Sel, pCtx->gs.u64Base, pCtx->gs.u32Limit, pCtx->gs.Attr.u, pCtx->cr0,  pCtx->cr2,
     1990             pCtx->ss.Sel, pCtx->ss.u64Base, pCtx->ss.u32Limit, pCtx->ss.Attr.u, pCtx->cr3,  pCtx->cr4,
     1991             pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, efl,
     1992             pCtx->ldtr.Sel, pCtx->ldtr.u64Base, pCtx->ldtr.u32Limit, pCtx->ldtr.Attr.u,
     1993             pCtx->tr.Sel, pCtx->tr.u64Base, pCtx->tr.u32Limit, pCtx->tr.Attr.u,
     1994             pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp));
    19951995
    19961996    Log(("FPU:\n"
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r41823 r41906  
    923923
    924924    /* Set CPL */
    925     pVMCB->guest.u8CPL     = pCtx->ssHid.Attr.n.u2Dpl;
     925    pVMCB->guest.u8CPL     = pCtx->ss.Attr.n.u2Dpl;
    926926
    927927    /* RAX/EAX too, as VMRUN uses RAX as an implicit parameter. */
     
    946946#endif
    947947        /* Unconditionally update these as wrmsr might have changed them. (HWACCM_CHANGED_GUEST_SEGMENT_REGS will not be set) */
    948         pVMCB->guest.FS.u64Base    = pCtx->fsHid.u64Base;
    949         pVMCB->guest.GS.u64Base    = pCtx->gsHid.u64Base;
     948        pVMCB->guest.FS.u64Base    = pCtx->fs.u64Base;
     949        pVMCB->guest.GS.u64Base    = pCtx->gs.u64Base;
    950950    }
    951951    else
     
    16441644     * register (yet).
    16451645     */
    1646     if (   !pCtx->csHid.Attr.n.u1Granularity
    1647         &&  pCtx->csHid.Attr.n.u1Present
    1648         &&  pCtx->csHid.u32Limit > UINT32_C(0xfffff))
    1649     {
    1650         Assert((pCtx->csHid.u32Limit & 0xfff) == 0xfff);
    1651         pCtx->csHid.Attr.n.u1Granularity = 1;
     1646    if (   !pCtx->cs.Attr.n.u1Granularity
     1647        &&  pCtx->cs.Attr.n.u1Present
     1648        &&  pCtx->cs.u32Limit > UINT32_C(0xfffff))
     1649    {
     1650        Assert((pCtx->cs.u32Limit & 0xfff) == 0xfff);
     1651        pCtx->cs.Attr.n.u1Granularity = 1;
    16521652    }
    16531653#define SVM_ASSERT_SEL_GRANULARITY(reg) \
    1654         AssertMsg(   !pCtx->reg##Hid.Attr.n.u1Present \
    1655                   || (   pCtx->reg##Hid.Attr.n.u1Granularity \
    1656                       ? (pCtx->reg##Hid.u32Limit & 0xfff) == 0xfff \
    1657                       :  pCtx->reg##Hid.u32Limit <= 0xfffff), \
    1658                   ("%#x %#x %#llx\n", pCtx->reg##Hid.u32Limit, pCtx->reg##Hid.Attr.u, pCtx->reg##Hid.u64Base))
     1654        AssertMsg(   !pCtx->reg.Attr.n.u1Present \
     1655                  || (   pCtx->reg.Attr.n.u1Granularity \
     1656                      ? (pCtx->reg.u32Limit & 0xfff) == 0xfff \
     1657                      :  pCtx->reg.u32Limit <= 0xfffff), \
     1658                  ("%#x %#x %#llx\n", pCtx->reg.u32Limit, pCtx->reg.Attr.u, pCtx->reg.u64Base))
    16591659    SVM_ASSERT_SEL_GRANULARITY(ss);
    16601660    SVM_ASSERT_SEL_GRANULARITY(cs);
     
    16721672     */
    16731673    Assert(!(pVMCB->guest.u8CPL & ~0x3));
    1674     pCtx->ssHid.Attr.n.u2Dpl = pVMCB->guest.u8CPL & 0x3;
     1674    pCtx->ss.Attr.n.u2Dpl = pVMCB->guest.u8CPL & 0x3;
    16751675
    16761676    /*
     
    17751775#ifdef DBGFTRACE_ENABLED /** @todo DTrace */
    17761776    RTTraceBufAddMsgF(pVM->CTX_SUFF(hTraceBuf), "vmexit %08x at %04:%08RX64 %RX64 %RX64 %RX64",
    1777                       exitCode, pCtx->cs, pCtx->rip,
     1777                      exitCode, pCtx->cs.Sel, pCtx->rip,
    17781778                      pVMCB->ctrl.u64ExitInfo1, pVMCB->ctrl.u64ExitInfo2, pVMCB->ctrl.ExitIntInfo.au64[0]);
    17791779#endif
     
    18251825            }
    18261826            /* Return to ring 3 to deal with the debug exit code. */
    1827             Log(("Debugger hardware BP at %04x:%RGv (rc=%Rrc)\n", pCtx->cs, pCtx->rip, VBOXSTRICTRC_VAL(rc)));
     1827            Log(("Debugger hardware BP at %04x:%RGv (rc=%Rrc)\n", pCtx->cs.Sel, pCtx->rip, VBOXSTRICTRC_VAL(rc)));
    18281828            break;
    18291829        }
     
    20312031                    break;
    20322032            }
    2033             Log(("Trap %x at %04x:%RGv esi=%x\n", vector, pCtx->cs, (RTGCPTR)pCtx->rip, pCtx->esi));
     2033            Log(("Trap %x at %04x:%RGv esi=%x\n", vector, pCtx->cs.Sel, (RTGCPTR)pCtx->rip, pCtx->esi));
    20342034            hmR0SvmInjectEvent(pVCpu, pVMCB, pCtx, &Event);
    20352035            goto ResumeExecution;
     
    29712971     * Only allow 32 & 64 bit code.
    29722972     */
    2973     DISCPUMODE enmMode = SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->cs, &pRegFrame->csHid);
     2973    DISCPUMODE enmMode = SELMGetCpuModeFromSelector(pVCpu, pRegFrame->eflags, pRegFrame->cs.Sel, &pRegFrame->cs);
    29742974    if (enmMode != DISCPUMODE_16BIT)
    29752975    {
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.h

    r41335 r41906  
    200200#define SVM_HIDSEGATTR_SVM2VMX(a)     (a & 0xFF) | ((a & 0x0F00) << 4)
    201201
    202 #define SVM_WRITE_SELREG(REG, reg)                                                 \
    203 {                                                                                  \
    204         pVMCB->guest.REG.u16Sel   = pCtx->reg;                                     \
    205         pVMCB->guest.REG.u32Limit = pCtx->reg##Hid.u32Limit;                       \
    206         pVMCB->guest.REG.u64Base  = pCtx->reg##Hid.u64Base;                        \
    207         pVMCB->guest.REG.u16Attr  = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg##Hid.Attr.u); \
    208 }
    209 
    210 #define SVM_READ_SELREG(REG, reg)                                                    \
    211 {                                                                                    \
    212         pCtx->reg                = pVMCB->guest.REG.u16Sel;                          \
    213         pCtx->reg##Hid.u32Limit  = pVMCB->guest.REG.u32Limit;                        \
    214         pCtx->reg##Hid.u64Base   = pVMCB->guest.REG.u64Base;                         \
    215         pCtx->reg##Hid.Attr.u    = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr); \
    216 }
     202#define SVM_WRITE_SELREG(REG, reg) \
     203    do \
     204    { \
     205        Assert(pCtx->reg.fFlags & CPUMSELREG_FLAGS_VALID); \
     206        Assert(pCtx->reg.ValidSel == pCtx->reg.Sel); \
     207        pVMCB->guest.REG.u16Sel     = pCtx->reg.Sel; \
     208        pVMCB->guest.REG.u32Limit   = pCtx->reg.u32Limit; \
     209        pVMCB->guest.REG.u64Base    = pCtx->reg.u64Base; \
     210        pVMCB->guest.REG.u16Attr    = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg.Attr.u); \
     211    } while (0)
     212
     213#define SVM_READ_SELREG(REG, reg) \
     214    do \
     215    { \
     216        pCtx->reg.Sel       = pVMCB->guest.REG.u16Sel; \
     217        pCtx->reg.ValidSel  = pVMCB->guest.REG.u16Sel; \
     218        pCtx->reg.fFlags    = CPUMSELREG_FLAGS_VALID; \
     219        pCtx->reg.u32Limit  = pVMCB->guest.REG.u32Limit; \
     220        pCtx->reg.u64Base   = pVMCB->guest.REG.u64Base; \
     221        pCtx->reg.Attr.u    = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr); \
     222    } while (0)
    217223
    218224#endif /* IN_RING0 */
     
    222228RT_C_DECLS_END
    223229
    224 #endif /* ___VMMR0_HWSVMR0_h */
    225 
     230#endif /* !___VMMR0_HWSVMR0_h */
     231
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r41834 r41906  
    904904        /** @todo Check stack limit. */
    905905        pCtx->sp -= 2;
    906         LogFlow(("ss:sp %04X:%04X eflags=%x\n", pCtx->ss, pCtx->sp, pCtx->eflags.u));
    907         rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ssHid.u64Base + pCtx->sp, &pCtx->eflags, sizeof(uint16_t)); AssertRC(rc);
     906        LogFlow(("ss:sp %04X:%04X eflags=%x\n", pCtx->ss.Sel, pCtx->sp, pCtx->eflags.u));
     907        rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ss.u64Base + pCtx->sp, &pCtx->eflags, sizeof(uint16_t)); AssertRC(rc);
    908908        pCtx->sp -= 2;
    909         LogFlow(("ss:sp %04X:%04X cs=%x\n", pCtx->ss, pCtx->sp, pCtx->cs));
    910         rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ssHid.u64Base + pCtx->sp, &pCtx->cs, sizeof(uint16_t)); AssertRC(rc);
     909        LogFlow(("ss:sp %04X:%04X cs=%x\n", pCtx->ss.Sel, pCtx->sp, pCtx->cs.Sel));
     910        rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ss.u64Base + pCtx->sp, &pCtx->cs, sizeof(uint16_t)); AssertRC(rc);
    911911        pCtx->sp -= 2;
    912         LogFlow(("ss:sp %04X:%04X ip=%x\n", pCtx->ss, pCtx->sp, ip));
    913         rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ssHid.u64Base + pCtx->sp, &ip, sizeof(ip)); AssertRC(rc);
     912        LogFlow(("ss:sp %04X:%04X ip=%x\n", pCtx->ss.Sel, pCtx->sp, ip));
     913        rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ss.u64Base + pCtx->sp, &ip, sizeof(ip)); AssertRC(rc);
    914914
    915915        /*
     
    917917         */
    918918        pCtx->rip           = offset;
    919         pCtx->cs            = sel;
    920         pCtx->csHid.u64Base = sel << 4;
     919        pCtx->cs.Sel        = sel;
     920        pCtx->cs.u64Base    = sel << 4;
    921921        pCtx->eflags.u     &= ~(X86_EFL_IF | X86_EFL_TF | X86_EFL_RF | X86_EFL_AC);
    922922
     
    10091009                rc = PDMGetInterrupt(pVCpu, &u8Interrupt);
    10101010                Log(("CPU%d: Dispatch interrupt: u8Interrupt=%x (%d) rc=%Rrc cs:rip=%04X:%RGv\n", pVCpu->idCpu,
    1011                      u8Interrupt, u8Interrupt, rc, pCtx->cs, (RTGCPTR)pCtx->rip));
     1011                     u8Interrupt, u8Interrupt, rc, pCtx->cs.Sel, (RTGCPTR)pCtx->rip));
    10121012                if (RT_SUCCESS(rc))
    10131013                {
     
    16421642                     * DPL of all hidden selector registers must match the current CPL (0).
    16431643                     */
    1644                     pCtx->csHid.Attr.n.u2Dpl  = 0;
    1645                     pCtx->csHid.Attr.n.u4Type = X86_SEL_TYPE_CODE | X86_SEL_TYPE_RW_ACC;
    1646 
    1647                     pCtx->dsHid.Attr.n.u2Dpl  = 0;
    1648                     pCtx->esHid.Attr.n.u2Dpl  = 0;
    1649                     pCtx->fsHid.Attr.n.u2Dpl  = 0;
    1650                     pCtx->gsHid.Attr.n.u2Dpl  = 0;
    1651                     pCtx->ssHid.Attr.n.u2Dpl  = 0;
     1644                    pCtx->cs.Attr.n.u2Dpl  = 0;
     1645                    pCtx->cs.Attr.n.u4Type = X86_SEL_TYPE_CODE | X86_SEL_TYPE_RW_ACC;
     1646
     1647                    pCtx->ds.Attr.n.u2Dpl  = 0;
     1648                    pCtx->es.Attr.n.u2Dpl  = 0;
     1649                    pCtx->fs.Attr.n.u2Dpl  = 0;
     1650                    pCtx->gs.Attr.n.u2Dpl  = 0;
     1651                    pCtx->ss.Attr.n.u2Dpl  = 0;
    16521652                }
    16531653                pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode = enmGuestMode;
    16541654            }
    16551655            else if (   CPUMIsGuestInRealModeEx(pCtx)
    1656                      && pCtx->csHid.u64Base == 0xffff0000)
     1656                     && pCtx->cs.u64Base == 0xffff0000)
    16571657            {
    16581658                /* VT-x will fail with a guest invalid state otherwise... (CPU state after a reset) */
    1659                 pCtx->csHid.u64Base = 0xf0000;
    1660                 pCtx->cs = 0xf000;
     1659                pCtx->cs.u64Base = 0xf0000;
     1660                pCtx->cs.Sel     = 0xf000;
    16611661            }
    16621662        }
     
    16861686    if (pVCpu->hwaccm.s.fContextUseFlags & HWACCM_CHANGED_GUEST_LDTR)
    16871687    {
    1688         if (pCtx->ldtr == 0)
     1688        if (pCtx->ldtr.Sel == 0)
    16891689        {
    16901690            rc =  VMXWriteVMCS(VMX_VMCS16_GUEST_FIELD_LDTR,         0);
     
    16961696        else
    16971697        {
    1698             rc =  VMXWriteVMCS(VMX_VMCS16_GUEST_FIELD_LDTR,         pCtx->ldtr);
    1699             rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_LDTR_LIMIT,         pCtx->ldtrHid.u32Limit);
    1700             rc |= VMXWriteVMCS64(VMX_VMCS64_GUEST_LDTR_BASE,        pCtx->ldtrHid.u64Base);
    1701             rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_LDTR_ACCESS_RIGHTS, pCtx->ldtrHid.Attr.u);
     1698            rc =  VMXWriteVMCS(VMX_VMCS16_GUEST_FIELD_LDTR,         pCtx->ldtr.Sel);
     1699            rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_LDTR_LIMIT,         pCtx->ldtr.u32Limit);
     1700            rc |= VMXWriteVMCS64(VMX_VMCS64_GUEST_LDTR_BASE,        pCtx->ldtr.u64Base);
     1701            rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_LDTR_ACCESS_RIGHTS, pCtx->ldtr.Attr.u);
    17021702        }
    17031703        AssertRC(rc);
     
    17351735        else
    17361736        {
    1737             rc =  VMXWriteVMCS(VMX_VMCS16_GUEST_FIELD_TR,         pCtx->tr);
    1738             rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_TR_LIMIT,         pCtx->trHid.u32Limit);
    1739             rc |= VMXWriteVMCS64(VMX_VMCS64_GUEST_TR_BASE,        pCtx->trHid.u64Base);
    1740 
    1741             val = pCtx->trHid.Attr.u;
     1737            rc =  VMXWriteVMCS(VMX_VMCS16_GUEST_FIELD_TR,         pCtx->tr.Sel);
     1738            rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_TR_LIMIT,         pCtx->tr.u32Limit);
     1739            rc |= VMXWriteVMCS64(VMX_VMCS64_GUEST_TR_BASE,        pCtx->tr.u64Base);
     1740
     1741            val = pCtx->tr.Attr.u;
    17421742
    17431743            /* The TSS selector must be busy (REM bugs? see defect #XXXX). */
     
    20762076        {
    20772077            /* Update these as wrmsr might have changed them. */
    2078             rc = VMXWriteVMCS64(VMX_VMCS64_GUEST_FS_BASE, pCtx->fsHid.u64Base);
     2078            rc = VMXWriteVMCS64(VMX_VMCS64_GUEST_FS_BASE, pCtx->fs.u64Base);
    20792079            AssertRC(rc);
    2080             rc = VMXWriteVMCS64(VMX_VMCS64_GUEST_GS_BASE, pCtx->gsHid.u64Base);
     2080            rc = VMXWriteVMCS64(VMX_VMCS64_GUEST_GS_BASE, pCtx->gs.u64Base);
    20812081            AssertRC(rc);
    20822082        }
     
    32153215#endif
    32163216
    3217     Log2(("E%d: New EIP=%x:%RGv\n", (uint32_t)exitReason, pCtx->cs, (RTGCPTR)pCtx->rip));
     3217    Log2(("E%d: New EIP=%x:%RGv\n", (uint32_t)exitReason, pCtx->cs.Sel, (RTGCPTR)pCtx->rip));
    32183218    Log2(("Exit reason %d, exitQualification %RGv\n", (uint32_t)exitReason, exitQualification));
    32193219    Log2(("instrInfo=%d instrError=%d instr length=%d\n", (uint32_t)instrInfo, (uint32_t)instrError, (uint32_t)cbInstr));
     
    32333233#ifdef DBGFTRACE_ENABLED /** @todo DTrace later. */
    32343234    RTTraceBufAddMsgF(pVM->CTX_SUFF(hTraceBuf), "vmexit %08x %016RX64 at %04:%08RX64 %RX64",
    3235                       exitReason, (uint64_t)exitQualification, pCtx->cs, pCtx->rip, (uint64_t)intInfo);
     3235                      exitReason, (uint64_t)exitQualification, pCtx->cs.Sel, pCtx->rip, (uint64_t)intInfo);
    32363236#endif
    32373237    STAM_PROFILE_ADV_STOP_START(&pVCpu->hwaccm.s.StatExit1, &pVCpu->hwaccm.s.StatExit2, x);
     
    34453445                    break;
    34463446                }
    3447                 Log(("Trap %x at %04X:%RGv\n", vector, pCtx->cs, (RTGCPTR)pCtx->rip));
     3447                Log(("Trap %x at %04X:%RGv\n", vector, pCtx->cs.Sel, (RTGCPTR)pCtx->rip));
    34483448                rc2 = hmR0VmxInjectEvent(pVM, pVCpu, pCtx, VMX_VMCS_CTRL_ENTRY_IRQ_INFO_FROM_EXIT_INT_INFO(intInfo),
    34493449                                         cbInstr, errCode);
     
    35063506                }
    35073507                /* Return to ring 3 to deal with the debug exit code. */
    3508                 Log(("Debugger hardware BP at %04x:%RGv (rc=%Rrc)\n", pCtx->cs, pCtx->rip, VBOXSTRICTRC_VAL(rc)));
     3508                Log(("Debugger hardware BP at %04x:%RGv (rc=%Rrc)\n", pCtx->cs.Sel, pCtx->rip, VBOXSTRICTRC_VAL(rc)));
    35093509                break;
    35103510            }
     
    35163516                if (rc == VINF_EM_RAW_GUEST_TRAP)
    35173517                {
    3518                     Log(("Guest #BP at %04x:%RGv\n", pCtx->cs, pCtx->rip));
     3518                    Log(("Guest #BP at %04x:%RGv\n", pCtx->cs.Sel, pCtx->rip));
    35193519                    rc2 = hmR0VmxInjectEvent(pVM, pVCpu, pCtx, VMX_VMCS_CTRL_ENTRY_IRQ_INFO_FROM_EXIT_INT_INFO(intInfo),
    35203520                                             cbInstr, errCode);
     
    35283528                    goto ResumeExecution;
    35293529                }
    3530                 Log(("Debugger BP at %04x:%RGv (rc=%Rrc)\n", pCtx->cs, pCtx->rip, VBOXSTRICTRC_VAL(rc)));
     3530                Log(("Debugger BP at %04x:%RGv (rc=%Rrc)\n", pCtx->cs.Sel, pCtx->rip, VBOXSTRICTRC_VAL(rc)));
    35313531                break;
    35323532            }
     
    35423542                    ||  !pVM->hwaccm.s.vmx.pRealModeTSS)
    35433543                {
    3544                     Log(("Trap %x at %04X:%RGv errorCode=%RGv\n", vector, pCtx->cs, (RTGCPTR)pCtx->rip, errCode));
     3544                    Log(("Trap %x at %04X:%RGv errorCode=%RGv\n", vector, pCtx->cs.Sel, (RTGCPTR)pCtx->rip, errCode));
    35453545                    rc2 = hmR0VmxInjectEvent(pVM, pVCpu, pCtx, VMX_VMCS_CTRL_ENTRY_IRQ_INFO_FROM_EXIT_INT_INFO(intInfo),
    35463546                                             cbInstr, errCode);
     
    35523552                Assert(CPUMIsGuestInRealModeEx(pCtx));
    35533553
    3554                 LogFlow(("Real mode X86_XCPT_GP instruction emulation at %x:%RGv\n", pCtx->cs, (RTGCPTR)pCtx->rip));
     3554                LogFlow(("Real mode X86_XCPT_GP instruction emulation at %x:%RGv\n", pCtx->cs.Sel, (RTGCPTR)pCtx->rip));
    35553555
    35563556                rc2 = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp);
     
    36953695                        }
    36963696                        pCtx->ip            = aIretFrame[0];
    3697                         pCtx->cs            = aIretFrame[1];
    3698                         pCtx->csHid.u64Base = pCtx->cs << 4;
     3697                        pCtx->cs.Sel        = aIretFrame[1];
     3698                        pCtx->cs.ValidSel   = aIretFrame[1];
     3699                        pCtx->cs.u64Base    = (uint32_t)pCtx->cs.Sel << 4;
    36993700                        pCtx->eflags.u      =   (pCtx->eflags.u & ~(X86_EFL_POPF_BITS & uMask))
    37003701                                              | (aIretFrame[2] & X86_EFL_POPF_BITS & uMask);
    37013702                        pCtx->sp           += sizeof(aIretFrame);
    37023703
    3703                         LogFlow(("iret to %04x:%x\n", pCtx->cs, pCtx->ip));
     3704                        LogFlow(("iret to %04x:%x\n", pCtx->cs.Sel, pCtx->ip));
    37043705                        fUpdateRIP = false;
    37053706                        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIret);
     
    38133814                }
    38143815
    3815                 Log(("Trap %x at %04X:%RGv\n", vector, pCtx->cs, (RTGCPTR)pCtx->rip));
     3816                Log(("Trap %x at %04X:%RGv\n", vector, pCtx->cs.Sel, (RTGCPTR)pCtx->rip));
    38163817                rc2 = hmR0VmxInjectEvent(pVM, pVCpu, pCtx, VMX_VMCS_CTRL_ENTRY_IRQ_INFO_FROM_EXIT_INT_INFO(intInfo),
    38173818                                         cbInstr, errCode);
     
    38273828                    &&  pVM->hwaccm.s.vmx.pRealModeTSS)
    38283829                {
    3829                     Log(("Real Mode Trap %x at %04x:%04X error code %x\n", vector, pCtx->cs, pCtx->eip, errCode));
     3830                    Log(("Real Mode Trap %x at %04x:%04X error code %x\n", vector, pCtx->cs.Sel, pCtx->eip, errCode));
    38303831                    rc = hmR0VmxInjectEvent(pVM, pVCpu, pCtx, VMX_VMCS_CTRL_ENTRY_IRQ_INFO_FROM_EXIT_INT_INFO(intInfo),
    38313832                                            cbInstr, errCode);
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.h

    r41330 r41906  
    217217
    218218# define VMX_WRITE_SELREG(REG, reg) \
    219 {                                                                                               \
    220         rc  = VMXWriteVMCS(VMX_VMCS16_GUEST_FIELD_##REG,      pCtx->reg);                       \
    221         rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT,    pCtx->reg##Hid.u32Limit);         \
    222         rc |= VMXWriteVMCS64(VMX_VMCS64_GUEST_##REG##_BASE,     pCtx->reg##Hid.u64Base);        \
     219    do \
     220    { \
     221        rc  = VMXWriteVMCS(VMX_VMCS16_GUEST_FIELD_##REG,        pCtx->reg.Sel);                 \
     222        rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT,      pCtx->reg.u32Limit);            \
     223        rc |= VMXWriteVMCS64(VMX_VMCS64_GUEST_##REG##_BASE,     pCtx->reg.u64Base);             \
    223224        if ((pCtx->eflags.u32 & X86_EFL_VM))                                                    \
    224225        {                                                                                       \
    225226            /* Must override this or else VT-x will fail with invalid guest state errors. */    \
    226227            /* DPL=3, present, code/data, r/w/accessed. */                                      \
    227             val = (pCtx->reg##Hid.Attr.u & ~0xFF) | 0xF3;                                       \
     228            val = (pCtx->reg.Attr.u & ~0xFF) | 0xF3;                                            \
    228229        }                                                                                       \
    229230        else                                                                                    \
     
    236237        }                                                                                       \
    237238        else                                                                                    \
    238         if (   (   pCtx->reg                                                                    \
     239        if (   (   pCtx->reg.Sel                                                                \
    239240                || !CPUMIsGuestInPagedProtectedModeEx(pCtx)                                     \
    240                 || (!pCtx->csHid.Attr.n.u1DefBig && !CPUMIsGuestIn64BitCodeEx(pCtx))            \
     241                || (!pCtx->cs.Attr.n.u1DefBig && !CPUMIsGuestIn64BitCodeEx(pCtx))               \
    241242                )                                                                               \
    242             && pCtx->reg##Hid.Attr.n.u1Present == 1)                                            \
     243            && pCtx->reg.Attr.n.u1Present == 1)                                                 \
    243244        {                                                                                       \
    244             val = pCtx->reg##Hid.Attr.u | X86_SEL_TYPE_ACCESSED;                                \
     245            val = pCtx->reg.Attr.u | X86_SEL_TYPE_ACCESSED;                                     \
    245246        }                                                                                       \
    246247        else                                                                                    \
     
    248249                                                                                                \
    249250        rc |= VMXWriteVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, val);                        \
    250 }
     251    } while (0)
    251252
    252253# define VMX_READ_SELREG(REG, reg) \
    253 {                                                                          \
    254         VMXReadCachedVMCS(VMX_VMCS16_GUEST_FIELD_##REG,           &val);   \
    255         pCtx->reg                = val;                                    \
    256         VMXReadCachedVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT,         &val);   \
    257         pCtx->reg##Hid.u32Limit    = val;                                  \
    258         VMXReadCachedVMCS(VMX_VMCS64_GUEST_##REG##_BASE,          &val);   \
    259         pCtx->reg##Hid.u64Base     = val;                                  \
    260         VMXReadCachedVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, &val);   \
    261         pCtx->reg##Hid.Attr.u    = val;                                    \
    262 }
     254    do \
     255    { \
     256        VMXReadCachedVMCS(VMX_VMCS16_GUEST_FIELD_##REG,           &val); \
     257        pCtx->reg.Sel       = val; \
     258        pCtx->reg.ValidSel  = val; \
     259        pCtx->reg.fFlags    = CPUMSELREG_FLAGS_VALID; \
     260        VMXReadCachedVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT,         &val); \
     261        pCtx->reg.u32Limit  = val; \
     262        VMXReadCachedVMCS(VMX_VMCS64_GUEST_##REG##_BASE,          &val); \
     263        pCtx->reg.u64Base   = val; \
     264        VMXReadCachedVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, &val); \
     265        pCtx->reg.Attr.u    = val; \
     266    } while (0)
    263267
    264268/* Don't read from the cache in this macro; used only in case of failure where the cache is out of sync. */
    265269# define VMX_LOG_SELREG(REG, szSelReg, val) \
    266 {                                                                          \
    267         VMXReadVMCS(VMX_VMCS16_GUEST_FIELD_##REG,           &(val));       \
    268         Log(("%s Selector     %x\n", szSelReg, (val)));                    \
    269         VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT,         &(val));       \
    270         Log(("%s Limit        %x\n", szSelReg, (val)));                    \
    271         VMXReadVMCS(VMX_VMCS64_GUEST_##REG##_BASE,          &(val));       \
    272         Log(("%s Base         %RX64\n", szSelReg, (uint64_t)(val)));       \
    273         VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, &(val));       \
    274         Log(("%s Attributes   %x\n", szSelReg, (val)));                    \
    275 }
     270    do \
     271    { \
     272        VMXReadVMCS(VMX_VMCS16_GUEST_FIELD_##REG,           &(val)); \
     273        Log(("%s Selector     %x\n", szSelReg, (val))); \
     274        VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_LIMIT,         &(val)); \
     275        Log(("%s Limit        %x\n", szSelReg, (val))); \
     276        VMXReadVMCS(VMX_VMCS64_GUEST_##REG##_BASE,          &(val)); \
     277        Log(("%s Base         %RX64\n", szSelReg, (uint64_t)(val))); \
     278        VMXReadVMCS(VMX_VMCS32_GUEST_##REG##_ACCESS_RIGHTS, &(val)); \
     279        Log(("%s Attributes   %x\n", szSelReg, (val))); \
     280    } while (0)
    276281
    277282/**
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r41905 r41906  
    176176    SSMFIELD_ENTRY(         CPUMCTX, rsp),
    177177    SSMFIELD_ENTRY_OLD(              lss_esp, sizeof(uint32_t)),
    178     SSMFIELD_ENTRY(         CPUMCTX, ss),
     178    SSMFIELD_ENTRY(         CPUMCTX, ss.Sel),
    179179    SSMFIELD_ENTRY_OLD(              ssPadding, sizeof(uint16_t)),
    180     SSMFIELD_ENTRY(         CPUMCTX, gs),
     180    SSMFIELD_ENTRY(         CPUMCTX, gs.Sel),
    181181    SSMFIELD_ENTRY_OLD(              gsPadding, sizeof(uint16_t)),
    182     SSMFIELD_ENTRY(         CPUMCTX, fs),
     182    SSMFIELD_ENTRY(         CPUMCTX, fs.Sel),
    183183    SSMFIELD_ENTRY_OLD(              fsPadding, sizeof(uint16_t)),
    184     SSMFIELD_ENTRY(         CPUMCTX, es),
     184    SSMFIELD_ENTRY(         CPUMCTX, es.Sel),
    185185    SSMFIELD_ENTRY_OLD(              esPadding, sizeof(uint16_t)),
    186     SSMFIELD_ENTRY(         CPUMCTX, ds),
     186    SSMFIELD_ENTRY(         CPUMCTX, ds.Sel),
    187187    SSMFIELD_ENTRY_OLD(              dsPadding, sizeof(uint16_t)),
    188     SSMFIELD_ENTRY(         CPUMCTX, cs),
     188    SSMFIELD_ENTRY(         CPUMCTX, cs.Sel),
    189189    SSMFIELD_ENTRY_OLD(              csPadding, sizeof(uint16_t)*3),
    190190    SSMFIELD_ENTRY(         CPUMCTX, rflags),
     
    198198    SSMFIELD_ENTRY(         CPUMCTX, r14),
    199199    SSMFIELD_ENTRY(         CPUMCTX, r15),
    200     SSMFIELD_ENTRY(         CPUMCTX, esHid.u64Base),
    201     SSMFIELD_ENTRY(         CPUMCTX, esHid.u32Limit),
    202     SSMFIELD_ENTRY(         CPUMCTX, esHid.Attr),
    203     SSMFIELD_ENTRY(         CPUMCTX, csHid.u64Base),
    204     SSMFIELD_ENTRY(         CPUMCTX, csHid.u32Limit),
    205     SSMFIELD_ENTRY(         CPUMCTX, csHid.Attr),
    206     SSMFIELD_ENTRY(         CPUMCTX, ssHid.u64Base),
    207     SSMFIELD_ENTRY(         CPUMCTX, ssHid.u32Limit),
    208     SSMFIELD_ENTRY(         CPUMCTX, ssHid.Attr),
    209     SSMFIELD_ENTRY(         CPUMCTX, dsHid.u64Base),
    210     SSMFIELD_ENTRY(         CPUMCTX, dsHid.u32Limit),
    211     SSMFIELD_ENTRY(         CPUMCTX, dsHid.Attr),
    212     SSMFIELD_ENTRY(         CPUMCTX, fsHid.u64Base),
    213     SSMFIELD_ENTRY(         CPUMCTX, fsHid.u32Limit),
    214     SSMFIELD_ENTRY(         CPUMCTX, fsHid.Attr),
    215     SSMFIELD_ENTRY(         CPUMCTX, gsHid.u64Base),
    216     SSMFIELD_ENTRY(         CPUMCTX, gsHid.u32Limit),
    217     SSMFIELD_ENTRY(         CPUMCTX, gsHid.Attr),
     200    SSMFIELD_ENTRY(         CPUMCTX, es.u64Base),
     201    SSMFIELD_ENTRY(         CPUMCTX, es.u32Limit),
     202    SSMFIELD_ENTRY(         CPUMCTX, es.Attr),
     203    SSMFIELD_ENTRY(         CPUMCTX, cs.u64Base),
     204    SSMFIELD_ENTRY(         CPUMCTX, cs.u32Limit),
     205    SSMFIELD_ENTRY(         CPUMCTX, cs.Attr),
     206    SSMFIELD_ENTRY(         CPUMCTX, ss.u64Base),
     207    SSMFIELD_ENTRY(         CPUMCTX, ss.u32Limit),
     208    SSMFIELD_ENTRY(         CPUMCTX, ss.Attr),
     209    SSMFIELD_ENTRY(         CPUMCTX, ds.u64Base),
     210    SSMFIELD_ENTRY(         CPUMCTX, ds.u32Limit),
     211    SSMFIELD_ENTRY(         CPUMCTX, ds.Attr),
     212    SSMFIELD_ENTRY(         CPUMCTX, fs.u64Base),
     213    SSMFIELD_ENTRY(         CPUMCTX, fs.u32Limit),
     214    SSMFIELD_ENTRY(         CPUMCTX, fs.Attr),
     215    SSMFIELD_ENTRY(         CPUMCTX, gs.u64Base),
     216    SSMFIELD_ENTRY(         CPUMCTX, gs.u32Limit),
     217    SSMFIELD_ENTRY(         CPUMCTX, gs.Attr),
    218218    SSMFIELD_ENTRY(         CPUMCTX, cr0),
    219219    SSMFIELD_ENTRY(         CPUMCTX, cr2),
     
    234234    SSMFIELD_ENTRY(         CPUMCTX, idtr.pIdt),
    235235    SSMFIELD_ENTRY_OLD(              idtrPadding, sizeof(uint16_t)),
    236     SSMFIELD_ENTRY(         CPUMCTX, ldtr),
     236    SSMFIELD_ENTRY(         CPUMCTX, ldtr.Sel),
    237237    SSMFIELD_ENTRY_OLD(              ldtrPadding, sizeof(uint16_t)),
    238     SSMFIELD_ENTRY(         CPUMCTX, tr),
     238    SSMFIELD_ENTRY(         CPUMCTX, tr.Sel),
    239239    SSMFIELD_ENTRY_OLD(              trPadding, sizeof(uint16_t)),
    240240    SSMFIELD_ENTRY(         CPUMCTX, SysEnter.cs),
     
    248248    SSMFIELD_ENTRY(         CPUMCTX, msrSFMASK),
    249249    SSMFIELD_ENTRY(         CPUMCTX, msrKERNELGSBASE),
    250     SSMFIELD_ENTRY(         CPUMCTX, ldtrHid.u64Base),
    251     SSMFIELD_ENTRY(         CPUMCTX, ldtrHid.u32Limit),
    252     SSMFIELD_ENTRY(         CPUMCTX, ldtrHid.Attr),
    253     SSMFIELD_ENTRY(         CPUMCTX, trHid.u64Base),
    254     SSMFIELD_ENTRY(         CPUMCTX, trHid.u32Limit),
    255     SSMFIELD_ENTRY(         CPUMCTX, trHid.Attr),
     250    SSMFIELD_ENTRY(         CPUMCTX, ldtr.u64Base),
     251    SSMFIELD_ENTRY(         CPUMCTX, ldtr.u32Limit),
     252    SSMFIELD_ENTRY(         CPUMCTX, ldtr.Attr),
     253    SSMFIELD_ENTRY(         CPUMCTX, tr.u64Base),
     254    SSMFIELD_ENTRY(         CPUMCTX, tr.u32Limit),
     255    SSMFIELD_ENTRY(         CPUMCTX, tr.Attr),
    256256    SSMFIELD_ENTRY_TERM()
    257257};
     
    305305    SSMFIELD_ENTRY(             CPUMCTX, rcx),
    306306    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, rsp),
    307     SSMFIELD_ENTRY(             CPUMCTX, ss),
     307    SSMFIELD_ENTRY(             CPUMCTX, ss.Sel),
    308308    SSMFIELD_ENTRY_OLD(                  ssPadding, sizeof(uint16_t)),
    309309    SSMFIELD_ENTRY_OLD(         CPUMCTX, sizeof(uint64_t) /*rsp_notused*/),
    310     SSMFIELD_ENTRY(             CPUMCTX, gs),
     310    SSMFIELD_ENTRY(             CPUMCTX, gs.Sel),
    311311    SSMFIELD_ENTRY_OLD(                  gsPadding, sizeof(uint16_t)),
    312     SSMFIELD_ENTRY(             CPUMCTX, fs),
     312    SSMFIELD_ENTRY(             CPUMCTX, fs.Sel),
    313313    SSMFIELD_ENTRY_OLD(                  fsPadding, sizeof(uint16_t)),
    314     SSMFIELD_ENTRY(             CPUMCTX, es),
     314    SSMFIELD_ENTRY(             CPUMCTX, es.Sel),
    315315    SSMFIELD_ENTRY_OLD(                  esPadding, sizeof(uint16_t)),
    316     SSMFIELD_ENTRY(             CPUMCTX, ds),
     316    SSMFIELD_ENTRY(             CPUMCTX, ds.Sel),
    317317    SSMFIELD_ENTRY_OLD(                  dsPadding, sizeof(uint16_t)),
    318     SSMFIELD_ENTRY(             CPUMCTX, cs),
     318    SSMFIELD_ENTRY(             CPUMCTX, cs.Sel),
    319319    SSMFIELD_ENTRY_OLD(                  csPadding, sizeof(uint16_t)*3),
    320320    SSMFIELD_ENTRY(             CPUMCTX, rflags),
     
    328328    SSMFIELD_ENTRY(             CPUMCTX, r14),
    329329    SSMFIELD_ENTRY(             CPUMCTX, r15),
    330     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, esHid.u64Base),
    331     SSMFIELD_ENTRY(             CPUMCTX, esHid.u32Limit),
    332     SSMFIELD_ENTRY(             CPUMCTX, esHid.Attr),
    333     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, csHid.u64Base),
    334     SSMFIELD_ENTRY(             CPUMCTX, csHid.u32Limit),
    335     SSMFIELD_ENTRY(             CPUMCTX, csHid.Attr),
    336     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, ssHid.u64Base),
    337     SSMFIELD_ENTRY(             CPUMCTX, ssHid.u32Limit),
    338     SSMFIELD_ENTRY(             CPUMCTX, ssHid.Attr),
    339     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, dsHid.u64Base),
    340     SSMFIELD_ENTRY(             CPUMCTX, dsHid.u32Limit),
    341     SSMFIELD_ENTRY(             CPUMCTX, dsHid.Attr),
    342     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, fsHid.u64Base),
    343     SSMFIELD_ENTRY(             CPUMCTX, fsHid.u32Limit),
    344     SSMFIELD_ENTRY(             CPUMCTX, fsHid.Attr),
    345     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, gsHid.u64Base),
    346     SSMFIELD_ENTRY(             CPUMCTX, gsHid.u32Limit),
    347     SSMFIELD_ENTRY(             CPUMCTX, gsHid.Attr),
     330    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, es.u64Base),
     331    SSMFIELD_ENTRY(             CPUMCTX, es.u32Limit),
     332    SSMFIELD_ENTRY(             CPUMCTX, es.Attr),
     333    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, cs.u64Base),
     334    SSMFIELD_ENTRY(             CPUMCTX, cs.u32Limit),
     335    SSMFIELD_ENTRY(             CPUMCTX, cs.Attr),
     336    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, ss.u64Base),
     337    SSMFIELD_ENTRY(             CPUMCTX, ss.u32Limit),
     338    SSMFIELD_ENTRY(             CPUMCTX, ss.Attr),
     339    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, ds.u64Base),
     340    SSMFIELD_ENTRY(             CPUMCTX, ds.u32Limit),
     341    SSMFIELD_ENTRY(             CPUMCTX, ds.Attr),
     342    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, fs.u64Base),
     343    SSMFIELD_ENTRY(             CPUMCTX, fs.u32Limit),
     344    SSMFIELD_ENTRY(             CPUMCTX, fs.Attr),
     345    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, gs.u64Base),
     346    SSMFIELD_ENTRY(             CPUMCTX, gs.u32Limit),
     347    SSMFIELD_ENTRY(             CPUMCTX, gs.Attr),
    348348    SSMFIELD_ENTRY(             CPUMCTX, cr0),
    349349    SSMFIELD_ENTRY(             CPUMCTX, cr2),
     
    367367    SSMFIELD_ENTRY_OLD(                  idtrPadding, sizeof(uint16_t)),
    368368    SSMFIELD_ENTRY_OLD(                  idtrPadding64, sizeof(uint64_t)),
    369     SSMFIELD_ENTRY(             CPUMCTX, ldtr),
     369    SSMFIELD_ENTRY(             CPUMCTX, ldtr.Sel),
    370370    SSMFIELD_ENTRY_OLD(                  ldtrPadding, sizeof(uint16_t)),
    371     SSMFIELD_ENTRY(             CPUMCTX, tr),
     371    SSMFIELD_ENTRY(             CPUMCTX, tr.Sel),
    372372    SSMFIELD_ENTRY_OLD(                  trPadding, sizeof(uint16_t)),
    373373    SSMFIELD_ENTRY(             CPUMCTX, SysEnter.cs),
     
    383383    SSMFIELD_ENTRY_OLD(                  msrGSBASE, sizeof(uint64_t)),
    384384    SSMFIELD_ENTRY(             CPUMCTX, msrKERNELGSBASE),
    385     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, ldtrHid.u64Base),
    386     SSMFIELD_ENTRY(             CPUMCTX, ldtrHid.u32Limit),
    387     SSMFIELD_ENTRY(             CPUMCTX, ldtrHid.Attr),
    388     SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, trHid.u64Base),
    389     SSMFIELD_ENTRY(             CPUMCTX, trHid.u32Limit),
    390     SSMFIELD_ENTRY(             CPUMCTX, trHid.Attr),
     385    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, ldtr.u64Base),
     386    SSMFIELD_ENTRY(             CPUMCTX, ldtr.u32Limit),
     387    SSMFIELD_ENTRY(             CPUMCTX, ldtr.Attr),
     388    SSMFIELD_ENTRY_U32_ZX_U64(  CPUMCTX, tr.u64Base),
     389    SSMFIELD_ENTRY(             CPUMCTX, tr.u32Limit),
     390    SSMFIELD_ENTRY(             CPUMCTX, tr.Attr),
    391391    SSMFIELD_ENTRY_OLD(                  padding, sizeof(uint32_t)*2),
    392392    SSMFIELD_ENTRY_TERM()
     
    13581358    pCtx->eflags.Bits.u1Reserved0   = 1;
    13591359
    1360     pCtx->cs                        = 0xf000;
    1361     pCtx->csHid.u64Base             = UINT64_C(0xffff0000);
    1362     pCtx->csHid.u32Limit            = 0x0000ffff;
    1363     pCtx->csHid.Attr.n.u1DescType   = 1; /* code/data segment */
    1364     pCtx->csHid.Attr.n.u1Present    = 1;
    1365     pCtx->csHid.Attr.n.u4Type       = X86_SEL_TYPE_READ | X86_SEL_TYPE_CODE;
    1366 
    1367     pCtx->dsHid.u32Limit            = 0x0000ffff;
    1368     pCtx->dsHid.Attr.n.u1DescType   = 1; /* code/data segment */
    1369     pCtx->dsHid.Attr.n.u1Present    = 1;
    1370     pCtx->dsHid.Attr.n.u4Type       = X86_SEL_TYPE_RW;
    1371 
    1372     pCtx->esHid.u32Limit            = 0x0000ffff;
    1373     pCtx->esHid.Attr.n.u1DescType   = 1; /* code/data segment */
    1374     pCtx->esHid.Attr.n.u1Present    = 1;
    1375     pCtx->esHid.Attr.n.u4Type       = X86_SEL_TYPE_RW;
    1376 
    1377     pCtx->fsHid.u32Limit            = 0x0000ffff;
    1378     pCtx->fsHid.Attr.n.u1DescType   = 1; /* code/data segment */
    1379     pCtx->fsHid.Attr.n.u1Present    = 1;
    1380     pCtx->fsHid.Attr.n.u4Type       = X86_SEL_TYPE_RW;
    1381 
    1382     pCtx->gsHid.u32Limit            = 0x0000ffff;
    1383     pCtx->gsHid.Attr.n.u1DescType   = 1; /* code/data segment */
    1384     pCtx->gsHid.Attr.n.u1Present    = 1;
    1385     pCtx->gsHid.Attr.n.u4Type       = X86_SEL_TYPE_RW;
    1386 
    1387     pCtx->ssHid.u32Limit            = 0x0000ffff;
    1388     pCtx->ssHid.Attr.n.u1Present    = 1;
    1389     pCtx->ssHid.Attr.n.u1DescType   = 1; /* code/data segment */
    1390     pCtx->ssHid.Attr.n.u4Type       = X86_SEL_TYPE_RW;
     1360    pCtx->cs.Sel                    = 0xf000;
     1361    pCtx->cs.ValidSel               = 0xf000;
     1362    pCtx->cs.fFlags                 = CPUMSELREG_FLAGS_VALID;
     1363    pCtx->cs.u64Base                = UINT64_C(0xffff0000);
     1364    pCtx->cs.u32Limit               = 0x0000ffff;
     1365    pCtx->cs.Attr.n.u1DescType      = 1; /* code/data segment */
     1366    pCtx->cs.Attr.n.u1Present       = 1;
     1367    pCtx->cs.Attr.n.u4Type          = X86_SEL_TYPE_READ | X86_SEL_TYPE_CODE;
     1368
     1369    pCtx->ds.fFlags                 = CPUMSELREG_FLAGS_VALID;
     1370    pCtx->ds.u32Limit               = 0x0000ffff;
     1371    pCtx->ds.Attr.n.u1DescType      = 1; /* code/data segment */
     1372    pCtx->ds.Attr.n.u1Present       = 1;
     1373    pCtx->ds.Attr.n.u4Type          = X86_SEL_TYPE_RW;
     1374
     1375    pCtx->es.fFlags                 = CPUMSELREG_FLAGS_VALID;
     1376    pCtx->es.u32Limit               = 0x0000ffff;
     1377    pCtx->es.Attr.n.u1DescType      = 1; /* code/data segment */
     1378    pCtx->es.Attr.n.u1Present       = 1;
     1379    pCtx->es.Attr.n.u4Type          = X86_SEL_TYPE_RW;
     1380
     1381    pCtx->fs.fFlags                 = CPUMSELREG_FLAGS_VALID;
     1382    pCtx->fs.u32Limit               = 0x0000ffff;
     1383    pCtx->fs.Attr.n.u1DescType      = 1; /* code/data segment */
     1384    pCtx->fs.Attr.n.u1Present       = 1;
     1385    pCtx->fs.Attr.n.u4Type          = X86_SEL_TYPE_RW;
     1386
     1387    pCtx->gs.fFlags                 = CPUMSELREG_FLAGS_VALID;
     1388    pCtx->gs.u32Limit               = 0x0000ffff;
     1389    pCtx->gs.Attr.n.u1DescType      = 1; /* code/data segment */
     1390    pCtx->gs.Attr.n.u1Present       = 1;
     1391    pCtx->gs.Attr.n.u4Type          = X86_SEL_TYPE_RW;
     1392
     1393    pCtx->ss.fFlags                 = CPUMSELREG_FLAGS_VALID;
     1394    pCtx->ss.u32Limit               = 0x0000ffff;
     1395    pCtx->ss.Attr.n.u1Present       = 1;
     1396    pCtx->ss.Attr.n.u1DescType      = 1; /* code/data segment */
     1397    pCtx->ss.Attr.n.u4Type          = X86_SEL_TYPE_RW;
    13911398
    13921399    pCtx->idtr.cbIdt                = 0xffff;
    13931400    pCtx->gdtr.cbGdt                = 0xffff;
    13941401
    1395     pCtx->ldtrHid.u32Limit          = 0xffff;
    1396     pCtx->ldtrHid.Attr.n.u1Present  = 1;
    1397     pCtx->ldtrHid.Attr.n.u4Type     = X86_SEL_TYPE_SYS_LDT;
    1398 
    1399     pCtx->trHid.u32Limit            = 0xffff;
    1400     pCtx->trHid.Attr.n.u1Present    = 1;
    1401     pCtx->trHid.Attr.n.u4Type       = X86_SEL_TYPE_SYS_386_TSS_BUSY;    /* Deduction, not properly documented by Intel. */
     1402    pCtx->ldtr.fFlags               = CPUMSELREG_FLAGS_VALID;
     1403    pCtx->ldtr.u32Limit             = 0xffff;
     1404    pCtx->ldtr.Attr.n.u1Present     = 1;
     1405    pCtx->ldtr.Attr.n.u4Type        = X86_SEL_TYPE_SYS_LDT;
     1406
     1407    pCtx->tr.fFlags                 = CPUMSELREG_FLAGS_VALID;
     1408    pCtx->tr.u32Limit               = 0xffff;
     1409    pCtx->tr.Attr.n.u1Present       = 1;
     1410    pCtx->tr.Attr.n.u4Type          = X86_SEL_TYPE_SYS_386_TSS_BUSY;    /* Deduction, not properly documented by Intel. */
    14021411
    14031412    pCtx->dr[6]                     = X86_DR6_INIT_VAL;
     
    26142623                    pszPrefix, pCtxCore->r14, pszPrefix, pCtxCore->r15,
    26152624                    pszPrefix, pCtxCore->rip, pszPrefix, pCtxCore->rsp, pszPrefix, pCtxCore->rbp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
    2616                     pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es,
    2617                     pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, efl);
     2625                    pszPrefix, pCtxCore->cs.Sel, pszPrefix, pCtxCore->ss.Sel, pszPrefix, pCtxCore->ds.Sel, pszPrefix, pCtxCore->es.Sel,
     2626                    pszPrefix, pCtxCore->fs.Sel, pszPrefix, pCtxCore->gs.Sel, pszPrefix, efl);
    26182627            else
    26192628                pHlp->pfnPrintf(pHlp,
     
    26232632                    pszPrefix, pCtxCore->eax, pszPrefix, pCtxCore->ebx, pszPrefix, pCtxCore->ecx, pszPrefix, pCtxCore->edx, pszPrefix, pCtxCore->esi, pszPrefix, pCtxCore->edi,
    26242633                    pszPrefix, pCtxCore->eip, pszPrefix, pCtxCore->esp, pszPrefix, pCtxCore->ebp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
    2625                     pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es,
    2626                     pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, efl);
     2634                    pszPrefix, pCtxCore->cs.Sel, pszPrefix, pCtxCore->ss.Sel, pszPrefix, pCtxCore->ds.Sel, pszPrefix, pCtxCore->es.Sel,
     2635                    pszPrefix, pCtxCore->fs.Sel, pszPrefix, pCtxCore->gs.Sel, pszPrefix, efl);
    26272636            break;
    26282637
     
    26422651                    pszPrefix, pCtxCore->r14, pszPrefix, pCtxCore->r15,
    26432652                    pszPrefix, pCtxCore->rip, pszPrefix, pCtxCore->rsp, pszPrefix, pCtxCore->rbp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
    2644                     pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es,
    2645                     pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, (RTSEL)pCtx->tr, pszPrefix, efl,
     2653                    pszPrefix, pCtxCore->cs.Sel, pszPrefix, pCtxCore->ss.Sel, pszPrefix, pCtxCore->ds.Sel, pszPrefix, pCtxCore->es.Sel,
     2654                    pszPrefix, pCtxCore->fs.Sel, pszPrefix, pCtxCore->gs.Sel, pszPrefix, pCtx->tr.Sel, pszPrefix, efl,
    26462655                    pszPrefix, pCtx->cr0, pszPrefix, pCtx->cr2, pszPrefix, pCtx->cr3, pszPrefix, pCtx->cr4,
    2647                     pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, (RTSEL)pCtx->ldtr);
     2656                    pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, pCtx->ldtr.Sel);
    26482657            else
    26492658                pHlp->pfnPrintf(pHlp,
     
    26552664                    pszPrefix, pCtxCore->eax, pszPrefix, pCtxCore->ebx, pszPrefix, pCtxCore->ecx, pszPrefix, pCtxCore->edx, pszPrefix, pCtxCore->esi, pszPrefix, pCtxCore->edi,
    26562665                    pszPrefix, pCtxCore->eip, pszPrefix, pCtxCore->esp, pszPrefix, pCtxCore->ebp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
    2657                     pszPrefix, (RTSEL)pCtxCore->cs, pszPrefix, (RTSEL)pCtxCore->ss, pszPrefix, (RTSEL)pCtxCore->ds, pszPrefix, (RTSEL)pCtxCore->es,
    2658                     pszPrefix, (RTSEL)pCtxCore->fs, pszPrefix, (RTSEL)pCtxCore->gs, pszPrefix, (RTSEL)pCtx->tr, pszPrefix, efl,
     2666                    pszPrefix, pCtxCore->cs.Sel, pszPrefix, pCtxCore->ss.Sel, pszPrefix, pCtxCore->ds.Sel, pszPrefix, pCtxCore->es.Sel,
     2667                    pszPrefix, pCtxCore->fs.Sel, pszPrefix, pCtxCore->gs.Sel, pszPrefix, pCtx->tr.Sel, pszPrefix, efl,
    26592668                    pszPrefix, pCtx->cr0, pszPrefix, pCtx->cr2, pszPrefix, pCtx->cr3, pszPrefix, pCtx->cr4,
    2660                     pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, (RTSEL)pCtx->ldtr);
     2669                    pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, pCtx->ldtr.Sel);
    26612670            break;
    26622671
     
    26872696                    pszPrefix, pCtxCore->r14, pszPrefix, pCtxCore->r15,
    26882697                    pszPrefix, pCtxCore->rip, pszPrefix, pCtxCore->rsp, pszPrefix, pCtxCore->rbp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
    2689                     pszPrefix, (RTSEL)pCtxCore->cs, pCtx->csHid.u64Base, pCtx->csHid.u32Limit, pCtx->csHid.Attr.u,
    2690                     pszPrefix, (RTSEL)pCtxCore->ds, pCtx->dsHid.u64Base, pCtx->dsHid.u32Limit, pCtx->dsHid.Attr.u,
    2691                     pszPrefix, (RTSEL)pCtxCore->es, pCtx->esHid.u64Base, pCtx->esHid.u32Limit, pCtx->esHid.Attr.u,
    2692                     pszPrefix, (RTSEL)pCtxCore->fs, pCtx->fsHid.u64Base, pCtx->fsHid.u32Limit, pCtx->fsHid.Attr.u,
    2693                     pszPrefix, (RTSEL)pCtxCore->gs, pCtx->gsHid.u64Base, pCtx->gsHid.u32Limit, pCtx->gsHid.Attr.u,
    2694                     pszPrefix, (RTSEL)pCtxCore->ss, pCtx->ssHid.u64Base, pCtx->ssHid.u32Limit, pCtx->ssHid.Attr.u,
     2698                    pszPrefix, pCtxCore->cs.Sel, pCtx->cs.u64Base, pCtx->cs.u32Limit, pCtx->cs.Attr.u,
     2699                    pszPrefix, pCtxCore->ds.Sel, pCtx->ds.u64Base, pCtx->ds.u32Limit, pCtx->ds.Attr.u,
     2700                    pszPrefix, pCtxCore->es.Sel, pCtx->es.u64Base, pCtx->es.u32Limit, pCtx->es.Attr.u,
     2701                    pszPrefix, pCtxCore->fs.Sel, pCtx->fs.u64Base, pCtx->fs.u32Limit, pCtx->fs.Attr.u,
     2702                    pszPrefix, pCtxCore->gs.Sel, pCtx->gs.u64Base, pCtx->gs.u32Limit, pCtx->gs.Attr.u,
     2703                    pszPrefix, pCtxCore->ss.Sel, pCtx->ss.u64Base, pCtx->ss.u32Limit, pCtx->ss.Attr.u,
    26952704                    pszPrefix, pCtx->cr0,  pszPrefix, pCtx->cr2, pszPrefix, pCtx->cr3,  pszPrefix, pCtx->cr4,
    26962705                    pszPrefix, pCtx->dr[0],  pszPrefix, pCtx->dr[1], pszPrefix, pCtx->dr[2],  pszPrefix, pCtx->dr[3],
    26972706                    pszPrefix, pCtx->dr[4],  pszPrefix, pCtx->dr[5], pszPrefix, pCtx->dr[6],  pszPrefix, pCtx->dr[7],
    26982707                    pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, pszPrefix, efl,
    2699                     pszPrefix, (RTSEL)pCtx->ldtr, pCtx->ldtrHid.u64Base, pCtx->ldtrHid.u32Limit, pCtx->ldtrHid.Attr.u,
    2700                     pszPrefix, (RTSEL)pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u,
     2708                    pszPrefix, pCtx->ldtr.Sel, pCtx->ldtr.u64Base, pCtx->ldtr.u32Limit, pCtx->ldtr.Attr.u,
     2709                    pszPrefix, pCtx->tr.Sel, pCtx->tr.u64Base, pCtx->tr.u32Limit, pCtx->tr.Attr.u,
    27012710                    pszPrefix, pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp);
    27022711            else
     
    27172726                    pszPrefix, pCtxCore->eax, pszPrefix, pCtxCore->ebx, pszPrefix, pCtxCore->ecx, pszPrefix, pCtxCore->edx, pszPrefix, pCtxCore->esi, pszPrefix, pCtxCore->edi,
    27182727                    pszPrefix, pCtxCore->eip, pszPrefix, pCtxCore->esp, pszPrefix, pCtxCore->ebp, pszPrefix, X86_EFL_GET_IOPL(efl), *pszPrefix ? 33 : 31, szEFlags,
    2719                     pszPrefix, (RTSEL)pCtxCore->cs, pCtx->csHid.u64Base, pCtx->csHid.u32Limit, pCtx->csHid.Attr.u, pszPrefix, pCtx->dr[0],  pszPrefix, pCtx->dr[1],
    2720                     pszPrefix, (RTSEL)pCtxCore->ds, pCtx->dsHid.u64Base, pCtx->dsHid.u32Limit, pCtx->dsHid.Attr.u, pszPrefix, pCtx->dr[2],  pszPrefix, pCtx->dr[3],
    2721                     pszPrefix, (RTSEL)pCtxCore->es, pCtx->esHid.u64Base, pCtx->esHid.u32Limit, pCtx->esHid.Attr.u, pszPrefix, pCtx->dr[4],  pszPrefix, pCtx->dr[5],
    2722                     pszPrefix, (RTSEL)pCtxCore->fs, pCtx->fsHid.u64Base, pCtx->fsHid.u32Limit, pCtx->fsHid.Attr.u, pszPrefix, pCtx->dr[6],  pszPrefix, pCtx->dr[7],
    2723                     pszPrefix, (RTSEL)pCtxCore->gs, pCtx->gsHid.u64Base, pCtx->gsHid.u32Limit, pCtx->gsHid.Attr.u, pszPrefix, pCtx->cr0,  pszPrefix, pCtx->cr2,
    2724                     pszPrefix, (RTSEL)pCtxCore->ss, pCtx->ssHid.u64Base, pCtx->ssHid.u32Limit, pCtx->ssHid.Attr.u, pszPrefix, pCtx->cr3,  pszPrefix, pCtx->cr4,
     2728                    pszPrefix, pCtxCore->cs.Sel, pCtx->cs.u64Base, pCtx->cs.u32Limit, pCtx->cs.Attr.u, pszPrefix, pCtx->dr[0],  pszPrefix, pCtx->dr[1],
     2729                    pszPrefix, pCtxCore->ds.Sel, pCtx->ds.u64Base, pCtx->ds.u32Limit, pCtx->ds.Attr.u, pszPrefix, pCtx->dr[2],  pszPrefix, pCtx->dr[3],
     2730                    pszPrefix, pCtxCore->es.Sel, pCtx->es.u64Base, pCtx->es.u32Limit, pCtx->es.Attr.u, pszPrefix, pCtx->dr[4],  pszPrefix, pCtx->dr[5],
     2731                    pszPrefix, pCtxCore->fs.Sel, pCtx->fs.u64Base, pCtx->fs.u32Limit, pCtx->fs.Attr.u, pszPrefix, pCtx->dr[6],  pszPrefix, pCtx->dr[7],
     2732                    pszPrefix, pCtxCore->gs.Sel, pCtx->gs.u64Base, pCtx->gs.u32Limit, pCtx->gs.Attr.u, pszPrefix, pCtx->cr0,  pszPrefix, pCtx->cr2,
     2733                    pszPrefix, pCtxCore->ss.Sel, pCtx->ss.u64Base, pCtx->ss.u32Limit, pCtx->ss.Attr.u, pszPrefix, pCtx->cr3,  pszPrefix, pCtx->cr4,
    27252734                    pszPrefix, pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt, pszPrefix, pCtx->idtr.pIdt, pCtx->idtr.cbIdt, pszPrefix, efl,
    2726                     pszPrefix, (RTSEL)pCtx->ldtr, pCtx->ldtrHid.u64Base, pCtx->ldtrHid.u32Limit, pCtx->ldtrHid.Attr.u,
    2727                     pszPrefix, (RTSEL)pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u,
     2735                    pszPrefix, pCtx->ldtr.Sel, pCtx->ldtr.u64Base, pCtx->ldtr.u32Limit, pCtx->ldtr.Attr.u,
     2736                    pszPrefix, pCtx->tr.Sel, pCtx->tr.u64Base, pCtx->tr.u32Limit, pCtx->tr.Attr.u,
    27282737                    pszPrefix, pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp);
    27292738
     
    29642973            /*pCtx->eax,*/ pCtx->ebx, /*pCtx->ecx, pCtx->edx,*/ pCtx->esi, pCtx->edi,
    29652974            /*pCtx->eip,*/ pCtx->esp, pCtx->ebp, X86_EFL_GET_IOPL(efl), szEFlags,
    2966             (RTSEL)pCtx->cs, (RTSEL)pCtx->ds, (RTSEL)pCtx->es, (RTSEL)pCtx->fs, (RTSEL)pCtx->gs, efl,
     2975            pCtx->cs, pCtx->ds, pCtx->es, pCtx->fs, pCtx->gs, efl,
    29672976            pCtx->cr0, /*pCtx->cr2,*/ pCtx->cr3, pCtx->cr4,
    29682977            pCtx->dr0, pCtx->dr1, pCtx->dr2, pCtx->dr3, pCtx->dr6, pCtx->dr7,
    2969             (uint32_t)pCtx->gdtr.uAddr, pCtx->gdtr.cb, (RTSEL)pCtx->ldtr,
     2978            (uint32_t)pCtx->gdtr.uAddr, pCtx->gdtr.cb, pCtx->ldtr,
    29702979            pCtx->SysEnter.cs, pCtx->SysEnter.eip, pCtx->SysEnter.esp);
    29712980    }
     
    30003009            pCtx->r14, pCtx->r15,
    30013010            X86_EFL_GET_IOPL(efl), szEFlags,
    3002             (RTSEL)pCtx->cs, (RTSEL)pCtx->ds, (RTSEL)pCtx->es, (RTSEL)pCtx->fs, (RTSEL)pCtx->gs, efl,
     3011            pCtx->cs, pCtx->ds, pCtx->es, pCtx->fs, pCtx->gs, efl,
    30033012            pCtx->cr0, /*pCtx->cr2,*/ pCtx->cr3,
    30043013            pCtx->cr4, pCtx->ldtr, pCtx->tr,
     
    38273836        if (CPUMAreHiddenSelRegsValid(pVCpu))
    38283837        {
    3829             State.f64Bits         = enmMode >= PGMMODE_AMD64 && pCtx->csHid.Attr.n.u1Long;
    3830             State.GCPtrSegBase    = pCtx->csHid.u64Base;
    3831             State.GCPtrSegEnd     = pCtx->csHid.u32Limit + 1 + (RTGCUINTPTR)pCtx->csHid.u64Base;
    3832             State.cbSegLimit      = pCtx->csHid.u32Limit;
     3838            State.f64Bits         = enmMode >= PGMMODE_AMD64 && pCtx->cs.Attr.n.u1Long;
     3839            State.GCPtrSegBase    = pCtx->cs.u64Base;
     3840            State.GCPtrSegEnd     = pCtx->cs.u32Limit + 1 + (RTGCUINTPTR)pCtx->cs.u64Base;
     3841            State.cbSegLimit      = pCtx->cs.u32Limit;
    38333842            enmDisCpuMode         = (State.f64Bits)
    38343843                                    ? DISCPUMODE_64BIT
    3835                                     : pCtx->csHid.Attr.n.u1DefBig
     3844                                    : pCtx->cs.Attr.n.u1DefBig
    38363845                                    ? DISCPUMODE_32BIT
    38373846                                    : DISCPUMODE_16BIT;
     
    38413850            DBGFSELINFO SelInfo;
    38423851
    3843             rc = SELMR3GetShadowSelectorInfo(pVM, pCtx->cs, &SelInfo);
     3852            rc = SELMR3GetShadowSelectorInfo(pVM, pCtx->cs.Sel, &SelInfo);
    38443853            if (RT_FAILURE(rc))
    38453854            {
    3846                 AssertMsgFailed(("SELMR3GetShadowSelectorInfo failed for %04X:%RGv rc=%d\n", pCtx->cs, GCPtrPC, rc));
     3855                AssertMsgFailed(("SELMR3GetShadowSelectorInfo failed for %04X:%RGv rc=%d\n", pCtx->cs.Sel, GCPtrPC, rc));
    38473856                return rc;
    38483857            }
     
    38513860             * Validate the selector.
    38523861             */
    3853             rc = DBGFR3SelInfoValidateCS(&SelInfo, pCtx->ss);
     3862            rc = DBGFR3SelInfoValidateCS(&SelInfo, pCtx->ss.Sel);
    38543863            if (RT_FAILURE(rc))
    38553864            {
    3856                 AssertMsgFailed(("SELMSelInfoValidateCS failed for %04X:%RGv rc=%d\n", pCtx->cs, GCPtrPC, rc));
     3865                AssertMsgFailed(("SELMSelInfoValidateCS failed for %04X:%RGv rc=%d\n", pCtx->cs.Sel, GCPtrPC, rc));
    38573866                return rc;
    38583867            }
     
    38673876        /* real or V86 mode */
    38683877        enmDisCpuMode         = DISCPUMODE_16BIT;
    3869         State.GCPtrSegBase    = pCtx->cs * 16;
     3878        State.GCPtrSegBase    = pCtx->cs.Sel * 16;
    38703879        State.GCPtrSegEnd     = 0xFFFFFFFF;
    38713880        State.cbSegLimit      = 0xFFFFFFFF;
     
    38953904    }
    38963905    else
    3897         Log(("CPUMR3DisasmInstrCPU: DISInstr failed for %04X:%RGv rc=%Rrc\n", pCtx->cs, GCPtrPC, rc));
     3906        Log(("CPUMR3DisasmInstrCPU: DISInstr failed for %04X:%RGv rc=%Rrc\n", pCtx->cs.Sel, GCPtrPC, rc));
    38983907
    38993908    /* Release mapping lock acquired in cpumR3DisasInstrRead. */
     
    40094018     * Are we in Ring-0?
    40104019     */
    4011     if (    pCtxCore->ss && (pCtxCore->ss & X86_SEL_RPL) == 0
     4020    if (    pCtxCore->ss.Sel && (pCtxCore->ss.Sel & X86_SEL_RPL) == 0
    40124021        &&  !pCtxCore->eflags.Bits.u1VM)
    40134022    {
     
    40204029         * Set CPL to Ring-1.
    40214030         */
    4022         pCtxCore->ss |= 1;
    4023         if (pCtxCore->cs && (pCtxCore->cs & X86_SEL_RPL) == 0)
    4024             pCtxCore->cs |= 1;
     4031        pCtxCore->ss.Sel |= 1;
     4032        if (pCtxCore->cs.Sel && (pCtxCore->cs.Sel & X86_SEL_RPL) == 0)
     4033            pCtxCore->cs.Sel |= 1;
    40254034    }
    40264035    else
    40274036    {
    4028         AssertMsg((pCtxCore->ss & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,
     4037        AssertMsg((pCtxCore->ss.Sel & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,
    40294038                  ("ring-1 code not supported\n"));
    40304039        /*
     
    40434052     */
    40444053    AssertMsg((pCtxCore->eflags.u32 & X86_EFL_IF), ("X86_EFL_IF is clear\n"));
    4045     AssertReleaseMsg(   pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss & X86_SEL_RPL)
     4054    AssertReleaseMsg(   pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss.Sel & X86_SEL_RPL)
    40464055                     || pCtxCore->eflags.Bits.u1VM,
    4047                      ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss & X86_SEL_RPL));
     4056                     ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
    40484057    Assert((pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP));
    40494058
     
    40824091    if (!pCtxCore)
    40834092        pCtxCore = CPUMCTX2CORE(pCtx);
    4084     Assert(pCtxCore->eflags.Bits.u1VM || (pCtxCore->ss & X86_SEL_RPL));
    4085     AssertMsg(pCtxCore->eflags.Bits.u1VM || pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss & X86_SEL_RPL),
    4086               ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss & X86_SEL_RPL));
     4093    Assert(pCtxCore->eflags.Bits.u1VM || (pCtxCore->ss.Sel & X86_SEL_RPL));
     4094    AssertMsg(pCtxCore->eflags.Bits.u1VM || pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss.Sel & X86_SEL_RPL),
     4095              ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
    40874096
    40884097    /*
    40894098     * Are we executing in raw ring-1?
    40904099     */
    4091     if (    (pCtxCore->ss & X86_SEL_RPL) == 1
     4100    if (    (pCtxCore->ss.Sel & X86_SEL_RPL) == 1
    40924101        &&  !pCtxCore->eflags.Bits.u1VM)
    40934102    {
     
    40984107        /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
    40994108        /** @todo See what happens if we remove this. */
    4100         if ((pCtxCore->ds & X86_SEL_RPL) == 1)
    4101             pCtxCore->ds &= ~X86_SEL_RPL;
    4102         if ((pCtxCore->es & X86_SEL_RPL) == 1)
    4103             pCtxCore->es &= ~X86_SEL_RPL;
    4104         if ((pCtxCore->fs & X86_SEL_RPL) == 1)
    4105             pCtxCore->fs &= ~X86_SEL_RPL;
    4106         if ((pCtxCore->gs & X86_SEL_RPL) == 1)
    4107             pCtxCore->gs &= ~X86_SEL_RPL;
     4109        if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
     4110            pCtxCore->ds.Sel &= ~X86_SEL_RPL;
     4111        if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
     4112            pCtxCore->es.Sel &= ~X86_SEL_RPL;
     4113        if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
     4114            pCtxCore->fs.Sel &= ~X86_SEL_RPL;
     4115        if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
     4116            pCtxCore->gs.Sel &= ~X86_SEL_RPL;
    41084117
    41094118        /*
    41104119         * Ring-1 selector => Ring-0.
    41114120         */
    4112         pCtxCore->ss &= ~X86_SEL_RPL;
    4113         if ((pCtxCore->cs & X86_SEL_RPL) == 1)
    4114             pCtxCore->cs &= ~X86_SEL_RPL;
     4121        pCtxCore->ss.Sel &= ~X86_SEL_RPL;
     4122        if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
     4123            pCtxCore->cs.Sel &= ~X86_SEL_RPL;
    41154124    }
    41164125    else
     
    41234132        {
    41244133            /** @todo See what happens if we remove this. */
    4125             if ((pCtxCore->ds & X86_SEL_RPL) == 1)
    4126                 pCtxCore->ds &= ~X86_SEL_RPL;
    4127             if ((pCtxCore->es & X86_SEL_RPL) == 1)
    4128                 pCtxCore->es &= ~X86_SEL_RPL;
    4129             if ((pCtxCore->fs & X86_SEL_RPL) == 1)
    4130                 pCtxCore->fs &= ~X86_SEL_RPL;
    4131             if ((pCtxCore->gs & X86_SEL_RPL) == 1)
    4132                 pCtxCore->gs &= ~X86_SEL_RPL;
     4134            if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
     4135                pCtxCore->ds.Sel &= ~X86_SEL_RPL;
     4136            if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
     4137                pCtxCore->es.Sel &= ~X86_SEL_RPL;
     4138            if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
     4139                pCtxCore->fs.Sel &= ~X86_SEL_RPL;
     4140            if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
     4141                pCtxCore->gs.Sel &= ~X86_SEL_RPL;
    41334142        }
    41344143    }
  • trunk/src/VBox/VMM/VMMR3/CPUMDbg.cpp

    r41803 r41906  
    10131013
    10141014#define CPU_REG_SEG(UName, LName) \
    1015     CPU_REG_RW_AS(#LName,           UName,          U16, LName,                 cpumR3RegGet_Generic, cpumR3RegSet_seg,     NULL,                       NULL                ), \
    1016     CPU_REG_RW_AS(#LName "_attr",   UName##_ATTR,   U32, LName##Hid.Attr.u,     cpumR3RegGet_Generic, cpumR3RegSet_Generic, NULL,                       g_aCpumRegFields_seg), \
    1017     CPU_REG_RW_AS(#LName "_base",   UName##_BASE,   U64, LName##Hid.u64Base,    cpumR3RegGet_Generic, cpumR3RegSet_Generic, NULL,                       NULL                ), \
    1018     CPU_REG_RW_AS(#LName "_lim",    UName##_LIMIT,  U32, LName##Hid.u32Limit,   cpumR3RegGet_Generic, cpumR3RegSet_Generic, NULL,                       NULL                )
     1015    CPU_REG_RW_AS(#LName,           UName,          U16, LName.Sel,             cpumR3RegGet_Generic, cpumR3RegSet_seg,     NULL,                       NULL                ), \
     1016    CPU_REG_RW_AS(#LName "_attr",   UName##_ATTR,   U32, LName.Attr.u,          cpumR3RegGet_Generic, cpumR3RegSet_Generic, NULL,                       g_aCpumRegFields_seg), \
     1017    CPU_REG_RW_AS(#LName "_base",   UName##_BASE,   U64, LName.u64Base,         cpumR3RegGet_Generic, cpumR3RegSet_Generic, NULL,                       NULL                ), \
     1018    CPU_REG_RW_AS(#LName "_lim",    UName##_LIMIT,  U32, LName.u32Limit,        cpumR3RegGet_Generic, cpumR3RegSet_Generic, NULL,                       NULL                )
    10191019
    10201020#define CPU_REG_MM(n) \
  • trunk/src/VBox/VMM/VMMR3/CSAM.cpp

    r41886 r41906  
    22952295    {
    22962296        /* Assuming 32 bits code for now. */
    2297         Assert(SELMGetCpuModeFromSelector(VMMGetCpu0(pVM), pCtxCore->eflags, pCtxCore->cs, &pCtxCore->csHid) == DISCPUMODE_32BIT);
     2297        Assert(SELMGetCpuModeFromSelector(VMMGetCpu0(pVM), pCtxCore->eflags, pCtxCore->cs.Sel, &pCtxCore->cs) == DISCPUMODE_32BIT);
    22982298
    22992299        pInstrGC = SELMToFlat(pVM, DISSELREG_CS, pCtxCore, pInstrGC);
  • trunk/src/VBox/VMM/VMMR3/DBGF.cpp

    r41801 r41906  
    588588        /* @todo SMP support!! */
    589589        PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu(pVM));
    590         RTGCPTR  eip = pCtx->rip + pCtx->csHid.u64Base;
     590        RTGCPTR  eip = pCtx->rip + pCtx->cs.u64Base;
    591591#endif
    592592        for (iBp = 0; iBp < RT_ELEMENTS(pVM->dbgf.s.aBreakpoints); iBp++)
  • trunk/src/VBox/VMM/VMMR3/DBGFDisas.cpp

    r41803 r41906  
    353353        else
    354354            pCtxCore = CPUMGetHyperCtxCore(pVCpu);
    355         Sel        = pCtxCore->cs;
    356         pHiddenSel = (CPUMSELREGHID *)&pCtxCore->csHid;
     355        Sel        = pCtxCore->cs.Sel;
     356        pHiddenSel = (PCPUMSELREGHID)&pCtxCore->cs;
    357357        GCPtr      = pCtxCore->rip;
    358358    }
     
    413413        {   /* Assume the current CS defines the execution mode. */
    414414            pCtxCore   = CPUMGetGuestCtxCore(pVCpu);
    415             pHiddenSel = (CPUMSELREGHID *)&pCtxCore->csHid;
     415            pHiddenSel = (CPUMSELREGHID *)&pCtxCore->cs;
    416416
    417417            SelInfo.u.Raw.Gen.u1Present     = pHiddenSel->Attr.n.u1Present;
  • trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp

    r41783 r41906  
    301301        pCur->AddrPC = *pAddrPC;
    302302    else
    303         rc = DBGFR3AddrFromSelOff(pVM, idCpu, &pCur->AddrPC, pCtxCore->cs, pCtxCore->rip);
     303        rc = DBGFR3AddrFromSelOff(pVM, idCpu, &pCur->AddrPC, pCtxCore->cs.Sel, pCtxCore->rip);
    304304    if (RT_SUCCESS(rc))
    305305    {
     
    341341            pCur->AddrStack = *pAddrStack;
    342342        else
    343             rc = DBGFR3AddrFromSelOff(pVM, idCpu, &pCur->AddrStack, pCtxCore->ss, pCtxCore->rsp & fAddrMask);
     343            rc = DBGFR3AddrFromSelOff(pVM, idCpu, &pCur->AddrStack, pCtxCore->ss.Sel, pCtxCore->rsp & fAddrMask);
    344344
    345345        if (pAddrFrame)
    346346            pCur->AddrFrame = *pAddrFrame;
    347347        else if (RT_SUCCESS(rc))
    348             rc = DBGFR3AddrFromSelOff(pVM, idCpu, &pCur->AddrFrame, pCtxCore->ss, pCtxCore->rbp & fAddrMask);
     348            rc = DBGFR3AddrFromSelOff(pVM, idCpu, &pCur->AddrFrame, pCtxCore->ss.Sel, pCtxCore->rbp & fAddrMask);
    349349    }
    350350    else
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r41801 r41906  
    965965
    966966    if (pCtx->eflags.Bits.u1VM)
    967         Log(("EMV86: %04X:%08X IF=%d\n", pCtx->cs, pCtx->eip, pCtx->eflags.Bits.u1IF));
     967        Log(("EMV86: %04X:%08X IF=%d\n", pCtx->cs.Sel, pCtx->eip, pCtx->eflags.Bits.u1IF));
    968968    else
    969         Log(("EMR%d: %04X:%08X ESP=%08X IF=%d CR0=%x eflags=%x\n", cpl, pCtx->cs, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, (uint32_t)pCtx->cr0, pCtx->eflags.u));
     969        Log(("EMR%d: %04X:%08X ESP=%08X IF=%d CR0=%x eflags=%x\n", cpl, pCtx->cs.Sel, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, (uint32_t)pCtx->cr0, pCtx->eflags.u));
    970970#endif
    971971    STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatREMTotal, a);
     
    12431243    }
    12441244
    1245     unsigned uSS = pCtx->ss;
     1245    unsigned uSS = pCtx->ss.Sel;
    12461246    if (    pCtx->eflags.Bits.u1VM
    12471247        ||  (uSS & X86_SEL_RPL) == 3)
     
    12761276        // Let's start with pure 32 bits ring 0 code first
    12771277        /** @todo What's pure 32-bit mode? flat? */
    1278         if (    !(pCtx->ssHid.Attr.n.u1DefBig)
    1279             ||  !(pCtx->csHid.Attr.n.u1DefBig))
     1278        if (    !(pCtx->ss.Attr.n.u1DefBig)
     1279            ||  !(pCtx->cs.Attr.n.u1DefBig))
    12801280        {
    12811281            Log2(("raw r0 mode refused: SS/CS not 32bit\n"));
  • trunk/src/VBox/VMM/VMMR3/EMHwaccm.cpp

    r41836 r41906  
    231231#endif /* 0 */
    232232    STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, a);
    233     Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
     233    Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
    234234#ifdef VBOX_WITH_REM
    235235    EMRemLock(pVM);
     
    469469    PCPUMCTX pCtx = pVCpu->em.s.pCtx;
    470470
    471     LogFlow(("emR3HwAccExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pCtx->cs, (RTGCPTR)pCtx->rip));
     471    LogFlow(("emR3HwAccExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pCtx->cs.Sel, (RTGCPTR)pCtx->rip));
    472472    *pfFFDone = false;
    473473
     
    509509         */
    510510        if (TRPMHasTrap(pVCpu))
    511             Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), pCtx->cs, (RTGCPTR)pCtx->rip));
     511            Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), pCtx->cs.Sel, (RTGCPTR)pCtx->rip));
    512512
    513513        uint32_t cpl = CPUMGetGuestCPL(pVCpu, CPUMCTX2CORE(pCtx));
     
    518518                Log(("HWV86: %08X IF=%d\n", pCtx->eip, pCtx->eflags.Bits.u1IF));
    519519            else if (CPUMIsGuestIn64BitCodeEx(pCtx))
    520                 Log(("HWR%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pCtx->cs, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
     520                Log(("HWR%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pCtx->cs.Sel, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
    521521            else
    522                 Log(("HWR%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pCtx->cs,          pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
     522                Log(("HWR%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pCtx->cs.Sel,          pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
    523523        }
    524524        else
     
    527527                Log(("HWV86-CPU%d: %08X IF=%d\n", pVCpu->idCpu, pCtx->eip, pCtx->eflags.Bits.u1IF));
    528528            else if (CPUMIsGuestIn64BitCodeEx(pCtx))
    529                 Log(("HWR%d-CPU%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pCtx->cs, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
     529                Log(("HWR%d-CPU%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pCtx->cs.Sel, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
    530530            else
    531                 Log(("HWR%d-CPU%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pCtx->cs,          pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
     531                Log(("HWR%d-CPU%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pCtx->cs.Sel,          pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));
    532532        }
    533533#endif /* LOG_ENABLED */
  • trunk/src/VBox/VMM/VMMR3/EMRaw.cpp

    r41801 r41906  
    123123    PCPUMCTX    pCtx = pVCpu->em.s.pCtx;
    124124    Assert(pVCpu->em.s.enmState == EMSTATE_DEBUG_HYPER);
    125     Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr\n", pCtx->cs, pCtx->eip, pCtx->eflags));
     125    Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr\n", pCtx->cs.Sel, pCtx->eip, pCtx->eflags));
    126126
    127127    /*
     
    131131    CPUMSetHyperEFlags(pVCpu, CPUMGetHyperEFlags(pVCpu) | X86_EFL_RF);
    132132    rc = VMMR3ResumeHyper(pVM, pVCpu);
    133     Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr - returned from GC with rc=%Rrc\n", pCtx->cs, pCtx->eip, pCtx->eflags, rc));
     133    Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr - returned from GC with rc=%Rrc\n", pCtx->cs.Sel, pCtx->eip, pCtx->eflags, rc));
    134134    rc = CPUMR3RawLeave(pVCpu, NULL, rc);
    135135    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
     
    367367
    368368    STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, a);
    369     Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
     369    Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
    370370#ifdef VBOX_WITH_REM
    371371    EMRemLock(pVM);
     
    578578     */
    579579    /** @todo move this up before the dispatching? */
    580     if (    (pCtx->ss & X86_SEL_RPL) <= 1
     580    if (    (pCtx->ss.Sel & X86_SEL_RPL) <= 1
    581581        &&  !pCtx->eflags.Bits.u1VM)
    582582    {
     
    643643    int rc2 = PGMGstGetPage(pVCpu, uCR2, &fFlags, &GCPhys);
    644644    Log(("emR3RawGuestTrap: cs:eip=%04x:%08x: trap=%02x err=%08x cr2=%08x cr0=%08x%s: Phys=%RGp fFlags=%08llx %s %s %s%s rc2=%d\n",
    645          pCtx->cs, pCtx->eip, u8TrapNo, uErrorCode, uCR2, (uint32_t)pCtx->cr0, (enmType == TRPM_SOFTWARE_INT) ? " software" : "",  GCPhys, fFlags,
     645         pCtx->cs.Sel, pCtx->eip, u8TrapNo, uErrorCode, uCR2, (uint32_t)pCtx->cr0,
     646         (enmType == TRPM_SOFTWARE_INT) ? " software" : "",  GCPhys, fFlags,
    646647         fFlags & X86_PTE_P  ? "P " : "NP", fFlags & X86_PTE_US ? "U"  : "S",
    647648         fFlags & X86_PTE_RW ? "RW" : "R0", fFlags & X86_PTE_G  ? " G" : "", rc2));
     
    684685            {
    685686                rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(pCtx), pCtx->eip),
    686                                         (SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs, &pCtx->csHid) == DISCPUMODE_32BIT) ? PATMFL_CODE32 : 0);
     687                                           SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs.Sel, &pCtx->cs)
     688                                        == DISCPUMODE_32BIT ? PATMFL_CODE32 : 0);
    687689                if (RT_SUCCESS(rc))
    688690                {
     
    929931            return VERR_EM_RAW_PATCH_CONFLICT;
    930932        }
    931         if (   (pCtx->ss & X86_SEL_RPL) == 0
     933        if (   (pCtx->ss.Sel & X86_SEL_RPL) == 0
    932934            && !pCtx->eflags.Bits.u1VM
    933935            && !PATMIsPatchGCAddr(pVM, pCtx->eip))
    934936        {
    935937            int rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(pCtx), pCtx->eip),
    936                                         (SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs, &pCtx->csHid) == DISCPUMODE_32BIT) ? PATMFL_CODE32 : 0);
     938                                        (   SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs.Sel, &pCtx->cs)
     939                                         == DISCPUMODE_32BIT) ? PATMFL_CODE32 : 0);
    937940            if (RT_SUCCESS(rc))
    938941            {
     
    10391042        }
    10401043#endif /* VBOX_WITH_STATISTICS */
    1041         if (    (pCtx->ss & X86_SEL_RPL) == 0
     1044        if (    (pCtx->ss.Sel & X86_SEL_RPL) == 0
    10421045            &&  !pCtx->eflags.Bits.u1VM
    1043             &&  SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs, &pCtx->csHid) == DISCPUMODE_32BIT)
     1046            &&  SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs.Sel, &pCtx->cs) == DISCPUMODE_32BIT)
    10441047        {
    10451048            STAM_PROFILE_START(&pVCpu->em.s.StatPrivEmu, a);
     
    13391342    int      rc = VERR_IPE_UNINITIALIZED_STATUS;
    13401343    PCPUMCTX pCtx = pVCpu->em.s.pCtx;
    1341     LogFlow(("emR3RawExecute: (cs:eip=%04x:%08x)\n", pCtx->cs, pCtx->eip));
     1344    LogFlow(("emR3RawExecute: (cs:eip=%04x:%08x)\n", pCtx->cs.Sel, pCtx->eip));
    13421345    pVCpu->em.s.fForceRAW = false;
    13431346    *pfFFDone = false;
     
    13611364        Assert(REMR3QueryPendingInterrupt(pVM, pVCpu) == REM_NO_PENDING_IRQ);
    13621365# endif
    1363         Assert(pCtx->eflags.Bits.u1VM || (pCtx->ss & X86_SEL_RPL) == 3 || (pCtx->ss & X86_SEL_RPL) == 0);
     1366        Assert(pCtx->eflags.Bits.u1VM || (pCtx->ss.Sel & X86_SEL_RPL) == 3 || (pCtx->ss.Sel & X86_SEL_RPL) == 0);
    13641367        AssertMsg(   (pCtx->eflags.u32 & X86_EFL_IF)
    13651368                  || PATMShouldUseRawMode(pVM, (RTGCPTR)pCtx->eip),
     
    14011404         * Scan code before executing it. Don't bother with user mode or V86 code
    14021405         */
    1403         if (    (pCtx->ss & X86_SEL_RPL) <= 1
     1406        if (    (pCtx->ss.Sel & X86_SEL_RPL) <= 1
    14041407            &&  !pCtx->eflags.Bits.u1VM
    14051408            && !PATMIsPatchGCAddr(pVM, pCtx->eip))
     
    14271430        PPATMGCSTATE pGCState = PATMR3QueryGCStateHC(pVM);
    14281431        if (pCtx->eflags.Bits.u1VM)
    1429             Log(("RV86: %04X:%08X IF=%d VMFlags=%x\n", pCtx->cs, pCtx->eip, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags));
    1430         else if ((pCtx->ss & X86_SEL_RPL) == 1)
     1432            Log(("RV86: %04X:%08X IF=%d VMFlags=%x\n", pCtx->cs.Sel, pCtx->eip, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags));
     1433        else if ((pCtx->ss.Sel & X86_SEL_RPL) == 1)
    14311434        {
    14321435            bool fCSAMScanned = CSAMIsPageScanned(pVM, (RTGCPTR)pCtx->eip);
    1433             Log(("RR0: %08X ESP=%08X IF=%d VMFlags=%x PIF=%d CPL=%d (Scanned=%d)\n", pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags, pGCState->fPIF, (pCtx->ss & X86_SEL_RPL), fCSAMScanned));
    1434         }
    1435         else if ((pCtx->ss & X86_SEL_RPL) == 3)
     1436            Log(("RR0: %08X ESP=%08X IF=%d VMFlags=%x PIF=%d CPL=%d (Scanned=%d)\n", pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags, pGCState->fPIF, (pCtx->ss.Sel & X86_SEL_RPL), fCSAMScanned));
     1437        }
     1438        else if ((pCtx->ss.Sel & X86_SEL_RPL) == 3)
    14361439            Log(("RR3: %08X ESP=%08X IF=%d VMFlags=%x\n", pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags));
    14371440#endif /* LOG_ENABLED */
     
    14611464        STAM_PROFILE_ADV_START(&pVCpu->em.s.StatRAWTail, d);
    14621465
    1463         LogFlow(("RR0-E: %08X ESP=%08X IF=%d VMFlags=%x PIF=%d CPL=%d\n", pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags, pGCState->fPIF, (pCtx->ss & X86_SEL_RPL)));
     1466        LogFlow(("RR0-E: %08X ESP=%08X IF=%d VMFlags=%x PIF=%d CPL=%d\n", pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags, pGCState->fPIF, (pCtx->ss.Sel & X86_SEL_RPL)));
    14641467        LogFlow(("VMMR3RawRunGC returned %Rrc\n", rc));
    14651468
     
    15421545            ||  VMCPU_FF_ISPENDING(pVCpu, ~VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK))
    15431546        {
    1544             Assert(pCtx->eflags.Bits.u1VM || (pCtx->ss & X86_SEL_RPL) != 1);
     1547            Assert(pCtx->eflags.Bits.u1VM || (pCtx->ss.Sel & X86_SEL_RPL) != 1);
    15451548
    15461549            STAM_REL_PROFILE_ADV_SUSPEND(&pVCpu->em.s.StatRAWTotal, a);
  • trunk/src/VBox/VMM/VMMR3/HWACCM.cpp

    r41894 r41906  
    15171517
    15181518            /* After a real mode switch to protected mode we must force
    1519              * CPL to 0. Our real mode emulation had to set it to 3.
    1520              */
    1521             pCtx->ssHid.Attr.n.u2Dpl  = 0;
     1519               CPL to 0. Our real mode emulation had to set it to 3. */
     1520            pCtx->ss.Attr.n.u2Dpl  = 0;
    15221521        }
    15231522    }
     
    21632162            {
    21642163                char     szOutput[256];
    2165                 rc = DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, GCPtrInstr, DBGF_DISAS_FLAGS_DEFAULT_MODE,
     2164                rc = DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, GCPtrInstr, DBGF_DISAS_FLAGS_DEFAULT_MODE,
    21662165                                        szOutput, sizeof(szOutput), &cbCurInstr);
    21672166                if (RT_SUCCESS(rc))
     
    23052304            if (CPUMIsGuestInRealModeEx(pCtx))
    23062305            {
    2307                 /* VT-x will not allow high selector bases in v86 mode; fall back to the recompiler in that case.
    2308                  * The base must also be equal to (sel << 4).
    2309                  */
    2310                 if (   (   pCtx->cs != (pCtx->csHid.u64Base >> 4)
    2311                         && pCtx->csHid.u64Base != 0xffff0000 /* we can deal with the BIOS code as it's also mapped into the lower region. */)
    2312                     || (pCtx->csHid.u32Limit != 0xffff)
    2313                     || (pCtx->dsHid.u32Limit != 0xffff)
    2314                     || (pCtx->esHid.u32Limit != 0xffff)
    2315                     || (pCtx->ssHid.u32Limit != 0xffff)
    2316                     || (pCtx->fsHid.u32Limit != 0xffff)
    2317                     || (pCtx->gsHid.u32Limit != 0xffff)
    2318                     || pCtx->ds != (pCtx->dsHid.u64Base >> 4)
    2319                     || pCtx->es != (pCtx->esHid.u64Base >> 4)
    2320                     || pCtx->fs != (pCtx->fsHid.u64Base >> 4)
    2321                     || pCtx->gs != (pCtx->gsHid.u64Base >> 4)
    2322                     || pCtx->ss != (pCtx->ssHid.u64Base >> 4))
     2306                /* VT-x will not allow high selector bases in v86 mode; fall
     2307                   back to the recompiler in that case.
     2308                   The base must also be equal to (sel << 4). */
     2309                if (   (   pCtx->cs.Sel != (pCtx->cs.u64Base >> 4)
     2310                        && pCtx->cs.u64Base != 0xffff0000 /* we can deal with the BIOS code as it's also mapped into the lower region. */)
     2311                    || (pCtx->cs.u32Limit != 0xffff)
     2312                    || (pCtx->ds.u32Limit != 0xffff)
     2313                    || (pCtx->es.u32Limit != 0xffff)
     2314                    || (pCtx->ss.u32Limit != 0xffff)
     2315                    || (pCtx->fs.u32Limit != 0xffff)
     2316                    || (pCtx->gs.u32Limit != 0xffff)
     2317                    || pCtx->ds.Sel != (pCtx->ds.u64Base >> 4)
     2318                    || pCtx->es.Sel != (pCtx->es.u64Base >> 4)
     2319                    || pCtx->fs.Sel != (pCtx->fs.u64Base >> 4)
     2320                    || pCtx->gs.Sel != (pCtx->gs.u64Base >> 4)
     2321                    || pCtx->ss.Sel != (pCtx->ss.u64Base >> 4))
    23232322                {
    23242323                    return false;
     
    23282327            {
    23292328                PGMMODE enmGuestMode = PGMGetGuestMode(pVCpu);
    2330                 /* Verify the requirements for executing code in protected mode. VT-x can't handle the CPU state right after a switch
    2331                  * from real to protected mode. (all sorts of RPL & DPL assumptions)
    2332                  */
     2329                /* Verify the requirements for executing code in protected
     2330                   mode. VT-x can't handle the CPU state right after a switch
     2331                   from real to protected mode. (all sorts of RPL & DPL assumptions) */
    23332332                if (    pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode == PGMMODE_REAL
    23342333                    &&  enmGuestMode >= PGMMODE_PROTECTED)
    23352334                {
    2336                     if (   (pCtx->cs & X86_SEL_RPL)
    2337                         || (pCtx->ds & X86_SEL_RPL)
    2338                         || (pCtx->es & X86_SEL_RPL)
    2339                         || (pCtx->fs & X86_SEL_RPL)
    2340                         || (pCtx->gs & X86_SEL_RPL)
    2341                         || (pCtx->ss & X86_SEL_RPL))
     2335                    if (   (pCtx->cs.Sel & X86_SEL_RPL)
     2336                        || (pCtx->ds.Sel & X86_SEL_RPL)
     2337                        || (pCtx->es.Sel & X86_SEL_RPL)
     2338                        || (pCtx->fs.Sel & X86_SEL_RPL)
     2339                        || (pCtx->gs.Sel & X86_SEL_RPL)
     2340                        || (pCtx->ss.Sel & X86_SEL_RPL))
    23422341                    {
    23432342                        return false;
     
    23462345                /* VT-x also chokes on invalid tr or ldtr selectors (minix) */
    23472346                if (    pCtx->gdtr.cbGdt
    2348                     &&  (   pCtx->tr > pCtx->gdtr.cbGdt
    2349                          || pCtx->ldtr > pCtx->gdtr.cbGdt))
     2347                    &&  (   pCtx->tr.Sel > pCtx->gdtr.cbGdt
     2348                         || pCtx->ldtr.Sel > pCtx->gdtr.cbGdt))
    23502349                {
    23512350                        return false;
     
    23702369
    23712370                /* Too early for VT-x; Solaris guests will fail with a guru meditation otherwise; same for XP. */
    2372                 if (pCtx->idtr.pIdt == 0 || pCtx->idtr.cbIdt == 0 || pCtx->tr == 0)
     2371                if (pCtx->idtr.pIdt == 0 || pCtx->idtr.cbIdt == 0 || pCtx->tr.Sel == 0)
    23732372                    return false;
    23742373
     
    23762375                /* Windows XP; switch to protected mode; all selectors are marked not present in the
    23772376                 * hidden registers (possible recompiler bug; see load_seg_vm) */
    2378                 if (pCtx->csHid.Attr.n.u1Present == 0)
     2377                if (pCtx->cs.Attr.n.u1Present == 0)
    23792378                    return false;
    2380                 if (pCtx->ssHid.Attr.n.u1Present == 0)
     2379                if (pCtx->ss.Attr.n.u1Present == 0)
    23812380                    return false;
    23822381
     
    23852384                /** @todo This check is actually wrong, it doesn't take the direction of the
    23862385                 *        stack segment into account. But, it does the job for now. */
    2387                 if (pCtx->rsp >= pCtx->ssHid.u32Limit)
     2386                if (pCtx->rsp >= pCtx->ss.u32Limit)
    23882387                    return false;
    23892388#if 0
    2390                 if (    pCtx->cs >= pCtx->gdtr.cbGdt
    2391                     ||  pCtx->ss >= pCtx->gdtr.cbGdt
    2392                     ||  pCtx->ds >= pCtx->gdtr.cbGdt
    2393                     ||  pCtx->es >= pCtx->gdtr.cbGdt
    2394                     ||  pCtx->fs >= pCtx->gdtr.cbGdt
    2395                     ||  pCtx->gs >= pCtx->gdtr.cbGdt)
     2389                if (    pCtx->cs.Sel >= pCtx->gdtr.cbGdt
     2390                    ||  pCtx->ss.Sel >= pCtx->gdtr.cbGdt
     2391                    ||  pCtx->ds.Sel >= pCtx->gdtr.cbGdt
     2392                    ||  pCtx->es.Sel >= pCtx->gdtr.cbGdt
     2393                    ||  pCtx->fs.Sel >= pCtx->gdtr.cbGdt
     2394                    ||  pCtx->gs.Sel >= pCtx->gdtr.cbGdt)
    23962395                    return false;
    23972396#endif
  • trunk/src/VBox/VMM/VMMR3/PATM.cpp

    r41898 r41906  
    40884088        if (pInstrGCFlat != pInstrGC)
    40894089        {
    4090             Log(("PATMR3InstallPatch: code selector not wide open: %04x:%RRv != %RRv eflags=%08x\n", pCtx->cs, pInstrGCFlat, pInstrGC, pCtx->eflags.u32));
     4090            Log(("PATMR3InstallPatch: code selector not wide open: %04x:%RRv != %RRv eflags=%08x\n", pCtx->cs.Sel, pInstrGCFlat, pInstrGC, pCtx->eflags.u32));
    40914091            return VERR_PATCHING_REFUSED;
    40924092        }
     
    61056105#ifdef DEBUG
    61066106        char szBuf[256];
    6107         DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurPatchInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
     6107        DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, pCurPatchInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
    61086108                           szBuf, sizeof(szBuf), NULL);
    61096109        Log(("DIRTY: %s\n", szBuf));
     
    61686168#ifdef DEBUG
    61696169                char szBuf[256];
    6170                 DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
     6170                DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, pCurInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
    61716171                                   szBuf, sizeof(szBuf), NULL);
    61726172                Log(("NEW:   %s\n", szBuf));
     
    61846184#ifdef DEBUG
    61856185                char szBuf[256];
    6186                 DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
     6186                DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, pCurInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
    61876187                                   szBuf, sizeof(szBuf), NULL);
    61886188                Log(("NEW:   %s (FAILED)\n", szBuf));
     
    62216221#ifdef DEBUG
    62226222                            char szBuf[256];
    6223                             DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurPatchInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
     6223                            DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, pCurPatchInstrGC, DBGF_DISAS_FLAGS_DEFAULT_MODE,
    62246224                                               szBuf, sizeof(szBuf), NULL);
    62256225                            Log(("FILL:  %s\n", szBuf));
     
    62336233#ifdef DEBUG
    62346234                                char szBuf[256];
    6235                                 DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurPatchInstrGC + i,
     6235                                DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, pCurPatchInstrGC + i,
    62366236                                                   DBGF_DISAS_FLAGS_DEFAULT_MODE, szBuf, sizeof(szBuf), NULL);
    62376237                                Log(("FILL:  %s\n", szBuf));
     
    64256425
    64266426        char szBuf[256];
    6427         DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pEip, DBGF_DISAS_FLAGS_DEFAULT_MODE, szBuf, sizeof(szBuf), NULL);
     6427        DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs.Sel, pEip, DBGF_DISAS_FLAGS_DEFAULT_MODE, szBuf, sizeof(szBuf), NULL);
    64286428
    64296429        /* Very bad. We crashed in emitted code. Probably stack? */
     
    65426542
    65436543    Log2(("pPatchBlockGC %RRv - pEip %RRv corresponding GC address %RRv\n", PATCHCODE_PTR_GC(&pPatch->patch), pEip, pNewEip));
    6544     DBGFR3DisasInstrLog(pVCpu, pCtx->cs, pNewEip, "PATCHRET: ");
     6544    DBGFR3DisasInstrLog(pVCpu, pCtx->cs.Sel, pNewEip, "PATCHRET: ");
    65456545    if (pNewEip >= pPatch->patch.pPrivInstrGC && pNewEip < pPatch->patch.pPrivInstrGC + pPatch->patch.cbPatchJump)
    65466546    {
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r41803 r41906  
    13301330    PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
    13311331
    1332     pCtx->cs                        = uVector << 8;
    1333     pCtx->csHid.u64Base             = uVector << 12;
    1334     pCtx->csHid.u32Limit            = 0x0000ffff;
    1335     pCtx->rip                       = 0;
     1332    pCtx->cs.Sel        = uVector << 8;
     1333    pCtx->cs.ValidSel   = uVector << 8;
     1334    pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     1335    pCtx->cs.u64Base    = uVector << 12;
     1336    pCtx->cs.u32Limit   = UINT32_C(0x0000ffff);
     1337    pCtx->rip           = 0;
    13361338
    13371339    Log(("vmmR3SendSipi for VCPU %d with vector %x\n", uVector));
  • trunk/src/VBox/VMM/VMMR3/VMMTests.cpp

    r41783 r41906  
    448448
    449449#define SYNC_SEL(pHyperCtx, reg)                                                        \
    450         if (pHyperCtx->reg)                                                             \
     450        if (pHyperCtx->reg.Sel)                                                         \
    451451        {                                                                               \
    452452            DBGFSELINFO selInfo;                                                        \
    453             int rc2 = SELMR3GetShadowSelectorInfo(pVM, pHyperCtx->reg, &selInfo);       \
     453            int rc2 = SELMR3GetShadowSelectorInfo(pVM, pHyperCtx->reg.Sel, &selInfo);   \
    454454            AssertRC(rc2);                                                              \
    455455                                                                                        \
    456             pHyperCtx->reg##Hid.u64Base              = selInfo.GCPtrBase;               \
    457             pHyperCtx->reg##Hid.u32Limit             = selInfo.cbLimit;                 \
    458             pHyperCtx->reg##Hid.Attr.n.u1Present     = selInfo.u.Raw.Gen.u1Present;     \
    459             pHyperCtx->reg##Hid.Attr.n.u1DefBig      = selInfo.u.Raw.Gen.u1DefBig;      \
    460             pHyperCtx->reg##Hid.Attr.n.u1Granularity = selInfo.u.Raw.Gen.u1Granularity; \
    461             pHyperCtx->reg##Hid.Attr.n.u4Type        = selInfo.u.Raw.Gen.u4Type;        \
    462             pHyperCtx->reg##Hid.Attr.n.u2Dpl         = selInfo.u.Raw.Gen.u2Dpl;         \
    463             pHyperCtx->reg##Hid.Attr.n.u1DescType    = selInfo.u.Raw.Gen.u1DescType;    \
    464             pHyperCtx->reg##Hid.Attr.n.u1Long        = selInfo.u.Raw.Gen.u1Long;        \
     456            pHyperCtx->reg.u64Base              = selInfo.GCPtrBase;                    \
     457            pHyperCtx->reg.u32Limit             = selInfo.cbLimit;                      \
     458            pHyperCtx->reg.Attr.n.u1Present     = selInfo.u.Raw.Gen.u1Present;          \
     459            pHyperCtx->reg.Attr.n.u1DefBig      = selInfo.u.Raw.Gen.u1DefBig;           \
     460            pHyperCtx->reg.Attr.n.u1Granularity = selInfo.u.Raw.Gen.u1Granularity;      \
     461            pHyperCtx->reg.Attr.n.u4Type        = selInfo.u.Raw.Gen.u4Type;             \
     462            pHyperCtx->reg.Attr.n.u2Dpl         = selInfo.u.Raw.Gen.u2Dpl;              \
     463            pHyperCtx->reg.Attr.n.u1DescType    = selInfo.u.Raw.Gen.u1DescType;         \
     464            pHyperCtx->reg.Attr.n.u1Long        = selInfo.u.Raw.Gen.u1Long;             \
    465465        }
    466466
  • trunk/src/VBox/VMM/VMMRC/CPUMRC.cpp

    r41783 r41906  
    9595
    9696            pGstCtxCore->eip        = *pEsp++;
    97             pGstCtxCore->cs         = (RTSEL)*pEsp++;
     97            pGstCtxCore->cs.Sel     = (RTSEL)*pEsp++;
    9898            pGstCtxCore->eflags.u32 = *pEsp++;
    9999            pGstCtxCore->esp        = *pEsp++;
    100             pGstCtxCore->ss         = (RTSEL)*pEsp++;
     100            pGstCtxCore->ss.Sel     = (RTSEL)*pEsp++;
    101101            if (pGstCtxCore->eflags.Bits.u1VM)
    102102            {
    103                 pGstCtxCore->es    = (RTSEL)*pEsp++;
    104                 pGstCtxCore->ds    = (RTSEL)*pEsp++;
    105                 pGstCtxCore->fs    = (RTSEL)*pEsp++;
    106                 pGstCtxCore->gs    = (RTSEL)*pEsp++;
     103                pGstCtxCore->es.Sel = (RTSEL)*pEsp++;
     104                pGstCtxCore->ds.Sel = (RTSEL)*pEsp++;
     105                pGstCtxCore->fs.Sel = (RTSEL)*pEsp++;
     106                pGstCtxCore->gs.Sel = (RTSEL)*pEsp++;
    107107            }
    108108
  • trunk/src/VBox/VMM/VMMRC/CPUMRCA.asm

    r37955 r41906  
    7474    mov     ecx, [edx + CPUMCPU.Guest.eip]
    7575    mov     [eax +  0h], ecx
    76     mov     ecx, [edx + CPUMCPU.Guest.cs]
     76    mov     ecx, [edx + CPUMCPU.Guest.cs.Sel]
    7777    mov     [eax +  4h], ecx
    7878    mov     ecx, [edx + CPUMCPU.Guest.eflags]
     
    8080    mov     ecx, [edx + CPUMCPU.Guest.esp]
    8181    mov     [eax + 0ch], ecx
    82     mov     ecx, [edx + CPUMCPU.Guest.ss]
     82    mov     ecx, [edx + CPUMCPU.Guest.ss.Sel]
    8383    mov     [eax + 10h], ecx
    8484
     
    9191    ; todo: potential trouble loading invalid es,fs,gs,ds because
    9292    ;       of a VMM imposed exception?
    93     mov     es,  [edx + CPUMCPU.Guest.es]
    94     mov     fs,  [edx + CPUMCPU.Guest.fs]
    95     mov     gs,  [edx + CPUMCPU.Guest.gs]
     93    mov     es,  [edx + CPUMCPU.Guest.es.Sel]
     94    mov     fs,  [edx + CPUMCPU.Guest.fs.Sel]
     95    mov     gs,  [edx + CPUMCPU.Guest.gs.Sel]
    9696    mov     esi, [edx + CPUMCPU.Guest.esi]
    9797    mov     edi, [edx + CPUMCPU.Guest.edi]
     
    100100    mov     ecx, [edx + CPUMCPU.Guest.ecx]
    101101    mov     eax, [edx + CPUMCPU.Guest.eax]
    102     push    dword [edx + CPUMCPU.Guest.ds]
     102    push    dword [edx + CPUMCPU.Guest.ds.Sel]
    103103    mov     edx, [edx + CPUMCPU.Guest.edx]
    104104    pop     ds
     
    108108CPUMGCRestoreInt_V86:
    109109    ; iret restores ds, es, fs & gs
    110     mov     ecx, [edx + CPUMCPU.Guest.es]
     110    mov     ecx, [edx + CPUMCPU.Guest.es.Sel]
    111111    mov     [eax + 14h], ecx
    112     mov     ecx, [edx + CPUMCPU.Guest.ds]
     112    mov     ecx, [edx + CPUMCPU.Guest.ds.Sel]
    113113    mov     [eax + 18h], ecx
    114     mov     ecx, [edx + CPUMCPU.Guest.fs]
     114    mov     ecx, [edx + CPUMCPU.Guest.fs.Sel]
    115115    mov     [eax + 1Ch], ecx
    116     mov     ecx, [edx + CPUMCPU.Guest.gs]
     116    mov     ecx, [edx + CPUMCPU.Guest.gs.Sel]
    117117    mov     [eax + 20h], ecx
    118118    mov     esi, [edx + CPUMCPU.Guest.esi]
     
    172172    ;; @todo  load segment registers *before* enabling WP.
    173173    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_GS | CPUM_HANDLER_CTXCORE_IN_EBP
    174     mov     gs, [ebp + CPUMCTXCORE.gs]
     174    mov     gs, [ebp + CPUMCTXCORE.gs.Sel]
    175175    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_FS | CPUM_HANDLER_CTXCORE_IN_EBP
    176     mov     fs, [ebp + CPUMCTXCORE.fs]
     176    mov     fs, [ebp + CPUMCTXCORE.fs.Sel]
    177177    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_ES | CPUM_HANDLER_CTXCORE_IN_EBP
    178     mov     es, [ebp + CPUMCTXCORE.es]
     178    mov     es, [ebp + CPUMCTXCORE.es.Sel]
    179179    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_DS | CPUM_HANDLER_CTXCORE_IN_EBP
    180     mov     ds, [ebp + CPUMCTXCORE.ds]
     180    mov     ds, [ebp + CPUMCTXCORE.ds.Sel]
    181181
    182182    mov     eax, [ebp + CPUMCTXCORE.eax]
     
    202202
    203203    ; construct iret stack frame
    204     push    dword [ebp + CPUMCTXCORE.gs]
    205     push    dword [ebp + CPUMCTXCORE.fs]
    206     push    dword [ebp + CPUMCTXCORE.ds]
    207     push    dword [ebp + CPUMCTXCORE.es]
    208     push    dword [ebp + CPUMCTXCORE.ss]
     204    push    dword [ebp + CPUMCTXCORE.gs.Sel]
     205    push    dword [ebp + CPUMCTXCORE.fs.Sel]
     206    push    dword [ebp + CPUMCTXCORE.ds.Sel]
     207    push    dword [ebp + CPUMCTXCORE.es.Sel]
     208    push    dword [ebp + CPUMCTXCORE.ss.Sel]
    209209    push    dword [ebp + CPUMCTXCORE.esp]
    210210    push    dword [ebp + CPUMCTXCORE.eflags]
    211     push    dword [ebp + CPUMCTXCORE.cs]
     211    push    dword [ebp + CPUMCTXCORE.cs.Sel]
    212212    push    dword [ebp + CPUMCTXCORE.eip]
    213213
     
    253253    ; Setup iretd
    254254    ;
    255     push    dword [edx + CPUMCPU.Guest.ss]
     255    push    dword [edx + CPUMCPU.Guest.ss.Sel]
    256256    push    dword [edx + CPUMCPU.Guest.esp]
    257257    push    dword [edx + CPUMCPU.Guest.eflags]
    258     push    dword [edx + CPUMCPU.Guest.cs]
     258    push    dword [edx + CPUMCPU.Guest.cs.Sel]
    259259    push    dword [edx + CPUMCPU.Guest.eip]
    260260
     
    263263    ;
    264264    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_ES
    265     mov     es,  [edx + CPUMCPU.Guest.es]
     265    mov     es,  [edx + CPUMCPU.Guest.es.Sel]
    266266    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_FS
    267     mov     fs,  [edx + CPUMCPU.Guest.fs]
     267    mov     fs,  [edx + CPUMCPU.Guest.fs.Sel]
    268268    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_GS
    269     mov     gs,  [edx + CPUMCPU.Guest.gs]
     269    mov     gs,  [edx + CPUMCPU.Guest.gs.Sel]
    270270
    271271%ifdef VBOX_WITH_STATISTICS
     
    302302    mov     ecx, [edx + CPUMCPU.Guest.ecx]
    303303    mov     eax, [edx + CPUMCPU.Guest.eax]
    304     push    dword [edx + CPUMCPU.Guest.ds]
     304    push    dword [edx + CPUMCPU.Guest.ds.Sel]
    305305    mov     edx, [edx + CPUMCPU.Guest.edx]
    306306    TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_DS
     
    331331    ; Setup iretd
    332332    ;
    333     push    dword [edx + CPUMCPU.Guest.gs]
    334     push    dword [edx + CPUMCPU.Guest.fs]
    335     push    dword [edx + CPUMCPU.Guest.ds]
    336     push    dword [edx + CPUMCPU.Guest.es]
    337 
    338     push    dword [edx + CPUMCPU.Guest.ss]
     333    push    dword [edx + CPUMCPU.Guest.gs.Sel]
     334    push    dword [edx + CPUMCPU.Guest.fs.Sel]
     335    push    dword [edx + CPUMCPU.Guest.ds.Sel]
     336    push    dword [edx + CPUMCPU.Guest.es.Sel]
     337
     338    push    dword [edx + CPUMCPU.Guest.ss.Sel]
    339339    push    dword [edx + CPUMCPU.Guest.esp]
    340340
    341341    push    dword [edx + CPUMCPU.Guest.eflags]
    342     push    dword [edx + CPUMCPU.Guest.cs]
     342    push    dword [edx + CPUMCPU.Guest.cs.Sel]
    343343    push    dword [edx + CPUMCPU.Guest.eip]
    344344
  • trunk/src/VBox/VMM/VMMRC/CSAMRC.cpp

    r41800 r41906  
    102102        cpl = 3;
    103103    else
    104         cpl = (pRegFrame->ss & X86_SEL_RPL);
     104        cpl = (pRegFrame->ss.Sel & X86_SEL_RPL);
    105105
    106106    Log(("CSAMGCCodePageWriteHandler: code page write at %RGv original address %RGv (cpl=%d)\n", pvFault, (RTGCUINTPTR)pvRange + offRange, cpl));
  • trunk/src/VBox/VMM/VMMRC/PATMRC.cpp

    r41897 r41906  
    155155
    156156    /* Very important check -> otherwise we have a security leak. */
    157     AssertReturn(!pRegFrame->eflags.Bits.u1VM && (pRegFrame->ss & X86_SEL_RPL) == 1, VERR_ACCESS_DENIED);
     157    AssertReturn(!pRegFrame->eflags.Bits.u1VM && (pRegFrame->ss.Sel & X86_SEL_RPL) == 1, VERR_ACCESS_DENIED);
    158158    Assert(PATMIsPatchGCAddr(pVM, pRegFrame->eip));
    159159
     
    455455    int rc;
    456456
    457     AssertReturn(!pRegFrame->eflags.Bits.u1VM && (pRegFrame->ss & X86_SEL_RPL) == 1, VERR_ACCESS_DENIED);
     457    AssertReturn(!pRegFrame->eflags.Bits.u1VM && (pRegFrame->ss.Sel & X86_SEL_RPL) == 1, VERR_ACCESS_DENIED);
    458458
    459459    /* Int 3 in PATM generated code? (most common case) */
     
    510510            }
    511511
    512             DISCPUMODE enmCpuMode = SELMGetCpuModeFromSelector(VMMGetCpu0(pVM), pRegFrame->eflags, pRegFrame->cs, 0);
     512            DISCPUMODE enmCpuMode = SELMGetCpuModeFromSelector(VMMGetCpu0(pVM), pRegFrame->eflags, pRegFrame->cs.Sel, 0);
    513513            if (enmCpuMode != DISCPUMODE_32BIT)
    514514            {
  • trunk/src/VBox/VMM/VMMRC/SELMRC.cpp

    r41803 r41906  
    140140
    141141#ifdef LOG_ENABLED
    142     if (Sel == (pRegFrame->cs & X86_SEL_MASK))
    143         Log(("GDT write to selector in CS register %04X\n", pRegFrame->cs));
    144     else if (Sel == (pRegFrame->ds & X86_SEL_MASK))
    145         Log(("GDT write to selector in DS register %04X\n", pRegFrame->ds));
    146     else if (Sel == (pRegFrame->es & X86_SEL_MASK))
    147         Log(("GDT write to selector in ES register %04X\n", pRegFrame->es));
    148     else if (Sel == (pRegFrame->fs & X86_SEL_MASK))
    149         Log(("GDT write to selector in FS register %04X\n", pRegFrame->fs));
    150     else if (Sel == (pRegFrame->gs & X86_SEL_MASK))
    151         Log(("GDT write to selector in GS register %04X\n", pRegFrame->gs));
    152     else if (Sel == (pRegFrame->ss & X86_SEL_MASK))
    153         Log(("GDT write to selector in SS register %04X\n", pRegFrame->ss));
     142    if (Sel == (pRegFrame->cs.Sel & X86_SEL_MASK))
     143        Log(("GDT write to selector in CS register %04X\n", pRegFrame->cs.Sel));
     144    else if (Sel == (pRegFrame->ds.Sel & X86_SEL_MASK))
     145        Log(("GDT write to selector in DS register %04X\n", pRegFrame->ds.Sel));
     146    else if (Sel == (pRegFrame->es.Sel & X86_SEL_MASK))
     147        Log(("GDT write to selector in ES register %04X\n", pRegFrame->es.Sel));
     148    else if (Sel == (pRegFrame->fs.Sel & X86_SEL_MASK))
     149        Log(("GDT write to selector in FS register %04X\n", pRegFrame->fs.Sel));
     150    else if (Sel == (pRegFrame->gs.Sel & X86_SEL_MASK))
     151        Log(("GDT write to selector in GS register %04X\n", pRegFrame->gs.Sel));
     152    else if (Sel == (pRegFrame->ss.Sel & X86_SEL_MASK))
     153        Log(("GDT write to selector in SS register %04X\n", pRegFrame->ss.Sel));
    154154#endif
    155155    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp

    r41823 r41906  
    257257    AssertMsg(     rc != VINF_SUCCESS
    258258              ||   (   pRegFrame->eflags.Bits.u1IF
    259                     && ( pRegFrame->eflags.Bits.u2IOPL < (unsigned)(pRegFrame->ss & X86_SEL_RPL) || pRegFrame->eflags.Bits.u1VM))
    260               , ("rc=%Rrc\neflags=%RX32 ss=%RTsel IOPL=%d\n", rc, pRegFrame->eflags.u32, pRegFrame->ss, pRegFrame->eflags.Bits.u2IOPL));
     259                    && ( pRegFrame->eflags.Bits.u2IOPL < (unsigned)(pRegFrame->ss.Sel & X86_SEL_RPL) || pRegFrame->eflags.Bits.u1VM))
     260              , ("rc=%Rrc\neflags=%RX32 ss=%RTsel IOPL=%d\n", rc, pRegFrame->eflags.u32, pRegFrame->ss.Sel, pRegFrame->eflags.Bits.u2IOPL));
    261261    PGMRZDynMapReleaseAutoSet(pVCpu);
    262262    return rc;
     
    281281    PVMCPU      pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
    282282
    283     LogFlow(("TRPMGC01: cs:eip=%04x:%08x uDr6=%RTreg\n", pRegFrame->cs, pRegFrame->eip, uDr6));
     283    LogFlow(("TRPMGC01: cs:eip=%04x:%08x uDr6=%RTreg\n", pRegFrame->cs.Sel, pRegFrame->eip, uDr6));
    284284
    285285    /*
     
    302302
    303303    rc = trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame);
    304     Log6(("TRPMGC01: %Rrc (%04x:%08x %RTreg)\n", rc, pRegFrame->cs, pRegFrame->eip, uDr6));
     304    Log6(("TRPMGC01: %Rrc (%04x:%08x %RTreg)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip, uDr6));
    305305    return rc;
    306306}
     
    328328    PVMCPU      pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
    329329
    330     LogFlow(("TRPMGCHyper01: cs:eip=%04x:%08x uDr6=%RTreg\n", pRegFrame->cs, pRegFrame->eip, uDr6));
     330    LogFlow(("TRPMGCHyper01: cs:eip=%04x:%08x uDr6=%RTreg\n", pRegFrame->cs.Sel, pRegFrame->eip, uDr6));
    331331
    332332    /*
     
    346346    AssertStmt(rc != VINF_EM_RAW_GUEST_TRAP, rc = VERR_TRPM_IPE_1);
    347347
    348     Log6(("TRPMGCHyper01: %Rrc (%04x:%08x %RTreg)\n", rc, pRegFrame->cs, pRegFrame->eip, uDr6));
     348    Log6(("TRPMGCHyper01: %Rrc (%04x:%08x %RTreg)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip, uDr6));
    349349    return rc;
    350350}
     
    365365DECLASM(int) TRPMGCTrap02Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    366366{
    367     LogFlow(("TRPMGCTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
    368     RTLogComPrintf("TRPMGCTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs, pRegFrame->eip);
     367    LogFlow(("TRPMGCTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
     368    RTLogComPrintf("TRPMGCTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip);
    369369    NOREF(pTrpmCpu);
    370370    return VERR_TRPM_DONT_PANIC;
     
    389389DECLASM(int) TRPMGCHyperTrap02Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    390390{
    391     LogFlow(("TRPMGCHyperTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
    392     RTLogComPrintf("TRPMGCHyperTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs, pRegFrame->eip);
     391    LogFlow(("TRPMGCHyperTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
     392    RTLogComPrintf("TRPMGCHyperTrap02Handler: cs:eip=%04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip);
    393393    NOREF(pTrpmCpu);
    394394    return VERR_TRPM_DONT_PANIC;
     
    409409DECLASM(int) TRPMGCTrap03Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    410410{
    411     LogFlow(("TRPMGC03: %04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
     411    LogFlow(("TRPMGC03: %04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
    412412    PVM     pVM   = TRPMCPU_2_VM(pTrpmCpu);
    413413    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
     
    418418     * PATM is using INT3s, let them have a go first.
    419419     */
    420     if (    (pRegFrame->ss & X86_SEL_RPL) == 1
     420    if (    (pRegFrame->ss.Sel & X86_SEL_RPL) == 1
    421421        &&  !pRegFrame->eflags.Bits.u1VM)
    422422    {
     
    428428        {
    429429            rc = trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame);
    430             Log6(("TRPMGC03: %Rrc (%04x:%08x) (PATM)\n", rc, pRegFrame->cs, pRegFrame->eip));
     430            Log6(("TRPMGC03: %Rrc (%04x:%08x) (PATM)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    431431            return rc;
    432432        }
     
    436436    /* anything we should do with this? Schedule it in GC? */
    437437    rc = trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame);
    438     Log6(("TRPMGC03: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs, pRegFrame->eip));
     438    Log6(("TRPMGC03: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    439439    return rc;
    440440}
     
    457457DECLASM(int) TRPMGCHyperTrap03Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    458458{
    459     LogFlow(("TRPMGCHyper03: %04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
     459    LogFlow(("TRPMGCHyper03: %04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
    460460    PVM     pVM   = TRPMCPU_2_VM(pTrpmCpu);
    461461    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
     
    467467    AssertStmt(rc != VINF_EM_RAW_GUEST_TRAP, rc = VERR_TRPM_IPE_2);
    468468
    469     Log6(("TRPMGCHyper03: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs, pRegFrame->eip));
     469    Log6(("TRPMGCHyper03: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    470470    return rc;
    471471}
     
    485485DECLASM(int) TRPMGCTrap06Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    486486{
    487     LogFlow(("TRPMGC06: %04x:%08x efl=%x\n", pRegFrame->cs, pRegFrame->eip, pRegFrame->eflags.u32));
     487    LogFlow(("TRPMGC06: %04x:%08x efl=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, pRegFrame->eflags.u32));
    488488    PVM     pVM   = TRPMCPU_2_VM(pTrpmCpu);
    489489    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
     
    497497         */
    498498        RTGCPTR PC;
    499         rc = SELMValidateAndConvertCSAddr(pVCpu, pRegFrame->eflags, pRegFrame->ss, pRegFrame->cs, &pRegFrame->csHid,
     499        rc = SELMValidateAndConvertCSAddr(pVCpu, pRegFrame->eflags, pRegFrame->ss.Sel, pRegFrame->cs.Sel, &pRegFrame->cs,
    500500                                          pRegFrame->rip, &PC);
    501501        if (RT_FAILURE(rc))
    502502        {
    503             Log(("TRPMGCTrap06Handler: Failed to convert %RTsel:%RX32 (cpl=%d) - rc=%Rrc !!\n", pRegFrame->cs, pRegFrame->eip, pRegFrame->ss & X86_SEL_RPL, rc));
     503            Log(("TRPMGCTrap06Handler: Failed to convert %RTsel:%RX32 (cpl=%d) - rc=%Rrc !!\n", pRegFrame->cs.Sel, pRegFrame->eip, pRegFrame->ss.Sel & X86_SEL_RPL, rc));
    504504            rc = trpmGCExitTrap(pVM, pVCpu, VINF_EM_RAW_GUEST_TRAP, pRegFrame);
    505             Log6(("TRPMGC06: %Rrc (%04x:%08x) (SELM)\n", rc, pRegFrame->cs, pRegFrame->eip));
     505            Log6(("TRPMGC06: %Rrc (%04x:%08x) (SELM)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    506506            return rc;
    507507        }
     
    513513        {
    514514            rc = trpmGCExitTrap(pVM, pVCpu, VINF_EM_RAW_EMULATE_INSTR, pRegFrame);
    515             Log6(("TRPMGC06: %Rrc (%04x:%08x) (EM)\n", rc, pRegFrame->cs, pRegFrame->eip));
     515            Log6(("TRPMGC06: %Rrc (%04x:%08x) (EM)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    516516            return rc;
    517517        }
     
    535535            {
    536536                rc = trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame);
    537                 Log6(("TRPMGC06: %Rrc (%04x:%08x) (PATM)\n", rc, pRegFrame->cs, pRegFrame->eip));
     537                Log6(("TRPMGC06: %Rrc (%04x:%08x) (PATM)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    538538                return rc;
    539539            }
     
    576576
    577577    rc = trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame);
    578     Log6(("TRPMGC06: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs, pRegFrame->eip));
     578    Log6(("TRPMGC06: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    579579    return rc;
    580580}
     
    596596DECLASM(int) TRPMGCTrap07Handler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    597597{
    598     LogFlow(("TRPMGC07: %04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
     598    LogFlow(("TRPMGC07: %04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
    599599    PVM     pVM   = TRPMCPU_2_VM(pTrpmCpu);
    600600    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
     
    603603    int rc = CPUMHandleLazyFPU(pVCpu);
    604604    rc = trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame);
    605     Log6(("TRPMGC07: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs, pRegFrame->eip));
     605    Log6(("TRPMGC07: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    606606    return rc;
    607607}
     
    621621DECLASM(int) TRPMGCTrap0bHandler(PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    622622{
    623     LogFlow(("TRPMGC0b: %04x:%08x\n", pRegFrame->cs, pRegFrame->eip));
     623    LogFlow(("TRPMGC0b: %04x:%08x\n", pRegFrame->cs.Sel, pRegFrame->eip));
    624624    PVM     pVM   = TRPMCPU_2_VM(pTrpmCpu);
    625625    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
     
    632632     */
    633633    RTGCPTR GCPtr;
    634     if (   SELMValidateAndConvertCSAddr(pVCpu, pRegFrame->eflags, pRegFrame->ss, pRegFrame->cs, &pRegFrame->csHid,
     634    if (   SELMValidateAndConvertCSAddr(pVCpu, pRegFrame->eflags, pRegFrame->ss.Sel, pRegFrame->cs.Sel, &pRegFrame->cs,
    635635                                        (RTGCPTR)pRegFrame->eip, &GCPtr)
    636636        == VINF_SUCCESS)
     
    697697             */
    698698            pTrpmCpu->uActiveVector = UINT32_MAX;
    699             Log6(("TRPMGC0b: %Rrc (%04x:%08x) (CG)\n", VINF_EM_RAW_RING_SWITCH, pRegFrame->cs, pRegFrame->eip));
     699            Log6(("TRPMGC0b: %Rrc (%04x:%08x) (CG)\n", VINF_EM_RAW_RING_SWITCH, pRegFrame->cs.Sel, pRegFrame->eip));
    700700            PGMRZDynMapReleaseAutoSet(pVCpu);
    701701            return VINF_EM_RAW_RING_SWITCH;
     
    706706     * Pass trap 0b as is to the recompiler in all other cases.
    707707     */
    708     Log6(("TRPMGC0b: %Rrc (%04x:%08x)\n", VINF_EM_RAW_GUEST_TRAP, pRegFrame->cs, pRegFrame->eip));
     708    Log6(("TRPMGC0b: %Rrc (%04x:%08x)\n", VINF_EM_RAW_GUEST_TRAP, pRegFrame->cs.Sel, pRegFrame->eip));
    709709    PGMRZDynMapReleaseAutoSet(pVCpu);
    710710    return VINF_EM_RAW_GUEST_TRAP;
     
    890890        {
    891891            uint32_t efl = CPUMRawGetEFlags(pVCpu, pRegFrame);
    892             if (X86_EFL_GET_IOPL(efl) >= (unsigned)(pRegFrame->ss & X86_SEL_RPL))
     892            if (X86_EFL_GET_IOPL(efl) >= (unsigned)(pRegFrame->ss.Sel & X86_SEL_RPL))
    893893            {
    894894                LogFlow(("trpmGCTrap0dHandlerRing3: CLI/STI -> REM\n"));
     
    945945static int trpmGCTrap0dHandler(PVM pVM, PTRPMCPU pTrpmCpu, PCPUMCTXCORE pRegFrame)
    946946{
    947     LogFlow(("trpmGCTrap0dHandler: cs:eip=%RTsel:%08RX32 uErr=%RGv\n", pRegFrame->ss, pRegFrame->eip, pTrpmCpu->uActiveErrorCode));
     947    LogFlow(("trpmGCTrap0dHandler: cs:eip=%RTsel:%08RX32 uErr=%RGv\n", pRegFrame->cs.Sel, pRegFrame->eip, pTrpmCpu->uActiveErrorCode));
    948948    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
    949949
     
    954954    RTGCPTR PC;
    955955    uint32_t cBits;
    956     int rc = SELMValidateAndConvertCSAddrGCTrap(pVCpu, pRegFrame->eflags, pRegFrame->ss, pRegFrame->cs,
     956    int rc = SELMValidateAndConvertCSAddrGCTrap(pVCpu, pRegFrame->eflags, pRegFrame->ss.Sel, pRegFrame->cs.Sel,
    957957                                                pRegFrame->rip, &PC, &cBits);
    958958    if (RT_FAILURE(rc))
    959959    {
    960960        Log(("trpmGCTrap0dHandler: Failed to convert %RTsel:%RX32 (cpl=%d) - rc=%Rrc !!\n",
    961              pRegFrame->cs, pRegFrame->eip, pRegFrame->ss & X86_SEL_RPL, rc));
     961             pRegFrame->cs.Sel, pRegFrame->eip, pRegFrame->ss.Sel & X86_SEL_RPL, rc));
    962962        STAM_PROFILE_STOP(&pVM->trpm.s.StatTrap0dDisasm, a);
    963963        return trpmGCExitTrap(pVM, pVCpu, VINF_EM_RAW_EMULATE_INSTR, pRegFrame);
     
    10041004     * Deal with Ring-0 (privileged instructions)
    10051005     */
    1006     if (    (pRegFrame->ss & X86_SEL_RPL) <= 1
     1006    if (    (pRegFrame->ss.Sel & X86_SEL_RPL) <= 1
    10071007        &&  !pRegFrame->eflags.Bits.u1VM)
    10081008        return trpmGCTrap0dHandlerRing0(pVM, pVCpu, pRegFrame, &Cpu, PC);
     
    10241024    X86EFLAGS eflags;
    10251025    eflags.u32 = CPUMRawGetEFlags(pVCpu, pRegFrame); /* Get the correct value. */
    1026     Log3(("TRPM #GP V86: cs:eip=%04x:%08x IOPL=%d efl=%08x\n", pRegFrame->cs, pRegFrame->eip, eflags.Bits.u2IOPL, eflags.u));
     1026    Log3(("TRPM #GP V86: cs:eip=%04x:%08x IOPL=%d efl=%08x\n", pRegFrame->cs.Sel, pRegFrame->eip, eflags.Bits.u2IOPL, eflags.u));
    10271027    if (eflags.Bits.u2IOPL != 3)
    10281028    {
     
    10531053    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
    10541054
    1055     LogFlow(("TRPMGC0d: %04x:%08x err=%x\n", pRegFrame->cs, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode));
     1055    LogFlow(("TRPMGC0d: %04x:%08x err=%x\n", pRegFrame->cs.Sel, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode));
    10561056
    10571057    PGMRZDynMapStartAutoSet(pVCpu);
     
    10881088            break;
    10891089        }
    1090     Log6(("TRPMGC0d: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs, pRegFrame->eip));
     1090    Log6(("TRPMGC0d: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    10911091    return rc;
    10921092}
     
    11121112    PVMCPU  pVCpu = TRPMCPU_2_VMCPU(pTrpmCpu);
    11131113
    1114     LogFlow(("TRPMGC0e: %04x:%08x err=%x cr2=%08x\n", pRegFrame->cs, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode, (uint32_t)pVCpu->trpm.s.uActiveCR2));
     1114    LogFlow(("TRPMGC0e: %04x:%08x err=%x cr2=%08x\n", pRegFrame->cs.Sel, pRegFrame->eip, (uint32_t)pVCpu->trpm.s.uActiveErrorCode, (uint32_t)pVCpu->trpm.s.uActiveCR2));
    11151115
    11161116    /*
     
    11641164    }
    11651165    rc = trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame);
    1166     Log6(("TRPMGC0e: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs, pRegFrame->eip));
     1166    Log6(("TRPMGC0e: %Rrc (%04x:%08x)\n", rc, pRegFrame->cs.Sel, pRegFrame->eip));
    11671167    return rc;
    11681168}
     
    13031303        {
    13041304            case TRPM_TRAP_IN_MOV_GS:
    1305                 pRegFrame->eax = 0;
    1306                 pRegFrame->gs = 0; /* prevent recursive trouble. */
     1305                pRegFrame->eax    = 0;
     1306                pRegFrame->gs.Sel = 0; /* prevent recursive trouble. */
    13071307                break;
    13081308            case TRPM_TRAP_IN_MOV_FS:
    1309                 pRegFrame->eax = 0;
    1310                 pRegFrame->fs = 0; /* prevent recursive trouble. */
     1309                pRegFrame->eax    = 0;
     1310                pRegFrame->fs.Sel = 0; /* prevent recursive trouble. */
    13111311                return VINF_SUCCESS;
    13121312
     
    13491349             */
    13501350            case TRPM_TRAP_IN_IRET:
    1351                 CtxCore.eip = *pEsp++;
    1352                 CtxCore.cs = (RTSEL)*pEsp++;
     1351                CtxCore.eip        = *pEsp++;
     1352                CtxCore.cs.Sel    = (RTSEL)*pEsp++;
    13531353                CtxCore.eflags.u32 = *pEsp++;
    1354                 CtxCore.esp = *pEsp++;
    1355                 CtxCore.ss = (RTSEL)*pEsp++;
     1354                CtxCore.esp        = *pEsp++;
     1355                CtxCore.ss.Sel    = (RTSEL)*pEsp++;
    13561356                rc = VINF_EM_RAW_IRET_TRAP;
    13571357                break;
     
    13611361             */
    13621362            case TRPM_TRAP_IN_IRET | TRPM_TRAP_IN_V86:
    1363                 CtxCore.eip = *pEsp++;
    1364                 CtxCore.cs = (RTSEL)*pEsp++;
     1363                CtxCore.eip        = *pEsp++;
     1364                CtxCore.cs.Sel    = (RTSEL)*pEsp++;
    13651365                CtxCore.eflags.u32 = *pEsp++;
    1366                 CtxCore.esp = *pEsp++;
    1367                 CtxCore.ss = (RTSEL)*pEsp++;
    1368                 CtxCore.es = (RTSEL)*pEsp++;
    1369                 CtxCore.ds = (RTSEL)*pEsp++;
    1370                 CtxCore.fs = (RTSEL)*pEsp++;
    1371                 CtxCore.gs = (RTSEL)*pEsp++;
     1366                CtxCore.esp        = *pEsp++;
     1367                CtxCore.ss.Sel    = (RTSEL)*pEsp++;
     1368                CtxCore.es.Sel    = (RTSEL)*pEsp++;
     1369                CtxCore.ds.Sel    = (RTSEL)*pEsp++;
     1370                CtxCore.fs.Sel    = (RTSEL)*pEsp++;
     1371                CtxCore.gs.Sel    = (RTSEL)*pEsp++;
    13721372                rc = VINF_EM_RAW_IRET_TRAP;
    13731373                break;
  • trunk/src/VBox/VMM/VMMRC/TRPMRCHandlersA.asm

    r38867 r41906  
    265265    mov     [esp + CPUMCTXCORE.esp], eax
    266266    mov     eax, [esp + 18h + ESPOFF]           ; ss
    267     mov     dword [esp + CPUMCTXCORE.ss], eax
     267    mov     dword [esp + CPUMCTXCORE.ss.Sel], eax
    268268
    269269    mov     eax, [esp + 0ch + ESPOFF]           ; cs
    270     mov     dword [esp + CPUMCTXCORE.cs], eax
     270    mov     dword [esp + CPUMCTXCORE.cs.Sel], eax
    271271    mov     eax, [esp + 08h + ESPOFF]           ; eip
    272272    mov     [esp + CPUMCTXCORE.eip], eax
     
    288288
    289289    mov     eax, es
    290     mov     dword [esp + CPUMCTXCORE.es], eax
     290    mov     dword [esp + CPUMCTXCORE.es.Sel], eax
    291291    mov     eax, ds
    292     mov     dword [esp + CPUMCTXCORE.ds], eax
     292    mov     dword [esp + CPUMCTXCORE.ds.Sel], eax
    293293    mov     eax, fs
    294     mov     dword [esp + CPUMCTXCORE.fs], eax
     294    mov     dword [esp + CPUMCTXCORE.fs.Sel], eax
    295295    mov     eax, gs
    296     mov     dword [esp + CPUMCTXCORE.gs], eax
     296    mov     dword [esp + CPUMCTXCORE.gs.Sel], eax
    297297
    298298    test    dword [esp + CPUMCTXCORE.eflags], X86_EFL_VM
     
    303303    ;
    304304    mov     eax, dword [esp + ESPOFF + 1Ch]
    305     mov     dword [esp + CPUMCTXCORE.es], eax
     305    mov     dword [esp + CPUMCTXCORE.es.Sel], eax
    306306
    307307    mov     eax, dword [esp + ESPOFF + 20h]
    308     mov     dword [esp + CPUMCTXCORE.ds], eax
     308    mov     dword [esp + CPUMCTXCORE.ds.Sel], eax
    309309
    310310    mov     eax, dword [esp + ESPOFF + 24h]
    311     mov     dword [esp + CPUMCTXCORE.fs], eax
     311    mov     dword [esp + CPUMCTXCORE.fs.Sel], eax
    312312
    313313    mov     eax, dword [esp + ESPOFF + 28h]
    314     mov     dword [esp + CPUMCTXCORE.gs], eax
     314    mov     dword [esp + CPUMCTXCORE.gs.Sel], eax
    315315
    316316gt_SkipV86Entry:
     
    467467    mov     eax, [esp + CPUMCTXCORE.esp]
    468468    mov     [esp + 14h + ESPOFF], eax           ; esp
    469     mov     eax, dword [esp + CPUMCTXCORE.ss]
     469    mov     eax, dword [esp + CPUMCTXCORE.ss.Sel]
    470470    mov     [esp + 18h + ESPOFF], eax           ; ss
    471471
    472     mov     eax, dword [esp + CPUMCTXCORE.gs]
     472    mov     eax, dword [esp + CPUMCTXCORE.gs.Sel]
    473473    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_GS
    474474    mov     gs, eax
    475475
    476     mov     eax, dword [esp + CPUMCTXCORE.fs]
     476    mov     eax, dword [esp + CPUMCTXCORE.fs.Sel]
    477477    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_FS
    478478    mov     fs, eax
    479479
    480     mov     eax, dword [esp + CPUMCTXCORE.es]
     480    mov     eax, dword [esp + CPUMCTXCORE.es.Sel]
    481481    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_ES
    482482    mov     es, eax
    483483
    484     mov     eax, dword [esp + CPUMCTXCORE.ds]
     484    mov     eax, dword [esp + CPUMCTXCORE.ds.Sel]
    485485    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_DS
    486486    mov     ds, eax
    487487
    488     mov     eax, dword [esp + CPUMCTXCORE.cs]
     488    mov     eax, dword [esp + CPUMCTXCORE.cs.Sel]
    489489    mov     [esp + 0ch + ESPOFF], eax           ; cs
    490490    mov     eax, [esp + CPUMCTXCORE.eflags]
     
    512512    mov     eax, [esp + CPUMCTXCORE.esp]
    513513    mov     [esp + 14h + ESPOFF], eax           ; esp
    514     mov     eax, dword [esp + CPUMCTXCORE.ss]
     514    mov     eax, dword [esp + CPUMCTXCORE.ss.Sel]
    515515    mov     [esp + 18h + ESPOFF], eax           ; ss
    516516
    517     mov     eax, dword [esp + CPUMCTXCORE.es]
     517    mov     eax, dword [esp + CPUMCTXCORE.es.Sel]
    518518    mov     [esp + 1ch + ESPOFF], eax           ; es
    519     mov     eax, dword [esp + CPUMCTXCORE.ds]
     519    mov     eax, dword [esp + CPUMCTXCORE.ds.Sel]
    520520    mov     [esp + 20h + ESPOFF], eax           ; ds
    521     mov     eax, dword [esp + CPUMCTXCORE.fs]
     521    mov     eax, dword [esp + CPUMCTXCORE.fs.Sel]
    522522    mov     [esp + 24h + ESPOFF], eax           ; fs
    523     mov     eax, dword [esp + CPUMCTXCORE.gs]
     523    mov     eax, dword [esp + CPUMCTXCORE.gs.Sel]
    524524    mov     [esp + 28h + ESPOFF], eax           ; gs
    525525
    526526    mov     eax, [esp + CPUMCTXCORE.eip]
    527527    mov     [esp + 08h + ESPOFF], eax           ; eip
    528     mov     eax, dword [esp + CPUMCTXCORE.cs]
     528    mov     eax, dword [esp + CPUMCTXCORE.cs.Sel]
    529529    mov     [esp + 0ch + ESPOFF], eax           ; cs
    530530    mov     eax, [esp + CPUMCTXCORE.eflags]
     
    549549    lea     ebx, [esp + 14h + ESPOFF]   ; calc esp at trap
    550550    mov     [esp + CPUMCTXCORE.esp], ebx; update esp in register frame
    551     mov     [esp + CPUMCTXCORE.ss], ss ; update ss in register frame
     551    mov     [esp + CPUMCTXCORE.ss.Sel], ss ; update ss in register frame
    552552
    553553    ; tell cpum about the context core.
     
    656656    mov     edi, [esp + CPUMCTXCORE.edi]
    657657
    658     mov     eax, dword [esp + CPUMCTXCORE.gs]
     658    mov     eax, dword [esp + CPUMCTXCORE.gs.Sel]
    659659    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_GS | TRPM_TRAP_IN_HYPER
    660660    mov     gs, eax
    661661
    662     mov     eax, dword [esp + CPUMCTXCORE.fs]
     662    mov     eax, dword [esp + CPUMCTXCORE.fs.Sel]
    663663    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_FS | TRPM_TRAP_IN_HYPER
    664664    mov     fs, eax
    665665
    666     mov     eax, dword [esp + CPUMCTXCORE.es]
     666    mov     eax, dword [esp + CPUMCTXCORE.es.Sel]
    667667    mov     es, eax
    668     mov     eax, dword [esp + CPUMCTXCORE.ds]
     668    mov     eax, dword [esp + CPUMCTXCORE.ds.Sel]
    669669    mov     ds, eax
    670670
     
    673673    mov     eax, [esp + CPUMCTXCORE.eip]
    674674    mov     [esp + 08h + ESPOFF], eax           ; eip
    675     mov     eax, dword [esp + CPUMCTXCORE.cs]
     675    mov     eax, dword [esp + CPUMCTXCORE.cs.Sel]
    676676    mov     [esp + 0ch + ESPOFF], eax           ; cs
    677677    mov     eax, [esp + CPUMCTXCORE.eflags]
     
    769769    mov     [esp + CPUMCTXCORE.eip], eax
    770770    mov     eax, dword [esp + 08h + ESPOFF]     ; cs
    771     mov     [esp + CPUMCTXCORE.cs], eax
     771    mov     [esp + CPUMCTXCORE.cs.Sel], eax
    772772    mov     eax, [esp + 0ch + ESPOFF]           ; eflags
    773773    mov     [esp + CPUMCTXCORE.eflags], eax
     
    776776    mov     [esp + CPUMCTXCORE.esp], eax
    777777    mov     eax, dword [esp + 14h + ESPOFF]     ; ss
    778     mov     [esp + CPUMCTXCORE.ss], eax
     778    mov     [esp + CPUMCTXCORE.ss.Sel], eax
    779779
    780780%if GC_ARCH_BITS == 64
     
    792792
    793793    mov     eax, es
    794     mov     dword [esp + CPUMCTXCORE.es], eax
     794    mov     dword [esp + CPUMCTXCORE.es.Sel], eax
    795795    mov     eax, ds
    796     mov     dword [esp + CPUMCTXCORE.ds], eax
     796    mov     dword [esp + CPUMCTXCORE.ds.Sel], eax
    797797    mov     eax, fs
    798     mov     dword [esp + CPUMCTXCORE.fs], eax
     798    mov     dword [esp + CPUMCTXCORE.fs.Sel], eax
    799799    mov     eax, gs
    800     mov     dword [esp + CPUMCTXCORE.gs], eax
     800    mov     dword [esp + CPUMCTXCORE.gs.Sel], eax
    801801
    802802    test    dword [esp + CPUMCTXCORE.eflags], X86_EFL_VM
     
    807807    ;
    808808    mov     eax, dword [esp + ESPOFF + 18h]
    809     mov     dword [esp + CPUMCTXCORE.es], eax
     809    mov     dword [esp + CPUMCTXCORE.es.Sel], eax
    810810
    811811    mov     eax, dword [esp + ESPOFF + 1Ch]
    812     mov     dword [esp + CPUMCTXCORE.ds], eax
     812    mov     dword [esp + CPUMCTXCORE.ds.Sel], eax
    813813
    814814    mov     eax, dword [esp + ESPOFF + 20h]
    815     mov     dword [esp + CPUMCTXCORE.fs], eax
     815    mov     dword [esp + CPUMCTXCORE.fs.Sel], eax
    816816
    817817    mov     eax, dword [esp + ESPOFF + 24h]
    818     mov     dword [esp + CPUMCTXCORE.gs], eax
     818    mov     dword [esp + CPUMCTXCORE.gs.Sel], eax
    819819
    820820ti_SkipV86Entry:
     
    925925    lea     eax, [esp + 14h + ESPOFF]      ; calc esp at trap
    926926    mov     [esp + CPUMCTXCORE.esp], eax   ; update esp in register frame
    927     mov     [esp + CPUMCTXCORE.ss], ss    ; update ss in register frame
     927    mov     [esp + CPUMCTXCORE.ss.Sel], ss ; update ss in register frame
    928928
    929929%ifdef DEBUG_STUFF_INT
     
    964964    jnz     short ti_SkipSelRegs
    965965
    966     mov     eax, [esp + CPUMCTXCORE.gs]
     966    mov     eax, [esp + CPUMCTXCORE.gs.Sel]
    967967    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_GS | TRPM_TRAP_IN_HYPER
    968968    mov     gs, eax
    969969
    970     mov     eax, [esp + CPUMCTXCORE.fs]
     970    mov     eax, [esp + CPUMCTXCORE.fs.Sel]
    971971    TRPM_NP_GP_HANDLER NAME(trpmGCTrapInGeneric), TRPM_TRAP_IN_MOV_FS | TRPM_TRAP_IN_HYPER
    972972    mov     fs, eax
    973973
    974     mov     eax, [esp + CPUMCTXCORE.es]
     974    mov     eax, [esp + CPUMCTXCORE.es.Sel]
    975975    mov     es, eax
    976     mov     eax, [esp + CPUMCTXCORE.ds]
     976    mov     eax, [esp + CPUMCTXCORE.ds.Sel]
    977977    mov     ds, eax
    978978
     
    10991099
    11001100    movzx   eax, word [ecx + VBOXTSS.cs]
    1101     mov     dword [esp + CPUMCTXCORE.cs], eax
     1101    mov     dword [esp + CPUMCTXCORE.cs.Sel], eax
    11021102    movzx   eax, word [ecx + VBOXTSS.ds]
    1103     mov     dword [esp + CPUMCTXCORE.ds], eax
     1103    mov     dword [esp + CPUMCTXCORE.ds.Sel], eax
    11041104    movzx   eax, word [ecx + VBOXTSS.es]
    1105     mov     dword [esp + CPUMCTXCORE.es], eax
     1105    mov     dword [esp + CPUMCTXCORE.es.Sel], eax
    11061106    movzx   eax, word [ecx + VBOXTSS.fs]
    1107     mov     dword [esp + CPUMCTXCORE.fs], eax
     1107    mov     dword [esp + CPUMCTXCORE.fs.Sel], eax
    11081108    movzx   eax, word [ecx + VBOXTSS.gs]
    1109     mov     dword [esp + CPUMCTXCORE.gs], eax
     1109    mov     dword [esp + CPUMCTXCORE.gs.Sel], eax
    11101110    movzx   eax, word [ecx + VBOXTSS.ss]
    1111     mov     [esp + CPUMCTXCORE.ss], eax
     1111    mov     [esp + CPUMCTXCORE.ss.Sel], eax
    11121112    mov     eax, [ecx + VBOXTSS.esp]
    11131113    mov     [esp + CPUMCTXCORE.esp], eax
     
    12601260tddrf_regs:
    12611261    COM_S_PRINT ' ***',10,13,'cs:eip='
    1262     movzx   ecx, word [eax + CPUMCTXCORE.cs]
     1262    movzx   ecx, word [eax + CPUMCTXCORE.cs.Sel]
    12631263    COM_S_DWORD_REG ecx
    12641264    COM_S_CHAR ':'
     
    12671267
    12681268    COM_S_PRINT '    ss:esp='
    1269     movzx   ecx, word [eax + CPUMCTXCORE.ss]
     1269    movzx   ecx, word [eax + CPUMCTXCORE.ss.Sel]
    12701270    COM_S_DWORD_REG ecx
    12711271    COM_S_CHAR ':'
     
    13231323
    13241324    COM_S_PRINT 10,13,' ds='
    1325     movzx   ecx, word [eax + CPUMCTXCORE.ds]
     1325    movzx   ecx, word [eax + CPUMCTXCORE.ds.Sel]
    13261326    COM_S_DWORD_REG ecx
    13271327
    13281328    COM_S_PRINT '   es='
    1329     movzx   ecx, word [eax + CPUMCTXCORE.es]
     1329    movzx   ecx, word [eax + CPUMCTXCORE.es.Sel]
    13301330    COM_S_DWORD_REG ecx
    13311331
    13321332    COM_S_PRINT '   fs='
    1333     movzx   ecx, word [eax + CPUMCTXCORE.fs]
     1333    movzx   ecx, word [eax + CPUMCTXCORE.fs.Sel]
    13341334    COM_S_DWORD_REG ecx
    13351335
    13361336    COM_S_PRINT '   gs='
    1337     movzx   ecx, word [eax + CPUMCTXCORE.gs]
     1337    movzx   ecx, word [eax + CPUMCTXCORE.gs.Sel]
    13381338    COM_S_DWORD_REG ecx
    13391339
  • trunk/src/VBox/VMM/VMMRC/VMMRC.cpp

    r41801 r41906  
    371371{
    372372    int rc = vmmGCTestTmpPFHandler(pVM, pRegFrame);
    373     pRegFrame->fs = 0x30;
     373    pRegFrame->fs.Sel = 0x30;
    374374    return rc;
    375375}
  • trunk/src/VBox/VMM/VMMRC/VMMRC.mac

    r35335 r41906  
    3939   [section .VMMR0.%1 progbits alloc noexec nowrite align=1 ]
    4040  %else
    41    [section .VMMR0.%1 align=1 ]
     41   [section .VMMR0.%1 ]
    4242  %endif
    4343 %endmacro
  • trunk/src/VBox/VMM/VMMRZ/DBGFRZ.cpp

    r41823 r41906  
    4646{
    4747#ifdef IN_RC
    48     const bool fInHyper = !(pRegFrame->ss & X86_SEL_RPL) && !pRegFrame->eflags.Bits.u1VM;
     48    const bool fInHyper = !(pRegFrame->ss.Sel & X86_SEL_RPL) && !pRegFrame->eflags.Bits.u1VM;
    4949#else
    5050    const bool fInHyper = false;
     
    6666                pVCpu->dbgf.s.fSingleSteppingRaw = false;
    6767                LogFlow(("DBGFRZTrap03Handler: hit hw breakpoint %d at %04x:%RGv\n",
    68                          pVM->dbgf.s.aHwBreakpoints[iBp].iBp, pRegFrame->cs, pRegFrame->rip));
     68                         pVM->dbgf.s.aHwBreakpoints[iBp].iBp, pRegFrame->cs.Sel, pRegFrame->rip));
    6969
    7070                return fInHyper ? VINF_EM_DBG_HYPER_BREAKPOINT : VINF_EM_DBG_BREAKPOINT;
     
    8181    {
    8282        pVCpu->dbgf.s.fSingleSteppingRaw = false;
    83         LogFlow(("DBGFRZTrap01Handler: single step at %04x:%RGv\n", pRegFrame->cs, pRegFrame->rip));
     83        LogFlow(("DBGFRZTrap01Handler: single step at %04x:%RGv\n", pRegFrame->cs.Sel, pRegFrame->rip));
    8484        return fInHyper ? VINF_EM_DBG_HYPER_STEPPED : VINF_EM_DBG_STEPPED;
    8585    }
     
    9191     */
    9292    AssertMsg(uDr6 & X86_DR6_BS, ("hey! we're not doing guest BPs yet! dr6=%RTreg %04x:%RGv\n",
    93                                   uDr6, pRegFrame->cs, pRegFrame->rip));
     93                                  uDr6, pRegFrame->cs.Sel, pRegFrame->rip));
    9494#endif
    9595
    96     LogFlow(("DBGFRZTrap01Handler: guest debug event %RTreg at %04x:%RGv!\n", uDr6, pRegFrame->cs, pRegFrame->rip));
     96    LogFlow(("DBGFRZTrap01Handler: guest debug event %RTreg at %04x:%RGv!\n", uDr6, pRegFrame->cs.Sel, pRegFrame->rip));
    9797    return fInHyper ? VERR_DBGF_HYPER_DB_XCPT : VINF_EM_RAW_GUEST_TRAP;
    9898}
     
    113113{
    114114#ifdef IN_RC
    115     const bool fInHyper = !(pRegFrame->ss & X86_SEL_RPL) && !pRegFrame->eflags.Bits.u1VM;
     115    const bool fInHyper = !(pRegFrame->ss.Sel & X86_SEL_RPL) && !pRegFrame->eflags.Bits.u1VM;
    116116#else
    117117    const bool fInHyper = false;
     
    125125    {
    126126        RTGCPTR pPc;
    127         int rc = SELMValidateAndConvertCSAddr(pVCpu, pRegFrame->eflags, pRegFrame->ss, pRegFrame->cs, &pRegFrame->csHid,
     127        int rc = SELMValidateAndConvertCSAddr(pVCpu, pRegFrame->eflags, pRegFrame->ss.Sel, pRegFrame->cs.Sel, &pRegFrame->cs,
    128128#ifdef IN_RC
    129129                                              pRegFrame->eip - 1,
     
    143143
    144144                LogFlow(("DBGFRZTrap03Handler: hit breakpoint %d at %RGv (%04x:%RGv) cHits=0x%RX64\n",
    145                          pVM->dbgf.s.aBreakpoints[iBp].iBp, pPc, pRegFrame->cs, pRegFrame->rip,
     145                         pVM->dbgf.s.aBreakpoints[iBp].iBp, pPc, pRegFrame->cs.Sel, pRegFrame->rip,
    146146                         pVM->dbgf.s.aBreakpoints[iBp].cHits));
    147147                return fInHyper
  • trunk/src/VBox/VMM/VMMSwitcher/AMD64andLegacy.mac

    r41905 r41906  
    544544    ; Setup stack.
    545545    DEBUG_CHAR('3')
    546     mov     ax, [edx + CPUMCPU.Hyper.ss]
     546    mov     ax, [edx + CPUMCPU.Hyper.ss.Sel]
    547547    mov     ss, ax
    548548    mov     esp, [edx + CPUMCPU.Hyper.esp]
     
    553553    and     dword [0ffffffffh], ~0200h      ; clear busy flag (2nd type2 bit)
    554554    DEBUG_CHAR('5')
    555     ltr     word [edx + CPUMCPU.Hyper.tr]
     555    ltr     word [edx + CPUMCPU.Hyper.tr.Sel]
    556556    DEBUG_CHAR('6')
    557557
    558558    ; Activate the ldt (now we can safely crash).
    559     lldt    [edx + CPUMCPU.Hyper.ldtr]
     559    lldt    [edx + CPUMCPU.Hyper.ldtr.Sel]
    560560    DEBUG_CHAR('7')
    561561
     
    750750    mov     [edx + CPUMCPU.Guest.esp], eax
    751751    ; selectors
    752     mov     eax, [esp + 4 + CPUMCTXCORE.ss]
    753     mov     [edx + CPUMCPU.Guest.ss], eax
    754     mov     eax, [esp + 4 + CPUMCTXCORE.gs]
    755     mov     [edx + CPUMCPU.Guest.gs], eax
    756     mov     eax, [esp + 4 + CPUMCTXCORE.fs]
    757     mov     [edx + CPUMCPU.Guest.fs], eax
    758     mov     eax, [esp + 4 + CPUMCTXCORE.es]
    759     mov     [edx + CPUMCPU.Guest.es], eax
    760     mov     eax, [esp + 4 + CPUMCTXCORE.ds]
    761     mov     [edx + CPUMCPU.Guest.ds], eax
    762     mov     eax, [esp + 4 + CPUMCTXCORE.cs]
    763     mov     [edx + CPUMCPU.Guest.cs], eax
     752    mov     eax, [esp + 4 + CPUMCTXCORE.ss.Sel]
     753    mov     [edx + CPUMCPU.Guest.ss.Sel], eax
     754    mov     eax, [esp + 4 + CPUMCTXCORE.gs.Sel]
     755    mov     [edx + CPUMCPU.Guest.gs.Sel], eax
     756    mov     eax, [esp + 4 + CPUMCTXCORE.fs.Sel]
     757    mov     [edx + CPUMCPU.Guest.fs.Sel], eax
     758    mov     eax, [esp + 4 + CPUMCTXCORE.es.Sel]
     759    mov     [edx + CPUMCPU.Guest.es.Sel], eax
     760    mov     eax, [esp + 4 + CPUMCTXCORE.ds.Sel]
     761    mov     [edx + CPUMCPU.Guest.ds.Sel], eax
     762    mov     eax, [esp + 4 + CPUMCTXCORE.cs.Sel]
     763    mov     [edx + CPUMCPU.Guest.cs.Sel], eax
    764764    ; flags
    765765    mov     eax, [esp + 4 + CPUMCTXCORE.eflags]
     
    833833    mov     [edx + CPUMCPU.Hyper.esp], eax
    834834    ; selectors
    835     mov     eax, [ecx + CPUMCTXCORE.ss]
    836     mov     [edx + CPUMCPU.Hyper.ss], eax
    837     mov     eax, [ecx + CPUMCTXCORE.gs]
    838     mov     [edx + CPUMCPU.Hyper.gs], eax
    839     mov     eax, [ecx + CPUMCTXCORE.fs]
    840     mov     [edx + CPUMCPU.Hyper.fs], eax
    841     mov     eax, [ecx + CPUMCTXCORE.es]
    842     mov     [edx + CPUMCPU.Hyper.es], eax
    843     mov     eax, [ecx + CPUMCTXCORE.ds]
    844     mov     [edx + CPUMCPU.Hyper.ds], eax
    845     mov     eax, [ecx + CPUMCTXCORE.cs]
    846     mov     [edx + CPUMCPU.Hyper.cs], eax
     835    mov     eax, [ecx + CPUMCTXCORE.ss.Sel]
     836    mov     [edx + CPUMCPU.Hyper.ss.Sel], eax
     837    mov     eax, [ecx + CPUMCTXCORE.gs.Sel]
     838    mov     [edx + CPUMCPU.Hyper.gs.Sel], eax
     839    mov     eax, [ecx + CPUMCTXCORE.fs.Sel]
     840    mov     [edx + CPUMCPU.Hyper.fs.Sel], eax
     841    mov     eax, [ecx + CPUMCTXCORE.es.Sel]
     842    mov     [edx + CPUMCPU.Hyper.es.Sel], eax
     843    mov     eax, [ecx + CPUMCTXCORE.ds.Sel]
     844    mov     [edx + CPUMCPU.Hyper.ds.Sel], eax
     845    mov     eax, [ecx + CPUMCTXCORE.cs.Sel]
     846    mov     [edx + CPUMCPU.Hyper.cs.Sel], eax
    847847    ; flags
    848848    mov     eax, [ecx + CPUMCTXCORE.eflags]
     
    916916%endif
    917917    ; str     [edx + CPUMCPU.Hyper.tr] - double fault only, and it won't be right then either.
    918     sldt    [edx + CPUMCPU.Hyper.ldtr]
     918    sldt    [edx + CPUMCPU.Hyper.ldtr.Sel]
    919919
    920920    ; No need to save CRx here. They are set dynamically according to Guest/Host requirements.
  • trunk/src/VBox/VMM/include/CPUMInternal.mac

    r41905 r41906  
    115115    .Hyper.r14                resq    1
    116116    .Hyper.r15                resq    1
    117     .Hyper.es                 resw    1
    118     .Hyper.esPadding          resw    3
    119     .Hyper.esHid.u64Base      resq    1
    120     .Hyper.esHid.u32Limit     resd    1
    121     .Hyper.esHid.Attr         resd    1
    122     .Hyper.cs                 resw    1
    123     .Hyper.csPadding          resw    3
    124     .Hyper.csHid.u64Base      resq    1
    125     .Hyper.csHid.u32Limit     resd    1
    126     .Hyper.csHid.Attr         resd    1
    127     .Hyper.ss                 resw    1
    128     .Hyper.ssPadding          resw    3
    129     .Hyper.ssHid.u64Base      resq    1
    130     .Hyper.ssHid.u32Limit     resd    1
    131     .Hyper.ssHid.Attr         resd    1
    132     .Hyper.ds                 resw    1
    133     .Hyper.dsPadding          resw    3
    134     .Hyper.dsHid.u64Base      resq    1
    135     .Hyper.dsHid.u32Limit     resd    1
    136     .Hyper.dsHid.Attr         resd    1
    137     .Hyper.fs                 resw    1
    138     .Hyper.fsPadding          resw    3
    139     .Hyper.fsHid.u64Base      resq    1
    140     .Hyper.fsHid.u32Limit     resd    1
    141     .Hyper.fsHid.Attr         resd    1
    142     .Hyper.gs                 resw    1
    143     .Hyper.gsPadding          resw    3
    144     .Hyper.gsHid.u64Base      resq    1
    145     .Hyper.gsHid.u32Limit     resd    1
    146     .Hyper.gsHid.Attr         resd    1
     117    .Hyper.es.Sel             resw    1
     118    .Hyper.es.PaddingSel      resw    1
     119    .Hyper.es.ValidSel        resw    1
     120    .Hyper.es.fFlags          resw    1
     121    .Hyper.es.u64Base         resq    1
     122    .Hyper.es.u32Limit        resd    1
     123    .Hyper.es.Attr            resd    1
     124    .Hyper.cs.Sel             resw    1
     125    .Hyper.cs.PaddingSel      resw    1
     126    .Hyper.cs.ValidSel        resw    1
     127    .Hyper.cs.fFlags          resw    1
     128    .Hyper.cs.u64Base         resq    1
     129    .Hyper.cs.u32Limit        resd    1
     130    .Hyper.cs.Attr            resd    1
     131    .Hyper.ss.Sel             resw    1
     132    .Hyper.ss.PaddingSel      resw    1
     133    .Hyper.ss.ValidSel        resw    1
     134    .Hyper.ss.fFlags          resw    1
     135    .Hyper.ss.u64Base         resq    1
     136    .Hyper.ss.u32Limit        resd    1
     137    .Hyper.ss.Attr            resd    1
     138    .Hyper.ds.Sel             resw    1
     139    .Hyper.ds.PaddingSel      resw    1
     140    .Hyper.ds.ValidSel        resw    1
     141    .Hyper.ds.fFlags          resw    1
     142    .Hyper.ds.u64Base         resq    1
     143    .Hyper.ds.u32Limit        resd    1
     144    .Hyper.ds.Attr            resd    1
     145    .Hyper.fs.Sel             resw    1
     146    .Hyper.fs.PaddingSel      resw    1
     147    .Hyper.fs.ValidSel        resw    1
     148    .Hyper.fs.fFlags          resw    1
     149    .Hyper.fs.u64Base         resq    1
     150    .Hyper.fs.u32Limit        resd    1
     151    .Hyper.fs.Attr            resd    1
     152    .Hyper.gs.Sel             resw    1
     153    .Hyper.gs.PaddingSel      resw    1
     154    .Hyper.gs.ValidSel        resw    1
     155    .Hyper.gs.fFlags          resw    1
     156    .Hyper.gs.u64Base         resq    1
     157    .Hyper.gs.u32Limit        resd    1
     158    .Hyper.gs.Attr            resd    1
    147159    .Hyper.eip                resq    1
    148160    .Hyper.eflags             resq    1
     
    160172    .Hyper.idtr.cbIdt         resw    1
    161173    .Hyper.idtr.pIdt          resq    1
    162     .Hyper.ldtr               resw    1
    163     .Hyper.ldtrPadding        resw    3
    164     .Hyper.ldtrHid.u64Base    resq    1
    165     .Hyper.ldtrHid.u32Limit   resd    1
    166     .Hyper.ldtrHid.Attr       resd    1
    167     .Hyper.tr                 resw    1
    168     .Hyper.trPadding          resw    3
    169     .Hyper.trHid.u64Base      resq    1
    170     .Hyper.trHid.u32Limit     resd    1
    171     .Hyper.trHid.Attr         resd    1
     174    .Hyper.ldtr.Sel           resw    1
     175    .Hyper.ldtr.PaddingSel    resw    1
     176    .Hyper.ldtr.ValidSel      resw    1
     177    .Hyper.ldtr.fFlags        resw    1
     178    .Hyper.ldtr.u64Base       resq    1
     179    .Hyper.ldtr.u32Limit      resd    1
     180    .Hyper.ldtr.Attr          resd    1
     181    .Hyper.tr.Sel             resw    1
     182    .Hyper.tr.PaddingSel      resw    1
     183    .Hyper.tr.ValidSel        resw    1
     184    .Hyper.tr.fFlags          resw    1
     185    .Hyper.tr.u64Base         resq    1
     186    .Hyper.tr.u32Limit        resd    1
     187    .Hyper.tr.Attr            resd    1
    172188    .Hyper.SysEnter.cs        resb    8
    173189    .Hyper.SysEnter.eip       resb    8
     
    319335    .Guest.r14                resq    1
    320336    .Guest.r15                resq    1
    321     .Guest.es                 resw    1
    322     .Guest.esPadding          resw    3
    323     .Guest.esHid.u64Base      resq    1
    324     .Guest.esHid.u32Limit     resd    1
    325     .Guest.esHid.Attr         resd    1
    326     .Guest.cs                 resw    1
    327     .Guest.csPadding          resw    3
    328     .Guest.csHid.u64Base      resq    1
    329     .Guest.csHid.u32Limit     resd    1
    330     .Guest.csHid.Attr         resd    1
    331     .Guest.ss                 resw    1
    332     .Guest.ssPadding          resw    3
    333     .Guest.ssHid.u64Base      resq    1
    334     .Guest.ssHid.u32Limit     resd    1
    335     .Guest.ssHid.Attr         resd    1
    336     .Guest.ds                 resw    1
    337     .Guest.dsPadding          resw    3
    338     .Guest.dsHid.u64Base      resq    1
    339     .Guest.dsHid.u32Limit     resd    1
    340     .Guest.dsHid.Attr         resd    1
    341     .Guest.fs                 resw    1
    342     .Guest.fsPadding          resw    3
    343     .Guest.fsHid.u64Base      resq    1
    344     .Guest.fsHid.u32Limit     resd    1
    345     .Guest.fsHid.Attr         resd    1
    346     .Guest.gs                 resw    1
    347     .Guest.gsPadding          resw    3
    348     .Guest.gsHid.u64Base      resq    1
    349     .Guest.gsHid.u32Limit     resd    1
    350     .Guest.gsHid.Attr         resd    1
     337    .Guest.es.Sel             resw    1
     338    .Guest.es.PaddingSel      resw    1
     339    .Guest.es.ValidSel        resw    1
     340    .Guest.es.fFlags          resw    1
     341    .Guest.es.u64Base         resq    1
     342    .Guest.es.u32Limit        resd    1
     343    .Guest.es.Attr            resd    1
     344    .Guest.cs.Sel             resw    1
     345    .Guest.cs.PaddingSel      resw    1
     346    .Guest.cs.ValidSel        resw    1
     347    .Guest.cs.fFlags          resw    1
     348    .Guest.cs.u64Base         resq    1
     349    .Guest.cs.u32Limit        resd    1
     350    .Guest.cs.Attr            resd    1
     351    .Guest.ss.Sel             resw    1
     352    .Guest.ss.PaddingSel      resw    1
     353    .Guest.ss.ValidSel        resw    1
     354    .Guest.ss.fFlags          resw    1
     355    .Guest.ss.u64Base         resq    1
     356    .Guest.ss.u32Limit        resd    1
     357    .Guest.ss.Attr            resd    1
     358    .Guest.ds.Sel             resw    1
     359    .Guest.ds.PaddingSel      resw    1
     360    .Guest.ds.ValidSel        resw    1
     361    .Guest.ds.fFlags          resw    1
     362    .Guest.ds.u64Base         resq    1
     363    .Guest.ds.u32Limit        resd    1
     364    .Guest.ds.Attr            resd    1
     365    .Guest.fs.Sel             resw    1
     366    .Guest.fs.PaddingSel      resw    1
     367    .Guest.fs.ValidSel        resw    1
     368    .Guest.fs.fFlags          resw    1
     369    .Guest.fs.u64Base         resq    1
     370    .Guest.fs.u32Limit        resd    1
     371    .Guest.fs.Attr            resd    1
     372    .Guest.gs.Sel             resw    1
     373    .Guest.gs.PaddingSel      resw    1
     374    .Guest.gs.ValidSel        resw    1
     375    .Guest.gs.fFlags          resw    1
     376    .Guest.gs.u64Base         resq    1
     377    .Guest.gs.u32Limit        resd    1
     378    .Guest.gs.Attr            resd    1
    351379    .Guest.eip                resq    1
    352380    .Guest.eflags             resq    1
     
    364392    .Guest.idtr.cbIdt         resw    1
    365393    .Guest.idtr.pIdt          resq    1
    366     .Guest.ldtr               resw    1
    367     .Guest.ldtrPadding        resw    3
    368     .Guest.ldtrHid.u64Base    resq    1
    369     .Guest.ldtrHid.u32Limit   resd    1
    370     .Guest.ldtrHid.Attr       resd    1
    371     .Guest.tr                 resw    1
    372     .Guest.trPadding          resw    3
    373     .Guest.trHid.u64Base      resq    1
    374     .Guest.trHid.u32Limit     resd    1
    375     .Guest.trHid.Attr         resd    1
     394    .Guest.ldtr.Sel           resw    1
     395    .Guest.ldtr.PaddingSel    resw    1
     396    .Guest.ldtr.ValidSel      resw    1
     397    .Guest.ldtr.fFlags        resw    1
     398    .Guest.ldtr.u64Base       resq    1
     399    .Guest.ldtr.u32Limit      resd    1
     400    .Guest.ldtr.Attr          resd    1
     401    .Guest.tr.Sel             resw    1
     402    .Guest.tr.PaddingSel      resw    1
     403    .Guest.tr.ValidSel        resw    1
     404    .Guest.tr.fFlags          resw    1
     405    .Guest.tr.u64Base         resq    1
     406    .Guest.tr.u32Limit        resd    1
     407    .Guest.tr.Attr            resd    1
    376408    .Guest.SysEnter.cs        resb    8
    377409    .Guest.SysEnter.eip       resb    8
  • trunk/src/VBox/VMM/include/EMHandleRCTmpl.h

    r41804 r41906  
    112112        case VINF_PATM_HC_MMIO_PATCH_READ:
    113113            rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(pCtx), pCtx->eip),
    114                                     PATMFL_MMIO_ACCESS | ((SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs, &pCtx->csHid) == DISCPUMODE_32BIT) ? PATMFL_CODE32 : 0));
     114                                      PATMFL_MMIO_ACCESS
     115                                    | (    SELMGetCpuModeFromSelector(pVCpu, pCtx->eflags, pCtx->cs.Sel, &pCtx->cs)
     116                                        == DISCPUMODE_32BIT ? PATMFL_CODE32 : 0));
    115117            if (RT_FAILURE(rc))
    116118                rc = emR3ExecuteInstruction(pVM, pVCpu, "MMIO");
  • trunk/src/VBox/VMM/testcase/tstMicroRCA.asm

    r41321 r41906  
    502502                              ;40
    503503
    504     test    byte [esp + CPUMCTXCORE.cs], 3h ; check CPL of the cs selector
     504    test    byte [esp + CPUMCTXCORE.cs.Sel], 3h ; check CPL of the cs selector
    505505    jmp short tstTrapHandler_Fault_Hyper ;; @todo
    506506    jz short tstTrapHandler_Fault_Hyper
     
    516516    lea     ebx, [esp + 14h + 040h]     ; calc esp at trap
    517517    mov     [esp + CPUMCTXCORE.esp], ebx; update esp in register frame
    518     mov     [esp + CPUMCTXCORE.ss], ss  ; update ss in register frame
     518    mov     [esp + CPUMCTXCORE.ss.Sel], ss  ; update ss in register frame
    519519
    520520    mov     ecx, esp
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r41905 r41906  
    148148    GEN_CHECK_OFF(CPUMCTX, rcx);
    149149    GEN_CHECK_OFF(CPUMCTX, rsp);
     150    GEN_CHECK_OFF(CPUMCTX, es);
     151#ifndef VBOX_FOR_DTRACE_LIB
     152    GEN_CHECK_OFF(CPUMCTX, es.Sel);
     153    GEN_CHECK_OFF(CPUMCTX, es.ValidSel);
     154    GEN_CHECK_OFF(CPUMCTX, es.fFlags);
     155    GEN_CHECK_OFF(CPUMCTX, es.u64Base);
     156    GEN_CHECK_OFF(CPUMCTX, es.u32Limit);
     157    GEN_CHECK_OFF(CPUMCTX, es.Attr);
     158#endif
     159    GEN_CHECK_OFF(CPUMCTX, cs);
    150160    GEN_CHECK_OFF(CPUMCTX, ss);
     161    GEN_CHECK_OFF(CPUMCTX, ds);
     162    GEN_CHECK_OFF(CPUMCTX, fs);
    151163    GEN_CHECK_OFF(CPUMCTX, gs);
    152     GEN_CHECK_OFF(CPUMCTX, fs);
    153     GEN_CHECK_OFF(CPUMCTX, es);
    154     GEN_CHECK_OFF(CPUMCTX, ds);
    155     GEN_CHECK_OFF(CPUMCTX, cs);
    156164    GEN_CHECK_OFF(CPUMCTX, rflags);
    157165    GEN_CHECK_OFF(CPUMCTX, rip);
     
    164172    GEN_CHECK_OFF(CPUMCTX, r14);
    165173    GEN_CHECK_OFF(CPUMCTX, r15);
    166     GEN_CHECK_OFF(CPUMCTX, esHid);
    167     GEN_CHECK_OFF(CPUMCTX, csHid);
    168     GEN_CHECK_OFF(CPUMCTX, ssHid);
    169     GEN_CHECK_OFF(CPUMCTX, dsHid);
    170     GEN_CHECK_OFF(CPUMCTX, fsHid);
    171     GEN_CHECK_OFF(CPUMCTX, gsHid);
    172174    GEN_CHECK_OFF(CPUMCTX, cr0);
    173175    GEN_CHECK_OFF(CPUMCTX, cr2);
     
    187189    GEN_CHECK_OFF(CPUMCTX, msrSFMASK);
    188190    GEN_CHECK_OFF(CPUMCTX, msrKERNELGSBASE);
    189     GEN_CHECK_OFF(CPUMCTX, ldtrHid);
    190     GEN_CHECK_OFF(CPUMCTX, trHid);
     191    GEN_CHECK_OFF(CPUMCTX, ldtr);
     192    GEN_CHECK_OFF(CPUMCTX, tr);
     193#ifndef VBOX_FOR_DTRACE_LIB
     194    GEN_CHECK_OFF(CPUMCTX, tr.Sel);
     195    GEN_CHECK_OFF(CPUMCTX, tr.ValidSel);
     196    GEN_CHECK_OFF(CPUMCTX, tr.fFlags);
     197    GEN_CHECK_OFF(CPUMCTX, tr.u64Base);
     198    GEN_CHECK_OFF(CPUMCTX, tr.u32Limit);
     199    GEN_CHECK_OFF(CPUMCTX, tr.Attr);
     200#endif
    191201
    192202    GEN_CHECK_SIZE(CPUMCTXMSRS);
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r41905 r41906  
    295295    CHECK_MEMBER_ALIGNMENT(CPUMCTX, SysEnter, 8);
    296296    CHECK_CPUMCTXCORE(rax);
    297     CHECK_CPUMCTXCORE(rbx);
    298297    CHECK_CPUMCTXCORE(rcx);
    299298    CHECK_CPUMCTXCORE(rdx);
     299    CHECK_CPUMCTXCORE(rbx);
     300    CHECK_CPUMCTXCORE(rsp);
    300301    CHECK_CPUMCTXCORE(rbp);
    301     CHECK_CPUMCTXCORE(rsp);
     302    CHECK_CPUMCTXCORE(rsi);
    302303    CHECK_CPUMCTXCORE(rdi);
    303     CHECK_CPUMCTXCORE(rsi);
    304     CHECK_CPUMCTXCORE(rip);
    305     CHECK_CPUMCTXCORE(rflags);
    306     CHECK_CPUMCTXCORE(cs);
    307     CHECK_CPUMCTXCORE(ds);
    308     CHECK_CPUMCTXCORE(es);
    309     CHECK_CPUMCTXCORE(fs);
    310     CHECK_CPUMCTXCORE(gs);
    311     CHECK_CPUMCTXCORE(ss);
    312304    CHECK_CPUMCTXCORE(r8);
    313305    CHECK_CPUMCTXCORE(r9);
     
    318310    CHECK_CPUMCTXCORE(r14);
    319311    CHECK_CPUMCTXCORE(r15);
    320     CHECK_CPUMCTXCORE(esHid);
    321     CHECK_CPUMCTXCORE(csHid);
    322     CHECK_CPUMCTXCORE(ssHid);
    323     CHECK_CPUMCTXCORE(dsHid);
    324     CHECK_CPUMCTXCORE(fsHid);
    325     CHECK_CPUMCTXCORE(gsHid);
     312    CHECK_CPUMCTXCORE(es);
     313    CHECK_CPUMCTXCORE(ss);
     314    CHECK_CPUMCTXCORE(cs);
     315    CHECK_CPUMCTXCORE(ds);
     316    CHECK_CPUMCTXCORE(fs);
     317    CHECK_CPUMCTXCORE(gs);
     318    CHECK_CPUMCTXCORE(rip);
     319    CHECK_CPUMCTXCORE(rflags);
    326320
    327321#if HC_ARCH_BITS == 32
  • trunk/src/recompiler/VBoxRecompiler.c

    r41675 r41906  
    14411441        Ctx.cr4            = env->cr[4];
    14421442
    1443         Ctx.tr             = env->tr.selector;
    1444         Ctx.trHid.u64Base  = env->tr.base;
    1445         Ctx.trHid.u32Limit = env->tr.limit;
    1446         Ctx.trHid.Attr.u   = (env->tr.flags >> 8) & 0xF0FF;
    1447 
    1448         Ctx.ldtr              = env->ldt.selector;
    1449         Ctx.ldtrHid.u64Base   = env->ldt.base;
    1450         Ctx.ldtrHid.u32Limit  = env->ldt.limit;
    1451         Ctx.ldtrHid.Attr.u    = (env->ldt.flags >> 8) & 0xF0FF;
     1443        Ctx.tr.Sel         = env->tr.selector;
     1444        Ctx.tr.ValidSel    = env->tr.selector;
     1445        Ctx.tr.fFlags      = CPUMSELREG_FLAGS_VALID;
     1446        Ctx.tr.u64Base     = env->tr.base;
     1447        Ctx.tr.u32Limit    = env->tr.limit;
     1448        Ctx.tr.Attr.u      = (env->tr.flags >> 8) & 0xF0FF;
     1449
     1450        Ctx.ldtr.Sel       = env->ldt.selector;
     1451        Ctx.ldtr.ValidSel  = env->ldt.selector;
     1452        Ctx.ldtr.fFlags    = CPUMSELREG_FLAGS_VALID;
     1453        Ctx.ldtr.u64Base   = env->ldt.base;
     1454        Ctx.ldtr.u32Limit  = env->ldt.limit;
     1455        Ctx.ldtr.Attr.u    = (env->ldt.flags >> 8) & 0xF0FF;
    14521456
    14531457        Ctx.idtr.cbIdt     = env->idt.limit;
     
    14621466        Ctx.eflags.u32     = env->eflags;
    14631467
    1464         Ctx.cs             = env->segs[R_CS].selector;
    1465         Ctx.csHid.u64Base  = env->segs[R_CS].base;
    1466         Ctx.csHid.u32Limit = env->segs[R_CS].limit;
    1467         Ctx.csHid.Attr.u   = (env->segs[R_CS].flags >> 8) & 0xF0FF;
    1468 
    1469         Ctx.ds             = env->segs[R_DS].selector;
    1470         Ctx.dsHid.u64Base  = env->segs[R_DS].base;
    1471         Ctx.dsHid.u32Limit = env->segs[R_DS].limit;
    1472         Ctx.dsHid.Attr.u   = (env->segs[R_DS].flags >> 8) & 0xF0FF;
    1473 
    1474         Ctx.es             = env->segs[R_ES].selector;
    1475         Ctx.esHid.u64Base  = env->segs[R_ES].base;
    1476         Ctx.esHid.u32Limit = env->segs[R_ES].limit;
    1477         Ctx.esHid.Attr.u   = (env->segs[R_ES].flags >> 8) & 0xF0FF;
    1478 
    1479         Ctx.fs             = env->segs[R_FS].selector;
    1480         Ctx.fsHid.u64Base  = env->segs[R_FS].base;
    1481         Ctx.fsHid.u32Limit = env->segs[R_FS].limit;
    1482         Ctx.fsHid.Attr.u   = (env->segs[R_FS].flags >> 8) & 0xF0FF;
    1483 
    1484         Ctx.gs             = env->segs[R_GS].selector;
    1485         Ctx.gsHid.u64Base  = env->segs[R_GS].base;
    1486         Ctx.gsHid.u32Limit = env->segs[R_GS].limit;
    1487         Ctx.gsHid.Attr.u   = (env->segs[R_GS].flags >> 8) & 0xF0FF;
    1488 
    1489         Ctx.ss             = env->segs[R_SS].selector;
    1490         Ctx.ssHid.u64Base  = env->segs[R_SS].base;
    1491         Ctx.ssHid.u32Limit = env->segs[R_SS].limit;
    1492         Ctx.ssHid.Attr.u   = (env->segs[R_SS].flags >> 8) & 0xF0FF;
     1468        Ctx.cs.Sel         = env->segs[R_CS].selector;
     1469        Ctx.cs.ValidSel    = env->segs[R_CS].selector;
     1470        Ctx.cs.fFlags      = CPUMSELREG_FLAGS_VALID;
     1471        Ctx.cs.u64Base     = env->segs[R_CS].base;
     1472        Ctx.cs.u32Limit    = env->segs[R_CS].limit;
     1473        Ctx.cs.Attr.u      = (env->segs[R_CS].flags >> 8) & 0xF0FF;
     1474
     1475        Ctx.ds.Sel         = env->segs[R_DS].selector;
     1476        Ctx.ds.ValidSel    = env->segs[R_DS].selector;
     1477        Ctx.ds.fFlags      = CPUMSELREG_FLAGS_VALID;
     1478        Ctx.ds.u64Base     = env->segs[R_DS].base;
     1479        Ctx.ds.u32Limit    = env->segs[R_DS].limit;
     1480        Ctx.ds.Attr.u      = (env->segs[R_DS].flags >> 8) & 0xF0FF;
     1481
     1482        Ctx.es.Sel         = env->segs[R_ES].selector;
     1483        Ctx.es.ValidSel    = env->segs[R_ES].selector;
     1484        Ctx.es.fFlags      = CPUMSELREG_FLAGS_VALID;
     1485        Ctx.es.u64Base     = env->segs[R_ES].base;
     1486        Ctx.es.u32Limit    = env->segs[R_ES].limit;
     1487        Ctx.es.Attr.u      = (env->segs[R_ES].flags >> 8) & 0xF0FF;
     1488
     1489        Ctx.fs.Sel         = env->segs[R_FS].selector;
     1490        Ctx.fs.ValidSel    = env->segs[R_FS].selector;
     1491        Ctx.fs.fFlags      = CPUMSELREG_FLAGS_VALID;
     1492        Ctx.fs.u64Base     = env->segs[R_FS].base;
     1493        Ctx.fs.u32Limit    = env->segs[R_FS].limit;
     1494        Ctx.fs.Attr.u      = (env->segs[R_FS].flags >> 8) & 0xF0FF;
     1495
     1496        Ctx.gs.Sel         = env->segs[R_GS].selector;
     1497        Ctx.gs.ValidSel    = env->segs[R_GS].selector;
     1498        Ctx.gs.fFlags      = CPUMSELREG_FLAGS_VALID;
     1499        Ctx.gs.u64Base     = env->segs[R_GS].base;
     1500        Ctx.gs.u32Limit    = env->segs[R_GS].limit;
     1501        Ctx.gs.Attr.u      = (env->segs[R_GS].flags >> 8) & 0xF0FF;
     1502
     1503        Ctx.ss.Sel         = env->segs[R_SS].selector;
     1504        Ctx.ss.ValidSel    = env->segs[R_SS].selector;
     1505        Ctx.ss.fFlags      = CPUMSELREG_FLAGS_VALID;
     1506        Ctx.ss.u64Base     = env->segs[R_SS].base;
     1507        Ctx.ss.u32Limit    = env->segs[R_SS].limit;
     1508        Ctx.ss.Attr.u      = (env->segs[R_SS].flags >> 8) & 0xF0FF;
    14931509
    14941510        Ctx.msrEFER        = env->efer;
     
    22612277        if (fFlags & CPUM_CHANGED_LDTR)
    22622278        {
    2263             if (fHiddenSelRegsValid)
     2279            if (fHiddenSelRegsValid || (pCtx->ldtr.fFlags & CPUMSELREG_FLAGS_VALID))
    22642280            {
    2265                 pVM->rem.s.Env.ldt.selector = pCtx->ldtr;
    2266                 pVM->rem.s.Env.ldt.base     = pCtx->ldtrHid.u64Base;
    2267                 pVM->rem.s.Env.ldt.limit    = pCtx->ldtrHid.u32Limit;
    2268                 pVM->rem.s.Env.ldt.flags    = (pCtx->ldtrHid.Attr.u << 8) & 0xFFFFFF;
     2281                pVM->rem.s.Env.ldt.selector = pCtx->ldtr.Sel;
     2282                pVM->rem.s.Env.ldt.base     = pCtx->ldtr.u64Base;
     2283                pVM->rem.s.Env.ldt.limit    = pCtx->ldtr.u32Limit;
     2284                pVM->rem.s.Env.ldt.flags    = (pCtx->ldtr.Attr.u << 8) & 0xFFFFFF;
    22692285            }
    22702286            else
    2271                 sync_ldtr(&pVM->rem.s.Env, pCtx->ldtr);
     2287                sync_ldtr(&pVM->rem.s.Env, pCtx->ldtr.Sel);
    22722288        }
    22732289
     
    22912307     * Sync TR unconditionally to make life simpler.
    22922308     */
    2293     pVM->rem.s.Env.tr.selector = pCtx->tr;
    2294     pVM->rem.s.Env.tr.base     = pCtx->trHid.u64Base;
    2295     pVM->rem.s.Env.tr.limit    = pCtx->trHid.u32Limit;
    2296     pVM->rem.s.Env.tr.flags    = (pCtx->trHid.Attr.u << 8) & 0xFFFFFF;
     2309    pVM->rem.s.Env.tr.selector = pCtx->tr.Sel;
     2310    pVM->rem.s.Env.tr.base     = pCtx->tr.u64Base;
     2311    pVM->rem.s.Env.tr.limit    = pCtx->tr.u32Limit;
     2312    pVM->rem.s.Env.tr.flags    = (pCtx->tr.Attr.u << 8) & 0xFFFFFF;
    22972313    /* Note! do_interrupt will fault if the busy flag is still set... */
    2298     pVM->rem.s.Env.tr.flags &= ~DESC_TSS_BUSY_MASK;
     2314    pVM->rem.s.Env.tr.flags   &= ~DESC_TSS_BUSY_MASK;
    22992315
    23002316    /*
     
    23172333        cpu_x86_set_cpl(&pVM->rem.s.Env, uCpl);
    23182334
    2319         cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_CS, pCtx->cs, pCtx->csHid.u64Base, pCtx->csHid.u32Limit, (pCtx->csHid.Attr.u << 8) & 0xFFFFFF);
    2320         cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_SS, pCtx->ss, pCtx->ssHid.u64Base, pCtx->ssHid.u32Limit, (pCtx->ssHid.Attr.u << 8) & 0xFFFFFF);
    2321         cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_DS, pCtx->ds, pCtx->dsHid.u64Base, pCtx->dsHid.u32Limit, (pCtx->dsHid.Attr.u << 8) & 0xFFFFFF);
    2322         cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_ES, pCtx->es, pCtx->esHid.u64Base, pCtx->esHid.u32Limit, (pCtx->esHid.Attr.u << 8) & 0xFFFFFF);
    2323         cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_FS, pCtx->fs, pCtx->fsHid.u64Base, pCtx->fsHid.u32Limit, (pCtx->fsHid.Attr.u << 8) & 0xFFFFFF);
    2324         cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_GS, pCtx->gs, pCtx->gsHid.u64Base, pCtx->gsHid.u32Limit, (pCtx->gsHid.Attr.u << 8) & 0xFFFFFF);
     2335        cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_CS, pCtx->cs.Sel, pCtx->cs.u64Base, pCtx->cs.u32Limit, (pCtx->cs.Attr.u << 8) & 0xFFFFFF);
     2336        cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_SS, pCtx->ss.Sel, pCtx->ss.u64Base, pCtx->ss.u32Limit, (pCtx->ss.Attr.u << 8) & 0xFFFFFF);
     2337        cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_DS, pCtx->ds.Sel, pCtx->ds.u64Base, pCtx->ds.u32Limit, (pCtx->ds.Attr.u << 8) & 0xFFFFFF);
     2338        cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_ES, pCtx->es.Sel, pCtx->es.u64Base, pCtx->es.u32Limit, (pCtx->es.Attr.u << 8) & 0xFFFFFF);
     2339        cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_FS, pCtx->fs.Sel, pCtx->fs.u64Base, pCtx->fs.u32Limit, (pCtx->fs.Attr.u << 8) & 0xFFFFFF);
     2340        cpu_x86_load_seg_cache(&pVM->rem.s.Env, R_GS, pCtx->gs.Sel, pCtx->gs.u64Base, pCtx->gs.u32Limit, (pCtx->gs.Attr.u << 8) & 0xFFFFFF);
    23252341    }
    23262342    else
    23272343    {
    23282344        /* In 'normal' raw mode we don't have access to the hidden selector registers. */
    2329         if (pVM->rem.s.Env.segs[R_SS].selector != pCtx->ss)
     2345        /** @todo use hidden registers when possible and make CPUM/someone do the
     2346         *        reading of lazily maintained hidden registers. */
     2347        if (pVM->rem.s.Env.segs[R_SS].selector != pCtx->ss.Sel)
    23302348        {
    2331             Log2(("REMR3State: SS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_SS].selector, pCtx->ss));
     2349            Log2(("REMR3State: SS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_SS].selector, pCtx->ss.Sel));
    23322350
    23332351            cpu_x86_set_cpl(&pVM->rem.s.Env, uCpl);
    2334             sync_seg(&pVM->rem.s.Env, R_SS, pCtx->ss);
     2352            sync_seg(&pVM->rem.s.Env, R_SS, pCtx->ss.Sel);
    23352353#ifdef VBOX_WITH_STATISTICS
    23362354            if (pVM->rem.s.Env.segs[R_SS].newselector)
     
    23432361            pVM->rem.s.Env.segs[R_SS].newselector = 0;
    23442362
    2345         if (pVM->rem.s.Env.segs[R_ES].selector != pCtx->es)
     2363        if (pVM->rem.s.Env.segs[R_ES].selector != pCtx->es.Sel)
    23462364        {
    2347             Log2(("REMR3State: ES changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_ES].selector, pCtx->es));
    2348             sync_seg(&pVM->rem.s.Env, R_ES, pCtx->es);
     2365            Log2(("REMR3State: ES changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_ES].selector, pCtx->es.Sel));
     2366            sync_seg(&pVM->rem.s.Env, R_ES, pCtx->es.Sel);
    23492367#ifdef VBOX_WITH_STATISTICS
    23502368            if (pVM->rem.s.Env.segs[R_ES].newselector)
     
    23572375            pVM->rem.s.Env.segs[R_ES].newselector = 0;
    23582376
    2359         if (pVM->rem.s.Env.segs[R_CS].selector != pCtx->cs)
     2377        if (pVM->rem.s.Env.segs[R_CS].selector != pCtx->cs.Sel)
    23602378        {
    2361             Log2(("REMR3State: CS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_CS].selector, pCtx->cs));
    2362             sync_seg(&pVM->rem.s.Env, R_CS, pCtx->cs);
     2379            Log2(("REMR3State: CS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_CS].selector, pCtx->cs.Sel));
     2380            sync_seg(&pVM->rem.s.Env, R_CS, pCtx->cs.Sel);
    23632381#ifdef VBOX_WITH_STATISTICS
    23642382            if (pVM->rem.s.Env.segs[R_CS].newselector)
     
    23712389            pVM->rem.s.Env.segs[R_CS].newselector = 0;
    23722390
    2373         if (pVM->rem.s.Env.segs[R_DS].selector != pCtx->ds)
     2391        if (pVM->rem.s.Env.segs[R_DS].selector != pCtx->ds.Sel)
    23742392        {
    2375             Log2(("REMR3State: DS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_DS].selector, pCtx->ds));
    2376             sync_seg(&pVM->rem.s.Env, R_DS, pCtx->ds);
     2393            Log2(("REMR3State: DS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_DS].selector, pCtx->ds.Sel));
     2394            sync_seg(&pVM->rem.s.Env, R_DS, pCtx->ds.Sel);
    23772395#ifdef VBOX_WITH_STATISTICS
    23782396            if (pVM->rem.s.Env.segs[R_DS].newselector)
     
    23872405    /** @todo need to find a way to communicate potential GDT/LDT changes and thread switches. The selector might
    23882406     * be the same but not the base/limit. */
    2389         if (pVM->rem.s.Env.segs[R_FS].selector != pCtx->fs)
     2407        if (pVM->rem.s.Env.segs[R_FS].selector != pCtx->fs.Sel)
    23902408        {
    2391             Log2(("REMR3State: FS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_FS].selector, pCtx->fs));
    2392             sync_seg(&pVM->rem.s.Env, R_FS, pCtx->fs);
     2409            Log2(("REMR3State: FS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_FS].selector, pCtx->fs.Sel));
     2410            sync_seg(&pVM->rem.s.Env, R_FS, pCtx->fs.Sel);
    23932411#ifdef VBOX_WITH_STATISTICS
    23942412            if (pVM->rem.s.Env.segs[R_FS].newselector)
     
    24012419            pVM->rem.s.Env.segs[R_FS].newselector = 0;
    24022420
    2403         if (pVM->rem.s.Env.segs[R_GS].selector != pCtx->gs)
     2421        if (pVM->rem.s.Env.segs[R_GS].selector != pCtx->gs.Sel)
    24042422        {
    2405             Log2(("REMR3State: GS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_GS].selector, pCtx->gs));
    2406             sync_seg(&pVM->rem.s.Env, R_GS, pCtx->gs);
     2423            Log2(("REMR3State: GS changed from %04x to %04x!\n", pVM->rem.s.Env.segs[R_GS].selector, pCtx->gs.Sel));
     2424            sync_seg(&pVM->rem.s.Env, R_GS, pCtx->gs.Sel);
    24072425#ifdef VBOX_WITH_STATISTICS
    24082426            if (pVM->rem.s.Env.segs[R_GS].newselector)
     
    25802598#endif
    25812599
    2582     pCtx->ss            = pVM->rem.s.Env.segs[R_SS].selector;
    2583 
    2584 #ifdef VBOX_WITH_STATISTICS
    2585     if (pVM->rem.s.Env.segs[R_SS].newselector)
    2586     {
    2587         STAM_COUNTER_INC(&gStatSelOutOfSyncStateBack[R_SS]);
    2588     }
    2589     if (pVM->rem.s.Env.segs[R_GS].newselector)
    2590     {
    2591         STAM_COUNTER_INC(&gStatSelOutOfSyncStateBack[R_GS]);
    2592     }
    2593     if (pVM->rem.s.Env.segs[R_FS].newselector)
    2594     {
    2595         STAM_COUNTER_INC(&gStatSelOutOfSyncStateBack[R_FS]);
    2596     }
    2597     if (pVM->rem.s.Env.segs[R_ES].newselector)
    2598     {
    2599         STAM_COUNTER_INC(&gStatSelOutOfSyncStateBack[R_ES]);
    2600     }
    2601     if (pVM->rem.s.Env.segs[R_DS].newselector)
    2602     {
    2603         STAM_COUNTER_INC(&gStatSelOutOfSyncStateBack[R_DS]);
    2604     }
    2605     if (pVM->rem.s.Env.segs[R_CS].newselector)
    2606     {
    2607         STAM_COUNTER_INC(&gStatSelOutOfSyncStateBack[R_CS]);
    2608     }
    2609 #endif
    2610     pCtx->gs            = pVM->rem.s.Env.segs[R_GS].selector;
    2611     pCtx->fs            = pVM->rem.s.Env.segs[R_FS].selector;
    2612     pCtx->es            = pVM->rem.s.Env.segs[R_ES].selector;
    2613     pCtx->ds            = pVM->rem.s.Env.segs[R_DS].selector;
    2614     pCtx->cs            = pVM->rem.s.Env.segs[R_CS].selector;
     2600#define SYNC_BACK_SREG(a_sreg, a_SREG) \
     2601        do \
     2602        { \
     2603            pCtx->a_sreg.Sel = pVM->rem.s.Env.segs[R_##a_SREG].selector; \
     2604            if (!pVM->rem.s.Env.segs[R_SS].newselector) \
     2605            { \
     2606                pCtx->a_sreg.ValidSel = pVM->rem.s.Env.segs[R_##a_SREG].selector; \
     2607                pCtx->a_sreg.fFlags   = CPUMSELREG_FLAGS_VALID; \
     2608                pCtx->a_sreg.u64Base  = pVM->rem.s.Env.segs[R_##a_SREG].base; \
     2609                pCtx->a_sreg.u32Limit = pVM->rem.s.Env.segs[R_##a_SREG].limit; \
     2610                /* Note! QEmu saves the 2nd dword of the descriptor; we should store the attribute word only! */ \
     2611                pCtx->a_sreg.Attr.u   = (pVM->rem.s.Env.segs[R_##a_SREG].flags >> 8) & 0xF0FF; \
     2612            } \
     2613            else \
     2614            { \
     2615                pCtx->a_sreg.fFlags = 0; \
     2616                STAM_COUNTER_INC(&gStatSelOutOfSyncStateBack[R_##a_SREG]); \
     2617            } \
     2618        } while (0)
     2619
     2620    SYNC_BACK_SREG(es, ES);
     2621    SYNC_BACK_SREG(cs, CS);
     2622    SYNC_BACK_SREG(ss, SS);
     2623    SYNC_BACK_SREG(ds, DS);
     2624    SYNC_BACK_SREG(fs, FS);
     2625    SYNC_BACK_SREG(gs, GS);
    26152626
    26162627#ifdef TARGET_X86_64
     
    26482659    }
    26492660
    2650     if (    pCtx->ldtr             != pVM->rem.s.Env.ldt.selector
    2651         ||  pCtx->ldtrHid.u64Base  != pVM->rem.s.Env.ldt.base
    2652         ||  pCtx->ldtrHid.u32Limit != pVM->rem.s.Env.ldt.limit
    2653         ||  pCtx->ldtrHid.Attr.u   != ((pVM->rem.s.Env.ldt.flags >> 8) & 0xF0FF))
    2654     {
    2655         pCtx->ldtr              = pVM->rem.s.Env.ldt.selector;
    2656         pCtx->ldtrHid.u64Base   = pVM->rem.s.Env.ldt.base;
    2657         pCtx->ldtrHid.u32Limit  = pVM->rem.s.Env.ldt.limit;
    2658         pCtx->ldtrHid.Attr.u    = (pVM->rem.s.Env.ldt.flags >> 8) & 0xF0FF;
     2661    if (    pCtx->ldtr.Sel      != pVM->rem.s.Env.ldt.selector
     2662        ||  pCtx->ldtr.ValidSel != pVM->rem.s.Env.ldt.selector
     2663        ||  pCtx->ldtr.u64Base  != pVM->rem.s.Env.ldt.base
     2664        ||  pCtx->ldtr.u32Limit != pVM->rem.s.Env.ldt.limit
     2665        ||  pCtx->ldtr.Attr.u   != ((pVM->rem.s.Env.ldt.flags >> 8) & 0xF0FF)
     2666        ||  !(pCtx->ldtr.fFlags & CPUMSELREG_FLAGS_VALID)
     2667       )
     2668    {
     2669        pCtx->ldtr.Sel      = pVM->rem.s.Env.ldt.selector;
     2670        pCtx->ldtr.ValidSel = pVM->rem.s.Env.ldt.selector;
     2671        pCtx->ldtr.fFlags   = CPUMSELREG_FLAGS_VALID;
     2672        pCtx->ldtr.u64Base  = pVM->rem.s.Env.ldt.base;
     2673        pCtx->ldtr.u32Limit = pVM->rem.s.Env.ldt.limit;
     2674        pCtx->ldtr.Attr.u   = (pVM->rem.s.Env.ldt.flags >> 8) & 0xF0FF;
    26592675        STAM_COUNTER_INC(&gStatREMLDTRChange);
    26602676        VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT);
    26612677    }
    26622678
    2663     if (    pCtx->tr             != pVM->rem.s.Env.tr.selector
    2664         ||  pCtx->trHid.u64Base  != pVM->rem.s.Env.tr.base
    2665         ||  pCtx->trHid.u32Limit != pVM->rem.s.Env.tr.limit
     2679    if (    pCtx->tr.Sel      != pVM->rem.s.Env.tr.selector
     2680        ||  pCtx->tr.ValidSel != pVM->rem.s.Env.tr.selector
     2681        ||  pCtx->tr.u64Base  != pVM->rem.s.Env.tr.base
     2682        ||  pCtx->tr.u32Limit != pVM->rem.s.Env.tr.limit
    26662683            /* Qemu and AMD/Intel have different ideas about the busy flag ... */
    2667         ||  pCtx->trHid.Attr.u   != (  (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF
     2684        ||  pCtx->tr.Attr.u   != (  (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF
    26682685                                     ? (pVM->rem.s.Env.tr.flags | DESC_TSS_BUSY_MASK) >> 8
    2669                                      : 0) )
     2686                                     : 0)
     2687        ||  !(pCtx->tr.fFlags & CPUMSELREG_FLAGS_VALID)
     2688       )
    26702689    {
    26712690        Log(("REM: TR changed! %#x{%#llx,%#x,%#x} -> %#x{%llx,%#x,%#x}\n",
    2672              pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u,
     2691             pCtx->tr.Sel, pCtx->tr.u64Base, pCtx->tr.u32Limit, pCtx->tr.Attr.u,
    26732692             pVM->rem.s.Env.tr.selector, (uint64_t)pVM->rem.s.Env.tr.base, pVM->rem.s.Env.tr.limit,
    26742693             (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF ? (pVM->rem.s.Env.tr.flags | DESC_TSS_BUSY_MASK) >> 8 : 0));
    2675         pCtx->tr                = pVM->rem.s.Env.tr.selector;
    2676         pCtx->trHid.u64Base     = pVM->rem.s.Env.tr.base;
    2677         pCtx->trHid.u32Limit    = pVM->rem.s.Env.tr.limit;
    2678         pCtx->trHid.Attr.u      = (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF;
    2679         if (pCtx->trHid.Attr.u)
    2680             pCtx->trHid.Attr.u |= DESC_TSS_BUSY_MASK >> 8;
     2694        pCtx->tr.Sel        = pVM->rem.s.Env.tr.selector;
     2695        pCtx->tr.ValidSel   = pVM->rem.s.Env.tr.selector;
     2696        pCtx->tr.fFlags     = CPUMSELREG_FLAGS_VALID;
     2697        pCtx->tr.u64Base    = pVM->rem.s.Env.tr.base;
     2698        pCtx->tr.u32Limit   = pVM->rem.s.Env.tr.limit;
     2699        pCtx->tr.Attr.u     = (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF;
     2700        if (pCtx->tr.Attr.u)
     2701            pCtx->tr.Attr.u |= DESC_TSS_BUSY_MASK >> 8;
    26812702        STAM_COUNTER_INC(&gStatREMTRChange);
    26822703        VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS);
    26832704    }
    2684 
    2685     /** @todo These values could still be out of sync! */
    2686     pCtx->csHid.u64Base    = pVM->rem.s.Env.segs[R_CS].base;
    2687     pCtx->csHid.u32Limit   = pVM->rem.s.Env.segs[R_CS].limit;
    2688     /* Note! QEmu saves the 2nd dword of the descriptor; we should store the attribute word only! */
    2689     pCtx->csHid.Attr.u     = (pVM->rem.s.Env.segs[R_CS].flags >> 8) & 0xF0FF;
    2690 
    2691     pCtx->dsHid.u64Base    = pVM->rem.s.Env.segs[R_DS].base;
    2692     pCtx->dsHid.u32Limit   = pVM->rem.s.Env.segs[R_DS].limit;
    2693     pCtx->dsHid.Attr.u     = (pVM->rem.s.Env.segs[R_DS].flags >> 8) & 0xF0FF;
    2694 
    2695     pCtx->esHid.u64Base    = pVM->rem.s.Env.segs[R_ES].base;
    2696     pCtx->esHid.u32Limit   = pVM->rem.s.Env.segs[R_ES].limit;
    2697     pCtx->esHid.Attr.u     = (pVM->rem.s.Env.segs[R_ES].flags >> 8) & 0xF0FF;
    2698 
    2699     pCtx->fsHid.u64Base    = pVM->rem.s.Env.segs[R_FS].base;
    2700     pCtx->fsHid.u32Limit   = pVM->rem.s.Env.segs[R_FS].limit;
    2701     pCtx->fsHid.Attr.u     = (pVM->rem.s.Env.segs[R_FS].flags >> 8) & 0xF0FF;
    2702 
    2703     pCtx->gsHid.u64Base    = pVM->rem.s.Env.segs[R_GS].base;
    2704     pCtx->gsHid.u32Limit   = pVM->rem.s.Env.segs[R_GS].limit;
    2705     pCtx->gsHid.Attr.u     = (pVM->rem.s.Env.segs[R_GS].flags >> 8) & 0xF0FF;
    2706 
    2707     pCtx->ssHid.u64Base    = pVM->rem.s.Env.segs[R_SS].base;
    2708     pCtx->ssHid.u32Limit   = pVM->rem.s.Env.segs[R_SS].limit;
    2709     pCtx->ssHid.Attr.u     = (pVM->rem.s.Env.segs[R_SS].flags >> 8) & 0xF0FF;
    27102705
    27112706    /* Sysenter MSR */
     
    28452840#endif
    28462841
    2847     pCtx->ss            = pVM->rem.s.Env.segs[R_SS].selector;
    2848 
    2849     pCtx->gs            = pVM->rem.s.Env.segs[R_GS].selector;
    2850     pCtx->fs            = pVM->rem.s.Env.segs[R_FS].selector;
    2851     pCtx->es            = pVM->rem.s.Env.segs[R_ES].selector;
    2852     pCtx->ds            = pVM->rem.s.Env.segs[R_DS].selector;
    2853     pCtx->cs            = pVM->rem.s.Env.segs[R_CS].selector;
     2842    SYNC_BACK_SREG(es, ES);
     2843    SYNC_BACK_SREG(cs, CS);
     2844    SYNC_BACK_SREG(ss, SS);
     2845    SYNC_BACK_SREG(ds, DS);
     2846    SYNC_BACK_SREG(fs, FS);
     2847    SYNC_BACK_SREG(gs, GS);
    28542848
    28552849#ifdef TARGET_X86_64
     
    28872881    }
    28882882
    2889     if (    pCtx->ldtr             != pVM->rem.s.Env.ldt.selector
    2890         ||  pCtx->ldtrHid.u64Base  != pVM->rem.s.Env.ldt.base
    2891         ||  pCtx->ldtrHid.u32Limit != pVM->rem.s.Env.ldt.limit
    2892         ||  pCtx->ldtrHid.Attr.u   != ((pVM->rem.s.Env.ldt.flags >> 8) & 0xF0FF))
    2893     {
    2894         pCtx->ldtr              = pVM->rem.s.Env.ldt.selector;
    2895         pCtx->ldtrHid.u64Base   = pVM->rem.s.Env.ldt.base;
    2896         pCtx->ldtrHid.u32Limit  = pVM->rem.s.Env.ldt.limit;
    2897         pCtx->ldtrHid.Attr.u    = (pVM->rem.s.Env.ldt.flags >> 8) & 0xFFFF;
     2883    if (    pCtx->ldtr.Sel      != pVM->rem.s.Env.ldt.selector
     2884        ||  pCtx->ldtr.ValidSel != pVM->rem.s.Env.ldt.selector
     2885        ||  pCtx->ldtr.u64Base  != pVM->rem.s.Env.ldt.base
     2886        ||  pCtx->ldtr.u32Limit != pVM->rem.s.Env.ldt.limit
     2887        ||  pCtx->ldtr.Attr.u   != ((pVM->rem.s.Env.ldt.flags >> 8) & 0xF0FF)
     2888        ||  !(pCtx->ldtr.fFlags & CPUMSELREG_FLAGS_VALID)
     2889       )
     2890    {
     2891        pCtx->ldtr.Sel      = pVM->rem.s.Env.ldt.selector;
     2892        pCtx->ldtr.ValidSel = pVM->rem.s.Env.ldt.selector;
     2893        pCtx->ldtr.fFlags   = CPUMSELREG_FLAGS_VALID;
     2894        pCtx->ldtr.u64Base  = pVM->rem.s.Env.ldt.base;
     2895        pCtx->ldtr.u32Limit = pVM->rem.s.Env.ldt.limit;
     2896        pCtx->ldtr.Attr.u   = (pVM->rem.s.Env.ldt.flags >> 8) & 0xF0FF;
    28982897        STAM_COUNTER_INC(&gStatREMLDTRChange);
    28992898        VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT);
    29002899    }
    29012900
    2902     if (    pCtx->tr             != pVM->rem.s.Env.tr.selector
    2903         ||  pCtx->trHid.u64Base  != pVM->rem.s.Env.tr.base
    2904         ||  pCtx->trHid.u32Limit != pVM->rem.s.Env.tr.limit
     2901    if (    pCtx->tr.Sel      != pVM->rem.s.Env.tr.selector
     2902        ||  pCtx->tr.ValidSel != pVM->rem.s.Env.tr.selector
     2903        ||  pCtx->tr.u64Base  != pVM->rem.s.Env.tr.base
     2904        ||  pCtx->tr.u32Limit != pVM->rem.s.Env.tr.limit
    29052905            /* Qemu and AMD/Intel have different ideas about the busy flag ... */
    2906         ||  pCtx->trHid.Attr.u   != (  (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF
     2906        ||  pCtx->tr.Attr.u   != (  (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF
    29072907                                     ? (pVM->rem.s.Env.tr.flags | DESC_TSS_BUSY_MASK) >> 8
    2908                                      : 0) )
     2908                                     : 0)
     2909        ||  !(pCtx->tr.fFlags & CPUMSELREG_FLAGS_VALID)
     2910       )
    29092911    {
    29102912        Log(("REM: TR changed! %#x{%#llx,%#x,%#x} -> %#x{%llx,%#x,%#x}\n",
    2911              pCtx->tr, pCtx->trHid.u64Base, pCtx->trHid.u32Limit, pCtx->trHid.Attr.u,
     2913             pCtx->tr.Sel, pCtx->tr.u64Base, pCtx->tr.u32Limit, pCtx->tr.Attr.u,
    29122914             pVM->rem.s.Env.tr.selector, (uint64_t)pVM->rem.s.Env.tr.base, pVM->rem.s.Env.tr.limit,
    29132915             (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF ? (pVM->rem.s.Env.tr.flags | DESC_TSS_BUSY_MASK) >> 8 : 0));
    2914         pCtx->tr                = pVM->rem.s.Env.tr.selector;
    2915         pCtx->trHid.u64Base     = pVM->rem.s.Env.tr.base;
    2916         pCtx->trHid.u32Limit    = pVM->rem.s.Env.tr.limit;
    2917         pCtx->trHid.Attr.u      = (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF;
    2918         if (pCtx->trHid.Attr.u)
    2919             pCtx->trHid.Attr.u |= DESC_TSS_BUSY_MASK >> 8;
     2916        pCtx->tr.Sel        = pVM->rem.s.Env.tr.selector;
     2917        pCtx->tr.ValidSel   = pVM->rem.s.Env.tr.selector;
     2918        pCtx->tr.fFlags     = CPUMSELREG_FLAGS_VALID;
     2919        pCtx->tr.u64Base    = pVM->rem.s.Env.tr.base;
     2920        pCtx->tr.u32Limit   = pVM->rem.s.Env.tr.limit;
     2921        pCtx->tr.Attr.u     = (pVM->rem.s.Env.tr.flags >> 8) & 0xF0FF;
     2922        if (pCtx->tr.Attr.u)
     2923            pCtx->tr.Attr.u |= DESC_TSS_BUSY_MASK >> 8;
    29202924        STAM_COUNTER_INC(&gStatREMTRChange);
    29212925        VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS);
    29222926    }
    2923 
    2924     /** @todo These values could still be out of sync! */
    2925     pCtx->csHid.u64Base    = pVM->rem.s.Env.segs[R_CS].base;
    2926     pCtx->csHid.u32Limit   = pVM->rem.s.Env.segs[R_CS].limit;
    2927     /** @note QEmu saves the 2nd dword of the descriptor; we should store the attribute word only! */
    2928     pCtx->csHid.Attr.u     = (pVM->rem.s.Env.segs[R_CS].flags >> 8) & 0xFFFF;
    2929 
    2930     pCtx->dsHid.u64Base    = pVM->rem.s.Env.segs[R_DS].base;
    2931     pCtx->dsHid.u32Limit   = pVM->rem.s.Env.segs[R_DS].limit;
    2932     pCtx->dsHid.Attr.u     = (pVM->rem.s.Env.segs[R_DS].flags >> 8) & 0xFFFF;
    2933 
    2934     pCtx->esHid.u64Base    = pVM->rem.s.Env.segs[R_ES].base;
    2935     pCtx->esHid.u32Limit   = pVM->rem.s.Env.segs[R_ES].limit;
    2936     pCtx->esHid.Attr.u     = (pVM->rem.s.Env.segs[R_ES].flags >> 8) & 0xFFFF;
    2937 
    2938     pCtx->fsHid.u64Base    = pVM->rem.s.Env.segs[R_FS].base;
    2939     pCtx->fsHid.u32Limit   = pVM->rem.s.Env.segs[R_FS].limit;
    2940     pCtx->fsHid.Attr.u     = (pVM->rem.s.Env.segs[R_FS].flags >> 8) & 0xFFFF;
    2941 
    2942     pCtx->gsHid.u64Base    = pVM->rem.s.Env.segs[R_GS].base;
    2943     pCtx->gsHid.u32Limit   = pVM->rem.s.Env.segs[R_GS].limit;
    2944     pCtx->gsHid.Attr.u     = (pVM->rem.s.Env.segs[R_GS].flags >> 8) & 0xFFFF;
    2945 
    2946     pCtx->ssHid.u64Base    = pVM->rem.s.Env.segs[R_SS].base;
    2947     pCtx->ssHid.u32Limit   = pVM->rem.s.Env.segs[R_SS].limit;
    2948     pCtx->ssHid.Attr.u     = (pVM->rem.s.Env.segs[R_SS].flags >> 8) & 0xFFFF;
    29492927
    29502928    /* Sysenter MSR */
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