amd_iommu: fix wrong MMIO operations
PATCH 1/1 amd_iommu: fix wrong MMIO operations
Address was swapped with value when writing MMIO registers, so the user saw garbage in lot of cases. The interrupt status was not correctly set.
--- hw/i386/amd_iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/i386/amd_iommu.c +3 -3
@@ -141,13 +141,13 @@ static bool amdvi_test_mask(AMDVIState *s, hwaddr addr, uint64_t val)/* OR a 64-bit register with a 64-bit value storing result in the register */ static void amdvi_assign_orq (AMDVIState *s,hwaddr addr,uint64_t val) { -amdvi_writeq_raw (s, addr,amdvi_readq (s, addr) | val); +amdvi_writeq_raw (s,amdvi_readq (s, addr) | val, addr); }/* AND a 64-bit register with a 64-bit value storing result in the register */ static void amdvi_assign_andq (AMDVIState *s,hwaddr addr,uint64_t val) { -amdvi_writeq_raw (s, addr,amdvi_readq (s, addr) & val); +amdvi_writeq_raw (s,amdvi_readq (s, addr) & val, addr); }static void amdvi_generate_msi_interrupt (AMDVIState *s)
@@ -382,7 +382,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd) }/* set completion interrupt */ if (extract64 (cmd[0 ],1 ,1 )) { -amdvi_test_mask (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT ); +amdvi_assign_orq (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT );/* generate interrupt */ amdvi_generate_msi_interrupt (s); }
Signature · 1 line
2.20.1
Quoted 4 lines · Roman Kapl
Address was swapped with value when writing MMIO registers, so the user saw garbage in lot of cases. The interrupt status was not correctly set.
Signed-off-by Roman Kapl <[email protected]>
Ouch. This API is just inconsistent, everyone else uses addr, value in this order. How about fixing the function signature instead?
Quoted 35 lines
--- hw/i386/amd_iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/i386/amd_iommu.c +3
-3@@ -141,13 +141,13 @@ static bool amdvi_test_mask(AMDVIState *s, hwaddr addr, uint64_t val)/* OR a 64-bit register with a 64-bit value storing result in the register */ static void amdvi_assign_orq (AMDVIState *s,hwaddr addr,uint64_t val) { -amdvi_writeq_raw (s, addr,amdvi_readq (s, addr) | val); +amdvi_writeq_raw (s,amdvi_readq (s, addr) | val, addr); }/* AND a 64-bit register with a 64-bit value storing result in the register */ static void amdvi_assign_andq (AMDVIState *s,hwaddr addr,uint64_t val) { -amdvi_writeq_raw (s, addr,amdvi_readq (s, addr) & val); +amdvi_writeq_raw (s,amdvi_readq (s, addr) & val, addr); }static void amdvi_generate_msi_interrupt (AMDVIState *s)@@ -382,7 +382,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd) }/* set completion interrupt */ if (extract64 (cmd[0 ],1 ,1 )) { -amdvi_test_mask (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT ); +amdvi_assign_orq (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT );/* generate interrupt */ amdvi_generate_msi_interrupt (s); }Signature · 1 line
2.20.1
Quoted 8 lines · Michael S. Tsirkin
Quoted 4 lines · Roman Kapl
Address was swapped with value when writing MMIO registers, so the user saw garbage in lot of cases. The interrupt status was not correctly set.
Signed-off-by Roman Kapl <[email protected]>Ouch. This API is just inconsistent, everyone else uses addr, value in this order. How about fixing the function signature instead?
True, even the code in the same module. I will send v2.
Quoted 37 lines
Quoted 36 lines
--- hw/i386/amd_iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/i386/amd_iommu.c +3
-3@@ -141,13 +141,13 @@ static bool amdvi_test_mask(AMDVIState *s, hwaddr addr, uint64_t val)/* OR a 64-bit register with a 64-bit value storing result in the register */ static void amdvi_assign_orq (AMDVIState *s,hwaddr addr,uint64_t val) { -amdvi_writeq_raw (s, addr,amdvi_readq (s, addr) | val); +amdvi_writeq_raw (s,amdvi_readq (s, addr) | val, addr); }/* AND a 64-bit register with a 64-bit value storing result in the register */ static void amdvi_assign_andq (AMDVIState *s,hwaddr addr,uint64_t val) { -amdvi_writeq_raw (s, addr,amdvi_readq (s, addr) & val); +amdvi_writeq_raw (s,amdvi_readq (s, addr) & val, addr); }static void amdvi_generate_msi_interrupt (AMDVIState *s)@@ -382,7 +382,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd) }/* set completion interrupt */ if (extract64 (cmd[0 ],1 ,1 )) { -amdvi_test_mask (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT ); +amdvi_assign_orq (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT );/* generate interrupt */ amdvi_generate_msi_interrupt (s); }Signature · 1 line
2.20.1