qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info
@ 2024-10-08 16:44 nifan.cxl
  2024-10-09  3:01 ` Davidlohr Bueso
  0 siblings, 1 reply; 4+ messages in thread
From: nifan.cxl @ 2024-10-08 16:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: jonathan.cameron, linux-cxl, a.manzanares, dave, nmtadam.samsung,
	abhi.n, alok.rathore, Fan Ni

From: Fan Ni <fan.ni@samsung.com>

In the function cmd_firmware_update_get_info for handling Get FW info
command (0x0200h), the vmem, pmem and DC capacity size check were
incorrect. The size should be aligned to 256MiB, not smaller than
256MiB.

Signed-off-by: Fan Ni <fan.ni@samsung.com>
---
 hw/cxl/cxl-mailbox-utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index 9258e48f95..c82ad50ac8 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -649,9 +649,9 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd,
     } QEMU_PACKED *fw_info;
     QEMU_BUILD_BUG_ON(sizeof(*fw_info) != 0x50);
 
-    if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) ||
-        (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) ||
-        (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) {
+    if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER)) ||
+        (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER)) ||
+        (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER))) {
         return CXL_MBOX_INTERNAL_ERROR;
     }
 
-- 
2.43.0



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

* Re: [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info
  2024-10-08 16:44 [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info nifan.cxl
@ 2024-10-09  3:01 ` Davidlohr Bueso
  2024-10-16 16:01   ` Jonathan Cameron via
  0 siblings, 1 reply; 4+ messages in thread
From: Davidlohr Bueso @ 2024-10-09  3:01 UTC (permalink / raw)
  To: nifan.cxl
  Cc: qemu-devel, jonathan.cameron, linux-cxl, a.manzanares,
	nmtadam.samsung, abhi.n, alok.rathore, Fan Ni

On Tue, 08 Oct 2024, nifan.cxl@gmail.com wrote:\n
>From: Fan Ni <fan.ni@samsung.com>
>
>In the function cmd_firmware_update_get_info for handling Get FW info
>command (0x0200h), the vmem, pmem and DC capacity size check were
>incorrect. The size should be aligned to 256MiB, not smaller than
>256MiB.

Can get rid of a level of parenthesis (other cmds as well), otherwise:

Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>

>
>Signed-off-by: Fan Ni <fan.ni@samsung.com>
>---
> hw/cxl/cxl-mailbox-utils.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
>index 9258e48f95..c82ad50ac8 100644
>--- a/hw/cxl/cxl-mailbox-utils.c
>+++ b/hw/cxl/cxl-mailbox-utils.c
>@@ -649,9 +649,9 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd,
>     } QEMU_PACKED *fw_info;
>     QEMU_BUILD_BUG_ON(sizeof(*fw_info) != 0x50);
>
>-    if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) ||
>-        (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) ||
>-        (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) {
>+    if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER)) ||
>+        (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER)) ||
>+        (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER))) {
>         return CXL_MBOX_INTERNAL_ERROR;
>     }
>
>--
>2.43.0
>


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

* Re: [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info
  2024-10-09  3:01 ` Davidlohr Bueso
@ 2024-10-16 16:01   ` Jonathan Cameron via
  2024-10-16 16:45     ` Fan Ni
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron via @ 2024-10-16 16:01 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: nifan.cxl, qemu-devel, linux-cxl, a.manzanares, nmtadam.samsung,
	abhi.n, alok.rathore, Fan Ni

On Tue, 8 Oct 2024 20:01:07 -0700
Davidlohr Bueso <dave@stgolabs.net> wrote:

> On Tue, 08 Oct 2024, nifan.cxl@gmail.com wrote:\n
> >From: Fan Ni <fan.ni@samsung.com>
> >
> >In the function cmd_firmware_update_get_info for handling Get FW info
> >command (0x0200h), the vmem, pmem and DC capacity size check were
> >incorrect. The size should be aligned to 256MiB, not smaller than
> >256MiB.  
> 
> Can get rid of a level of parenthesis (other cmds as well), otherwise:
> 
> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
I missed this one when gathering up fixes the other day.
I'll queue it up now with the excess brackets dropped.

Jonathan

> 
> >
> >Signed-off-by: Fan Ni <fan.ni@samsung.com>
> >---
> > hw/cxl/cxl-mailbox-utils.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> >diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> >index 9258e48f95..c82ad50ac8 100644
> >--- a/hw/cxl/cxl-mailbox-utils.c
> >+++ b/hw/cxl/cxl-mailbox-utils.c
> >@@ -649,9 +649,9 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd,
> >     } QEMU_PACKED *fw_info;
> >     QEMU_BUILD_BUG_ON(sizeof(*fw_info) != 0x50);
> >
> >-    if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) ||
> >-        (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) ||
> >-        (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) {
> >+    if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER)) ||
> >+        (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER)) ||
> >+        (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER))) {
> >         return CXL_MBOX_INTERNAL_ERROR;
> >     }
> >
> >--
> >2.43.0
> >  



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

* Re: [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info
  2024-10-16 16:01   ` Jonathan Cameron via
@ 2024-10-16 16:45     ` Fan Ni
  0 siblings, 0 replies; 4+ messages in thread
From: Fan Ni @ 2024-10-16 16:45 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Davidlohr Bueso, nifan.cxl, qemu-devel, linux-cxl, a.manzanares,
	nmtadam.samsung, abhi.n, alok.rathore

On Wed, Oct 16, 2024 at 05:01:38PM +0100, Jonathan Cameron wrote:
> On Tue, 8 Oct 2024 20:01:07 -0700
> Davidlohr Bueso <dave@stgolabs.net> wrote:
> 
> > On Tue, 08 Oct 2024, nifan.cxl@gmail.com wrote:\n
> > >From: Fan Ni <fan.ni@samsung.com>
> > >
> > >In the function cmd_firmware_update_get_info for handling Get FW info
> > >command (0x0200h), the vmem, pmem and DC capacity size check were
> > >incorrect. The size should be aligned to 256MiB, not smaller than
> > >256MiB.  
> > 
> > Can get rid of a level of parenthesis (other cmds as well), otherwise:
> > 
> > Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
> I missed this one when gathering up fixes the other day.
> I'll queue it up now with the excess brackets dropped.
> 
> Jonathan
Thanks Jonathan,
Please also take a look the following patch, it is a fix for dcd.

https://lore.kernel.org/linux-cxl/20241015190224.251293-1-nifan.cxl@gmail.com/T/#u

Fan

> 
> > 
> > >
> > >Signed-off-by: Fan Ni <fan.ni@samsung.com>
> > >---
> > > hw/cxl/cxl-mailbox-utils.c | 6 +++---
> > > 1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > >diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> > >index 9258e48f95..c82ad50ac8 100644
> > >--- a/hw/cxl/cxl-mailbox-utils.c
> > >+++ b/hw/cxl/cxl-mailbox-utils.c
> > >@@ -649,9 +649,9 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd,
> > >     } QEMU_PACKED *fw_info;
> > >     QEMU_BUILD_BUG_ON(sizeof(*fw_info) != 0x50);
> > >
> > >-    if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) ||
> > >-        (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) ||
> > >-        (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) {
> > >+    if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER)) ||
> > >+        (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER)) ||
> > >+        (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER))) {
> > >         return CXL_MBOX_INTERNAL_ERROR;
> > >     }
> > >
> > >--
> > >2.43.0
> > >  
> 

-- 
Fan Ni


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

end of thread, other threads:[~2024-10-16 16:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 16:44 [QEMU PATCH] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info nifan.cxl
2024-10-09  3:01 ` Davidlohr Bueso
2024-10-16 16:01   ` Jonathan Cameron via
2024-10-16 16:45     ` Fan Ni

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