* Re: [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size
2020-05-11 20:52 [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size Philippe Mathieu-Daudé
@ 2020-05-12 14:54 ` Alistair Francis
2020-05-18 12:42 ` Peter Maydell
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alistair Francis @ 2020-05-12 14:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Kevin Wolf, Peter Maydell, Radoslaw Biernacki, open list:RISC-V,
Sagar Karandikar, Qemu-block, Michael S. Tsirkin,
Bastian Koppelmann, Richard Henderson,
qemu-devel@nongnu.org Developers, Max Reitz, qemu-arm,
Alistair Francis, Paolo Bonzini, Leif Lindholm, Palmer Dabbelt,
Eduardo Habkost
On Mon, May 11, 2020 at 1:54 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> Use the QEMU_IS_ALIGNED() macro to verify the flash block size
> is properly aligned. It is quicker to process when reviewing.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/arm/sbsa-ref.c | 2 +-
> hw/arm/virt.c | 2 +-
> hw/block/pflash_cfi01.c | 2 +-
> hw/block/pflash_cfi02.c | 2 +-
> hw/i386/pc_sysfw.c | 2 +-
> hw/riscv/virt.c | 2 +-
> 6 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index 8409ba853d..b379e4a76a 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -241,7 +241,7 @@ static void sbsa_flash_map1(PFlashCFI01 *flash,
> {
> DeviceState *dev = DEVICE(flash);
>
> - assert(size % SBSA_FLASH_SECTOR_SIZE == 0);
> + assert(QEMU_IS_ALIGNED(size, SBSA_FLASH_SECTOR_SIZE));
> assert(size / SBSA_FLASH_SECTOR_SIZE <= UINT32_MAX);
> qdev_prop_set_uint32(dev, "num-blocks", size / SBSA_FLASH_SECTOR_SIZE);
> qdev_init_nofail(dev);
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 634db0cfe9..0a99fddb3d 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -978,7 +978,7 @@ static void virt_flash_map1(PFlashCFI01 *flash,
> {
> DeviceState *dev = DEVICE(flash);
>
> - assert(size % VIRT_FLASH_SECTOR_SIZE == 0);
> + assert(QEMU_IS_ALIGNED(size, VIRT_FLASH_SECTOR_SIZE));
> assert(size / VIRT_FLASH_SECTOR_SIZE <= UINT32_MAX);
> qdev_prop_set_uint32(dev, "num-blocks", size / VIRT_FLASH_SECTOR_SIZE);
> qdev_init_nofail(dev);
> diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
> index f586bac269..11922c0f96 100644
> --- a/hw/block/pflash_cfi01.c
> +++ b/hw/block/pflash_cfi01.c
> @@ -964,7 +964,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
> if (blk) {
> qdev_prop_set_drive(dev, "drive", blk, &error_abort);
> }
> - assert(size % sector_len == 0);
> + assert(QEMU_IS_ALIGNED(size, sector_len));
> qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
> qdev_prop_set_uint64(dev, "sector-length", sector_len);
> qdev_prop_set_uint8(dev, "width", bank_width);
> diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
> index c6b6f2d082..895f7daee3 100644
> --- a/hw/block/pflash_cfi02.c
> +++ b/hw/block/pflash_cfi02.c
> @@ -1003,7 +1003,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base,
> if (blk) {
> qdev_prop_set_drive(dev, "drive", blk, &error_abort);
> }
> - assert(size % sector_len == 0);
> + assert(QEMU_IS_ALIGNED(size, sector_len));
> qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
> qdev_prop_set_uint32(dev, "sector-length", sector_len);
> qdev_prop_set_uint8(dev, "width", width);
> diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
> index f5f3f466b0..fad41f0e73 100644
> --- a/hw/i386/pc_sysfw.c
> +++ b/hw/i386/pc_sysfw.c
> @@ -168,7 +168,7 @@ static void pc_system_flash_map(PCMachineState *pcms,
> blk_name(blk), strerror(-size));
> exit(1);
> }
> - if (size == 0 || size % FLASH_SECTOR_SIZE != 0) {
> + if (size == 0 || !QEMU_IS_ALIGNED(size, FLASH_SECTOR_SIZE)) {
> error_report("system firmware block device %s has invalid size "
> "%" PRId64,
> blk_name(blk), size);
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index daae3ebdbb..71481d59c2 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -112,7 +112,7 @@ static void virt_flash_map1(PFlashCFI01 *flash,
> {
> DeviceState *dev = DEVICE(flash);
>
> - assert(size % VIRT_FLASH_SECTOR_SIZE == 0);
> + assert(QEMU_IS_ALIGNED(size, VIRT_FLASH_SECTOR_SIZE));
> assert(size / VIRT_FLASH_SECTOR_SIZE <= UINT32_MAX);
> qdev_prop_set_uint32(dev, "num-blocks", size / VIRT_FLASH_SECTOR_SIZE);
> qdev_init_nofail(dev);
> --
> 2.21.3
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size
2020-05-11 20:52 [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size Philippe Mathieu-Daudé
2020-05-12 14:54 ` Alistair Francis
@ 2020-05-18 12:42 ` Peter Maydell
2020-05-18 12:49 ` Paolo Bonzini
2020-05-18 13:46 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2020-05-18 12:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Kevin Wolf, Radoslaw Biernacki, open list:RISC-V, Qemu-block,
Sagar Karandikar, Michael S. Tsirkin, Bastian Koppelmann,
QEMU Developers, Eduardo Habkost, Max Reitz, qemu-arm,
Alistair Francis, Paolo Bonzini, Palmer Dabbelt, Leif Lindholm,
Richard Henderson
On Mon, 11 May 2020 at 21:52, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Use the QEMU_IS_ALIGNED() macro to verify the flash block size
> is properly aligned. It is quicker to process when reviewing.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/arm/sbsa-ref.c | 2 +-
> hw/arm/virt.c | 2 +-
> hw/block/pflash_cfi01.c | 2 +-
> hw/block/pflash_cfi02.c | 2 +-
> hw/i386/pc_sysfw.c | 2 +-
> hw/riscv/virt.c | 2 +-
> 6 files changed, 6 insertions(+), 6 deletions(-)
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size
2020-05-11 20:52 [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size Philippe Mathieu-Daudé
2020-05-12 14:54 ` Alistair Francis
2020-05-18 12:42 ` Peter Maydell
@ 2020-05-18 12:49 ` Paolo Bonzini
2020-05-18 13:46 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-05-18 12:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Kevin Wolf, Peter Maydell, Radoslaw Biernacki, qemu-riscv,
qemu-block, Sagar Karandikar, Michael S. Tsirkin,
Bastian Koppelmann, Eduardo Habkost, Max Reitz, qemu-arm,
Alistair Francis, Palmer Dabbelt, Leif Lindholm,
Richard Henderson
On 11/05/20 22:52, Philippe Mathieu-Daudé wrote:
> Use the QEMU_IS_ALIGNED() macro to verify the flash block size
> is properly aligned. It is quicker to process when reviewing.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/arm/sbsa-ref.c | 2 +-
> hw/arm/virt.c | 2 +-
> hw/block/pflash_cfi01.c | 2 +-
> hw/block/pflash_cfi02.c | 2 +-
> hw/i386/pc_sysfw.c | 2 +-
> hw/riscv/virt.c | 2 +-
> 6 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index 8409ba853d..b379e4a76a 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -241,7 +241,7 @@ static void sbsa_flash_map1(PFlashCFI01 *flash,
> {
> DeviceState *dev = DEVICE(flash);
>
> - assert(size % SBSA_FLASH_SECTOR_SIZE == 0);
> + assert(QEMU_IS_ALIGNED(size, SBSA_FLASH_SECTOR_SIZE));
> assert(size / SBSA_FLASH_SECTOR_SIZE <= UINT32_MAX);
> qdev_prop_set_uint32(dev, "num-blocks", size / SBSA_FLASH_SECTOR_SIZE);
> qdev_init_nofail(dev);
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 634db0cfe9..0a99fddb3d 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -978,7 +978,7 @@ static void virt_flash_map1(PFlashCFI01 *flash,
> {
> DeviceState *dev = DEVICE(flash);
>
> - assert(size % VIRT_FLASH_SECTOR_SIZE == 0);
> + assert(QEMU_IS_ALIGNED(size, VIRT_FLASH_SECTOR_SIZE));
> assert(size / VIRT_FLASH_SECTOR_SIZE <= UINT32_MAX);
> qdev_prop_set_uint32(dev, "num-blocks", size / VIRT_FLASH_SECTOR_SIZE);
> qdev_init_nofail(dev);
> diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
> index f586bac269..11922c0f96 100644
> --- a/hw/block/pflash_cfi01.c
> +++ b/hw/block/pflash_cfi01.c
> @@ -964,7 +964,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
> if (blk) {
> qdev_prop_set_drive(dev, "drive", blk, &error_abort);
> }
> - assert(size % sector_len == 0);
> + assert(QEMU_IS_ALIGNED(size, sector_len));
> qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
> qdev_prop_set_uint64(dev, "sector-length", sector_len);
> qdev_prop_set_uint8(dev, "width", bank_width);
> diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
> index c6b6f2d082..895f7daee3 100644
> --- a/hw/block/pflash_cfi02.c
> +++ b/hw/block/pflash_cfi02.c
> @@ -1003,7 +1003,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base,
> if (blk) {
> qdev_prop_set_drive(dev, "drive", blk, &error_abort);
> }
> - assert(size % sector_len == 0);
> + assert(QEMU_IS_ALIGNED(size, sector_len));
> qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
> qdev_prop_set_uint32(dev, "sector-length", sector_len);
> qdev_prop_set_uint8(dev, "width", width);
> diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
> index f5f3f466b0..fad41f0e73 100644
> --- a/hw/i386/pc_sysfw.c
> +++ b/hw/i386/pc_sysfw.c
> @@ -168,7 +168,7 @@ static void pc_system_flash_map(PCMachineState *pcms,
> blk_name(blk), strerror(-size));
> exit(1);
> }
> - if (size == 0 || size % FLASH_SECTOR_SIZE != 0) {
> + if (size == 0 || !QEMU_IS_ALIGNED(size, FLASH_SECTOR_SIZE)) {
> error_report("system firmware block device %s has invalid size "
> "%" PRId64,
> blk_name(blk), size);
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index daae3ebdbb..71481d59c2 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -112,7 +112,7 @@ static void virt_flash_map1(PFlashCFI01 *flash,
> {
> DeviceState *dev = DEVICE(flash);
>
> - assert(size % VIRT_FLASH_SECTOR_SIZE == 0);
> + assert(QEMU_IS_ALIGNED(size, VIRT_FLASH_SECTOR_SIZE));
> assert(size / VIRT_FLASH_SECTOR_SIZE <= UINT32_MAX);
> qdev_prop_set_uint32(dev, "num-blocks", size / VIRT_FLASH_SECTOR_SIZE);
> qdev_init_nofail(dev);
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size
2020-05-11 20:52 [PATCH] hw: Use QEMU_IS_ALIGNED() on parallel flash block size Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-05-18 12:49 ` Paolo Bonzini
@ 2020-05-18 13:46 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2020-05-18 13:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, Radoslaw Biernacki, qemu-riscv, qemu-block,
Sagar Karandikar, Michael S. Tsirkin, Bastian Koppelmann,
qemu-devel, Eduardo Habkost, Max Reitz, qemu-arm,
Alistair Francis, Paolo Bonzini, Palmer Dabbelt, Leif Lindholm,
Richard Henderson
Am 11.05.2020 um 22:52 hat Philippe Mathieu-Daudé geschrieben:
> Use the QEMU_IS_ALIGNED() macro to verify the flash block size
> is properly aligned. It is quicker to process when reviewing.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread