From: Gollu Appalanaidu <anaidu.gollu@samsung.com>
To: Klaus Jensen <its@irrelevant.dk>
Cc: Keith Busch <kbusch@kernel.org>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Klaus Jensen <k.jensen@samsung.com>
Subject: Re: [PATCH] hw/nvme: fix mmio read
Date: Tue, 13 Jul 2021 14:58:43 +0530 [thread overview]
Message-ID: <20210713092843.GA13103@2030045822> (raw)
In-Reply-To: <20210713054359.831878-1-its@irrelevant.dk>
[-- Attachment #1: Type: text/plain, Size: 1792 bytes --]
On Tue, Jul 13, 2021 at 07:43:59AM +0200, Klaus Jensen wrote:
>From: Klaus Jensen <k.jensen@samsung.com>
>
>The new PMR test unearthed a long-standing issue with MMIO reads on
>big-endian hosts.
>
>Fix by using the ldn_he_p helper instead of memcpy.
>
>Cc: Gollu Appalanaidu <anaidu.gollu@samsung.com>
>Reported-by: Peter Maydell <peter.maydell@linaro.org>
>Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>---
> hw/nvme/ctrl.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
>diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
>index 2f0524e12a36..dd81c3b19c7e 100644
>--- a/hw/nvme/ctrl.c
>+++ b/hw/nvme/ctrl.c
>@@ -5951,7 +5951,6 @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr addr, unsigned size)
> {
> NvmeCtrl *n = (NvmeCtrl *)opaque;
> uint8_t *ptr = (uint8_t *)&n->bar;
>- uint64_t val = 0;
>
> trace_pci_nvme_mmio_read(addr, size);
>
>@@ -5977,14 +5976,15 @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr addr, unsigned size)
> (NVME_PMRCAP_PMRWBM(n->bar.pmrcap) & 0x02)) {
> memory_region_msync(&n->pmr.dev->mr, 0, n->pmr.dev->size);
> }
>- memcpy(&val, ptr + addr, size);
>- } else {
>- NVME_GUEST_ERR(pci_nvme_ub_mmiord_invalid_ofs,
>- "MMIO read beyond last register,"
>- " offset=0x%"PRIx64", returning 0", addr);
>+
>+ return ldn_he_p(ptr + addr, size);
> }
>
>- return val;
>+ NVME_GUEST_ERR(pci_nvme_ub_mmiord_invalid_ofs,
>+ "MMIO read beyond last register,"
>+ " offset=0x%"PRIx64", returning 0", addr);
>+
>+ return 0;
> }
>
> static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
>--
>2.32.0
>
>
LGTM.
Reviewed-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
next prev parent reply other threads:[~2021-07-13 9:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 5:43 [PATCH] hw/nvme: fix mmio read Klaus Jensen
[not found] ` <CGME20210713093226epcas5p48dda40b1c0b3c76a9cced6b8889dde1d@epcas5p4.samsung.com>
2021-07-13 9:28 ` Gollu Appalanaidu [this message]
2021-07-13 10:07 ` Peter Maydell
2021-07-13 10:19 ` Klaus Jensen
2021-07-13 10:31 ` Peter Maydell
2021-07-13 10:34 ` Klaus Jensen
2021-07-13 14:33 ` Klaus Jensen
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=20210713092843.GA13103@2030045822 \
--to=anaidu.gollu@samsung.com \
--cc=its@irrelevant.dk \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).