VirtualBox

Changeset 2260 in vbox


Ignore:
Timestamp:
Apr 20, 2007 9:18:48 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
20619
Message:

Corrections for real and v86 addresses + cleanup + notes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/SELMAll.cpp

    r2189 r2260  
    9191SELMDECL(RTGCPTR) SELMToFlat(PVM pVM, X86EFLAGS eflags, RTSEL Sel, CPUMSELREGHID *pHiddenSel, RTGCPTR Addr)
    9292{
     93    Assert(pHiddenSel);
     94
     95   /*
     96    * Deal with real & v86 mode first.
     97    */
     98    if (    CPUMIsGuestInRealMode(pVM)
     99        ||  eflags.Bits.u1VM)
     100    {
     101        RTGCUINTPTR uFlat = (RTGCUINTPTR)Addr & 0xffff;
     102
     103        if (CPUMAreHiddenSelRegsValid(pVM))
     104            uFlat += pHiddenSel->u32Base;
     105        else
     106            uFlat += ((RTGCUINTPTR)Sel << 4);
     107        return (RTGCPTR)uFlat;
     108    }
     109
     110    /** @todo when we're in 16 bits mode, we should cut off the address as well.. */
    93111    if (!CPUMAreHiddenSelRegsValid(pVM))
    94     {
    95         /*
    96         * Deal with real & v86 mode first.
    97         */
    98         if (    CPUMIsGuestInRealMode(pVM)
    99             ||  eflags.Bits.u1VM)
    100         {
    101             RTGCUINTPTR uFlat = ((RTGCUINTPTR)Addr & 0xffff) + ((RTGCUINTPTR)Sel << 4);
    102             return (RTGCPTR)uFlat;
    103         }
    104 
    105112        return selmToFlat(pVM, Sel, Addr);
    106     }
    107     return (RTGCPTR)(pHiddenSel->u32Base + (RTGCUINTPTR)Addr);
     113    else
     114        return (RTGCPTR)(pHiddenSel->u32Base + (RTGCUINTPTR)Addr);
    108115}
    109116
     
    134141        ||  eflags.Bits.u1VM)
    135142    {
     143        RTGCUINTPTR uFlat = (RTGCUINTPTR)Addr & 0xffff;
    136144        if (ppvGC)
    137145        {
    138146            if (    pHiddenSel
    139147                &&  CPUMAreHiddenSelRegsValid(pVM))
    140             {
    141                 *ppvGC = (RTGCPTR)(pHiddenSel->u32Base + (RTGCUINTPTR)Addr);
    142             }
     148                *ppvGC = (RTGCPTR)(pHiddenSel->u32Base + uFlat);
    143149            else
    144             {
    145                 RTGCUINTPTR uFlat = ((RTGCUINTPTR)Addr & 0xffff) + ((RTGCUINTPTR)Sel << 4);
    146                 *ppvGC = (RTGCPTR)uFlat;
    147             }
     150                *ppvGC = (RTGCPTR)(((RTGCUINTPTR)Sel << 4) + uFlat);
    148151        }
    149152        if (pcb)
    150             *pcb = 0x10000 - ((RTGCUINTPTR)Addr & 0xffff);
     153            *pcb = 0x10000 - uFlat;
    151154        return VINF_SUCCESS;
    152155    }
     
    157160    uint32_t    u1Present, u1DescType, u1Granularity, u4Type;
    158161
     162    /** @todo when we're in 16 bits mode, we should cut off the address as well.. */
    159163    if (    pHiddenSel
    160164        &&  CPUMAreHiddenSelRegsValid(pVM))
     
    420424        if (ppvFlat)
    421425        {
    422             RTGCUINTPTR uFlat;
     426            RTGCUINTPTR uFlat = (RTGCUINTPTR)Addr & 0xffff;
    423427
    424428            if (!CPUMAreHiddenSelRegsValid(pVM))
    425                 uFlat = ((RTGCUINTPTR)Addr & 0xffff) + ((RTGCUINTPTR)SelCS << 4);
     429                uFlat += ((RTGCUINTPTR)SelCS << 4);
    426430            else
    427                 uFlat = pHiddenCSSel->u32Base + (RTGCUINTPTR)Addr;
     431                uFlat += pHiddenCSSel->u32Base;
    428432
    429433            *ppvFlat = (RTGCPTR)uFlat;
     
    431435        return VINF_SUCCESS;
    432436    }
     437
     438    /** @todo when we're in 16 bits mode, we should cut off the address as well.. */
    433439
    434440    if (!CPUMAreHiddenSelRegsValid(pVM))
Note: See TracChangeset for help on using the changeset viewer.

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