From: "Michael S. Tsirkin" <mst@redhat.com>
To: Roman Kapl <rka@sysgo.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <ehabkost@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/1] amd_iommu: fix wrong MMIO operations
Date: Mon, 26 Apr 2021 19:24:30 -0400 [thread overview]
Message-ID: <20210426192311-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210426082154.19734-1-rka@sysgo.com>
On Mon, Apr 26, 2021 at 10:21:54AM +0200, Roman Kapl wrote:
> 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>
Ouch. This API is just inconsistent, everyone else
uses addr, value in this order. How about fixing the
function signature instead?
> ---
> hw/i386/amd_iommu.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
> index 74a93a5d93..bb5ce8c04d 100644
> --- a/hw/i386/amd_iommu.c
> +++ b/hw/i386/amd_iommu.c
> @@ -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);
> }
> --
> 2.20.1
next prev parent reply other threads:[~2021-04-26 23:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-26 8:21 [PATCH 1/1] amd_iommu: fix wrong MMIO operations Roman Kapl
2021-04-26 23:24 ` Michael S. Tsirkin [this message]
2021-04-27 10:52 ` Roman Kapl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210426192311-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=rka@sysgo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.