diff mbox series

[14/17] hw/arm/spitz: Use LOG_GUEST_ERROR for bad guest register accesses

Message ID 20200628142429.17111-15-peter.maydell@linaro.org
State Superseded
Headers show
Series spitz: fix hacks, fix CID 1421913, various cleanups | expand

Commit Message

Peter Maydell June 28, 2020, 2:24 p.m. UTC
Instead of logging guest accesses to invalid register offsets in the
Spitz flash device with zaurus_printf() (which just prints to stderr),
use the usual qemu_log_mask(LOG_GUEST_ERROR,...).

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

---
 hw/arm/spitz.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

-- 
2.20.1

Comments

Philippe Mathieu-Daudé June 29, 2020, 9:14 a.m. UTC | #1
On 6/28/20 4:24 PM, Peter Maydell wrote:
> Instead of logging guest accesses to invalid register offsets in the

> Spitz flash device with zaurus_printf() (which just prints to stderr),

> use the usual qemu_log_mask(LOG_GUEST_ERROR,...).

> 

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


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


> ---

>  hw/arm/spitz.c | 12 +++++++-----

>  1 file changed, 7 insertions(+), 5 deletions(-)

> 

> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c

> index 6eb46869157..49eae3fce4e 100644

> --- a/hw/arm/spitz.c

> +++ b/hw/arm/spitz.c

> @@ -23,6 +23,7 @@

>  #include "hw/ssi/ssi.h"

>  #include "hw/block/flash.h"

>  #include "qemu/timer.h"

> +#include "qemu/log.h"

>  #include "hw/arm/sharpsl.h"

>  #include "ui/console.h"

>  #include "hw/audio/wm8750.h"

> @@ -65,9 +66,6 @@ typedef struct {

>  #define zaurus_printf(format, ...)                              \

>      fprintf(stderr, "%s: " format, __func__, ##__VA_ARGS__)

>  

> -#undef REG_FMT

> -#define REG_FMT                         "0x%02lx"

> -

>  /* Spitz Flash */

>  #define FLASH_BASE              0x0c000000

>  #define FLASH_ECCLPLB           0x00    /* Line parity 7 - 0 bit */

> @@ -137,7 +135,9 @@ static uint64_t sl_read(void *opaque, hwaddr addr, unsigned size)

>          return ecc_digest(&s->ecc, nand_getio(s->nand));

>  

>      default:

> -        zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr);

> +        qemu_log_mask(LOG_GUEST_ERROR,

> +                      "sl_read: bad register offset 0x%02" HWADDR_PRIx "\n",

> +                      addr);

>      }

>      return 0;

>  }

> @@ -168,7 +168,9 @@ static void sl_write(void *opaque, hwaddr addr,

>          break;

>  

>      default:

> -        zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr);

> +        qemu_log_mask(LOG_GUEST_ERROR,

> +                      "sl_write: bad register offset 0x%02" HWADDR_PRIx "\n",

> +                      addr);

>      }

>  }

>  

>
Alistair Francis July 1, 2020, 12:52 a.m. UTC | #2
On Sun, Jun 28, 2020 at 7:33 AM Peter Maydell <peter.maydell@linaro.org> wrote:
>

> Instead of logging guest accesses to invalid register offsets in the

> Spitz flash device with zaurus_printf() (which just prints to stderr),

> use the usual qemu_log_mask(LOG_GUEST_ERROR,...).

>

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


Reviewed-by: Alistair Francis <alistair.francis@wdc.com>


Alistair

> ---

>  hw/arm/spitz.c | 12 +++++++-----

>  1 file changed, 7 insertions(+), 5 deletions(-)

>

> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c

> index 6eb46869157..49eae3fce4e 100644

> --- a/hw/arm/spitz.c

> +++ b/hw/arm/spitz.c

> @@ -23,6 +23,7 @@

>  #include "hw/ssi/ssi.h"

>  #include "hw/block/flash.h"

>  #include "qemu/timer.h"

> +#include "qemu/log.h"

>  #include "hw/arm/sharpsl.h"

>  #include "ui/console.h"

>  #include "hw/audio/wm8750.h"

> @@ -65,9 +66,6 @@ typedef struct {

>  #define zaurus_printf(format, ...)                              \

>      fprintf(stderr, "%s: " format, __func__, ##__VA_ARGS__)

>

> -#undef REG_FMT

> -#define REG_FMT                         "0x%02lx"

> -

>  /* Spitz Flash */

>  #define FLASH_BASE              0x0c000000

>  #define FLASH_ECCLPLB           0x00    /* Line parity 7 - 0 bit */

> @@ -137,7 +135,9 @@ static uint64_t sl_read(void *opaque, hwaddr addr, unsigned size)

>          return ecc_digest(&s->ecc, nand_getio(s->nand));

>

>      default:

> -        zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr);

> +        qemu_log_mask(LOG_GUEST_ERROR,

> +                      "sl_read: bad register offset 0x%02" HWADDR_PRIx "\n",

> +                      addr);

>      }

>      return 0;

>  }

> @@ -168,7 +168,9 @@ static void sl_write(void *opaque, hwaddr addr,

>          break;

>

>      default:

> -        zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr);

> +        qemu_log_mask(LOG_GUEST_ERROR,

> +                      "sl_write: bad register offset 0x%02" HWADDR_PRIx "\n",

> +                      addr);

>      }

>  }

>

> --

> 2.20.1

>

>
diff mbox series

Patch

diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index 6eb46869157..49eae3fce4e 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -23,6 +23,7 @@ 
 #include "hw/ssi/ssi.h"
 #include "hw/block/flash.h"
 #include "qemu/timer.h"
+#include "qemu/log.h"
 #include "hw/arm/sharpsl.h"
 #include "ui/console.h"
 #include "hw/audio/wm8750.h"
@@ -65,9 +66,6 @@  typedef struct {
 #define zaurus_printf(format, ...)                              \
     fprintf(stderr, "%s: " format, __func__, ##__VA_ARGS__)
 
-#undef REG_FMT
-#define REG_FMT                         "0x%02lx"
-
 /* Spitz Flash */
 #define FLASH_BASE              0x0c000000
 #define FLASH_ECCLPLB           0x00    /* Line parity 7 - 0 bit */
@@ -137,7 +135,9 @@  static uint64_t sl_read(void *opaque, hwaddr addr, unsigned size)
         return ecc_digest(&s->ecc, nand_getio(s->nand));
 
     default:
-        zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr);
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "sl_read: bad register offset 0x%02" HWADDR_PRIx "\n",
+                      addr);
     }
     return 0;
 }
@@ -168,7 +168,9 @@  static void sl_write(void *opaque, hwaddr addr,
         break;
 
     default:
-        zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr);
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "sl_write: bad register offset 0x%02" HWADDR_PRIx "\n",
+                      addr);
     }
 }