Changeset 74134 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Sep 7, 2018 8:05:40 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h
r74133 r74134 696 696 697 697 /** 698 * Gets a segment register from the VMCS given its index. 699 * 700 * @returns VBox status code. 701 * @param pVmcs Pointer to the virtual VMCS. 702 * @param iSegReg The index of the segment register (X86_SREG_XXX). 703 * @param pSelReg Where to store the segment register (only updated when 704 * VINF_SUCCESS is returned). 705 * 706 * @remarks Warning! This does not validate the contents of the retreived segment 707 * register. 708 */ 709 IEM_STATIC int iemVmxVmcsGetGuestSegReg(PCVMXVVMCS pVmcs, uint8_t iSegReg, PCPUMSELREG pSelReg) 710 { 711 Assert(pSelReg); 712 Assert(iSegReg < X86_SREG_COUNT); 713 714 /* Selector. */ 715 uint16_t u16Sel; 716 { 717 uint8_t const uWidth = VMX_VMCS_ENC_WIDTH_16BIT; 718 uint8_t const uType = VMX_VMCS_ENC_TYPE_GUEST_STATE; 719 uint8_t const uWidthType = (uWidth << 2) | uType; 720 uint8_t const uIndex = (iSegReg << 1) + RT_BF_GET(VMX_VMCS16_GUEST_ES_SEL, VMX_BF_VMCS_ENC_INDEX); 721 AssertRCReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_3); 722 uint16_t const offField = g_aoffVmcsMap[uWidthType][uIndex]; 723 uint8_t const *pbVmcs = (uint8_t *)pVmcs; 724 uint8_t const *pbField = pbVmcs + offField; 725 u16Sel = *(uint16_t *)pbField; 726 } 727 728 /* Limit. */ 729 uint32_t u32Limit; 730 { 731 uint8_t const uWidth = VMX_VMCS_ENC_WIDTH_32BIT; 732 uint8_t const uType = VMX_VMCS_ENC_TYPE_GUEST_STATE; 733 uint8_t const uWidthType = (uWidth << 2) | uType; 734 uint8_t const uIndex = (iSegReg << 1) + RT_BF_GET(VMX_VMCS32_GUEST_ES_LIMIT, VMX_BF_VMCS_ENC_INDEX); 735 AssertRCReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_3); 736 uint16_t const offField = g_aoffVmcsMap[uWidthType][uIndex]; 737 uint8_t const *pbVmcs = (uint8_t *)pVmcs; 738 uint8_t const *pbField = pbVmcs + offField; 739 u32Limit = *(uint32_t *)pbField; 740 } 741 742 /* Base. */ 743 uint64_t u64Base; 744 { 745 uint8_t const uWidth = VMX_VMCS_ENC_WIDTH_NATURAL; 746 uint8_t const uType = VMX_VMCS_ENC_TYPE_GUEST_STATE; 747 uint8_t const uWidthType = (uWidth << 2) | uType; 748 uint8_t const uIndex = (iSegReg << 1) + RT_BF_GET(VMX_VMCS_GUEST_ES_BASE, VMX_BF_VMCS_ENC_INDEX); 749 AssertRCReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_3); 750 uint16_t const offField = g_aoffVmcsMap[uWidthType][uIndex]; 751 uint8_t const *pbVmcs = (uint8_t *)pVmcs; 752 uint8_t const *pbField = pbVmcs + offField; 753 u64Base = *(uint64_t *)pbField; 754 /** @todo NSTVMX: Should we zero out high bits here for 32-bit virtual CPUs? */ 755 } 756 757 /* Attributes. */ 758 uint32_t u32Attr; 759 { 760 uint8_t const uWidth = VMX_VMCS_ENC_WIDTH_32BIT; 761 uint8_t const uType = VMX_VMCS_ENC_TYPE_GUEST_STATE; 762 uint8_t const uWidthType = (uWidth << 2) | uType; 763 uint8_t const uIndex = (iSegReg << 1) + RT_BF_GET(VMX_VMCS32_GUEST_ES_ACCESS_RIGHTS, VMX_BF_VMCS_ENC_INDEX); 764 AssertRCReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_3); 765 uint16_t const offField = g_aoffVmcsMap[uWidthType][uIndex]; 766 uint8_t const *pbVmcs = (uint8_t *)pVmcs; 767 uint8_t const *pbField = pbVmcs + offField; 768 u32Attr = *(uint32_t *)pbField; 769 } 770 771 pSelReg->Sel = u16Sel; 772 pSelReg->u32Limit = u32Limit; 773 pSelReg->u64Base = u64Base; 774 pSelReg->Attr.u = u32Attr; 775 return VINF_SUCCESS; 776 } 777 778 779 /** 698 780 * Gets VM-exit instruction information along with any displacement for an 699 781 * instruction VM-exit.
Note:
See TracChangeset
for help on using the changeset viewer.