qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/nvme: fix invalid endian conversion
@ 2024-02-22  9:29 Klaus Jensen
  2024-02-22 10:08 ` Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Klaus Jensen @ 2024-02-22  9:29 UTC (permalink / raw)
  To: Keith Busch, Klaus Jensen
  Cc: qemu-block, qemu-devel, Klaus Jensen, Kevin Wolf

From: Klaus Jensen <k.jensen@samsung.com>

numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian
hosts results in numcntl being set to 0.

Fix by dropping the endian conversion.

Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers")
Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/nvme/ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index f026245d1e9e..76fe0397045b 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -7924,7 +7924,7 @@ static void nvme_init_state(NvmeCtrl *n)
     n->aer_reqs = g_new0(NvmeRequest *, n->params.aerl + 1);
     QTAILQ_INIT(&n->aer_queue);
 
-    list->numcntl = cpu_to_le16(max_vfs);
+    list->numcntl = max_vfs;
     for (i = 0; i < max_vfs; i++) {
         sctrl = &list->sec[i];
         sctrl->pcid = cpu_to_le16(n->cntlid);

---
base-commit: 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0
change-id: 20240222-fix-sriov-numcntl-5ebe46a42176

Best regards,
-- 
Klaus Jensen <k.jensen@samsung.com>



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/nvme: fix invalid endian conversion
  2024-02-22  9:29 [PATCH] hw/nvme: fix invalid endian conversion Klaus Jensen
@ 2024-02-22 10:08 ` Philippe Mathieu-Daudé
  2024-02-22 10:13   ` Klaus Jensen
  2024-02-24 13:15 ` Minwoo Im
  2024-02-26  8:18 ` Philippe Mathieu-Daudé
  2 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 10:08 UTC (permalink / raw)
  To: Klaus Jensen, Keith Busch
  Cc: qemu-block, qemu-devel, Klaus Jensen, Kevin Wolf

Hi Klaus,

On 22/2/24 10:29, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian
> hosts results in numcntl being set to 0.
> 
> Fix by dropping the endian conversion.
> 
> Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers")

Isn't it commit 99f48ae7ae ("Add support for Secondary Controller
List") instead?

> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>   hw/nvme/ctrl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index f026245d1e9e..76fe0397045b 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -7924,7 +7924,7 @@ static void nvme_init_state(NvmeCtrl *n)
>       n->aer_reqs = g_new0(NvmeRequest *, n->params.aerl + 1);
>       QTAILQ_INIT(&n->aer_queue);
>   
> -    list->numcntl = cpu_to_le16(max_vfs);
> +    list->numcntl = max_vfs;
>       for (i = 0; i < max_vfs; i++) {
>           sctrl = &list->sec[i];
>           sctrl->pcid = cpu_to_le16(n->cntlid);
> 
> ---
> base-commit: 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0
> change-id: 20240222-fix-sriov-numcntl-5ebe46a42176
> 
> Best regards,



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/nvme: fix invalid endian conversion
  2024-02-22 10:08 ` Philippe Mathieu-Daudé
@ 2024-02-22 10:13   ` Klaus Jensen
  0 siblings, 0 replies; 6+ messages in thread
From: Klaus Jensen @ 2024-02-22 10:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Keith Busch, qemu-block, qemu-devel, Klaus Jensen, Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

On Feb 22 11:08, Philippe Mathieu-Daudé wrote:
> Hi Klaus,
> 
> On 22/2/24 10:29, Klaus Jensen wrote:
> > From: Klaus Jensen <k.jensen@samsung.com>
> > 
> > numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian
> > hosts results in numcntl being set to 0.
> > 
> > Fix by dropping the endian conversion.
> > 
> > Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers")
> 
> Isn't it commit 99f48ae7ae ("Add support for Secondary Controller
> List") instead?
> 

Thanks Philippe,

Yes, that is the commit that had the bug originally. I'll fix it up.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/nvme: fix invalid endian conversion
  2024-02-22  9:29 [PATCH] hw/nvme: fix invalid endian conversion Klaus Jensen
  2024-02-22 10:08 ` Philippe Mathieu-Daudé
@ 2024-02-24 13:15 ` Minwoo Im
  2024-02-26  8:18 ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 6+ messages in thread
From: Minwoo Im @ 2024-02-24 13:15 UTC (permalink / raw)
  To: Klaus Jensen
  Cc: Keith Busch, qemu-block, qemu-devel, Klaus Jensen, Kevin Wolf

On 24-02-22 10:29:06, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian
> hosts results in numcntl being set to 0.
> 
> Fix by dropping the endian conversion.
> 
> Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers")
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>

Reviewed-by: Minwoo Im <minwoo.im@samsung.com>

Thanks,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/nvme: fix invalid endian conversion
  2024-02-22  9:29 [PATCH] hw/nvme: fix invalid endian conversion Klaus Jensen
  2024-02-22 10:08 ` Philippe Mathieu-Daudé
  2024-02-24 13:15 ` Minwoo Im
@ 2024-02-26  8:18 ` Philippe Mathieu-Daudé
  2024-02-26  8:42   ` Klaus Jensen
  2 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-26  8:18 UTC (permalink / raw)
  To: Klaus Jensen, Keith Busch
  Cc: qemu-block, qemu-devel, Klaus Jensen, Kevin Wolf

On 22/2/24 10:29, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian
> hosts results in numcntl being set to 0.
> 
> Fix by dropping the endian conversion.
> 
> Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers")
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>   hw/nvme/ctrl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Hi Klaus, I'm not seeing other NVMe patches on the list,
so I'll queue this on my hw-misc tree, but feel free to
object and I'll unqueue :)

Thanks,

Phil.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/nvme: fix invalid endian conversion
  2024-02-26  8:18 ` Philippe Mathieu-Daudé
@ 2024-02-26  8:42   ` Klaus Jensen
  0 siblings, 0 replies; 6+ messages in thread
From: Klaus Jensen @ 2024-02-26  8:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Keith Busch, qemu-block, qemu-devel, Klaus Jensen, Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

On Feb 26 09:18, Philippe Mathieu-Daudé wrote:
> On 22/2/24 10:29, Klaus Jensen wrote:
> > From: Klaus Jensen <k.jensen@samsung.com>
> > 
> > numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian
> > hosts results in numcntl being set to 0.
> > 
> > Fix by dropping the endian conversion.
> > 
> > Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers")
> > Reported-by: Kevin Wolf <kwolf@redhat.com>
> > Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> > ---
> >   hw/nvme/ctrl.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Hi Klaus, I'm not seeing other NVMe patches on the list,
> so I'll queue this on my hw-misc tree, but feel free to
> object and I'll unqueue :)
> 
> Thanks,
> 

No, thats perfect! Thanks! :)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-26  8:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-22  9:29 [PATCH] hw/nvme: fix invalid endian conversion Klaus Jensen
2024-02-22 10:08 ` Philippe Mathieu-Daudé
2024-02-22 10:13   ` Klaus Jensen
2024-02-24 13:15 ` Minwoo Im
2024-02-26  8:18 ` Philippe Mathieu-Daudé
2024-02-26  8:42   ` Klaus Jensen

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).