[PATCH] hw/misc: Fix the valid access size to the avr-power device

Thomas Huth posted 1 patch 4 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260421082935.85995-1-thuth@redhat.com
Maintainers: Michael Rolnik <mrolnik@gmail.com>
hw/misc/avr_power.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] hw/misc: Fix the valid access size to the avr-power device
Posted by Thomas Huth 4 hours ago
From: Thomas Huth <thuth@redhat.com>

Accessing the device with in non-single byte mode currently causes
QEMU to abort:

 $ echo "writew 0x800064 0x4142" | \
   ./qemu-system-avr -M mega2560 -display none -qtest stdio -accel qtest
 [I 0.000000] OPENED
 [R +0.001784] writew 0x800064 0x4142
 qemu-system-avr: ../../devel/qemu/hw/misc/avr_power.c:58: avr_mask_write:
  Assertion `offset == 0' failed.
 Aborted                    (core dumped)

Set the valid max access size to 1 to fix the problem.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3393
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/misc/avr_power.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/misc/avr_power.c b/hw/misc/avr_power.c
index f42cf4fd906..42be2656911 100644
--- a/hw/misc/avr_power.c
+++ b/hw/misc/avr_power.c
@@ -73,6 +73,9 @@ static const MemoryRegionOps avr_mask_ops = {
     .impl = {
         .max_access_size = 1,
     },
+    .valid = {
+        .max_access_size = 1,
+    },
 };
 
 static void avr_mask_init(Object *dev)
-- 
2.53.0
Re: [PATCH] hw/misc: Fix the valid access size to the avr-power device
Posted by Philippe Mathieu-Daudé 3 hours ago
On 21/4/26 10:29, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> Accessing the device with in non-single byte mode currently causes
> QEMU to abort:
> 
>   $ echo "writew 0x800064 0x4142" | \
>     ./qemu-system-avr -M mega2560 -display none -qtest stdio -accel qtest
>   [I 0.000000] OPENED
>   [R +0.001784] writew 0x800064 0x4142
>   qemu-system-avr: ../../devel/qemu/hw/misc/avr_power.c:58: avr_mask_write:
>    Assertion `offset == 0' failed.
>   Aborted                    (core dumped)
> 
> Set the valid max access size to 1 to fix the problem.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3393
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   hw/misc/avr_power.c | 3 +++
>   1 file changed, 3 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

and queued, thanks!

Re: [PATCH] hw/misc: Fix the valid access size to the avr-power device
Posted by Peter Maydell 4 hours ago
On Tue, 21 Apr 2026 at 09:29, Thomas Huth <thuth@redhat.com> wrote:
>
> From: Thomas Huth <thuth@redhat.com>
>
> Accessing the device with in non-single byte mode currently causes
> QEMU to abort:
>
>  $ echo "writew 0x800064 0x4142" | \
>    ./qemu-system-avr -M mega2560 -display none -qtest stdio -accel qtest
>  [I 0.000000] OPENED
>  [R +0.001784] writew 0x800064 0x4142
>  qemu-system-avr: ../../devel/qemu/hw/misc/avr_power.c:58: avr_mask_write:
>   Assertion `offset == 0' failed.
>  Aborted                    (core dumped)
>
> Set the valid max access size to 1 to fix the problem.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3393
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/misc/avr_power.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/hw/misc/avr_power.c b/hw/misc/avr_power.c
> index f42cf4fd906..42be2656911 100644
> --- a/hw/misc/avr_power.c
> +++ b/hw/misc/avr_power.c
> @@ -73,6 +73,9 @@ static const MemoryRegionOps avr_mask_ops = {
>      .impl = {
>          .max_access_size = 1,
>      },
> +    .valid = {
> +        .max_access_size = 1,
> +    },
>  };

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM