[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] hw/m68k/mcf52xx: Replace hw_error() by qemu_log_mask()
From: |
Thomas Huth |
Subject: |
Re: [PATCH] hw/m68k/mcf52xx: Replace hw_error() by qemu_log_mask() |
Date: |
Mon, 18 May 2020 18:32:17 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
On 18/05/2020 11.49, Philippe Mathieu-Daudé wrote:
> hw_error() calls exit(). This a bit overkill when we can log
> the accesses as unimplemented or guest error.
Good idea. hw_error() is also mainly for CPU errors, it really should
not be used for non-CPU devices.
> When fuzzing the devices, we don't want the whole process to
> exit. Replace some hw_error() calls by qemu_log_mask().
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> hw/m68k/mcf5206.c | 7 +++++--
> hw/m68k/mcf5208.c | 14 +++++++++-----
> hw/m68k/mcf_intc.c | 4 +++-
> hw/net/mcf_fec.c | 8 +++++---
> 4 files changed, 22 insertions(+), 11 deletions(-)
>
> diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
> index b155dd8170..34a863a588 100644
> --- a/hw/m68k/mcf5206.c
> +++ b/hw/m68k/mcf5206.c
> @@ -8,6 +8,7 @@
>
> #include "qemu/osdep.h"
> #include "qemu/error-report.h"
> +#include "qemu/log.h"
> #include "cpu.h"
> #include "hw/hw.h"
> #include "hw/irq.h"
> @@ -306,7 +307,8 @@ static uint64_t m5206_mbar_read(m5206_mbar_state *s,
> case 0x170: return s->uivr[0];
> case 0x1b0: return s->uivr[1];
> }
> - hw_error("Bad MBAR read offset 0x%x", (int)offset);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad MBAR offset 0x%" HWADDR_PRIX
> "\n",
offset seems to be uint64_t in this function, so I think this should
rather use PRIx64 instead of HWADDR_PRIX ? Or maybe check whether we can
change the offset to uint32_t ?
> + __func__, offset);
> return 0;
> }
>
> @@ -360,7 +362,8 @@ static void m5206_mbar_write(m5206_mbar_state *s,
> uint32_t offset,
> s->uivr[1] = value;
> break;
> default:
> - hw_error("Bad MBAR write offset 0x%x", (int)offset);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad MBAR offset 0x%x\n",
> + __func__, offset);
Here offset seems to be uint32_t ... so I guess it should be fine for
the _read function, too.
> break;
> }
> }
> diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
> index b84c152ce3..cd8a32e0c6 100644
> --- a/hw/m68k/mcf5208.c
> +++ b/hw/m68k/mcf5208.c
> @@ -9,10 +9,10 @@
> #include "qemu/osdep.h"
> #include "qemu/units.h"
> #include "qemu/error-report.h"
> +#include "qemu/log.h"
> #include "qapi/error.h"
> #include "qemu-common.h"
> #include "cpu.h"
> -#include "hw/hw.h"
> #include "hw/irq.h"
> #include "hw/m68k/mcf.h"
> #include "hw/m68k/mcf_fec.h"
> @@ -111,7 +111,8 @@ static void m5208_timer_write(void *opaque, hwaddr offset,
> case 4:
> break;
> default:
> - hw_error("m5208_timer_write: Bad offset 0x%x\n", (int)offset);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
> + __func__, offset);
> break;
Should the "break" be replaced by a "return" now?
> }
> m5208_timer_update(s);
> @@ -136,7 +137,8 @@ static uint64_t m5208_timer_read(void *opaque, hwaddr
> addr,
> case 4:
> return ptimer_get_count(s->timer);
> default:
> - hw_error("m5208_timer_read: Bad offset 0x%x\n", (int)addr);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
> + __func__, addr);
> return 0;
> }
> }
> @@ -164,7 +166,8 @@ static uint64_t m5208_sys_read(void *opaque, hwaddr addr,
> return 0;
>
> default:
> - hw_error("m5208_sys_read: Bad offset 0x%x\n", (int)addr);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
> + __func__, addr);
> return 0;
> }
> }
> @@ -172,7 +175,8 @@ static uint64_t m5208_sys_read(void *opaque, hwaddr addr,
> static void m5208_sys_write(void *opaque, hwaddr addr,
> uint64_t value, unsigned size)
> {
> - hw_error("m5208_sys_write: Bad offset 0x%x\n", (int)addr);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
> + __func__, addr);
> }
>
> static const MemoryRegionOps m5208_sys_ops = {
> diff --git a/hw/m68k/mcf_intc.c b/hw/m68k/mcf_intc.c
> index d9e03a06ab..7dddf17d33 100644
> --- a/hw/m68k/mcf_intc.c
> +++ b/hw/m68k/mcf_intc.c
> @@ -8,6 +8,7 @@
>
> #include "qemu/osdep.h"
> #include "qemu/module.h"
> +#include "qemu/log.h"
> #include "cpu.h"
> #include "hw/hw.h"
> #include "hw/irq.h"
> @@ -127,7 +128,8 @@ static void mcf_intc_write(void *opaque, hwaddr addr,
> }
> break;
> default:
> - hw_error("mcf_intc_write: Bad write offset %d\n", offset);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%02x\n",
> + __func__, offset);
> break;
"return" instead of "break" ?
> }
> mcf_intc_update(s);
> diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
> index 9327ac8a30..b3a92c0114 100644
> --- a/hw/net/mcf_fec.c
> +++ b/hw/net/mcf_fec.c
> @@ -7,7 +7,7 @@
> */
>
> #include "qemu/osdep.h"
> -#include "hw/hw.h"
> +#include "qemu/log.h"
> #include "hw/irq.h"
> #include "net/net.h"
> #include "qemu/module.h"
> @@ -392,7 +392,8 @@ static uint64_t mcf_fec_read(void *opaque, hwaddr addr,
> case 0x188: return s->emrbr;
> case 0x200 ... 0x2e0: return s->mib[(addr & 0x1ff) / 4];
> default:
> - hw_error("mcf_fec_read: Bad address 0x%x\n", (int)addr);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address 0x%" HWADDR_PRIX
> "\n",
> + __func__, addr);
> return 0;
> }
> }
> @@ -492,7 +493,8 @@ static void mcf_fec_write(void *opaque, hwaddr addr,
> s->mib[(addr & 0x1ff) / 4] = value;
> break;
> default:
> - hw_error("mcf_fec_write Bad address 0x%x\n", (int)addr);
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address 0x%" HWADDR_PRIX
> "\n",
> + __func__, addr);
return here?
> }
> mcf_fec_update(s);
> }
>
Thomas