qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state
@ 2022-01-20 15:16 Peter Maydell
  2022-01-20 17:18 ` Guenter Roeck
  2022-01-22  9:50 ` Philippe Mathieu-Daudé via
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Maydell @ 2022-01-20 15:16 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Guenter Roeck

The exynos4210_uart_post_load() function assumes that it is passed
the Exynos4210UartState, but it has been attached to the
VMStateDescription for the Exynos4210UartFIFO type.  The result is a
SIGSEGV when attempting to load VM state for any machine type
including this device.

Fix the bug by attaching the post-load function to the VMSD for the
Exynos4210UartState.  This is the logical place for it, because the
actions it does relate to the entire UART state, not just the FIFO.

Thanks to the bug reporter @TrungNguyen1909 for the clear bug
description and the suggested fix.

Fixes: c9d3396d80fe7ece9b
   ("hw/char/exynos4210_uart: Implement post_load function")
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/638
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/char/exynos4210_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 80d401a3795..addcd59b028 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -628,7 +628,6 @@ static const VMStateDescription vmstate_exynos4210_uart_fifo = {
     .name = "exynos4210.uart.fifo",
     .version_id = 1,
     .minimum_version_id = 1,
-    .post_load = exynos4210_uart_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(sp, Exynos4210UartFIFO),
         VMSTATE_UINT32(rp, Exynos4210UartFIFO),
@@ -641,6 +640,7 @@ static const VMStateDescription vmstate_exynos4210_uart = {
     .name = "exynos4210.uart",
     .version_id = 1,
     .minimum_version_id = 1,
+    .post_load = exynos4210_uart_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(rx, Exynos4210UartState, 1,
                        vmstate_exynos4210_uart_fifo, Exynos4210UartFIFO),
-- 
2.25.1



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

* Re: [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state
  2022-01-20 15:16 [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state Peter Maydell
@ 2022-01-20 17:18 ` Guenter Roeck
  2022-01-22  9:50 ` Philippe Mathieu-Daudé via
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2022-01-20 17:18 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 1/20/22 7:16 AM, Peter Maydell wrote:
> The exynos4210_uart_post_load() function assumes that it is passed
> the Exynos4210UartState, but it has been attached to the
> VMStateDescription for the Exynos4210UartFIFO type.  The result is a
> SIGSEGV when attempting to load VM state for any machine type
> including this device.
> 
> Fix the bug by attaching the post-load function to the VMSD for the
> Exynos4210UartState.  This is the logical place for it, because the
> actions it does relate to the entire UART state, not just the FIFO.
> 
> Thanks to the bug reporter @TrungNguyen1909 for the clear bug
> description and the suggested fix.
> 
> Fixes: c9d3396d80fe7ece9b
>     ("hw/char/exynos4210_uart: Implement post_load function")
> Buglink: https://gitlab.com/qemu-project/qemu/-/issues/638
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   hw/char/exynos4210_uart.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
> index 80d401a3795..addcd59b028 100644
> --- a/hw/char/exynos4210_uart.c
> +++ b/hw/char/exynos4210_uart.c
> @@ -628,7 +628,6 @@ static const VMStateDescription vmstate_exynos4210_uart_fifo = {
>       .name = "exynos4210.uart.fifo",
>       .version_id = 1,
>       .minimum_version_id = 1,
> -    .post_load = exynos4210_uart_post_load,
>       .fields = (VMStateField[]) {
>           VMSTATE_UINT32(sp, Exynos4210UartFIFO),
>           VMSTATE_UINT32(rp, Exynos4210UartFIFO),
> @@ -641,6 +640,7 @@ static const VMStateDescription vmstate_exynos4210_uart = {
>       .name = "exynos4210.uart",
>       .version_id = 1,
>       .minimum_version_id = 1,
> +    .post_load = exynos4210_uart_post_load,
>       .fields = (VMStateField[]) {
>           VMSTATE_STRUCT(rx, Exynos4210UartState, 1,
>                          vmstate_exynos4210_uart_fifo, Exynos4210UartFIFO),
> 



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

* Re: [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state
  2022-01-20 15:16 [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state Peter Maydell
  2022-01-20 17:18 ` Guenter Roeck
@ 2022-01-22  9:50 ` Philippe Mathieu-Daudé via
  2022-01-22 11:27   ` Peter Maydell
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-01-22  9:50 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Guenter Roeck

On 20/1/22 16:16, Peter Maydell wrote:
> The exynos4210_uart_post_load() function assumes that it is passed
> the Exynos4210UartState, but it has been attached to the
> VMStateDescription for the Exynos4210UartFIFO type.  The result is a
> SIGSEGV when attempting to load VM state for any machine type
> including this device.
> 
> Fix the bug by attaching the post-load function to the VMSD for the
> Exynos4210UartState.  This is the logical place for it, because the
> actions it does relate to the entire UART state, not just the FIFO.
> 
> Thanks to the bug reporter @TrungNguyen1909 for the clear bug
> description and the suggested fix.
> 
> Fixes: c9d3396d80fe7ece9b
>     ("hw/char/exynos4210_uart: Implement post_load function")
> Buglink: https://gitlab.com/qemu-project/qemu/-/issues/638

Apparently GitLab doesn't recognize "Buglink":
https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#default-closing-pattern
which might be why we use "Resolves: " to have GitLab
automatically close issues.

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

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/char/exynos4210_uart.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)


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

* Re: [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state
  2022-01-22  9:50 ` Philippe Mathieu-Daudé via
@ 2022-01-22 11:27   ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2022-01-22 11:27 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-arm, qemu-devel, Guenter Roeck

On Sat, 22 Jan 2022 at 09:50, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 20/1/22 16:16, Peter Maydell wrote:
> > The exynos4210_uart_post_load() function assumes that it is passed
> > the Exynos4210UartState, but it has been attached to the
> > VMStateDescription for the Exynos4210UartFIFO type.  The result is a
> > SIGSEGV when attempting to load VM state for any machine type
> > including this device.
> >
> > Fix the bug by attaching the post-load function to the VMSD for the
> > Exynos4210UartState.  This is the logical place for it, because the
> > actions it does relate to the entire UART state, not just the FIFO.
> >
> > Thanks to the bug reporter @TrungNguyen1909 for the clear bug
> > description and the suggested fix.
> >
> > Fixes: c9d3396d80fe7ece9b
> >     ("hw/char/exynos4210_uart: Implement post_load function")
> > Buglink: https://gitlab.com/qemu-project/qemu/-/issues/638
>
> Apparently GitLab doesn't recognize "Buglink":
> https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#default-closing-pattern
> which might be why we use "Resolves: " to have GitLab
> automatically close issues.


Thanks; I can never remember which tag is the right one. I think
I just fished this one out of a random commit in the git history,
but I should have checked the docs, where we do have this
documented.

-- PMM


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

end of thread, other threads:[~2022-01-22 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-20 15:16 [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state Peter Maydell
2022-01-20 17:18 ` Guenter Roeck
2022-01-22  9:50 ` Philippe Mathieu-Daudé via
2022-01-22 11:27   ` Peter Maydell

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