Changeset 42166 in vbox
- Timestamp:
- Jul 16, 2012 2:07:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r42165 r42166 2541 2541 VMMDECL(uint32_t) CPUMGetGuestCPL(PVMCPU pVCpu) 2542 2542 { 2543 /* 2544 * CPL can reliably be found in SS.DPL (hidden regs valid) or SS if not. 2545 * 2546 * Note! We used to check CS.DPL here, assuming it was always equal to 2547 * CPL even if a conforming segment was loaded. But this truned out to 2548 * only apply to older AMD-V. With VT-x we had an ACP2 regression 2549 * during install after a far call to ring 2 with VT-x. Then on newer 2550 * AMD-V CPUs we have to move the VMCB.guest.u8CPL into cs.Attr.n.u2Dpl 2551 * as well as ss.Attr.n.u2Dpl to make this (and other) code work right. 2552 * 2553 * So, forget CS.DPL, always use SS.DPL. 2554 * 2555 * Note! The SS RPL is always equal to the CPL, while the CS RPL 2556 * isn't necessarily equal if the segment is conforming. 2557 * See section 4.11.1 in the AMD manual. 2558 */ 2543 2559 uint32_t uCpl; 2544 2545 #if 1 2546 if (CPUMAreHiddenSelRegsValid(pVCpu)) 2547 #else 2548 if (CPUMSELREG_ARE_HIDDEN_PARTS_VALID(&pVCpu->cpum.s.Guest.ss)) 2549 #endif 2560 if (pVCpu->cpum.s.Guest.cr0 & X86_CR0_PE) 2550 2561 { 2551 /* 2552 * CPL can reliably be found in SS.DPL. 2553 * 2554 * Note! We used to check CS.DPL here, assuming it was always equal to 2555 * CPL even if a conforming segment was loaded. But this truned out to 2556 * only apply to older AMD-V. With VT-x we had an ACP2 regression 2557 * during install after a far call to ring 2 with VT-x. Then on newer 2558 * AMD-V CPUs we have to move the VMCB.guest.u8CPL into cs.Attr.n.u2Dpl 2559 * as well as ss.Attr.n.u2Dpl to make this (and other) code work right. 2560 * 2561 * So, forget CS.DPL, always use SS.DPL. 2562 */ 2563 if (RT_LIKELY(pVCpu->cpum.s.Guest.cr0 & X86_CR0_PE)) 2564 { 2565 if (!pVCpu->cpum.s.Guest.eflags.Bits.u1VM) 2562 if (!pVCpu->cpum.s.Guest.eflags.Bits.u1VM) 2563 { 2564 if (CPUMSELREG_ARE_HIDDEN_PARTS_VALID(&pVCpu->cpum.s.Guest.ss)) 2566 2565 uCpl = pVCpu->cpum.s.Guest.ss.Attr.n.u2Dpl; 2567 2566 else 2568 uCpl = 3; /* REM doesn't set DPL=3 in V8086 mode. See @bugref{5130}. */ 2567 { 2568 uCpl = (pVCpu->cpum.s.Guest.ss.Sel & X86_SEL_RPL); 2569 #ifndef IN_RING0 2570 if (uCpl == 1) 2571 uCpl = 0; 2572 #endif 2573 } 2569 2574 } 2570 2575 else 2571 uCpl = 0; /* CPL set to 3 for VT-x real-mode emulation. */ 2572 } 2573 else if (pVCpu->cpum.s.Guest.cr0 & X86_CR0_PE) 2574 { 2575 if (!pVCpu->cpum.s.Guest.eflags.Bits.u1VM) 2576 { 2577 /* 2578 * The SS RPL is always equal to the CPL, while the CS RPL 2579 * isn't necessarily equal if the segment is conforming. 2580 * See section 4.11.1 in the AMD manual. 2581 */ 2582 uCpl = (pVCpu->cpum.s.Guest.ss.Sel & X86_SEL_RPL); 2583 #ifndef IN_RING0 2584 if (uCpl == 1) 2585 uCpl = 0; 2586 #endif 2587 } 2588 else 2589 uCpl = 3; 2576 uCpl = 3; /* V86 has CPL=3; REM doesn't set DPL=3 in V8086 mode. See @bugref{5130}. */ 2590 2577 } 2591 2578 else 2592 uCpl = 0; /* real mode; CPL is zero */ 2593 2579 uCpl = 0; /* Real mode is zero; CPL set to 3 for VT-x real-mode emulation. */ 2594 2580 return uCpl; 2595 2581 }
Note:
See TracChangeset
for help on using the changeset viewer.