[PATCH v2] hw/display/artist: Fix bug in coordinate extraction in artist_vram_read() and artist_vram_write()

Helge Deller posted 1 patch 2 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/next-importer-push tags/patchew/YK1aPb8keur9W7h2@ls3530
[PATCH v2] hw/display/artist: Fix bug in coordinate extraction in artist_vram_read() and artist_vram_write()
Posted by Helge Deller 2 years, 11 months ago
The CDE desktop on HP-UX 10 shows wrongly rendered pixels when the local screen
menu is closed. This bug was introduced by commit c7050f3f167b
("hw/display/artist: Refactor x/y coordination extraction") which converted the
coordinate extraction in artist_vram_read() and artist_vram_write() to use the
ADDR_TO_X and ADDR_TO_Y macros, but forgot to right-shift the address by 2 as
it was done before.

Signed-off-by: Helge Deller <deller@gmx.de>
Fixes: c7050f3f167b ("hw/display/artist: Refactor x/y coordination extraction")
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Sven Schnelle <svens@stackframe.org>

---
v2: Fix artist_vram_write() too, noticed by Philippe Mathieu-Daudé

diff --git a/hw/display/artist.c b/hw/display/artist.c
index ed0e637f25..8758c77bbf 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -1171,8 +1171,8 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
     }

     buf = vram_write_buffer(s);
-    posy = ADDR_TO_Y(addr);
-    posx = ADDR_TO_X(addr);
+    posy = ADDR_TO_Y(addr >> 2);
+    posx = ADDR_TO_X(addr >> 2);

     if (!buf->size) {
         return;
@@ -1233,8 +1233,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
         return 0;
     }

-    posy = ADDR_TO_Y(addr);
-    posx = ADDR_TO_X(addr);
+    posy = ADDR_TO_Y(addr >> 2);
+    posx = ADDR_TO_X(addr >> 2);

     if (posy > buf->height || posx > buf->width) {
         return 0;

Re: [PATCH v2] hw/display/artist: Fix bug in coordinate extraction in artist_vram_read() and artist_vram_write()
Posted by Philippe Mathieu-Daudé 2 years, 11 months ago
On 5/25/21 10:12 PM, Helge Deller wrote:
> The CDE desktop on HP-UX 10 shows wrongly rendered pixels when the local screen
> menu is closed. This bug was introduced by commit c7050f3f167b
> ("hw/display/artist: Refactor x/y coordination extraction") which converted the
> coordinate extraction in artist_vram_read() and artist_vram_write() to use the
> ADDR_TO_X and ADDR_TO_Y macros, but forgot to right-shift the address by 2 as
> it was done before.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> Fixes: c7050f3f167b ("hw/display/artist: Refactor x/y coordination extraction")
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Sven Schnelle <svens@stackframe.org>
> 
> ---
> v2: Fix artist_vram_write() too, noticed by Philippe Mathieu-Daudé
> 
> diff --git a/hw/display/artist.c b/hw/display/artist.c
> index ed0e637f25..8758c77bbf 100644
> --- a/hw/display/artist.c
> +++ b/hw/display/artist.c
> @@ -1171,8 +1171,8 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
>      }
> 
>      buf = vram_write_buffer(s);
> -    posy = ADDR_TO_Y(addr);
> -    posx = ADDR_TO_X(addr);
> +    posy = ADDR_TO_Y(addr >> 2);
> +    posx = ADDR_TO_X(addr >> 2);
> 
>      if (!buf->size) {
>          return;
> @@ -1233,8 +1233,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
>          return 0;
>      }
> 
> -    posy = ADDR_TO_Y(addr);
> -    posx = ADDR_TO_X(addr);
> +    posy = ADDR_TO_Y(addr >> 2);
> +    posx = ADDR_TO_X(addr >> 2);
> 
>      if (posy > buf->height || posx > buf->width) {
>          return 0;
> 

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>