Skip to content

Commit e95b316

Browse files
shiqinggwenlingz
authored andcommitted
hv: vtd: fix improper use of DMAR_GCMD_REG
The initialization of "dmar_unit->gcmd" shall be done via reading from Global Status Register rather than Global Command Register. Rationale: According to Chapter 10.4.4 Global Command Register in VT-d spec, Global Command Register is a write-only register to control remapping hardware. Global Status Register is the corresponding read-only register to report remapping hardware status. Tracked-On: #1842 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
1 parent 68ea2cc commit e95b316

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

hypervisor/arch/x86/vtd.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,15 @@ static int32_t dmar_register_hrhd(struct dmar_drhd_rt *dmar_unit)
471471

472472
dmar_unit->cap = iommu_read64(dmar_unit, DMAR_CAP_REG);
473473
dmar_unit->ecap = iommu_read64(dmar_unit, DMAR_ECAP_REG);
474-
dmar_unit->gcmd = iommu_read32(dmar_unit, DMAR_GCMD_REG);
474+
475+
/*
476+
* The initialization of "dmar_unit->gcmd" shall be done via reading from Global Status Register rather than
477+
* Global Command Register.
478+
* According to Chapter 10.4.4 Global Command Register in VT-d spec, Global Command Register is a write-only
479+
* register to control remapping hardware. Global Status Register is the corresponding read-only register to
480+
* report remapping hardware status.
481+
*/
482+
dmar_unit->gcmd = iommu_read32(dmar_unit, DMAR_GSTS_REG);
475483

476484
dmar_unit->cap_msagaw = dmar_unit_get_msagw(dmar_unit);
477485

0 commit comments

Comments
 (0)