Changeset 88590 in vbox
- Timestamp:
- Apr 20, 2021 2:49:16 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp
r88589 r88590 131 131 * DMAR error diagnostics. 132 132 * 133 * @note Members of this enum are used as array indices, so no gaps are allowed. 134 * Please update g_apsz when you add new fields to this enum. 133 * @note Members of this enum are used as array indices, so no gaps in enum 134 * values are not allowed. Update g_apszDmarDiagDesc when you modify 135 * fields in this enum. 135 136 */ 136 137 typedef enum … … 211 212 typedef DMAR *PDMAR; 212 213 /** Pointer to the const DMAR device state. */ 213 typedef const DMAR*PCDMAR;214 typedef DMAR const *PCDMAR; 214 215 215 216 /** … … 226 227 typedef DMARR3 *PDMARR3; 227 228 /** Pointer to the const ring-3 DMAR device state. */ 228 typedef const DMARR3*PCDMARR3;229 typedef DMARR3 const *PCDMARR3; 229 230 230 231 /** … … 241 242 typedef DMARR0 *PDMARR0; 242 243 /** Pointer to the const ring-0 IOMMU device state. */ 243 typedef const DMARR0*PCDMARR0;244 typedef DMARR0 const *PCDMARR0; 244 245 245 246 /** … … 256 257 typedef DMARRC *PDMARRC; 257 258 /** Pointer to the const raw-mode DMAR device state. */ 258 typedef const DMARRC*PCIDMARRC;259 typedef DMARRC const *PCIDMARRC; 259 260 260 261 /** The DMAR device state for the current context. */ … … 263 264 typedef CTX_SUFF(PDMAR) PDMARCC; 264 265 /** Pointer to the const DMAR device state for the current context. */ 265 typedef const CTX_SUFF(PDMAR)PCDMARCC;266 typedef CTX_SUFF(PDMAR) const PCDMARCC; 266 267 267 268 … … 627 628 628 629 /** 629 * Modifies a 32-bit register.630 * Reads a 32-bit register with exactly the value it contains. 630 631 * 631 632 * @param pThis The shared DMAR device state. … … 634 635 * @param fOrMask The OR mask. 635 636 */ 636 static void dmarRegChange32(PDMAR pThis, uint16_t offReg, uint32_t fAndMask, uint32_t fOrMask)637 static uint32_t dmarRegReadRaw32(PCDMAR pThis, uint16_t offReg) 637 638 { 638 639 uint8_t idxGroup; 639 uint8_t *pabRegs = dmarRegGetGroup(pThis, offReg, sizeof(uint32_t), &idxGroup);640 uint8_t const *pabRegs = dmarRegGetGroupRo(pThis, offReg, sizeof(uint32_t), &idxGroup); 640 641 NOREF(idxGroup); 641 uint32_t uReg = *(uint32_t *)(pabRegs + offReg); 642 uReg = (uReg & fAndMask) | fOrMask; 643 *(uint32_t *)(pabRegs + offReg) = uReg; 644 } 645 646 647 /** 648 * Modifies a 64-bit register. 642 return *(uint32_t *)(pabRegs + offReg); 643 } 644 645 646 /** 647 * Reads a 64-bit register with exactly the value it contains. 649 648 * 650 649 * @param pThis The shared DMAR device state. 651 650 * @param offReg The MMIO offset of the register. 652 * @param fAndMask The AND mask (applied first). 653 * @param fOrMask The OR mask. 654 */ 655 static void dmarRegChange64(PDMAR pThis, uint16_t offReg, uint64_t fAndMask, uint64_t fOrMask) 651 */ 652 static uint32_t dmarRegReadRaw64(PCDMAR pThis, uint16_t offReg) 656 653 { 657 654 uint8_t idxGroup; 658 uint8_t *pabRegs = dmarRegGetGroup(pThis, offReg, sizeof(uint64_t), &idxGroup);655 uint8_t const *pabRegs = dmarRegGetGroupRo(pThis, offReg, sizeof(uint64_t), &idxGroup); 659 656 NOREF(idxGroup); 660 uint64_t uReg = *(uint64_t *)(pabRegs + offReg); 661 uReg = (uReg & fAndMask) | fOrMask; 662 *(uint64_t *)(pabRegs + offReg) = uReg; 663 } 664 665 666 /** 667 * Reads a 64-bit register with exactly the value it contains. 657 return *(uint64_t *)(pabRegs + offReg); 658 } 659 660 661 /** 662 * Reads a 32-bit register with exactly the value it contains along with their 663 * corresponding masks 664 * 665 * @param pThis The shared DMAR device state. 666 * @param offReg The MMIO offset of the register. 667 * @param puReg Where to store the raw 32-bit register value. 668 * @param pfRwMask Where to store the RW mask corresponding to this register. 669 * @param pfRw1cMask Where to store the RW1C mask corresponding to this register. 670 */ 671 static void dmarRegReadRaw32Ex(PCDMAR pThis, uint16_t offReg, uint32_t *puReg, uint32_t *pfRwMask, uint32_t *pfRw1cMask) 672 { 673 uint8_t idxGroup; 674 uint8_t const *pabRegs = dmarRegGetGroupRo(pThis, offReg, sizeof(uint32_t), &idxGroup); 675 Assert(idxGroup < RT_ELEMENTS(g_apbRwMasks)); 676 uint8_t const *pabRwMasks = g_apbRwMasks[idxGroup]; 677 uint8_t const *pabRw1cMasks = g_apbRw1cMasks[idxGroup]; 678 *puReg = *(uint32_t *)(pabRegs + offReg); 679 *pfRwMask = *(uint32_t *)(pabRwMasks + offReg); 680 *pfRw1cMask = *(uint32_t *)(pabRw1cMasks + offReg); 681 } 682 683 684 /** 685 * Reads a 64-bit register with exactly the value it contains along with their 686 * corresponding masks. 668 687 * 669 688 * @param pThis The shared DMAR device state. … … 673 692 * @param pfRw1cMask Where to store the RW1C mask corresponding to this register. 674 693 */ 675 static void dmarRegReadRaw64 (PCDMAR pThis, uint16_t offReg, uint64_t *puReg, uint64_t *pfRwMask, uint64_t *pfRw1cMask)694 static void dmarRegReadRaw64Ex(PCDMAR pThis, uint16_t offReg, uint64_t *puReg, uint64_t *pfRwMask, uint64_t *pfRw1cMask) 676 695 { 677 696 uint8_t idxGroup; … … 687 706 688 707 /** 689 * Reads a 32-bit register with exactly the value it contains.690 *691 * @param pThis The shared DMAR device state.692 * @param offReg The MMIO offset of the register.693 * @param puReg Where to store the raw 32-bit register value.694 * @param pfRwMask Where to store the RW mask corresponding to this register.695 * @param pfRw1cMask Where to store the RW1C mask corresponding to this register.696 */697 static void dmarRegReadRaw32(PCDMAR pThis, uint16_t offReg, uint32_t *puReg, uint32_t *pfRwMask, uint32_t *pfRw1cMask)698 {699 uint8_t idxGroup;700 uint8_t const *pabRegs = dmarRegGetGroupRo(pThis, offReg, sizeof(uint32_t), &idxGroup);701 Assert(idxGroup < RT_ELEMENTS(g_apbRwMasks));702 uint8_t const *pabRwMasks = g_apbRwMasks[idxGroup];703 uint8_t const *pabRw1cMasks = g_apbRw1cMasks[idxGroup];704 *puReg = *(uint32_t *)(pabRegs + offReg);705 *pfRwMask = *(uint32_t *)(pabRwMasks + offReg);706 *pfRw1cMask = *(uint32_t *)(pabRw1cMasks + offReg);707 }708 709 710 /**711 708 * Writes a 64-bit register as it would be when written by software. 712 709 * This will preserve read-only bits, mask off reserved bits and clear RW1C bits. … … 723 720 uint64_t fRwMask; 724 721 uint64_t fRw1cMask; 725 dmarRegReadRaw64 (pThis, offReg, &uCurReg, &fRwMask, &fRw1cMask);722 dmarRegReadRaw64Ex(pThis, offReg, &uCurReg, &fRwMask, &fRw1cMask); 726 723 727 724 uint64_t const fRoBits = uCurReg & ~fRwMask; /* Preserve current read-only and reserved bits. */ … … 751 748 uint32_t fRwMask; 752 749 uint32_t fRw1cMask; 753 dmarRegReadRaw32 (pThis, offReg, &uCurReg, &fRwMask, &fRw1cMask);750 dmarRegReadRaw32Ex(pThis, offReg, &uCurReg, &fRwMask, &fRw1cMask); 754 751 755 752 uint32_t const fRoBits = uCurReg & ~fRwMask; /* Preserve current read-only and reserved bits. */ … … 773 770 static uint64_t dmarRegRead64(PCDMAR pThis, uint16_t offReg) 774 771 { 775 uint64_t uCurReg; 776 uint64_t fRwMask; 777 uint64_t fRw1cMask; 778 dmarRegReadRaw64(pThis, offReg, &uCurReg, &fRwMask, &fRw1cMask); 779 NOREF(fRwMask); NOREF(fRw1cMask); 780 return uCurReg; 772 return dmarRegReadRaw64(pThis, offReg); 781 773 } 782 774 … … 791 783 static uint32_t dmarRegRead32(PCDMAR pThis, uint16_t offReg) 792 784 { 793 uint32_t uCurReg; 794 uint32_t fRwMask; 795 uint32_t fRw1cMask; 796 dmarRegReadRaw32(pThis, offReg, &uCurReg, &fRwMask, &fRw1cMask); 797 NOREF(fRwMask); NOREF(fRw1cMask); 798 return uCurReg; 785 return dmarRegReadRaw32(pThis, offReg); 786 } 787 788 789 /** 790 * Modifies a 32-bit register. 791 * 792 * @param pThis The shared DMAR device state. 793 * @param offReg The MMIO offset of the register. 794 * @param fAndMask The AND mask (applied first). 795 * @param fOrMask The OR mask. 796 * @remarks This does NOT apply RO or RW1C masks while modifying the 797 * register. 798 */ 799 static void dmarRegChange32(PDMAR pThis, uint16_t offReg, uint32_t fAndMask, uint32_t fOrMask) 800 { 801 uint32_t uReg = dmarRegRead32(pThis, offReg); 802 uReg = (uReg & fAndMask) | fOrMask; 803 dmarRegWriteRaw32(pThis, offReg, uReg); 804 } 805 806 807 /** 808 * Modifies a 64-bit register. 809 * 810 * @param pThis The shared DMAR device state. 811 * @param offReg The MMIO offset of the register. 812 * @param fAndMask The AND mask (applied first). 813 * @param fOrMask The OR mask. 814 * @remarks This does NOT apply RO or RW1C masks while modifying the 815 * register. 816 */ 817 static void dmarRegChange64(PDMAR pThis, uint16_t offReg, uint64_t fAndMask, uint64_t fOrMask) 818 { 819 uint64_t uReg = dmarRegRead64(pThis, offReg); 820 uReg = (uReg & fAndMask) | fOrMask; 821 dmarRegWriteRaw64(pThis, offReg, uReg); 799 822 } 800 823
Note:
See TracChangeset
for help on using the changeset viewer.