Message ID | 1ecc1748443a161ecb988aab6b89c68e5ae631ff.1635449225.git.balaton@eik.bme.hu |
---|---|
State | New |
Headers | show |
Series | More SH4 clean ups | expand |
On 10/28/21 21:27, BALATON Zoltan wrote: > It does the same with dumping some more state but avoids calling abort > directly and printing to stderr from the device model. hw_error() is unfortunately misnamed, it is meant for CPU code, and we want to get ride of it. What you probably want here is error_report() which also reports to the monitor. > Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> > --- > hw/char/sh_serial.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c > index 1b1e6a6a04..dbefb51d71 100644 > --- a/hw/char/sh_serial.c > +++ b/hw/char/sh_serial.c > @@ -26,6 +26,7 @@ > */ > > #include "qemu/osdep.h" > +#include "hw/hw.h" > #include "hw/irq.h" > #include "hw/sh4/sh.h" > #include "chardev/char-fe.h" > @@ -200,9 +201,7 @@ static void sh_serial_write(void *opaque, hwaddr offs, > } > } > > - fprintf(stderr, "sh_serial: unsupported write to 0x%02" > - HWADDR_PRIx "\n", offs); > - abort(); > + hw_error("sh_serial: unsupported write to 0x%02"HWADDR_PRIx"\n", offs); > } > > static uint64_t sh_serial_read(void *opaque, hwaddr offs, > @@ -307,9 +306,7 @@ static uint64_t sh_serial_read(void *opaque, hwaddr offs, > #endif > > if (ret & ~((1 << 16) - 1)) { > - fprintf(stderr, "sh_serial: unsupported read from 0x%02" > - HWADDR_PRIx "\n", offs); > - abort(); > + hw_error("sh_serial: unsupported read from 0x%02"HWADDR_PRIx"\n", offs); > } > > return ret; >
On 29/10/2021 07.38, Philippe Mathieu-Daudé wrote: > On 10/28/21 21:27, BALATON Zoltan wrote: >> It does the same with dumping some more state but avoids calling abort >> directly and printing to stderr from the device model. > > hw_error() is unfortunately misnamed, it is meant for CPU code, > and we want to get ride of it. What you probably want here is > error_report() which also reports to the monitor. Looking at the text of the messages, maybe it would be even better to use qemu_log_mask(LOG_UNIMP, ...) or qemu_log_mask(LOG_GUEST_ERROR, ...) ? Thomas >> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> >> --- >> hw/char/sh_serial.c | 9 +++------ >> 1 file changed, 3 insertions(+), 6 deletions(-) >> >> diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c >> index 1b1e6a6a04..dbefb51d71 100644 >> --- a/hw/char/sh_serial.c >> +++ b/hw/char/sh_serial.c >> @@ -26,6 +26,7 @@ >> */ >> >> #include "qemu/osdep.h" >> +#include "hw/hw.h" >> #include "hw/irq.h" >> #include "hw/sh4/sh.h" >> #include "chardev/char-fe.h" >> @@ -200,9 +201,7 @@ static void sh_serial_write(void *opaque, hwaddr offs, >> } >> } >> >> - fprintf(stderr, "sh_serial: unsupported write to 0x%02" >> - HWADDR_PRIx "\n", offs); >> - abort(); >> + hw_error("sh_serial: unsupported write to 0x%02"HWADDR_PRIx"\n", offs); >> } >> >> static uint64_t sh_serial_read(void *opaque, hwaddr offs, >> @@ -307,9 +306,7 @@ static uint64_t sh_serial_read(void *opaque, hwaddr offs, >> #endif >> >> if (ret & ~((1 << 16) - 1)) { >> - fprintf(stderr, "sh_serial: unsupported read from 0x%02" >> - HWADDR_PRIx "\n", offs); >> - abort(); >> + hw_error("sh_serial: unsupported read from 0x%02"HWADDR_PRIx"\n", offs); >> } >> >> return ret; >> >
On Fri, 29 Oct 2021, Philippe Mathieu-Daudé wrote: > On 10/28/21 21:27, BALATON Zoltan wrote: >> It does the same with dumping some more state but avoids calling abort >> directly and printing to stderr from the device model. > > hw_error() is unfortunately misnamed, it is meant for CPU code, > and we want to get ride of it. What you probably want here is > error_report() which also reports to the monitor. OK, I'll drop the abort and make these qemu_log_mask UNIMP or GUEST_ERROR, have to check docs if these are valid or not otherwise. Regards, BALATON Zoltan >> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> >> --- >> hw/char/sh_serial.c | 9 +++------ >> 1 file changed, 3 insertions(+), 6 deletions(-) >> >> diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c >> index 1b1e6a6a04..dbefb51d71 100644 >> --- a/hw/char/sh_serial.c >> +++ b/hw/char/sh_serial.c >> @@ -26,6 +26,7 @@ >> */ >> >> #include "qemu/osdep.h" >> +#include "hw/hw.h" >> #include "hw/irq.h" >> #include "hw/sh4/sh.h" >> #include "chardev/char-fe.h" >> @@ -200,9 +201,7 @@ static void sh_serial_write(void *opaque, hwaddr offs, >> } >> } >> >> - fprintf(stderr, "sh_serial: unsupported write to 0x%02" >> - HWADDR_PRIx "\n", offs); >> - abort(); >> + hw_error("sh_serial: unsupported write to 0x%02"HWADDR_PRIx"\n", offs); >> } >> >> static uint64_t sh_serial_read(void *opaque, hwaddr offs, >> @@ -307,9 +306,7 @@ static uint64_t sh_serial_read(void *opaque, hwaddr offs, >> #endif >> >> if (ret & ~((1 << 16) - 1)) { >> - fprintf(stderr, "sh_serial: unsupported read from 0x%02" >> - HWADDR_PRIx "\n", offs); >> - abort(); >> + hw_error("sh_serial: unsupported read from 0x%02"HWADDR_PRIx"\n", offs); >> } >> >> return ret; >> > >
diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index 1b1e6a6a04..dbefb51d71 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c @@ -26,6 +26,7 @@ */ #include "qemu/osdep.h" +#include "hw/hw.h" #include "hw/irq.h" #include "hw/sh4/sh.h" #include "chardev/char-fe.h" @@ -200,9 +201,7 @@ static void sh_serial_write(void *opaque, hwaddr offs, } } - fprintf(stderr, "sh_serial: unsupported write to 0x%02" - HWADDR_PRIx "\n", offs); - abort(); + hw_error("sh_serial: unsupported write to 0x%02"HWADDR_PRIx"\n", offs); } static uint64_t sh_serial_read(void *opaque, hwaddr offs, @@ -307,9 +306,7 @@ static uint64_t sh_serial_read(void *opaque, hwaddr offs, #endif if (ret & ~((1 << 16) - 1)) { - fprintf(stderr, "sh_serial: unsupported read from 0x%02" - HWADDR_PRIx "\n", offs); - abort(); + hw_error("sh_serial: unsupported read from 0x%02"HWADDR_PRIx"\n", offs); } return ret;
It does the same with dumping some more state but avoids calling abort directly and printing to stderr from the device model. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> --- hw/char/sh_serial.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)