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.

Signed-off-by: Roman Kapl <rka@sysgo.com>
Message-Id: <20210427110504.10878-1-rka@sysgo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Roman Kapl 2021-04-27 13:05:04 +02:00 committed by Michael S. Tsirkin
parent ad6461ad6e
commit e526ab61e9
1 changed files with 3 additions and 3 deletions

View File

@ -99,7 +99,7 @@ static uint64_t amdvi_readq(AMDVIState *s, hwaddr addr)
} }
/* internal write */ /* internal write */
static void amdvi_writeq_raw(AMDVIState *s, uint64_t val, hwaddr addr) static void amdvi_writeq_raw(AMDVIState *s, hwaddr addr, uint64_t val)
{ {
stq_le_p(&s->mmior[addr], val); stq_le_p(&s->mmior[addr], val);
} }
@ -382,7 +382,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd)
} }
/* set completion interrupt */ /* set completion interrupt */
if (extract64(cmd[0], 1, 1)) { 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 */ /* generate interrupt */
amdvi_generate_msi_interrupt(s); amdvi_generate_msi_interrupt(s);
} }
@ -553,7 +553,7 @@ static void amdvi_cmdbuf_run(AMDVIState *s)
trace_amdvi_command_exec(s->cmdbuf_head, s->cmdbuf_tail, s->cmdbuf); trace_amdvi_command_exec(s->cmdbuf_head, s->cmdbuf_tail, s->cmdbuf);
amdvi_cmdbuf_exec(s); amdvi_cmdbuf_exec(s);
s->cmdbuf_head += AMDVI_COMMAND_SIZE; s->cmdbuf_head += AMDVI_COMMAND_SIZE;
amdvi_writeq_raw(s, s->cmdbuf_head, AMDVI_MMIO_COMMAND_HEAD); amdvi_writeq_raw(s, AMDVI_MMIO_COMMAND_HEAD, s->cmdbuf_head);
/* wrap head pointer */ /* wrap head pointer */
if (s->cmdbuf_head >= s->cmdbuf_len * AMDVI_COMMAND_SIZE) { if (s->cmdbuf_head >= s->cmdbuf_len * AMDVI_COMMAND_SIZE) {