cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info
PATCH 1/1 cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info
From: Fan Ni <[email protected]>
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.
--- hw/cxl/cxl-mailbox-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/cxl/cxl-mailbox-utils.c +3 -3
@@ -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 ; }
Signature · 1 line
2.43.0
On Tue, 08 Oct 2024, [email protected] wrote:\n
Quoted 6 lines
From: Fan Ni <[email protected]>
In the function
cmd_firmware_update_get_infofor 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:
Quoted 26 lines
Signed-off-by Fan Ni <[email protected]>---
hw/cxl/cxl-mailbox-utils.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)hw/cxl/cxl-mailbox-utils.c +3
-4@@ -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
Quoted 11 lines · On Tue, 8 Oct 2024 20:01:07 -0700 Davidlohr Bueso <[email protected]> wrote:
On Tue, 08 Oct 2024, [email protected] wrote:\n
Quoted 6 lines
From: Fan Ni <[email protected]>
In the function
cmd_firmware_update_get_infofor 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 <[email protected]>
I missed this one when gathering up fixes the other day. I'll queue it up now with the excess brackets dropped.
Jonathan
Quoted 27 lines
Quoted 27 lines
Signed-off-by Fan Ni <[email protected]>---
hw/cxl/cxl-mailbox-utils.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)hw/cxl/cxl-mailbox-utils.c +3
-4@@ -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
Quoted 11 lines · Jonathan Cameron
Quoted 8 lines · On Tue, 8 Oct 2024 20:01:07 -0700 Davidlohr Bueso <[email protected]> wrote:
On Tue, 08 Oct 2024, [email protected] wrote:\n
Quoted 6 lines
From: Fan Ni <[email protected]>
In the function
cmd_firmware_update_get_infofor 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.
Quoted 7 lines
Quoted 3 lines
Can get rid of a level of parenthesis (other cmds as well), otherwise:
Reviewed-by Davidlohr Bueso <[email protected]>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/[email protected]/T/#u
Fan
Quoted 29 lines
Quoted 28 lines
Quoted 28 lines
Signed-off-by Fan Ni <[email protected]>---
hw/cxl/cxl-mailbox-utils.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)hw/cxl/cxl-mailbox-utils.c +3
-4@@ -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
Signature · 1 line
Fan Ni