* [PATCH 0/2] hw/core: Move hw_error() out of cpus.c @ 2020-09-01 11:23 Philippe Mathieu-Daudé 2020-09-01 11:23 ` [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() Philippe Mathieu-Daudé ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2020-09-01 11:23 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Thomas Huth, Philippe Mathieu-Daudé, Claudio Fontana, Richard Henderson Move hw_error() out of cpus.c because we already have cpu_abort() there. Philippe Mathieu-Daudé (2): cpus: Do not dump CPU state when calling hw_error() hw/core: Move hw_error() out of cpus.c hw/core/error.c | 38 ++++++++++++++++++++++++++++++++++++++ softmmu/cpus.c | 17 ----------------- hw/core/meson.build | 1 + 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 hw/core/error.c -- 2.26.2 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() 2020-09-01 11:23 [PATCH 0/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé @ 2020-09-01 11:23 ` Philippe Mathieu-Daudé 2020-09-02 6:33 ` Thomas Huth 2020-09-01 11:23 ` [PATCH 2/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé 2020-09-01 16:44 ` [PATCH 0/2] " Richard Henderson 2 siblings, 1 reply; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2020-09-01 11:23 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Thomas Huth, Philippe Mathieu-Daudé, Claudio Fontana, Richard Henderson We already have cpu_abort() to dump CPU states and abort. Restrict hw_error() to peripheral errors, hoping we can completely remove it by proper functions from "error-report.h" in the future. Suggested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- softmmu/cpus.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/softmmu/cpus.c b/softmmu/cpus.c index a802e899abb..c96a04d7f18 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -913,16 +913,11 @@ static void stop_tcg_kick_timer(void) void hw_error(const char *fmt, ...) { va_list ap; - CPUState *cpu; va_start(ap, fmt); fprintf(stderr, "qemu: hardware error: "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); - CPU_FOREACH(cpu) { - fprintf(stderr, "CPU #%d:\n", cpu->cpu_index); - cpu_dump_state(cpu, stderr, CPU_DUMP_FPU); - } va_end(ap); abort(); } -- 2.26.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() 2020-09-01 11:23 ` [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() Philippe Mathieu-Daudé @ 2020-09-02 6:33 ` Thomas Huth 2020-09-02 16:04 ` Philippe Mathieu-Daudé 0 siblings, 1 reply; 11+ messages in thread From: Thomas Huth @ 2020-09-02 6:33 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: Paolo Bonzini, Claudio Fontana, Richard Henderson On 01/09/2020 13.23, Philippe Mathieu-Daudé wrote: > We already have cpu_abort() to dump CPU states and abort. > > Restrict hw_error() to peripheral errors, hoping we can completely > remove it by proper functions from "error-report.h" in the future. > > Suggested-by: Thomas Huth <thuth@redhat.com> IIRC I rather suggested to rename the function to "cpu_hw_error" and only use it for real CPU problems... But I think your approach here is fine as well. Please replace the "Suggested-by" with "Reviewed-by" now :-) Thomas > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > softmmu/cpus.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/softmmu/cpus.c b/softmmu/cpus.c > index a802e899abb..c96a04d7f18 100644 > --- a/softmmu/cpus.c > +++ b/softmmu/cpus.c > @@ -913,16 +913,11 @@ static void stop_tcg_kick_timer(void) > void hw_error(const char *fmt, ...) > { > va_list ap; > - CPUState *cpu; > > va_start(ap, fmt); > fprintf(stderr, "qemu: hardware error: "); > vfprintf(stderr, fmt, ap); > fprintf(stderr, "\n"); > - CPU_FOREACH(cpu) { > - fprintf(stderr, "CPU #%d:\n", cpu->cpu_index); > - cpu_dump_state(cpu, stderr, CPU_DUMP_FPU); > - } You could argue that cpu_abort() only prints the state of one CPU and not of all. But I doubt that dumping the state of *all* CPUs is really helpful in any of the contexts where hw_error() is used. So I think it's fine to remove this CPU_FOREACH loop here. > va_end(ap); > abort(); > } > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() 2020-09-02 6:33 ` Thomas Huth @ 2020-09-02 16:04 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2020-09-02 16:04 UTC (permalink / raw) To: Thomas Huth, qemu-devel; +Cc: Paolo Bonzini, Claudio Fontana, Richard Henderson On 9/2/20 8:33 AM, Thomas Huth wrote: > On 01/09/2020 13.23, Philippe Mathieu-Daudé wrote: >> We already have cpu_abort() to dump CPU states and abort. >> >> Restrict hw_error() to peripheral errors, hoping we can completely >> remove it by proper functions from "error-report.h" in the future. >> >> Suggested-by: Thomas Huth <thuth@redhat.com> > > IIRC I rather suggested to rename the function to "cpu_hw_error" and > only use it for real CPU problems... > But I think your approach here is fine as well. Please replace the > "Suggested-by" with "Reviewed-by" now :-) > > Thomas > > >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> --- >> softmmu/cpus.c | 5 ----- >> 1 file changed, 5 deletions(-) >> >> diff --git a/softmmu/cpus.c b/softmmu/cpus.c >> index a802e899abb..c96a04d7f18 100644 >> --- a/softmmu/cpus.c >> +++ b/softmmu/cpus.c >> @@ -913,16 +913,11 @@ static void stop_tcg_kick_timer(void) >> void hw_error(const char *fmt, ...) >> { >> va_list ap; >> - CPUState *cpu; >> >> va_start(ap, fmt); >> fprintf(stderr, "qemu: hardware error: "); >> vfprintf(stderr, fmt, ap); >> fprintf(stderr, "\n"); >> - CPU_FOREACH(cpu) { >> - fprintf(stderr, "CPU #%d:\n", cpu->cpu_index); >> - cpu_dump_state(cpu, stderr, CPU_DUMP_FPU); >> - } > > You could argue that cpu_abort() only prints the state of one CPU and > not of all. But I doubt that dumping the state of *all* CPUs is really > helpful in any of the contexts where hw_error() is used. So I think it's > fine to remove this CPU_FOREACH loop here. I find this not very practical when using more than 8 vCPUs. Personally I stopped looking at this output because it is too noisy. Are there developers interested in having cpu_abort() dumping all vCPU registers? I can move that there. Or the interested ones can also do it later if they find it useful :) > >> va_end(ap); >> abort(); >> } >> > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/2] hw/core: Move hw_error() out of cpus.c 2020-09-01 11:23 [PATCH 0/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé 2020-09-01 11:23 ` [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() Philippe Mathieu-Daudé @ 2020-09-01 11:23 ` Philippe Mathieu-Daudé 2020-09-02 6:37 ` Thomas Huth 2020-09-01 16:44 ` [PATCH 0/2] " Richard Henderson 2 siblings, 1 reply; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2020-09-01 11:23 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Thomas Huth, Philippe Mathieu-Daudé, Claudio Fontana, Richard Henderson As hw_error() is unrelated to CPU error - for which we have cpu_abort() - move it out of cpus.c, under the hw/ directory. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- Couldn't find better file/name to put it in... --- hw/core/error.c | 38 ++++++++++++++++++++++++++++++++++++++ softmmu/cpus.c | 12 ------------ hw/core/meson.build | 1 + 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 hw/core/error.c diff --git a/hw/core/error.c b/hw/core/error.c new file mode 100644 index 00000000000..5a783c82dff --- /dev/null +++ b/hw/core/error.c @@ -0,0 +1,38 @@ +/* + * Peripheral error reporting + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "hw/hw.h" + +void hw_error(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fprintf(stderr, "qemu: hardware error: "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); + abort(); +} diff --git a/softmmu/cpus.c b/softmmu/cpus.c index c96a04d7f18..eca57c76c9b 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -59,7 +59,6 @@ #include "sysemu/replay.h" #include "sysemu/runstate.h" #include "hw/boards.h" -#include "hw/hw.h" #include "sysemu/cpu-throttle.h" @@ -910,17 +909,6 @@ static void stop_tcg_kick_timer(void) } /***********************************************************/ -void hw_error(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fprintf(stderr, "qemu: hardware error: "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - abort(); -} void cpu_synchronize_all_states(void) { diff --git a/hw/core/meson.build b/hw/core/meson.build index fc91f980758..99466dc93fd 100644 --- a/hw/core/meson.build +++ b/hw/core/meson.build @@ -1,6 +1,7 @@ # core qdev-related obj files, also used by *-user and unit tests hwcore_files = files( 'bus.c', + 'error.c', 'fw-path-provider.c', 'hotplug.c', 'qdev-properties.c', -- 2.26.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] hw/core: Move hw_error() out of cpus.c 2020-09-01 11:23 ` [PATCH 2/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé @ 2020-09-02 6:37 ` Thomas Huth 2020-09-02 15:38 ` Richard Henderson 0 siblings, 1 reply; 11+ messages in thread From: Thomas Huth @ 2020-09-02 6:37 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: Paolo Bonzini, Claudio Fontana, Richard Henderson On 01/09/2020 13.23, Philippe Mathieu-Daudé wrote: > As hw_error() is unrelated to CPU error - for which we have > cpu_abort() - move it out of cpus.c, under the hw/ directory. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > Couldn't find better file/name to put it in... > --- > hw/core/error.c | 38 ++++++++++++++++++++++++++++++++++++++ > softmmu/cpus.c | 12 ------------ > hw/core/meson.build | 1 + > 3 files changed, 39 insertions(+), 12 deletions(-) > create mode 100644 hw/core/error.c > > diff --git a/hw/core/error.c b/hw/core/error.c > new file mode 100644 > index 00000000000..5a783c82dff > --- /dev/null > +++ b/hw/core/error.c > @@ -0,0 +1,38 @@ > +/* > + * Peripheral error reporting > + * > + * Copyright (c) 2003-2008 Fabrice Bellard > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +#include "qemu/osdep.h" > +#include "hw/hw.h" > + > +void hw_error(const char *fmt, ...) > +{ > + va_list ap; > + > + va_start(ap, fmt); > + fprintf(stderr, "qemu: hardware error: "); > + vfprintf(stderr, fmt, ap); > + fprintf(stderr, "\n"); > + va_end(ap); > + abort(); > +} > diff --git a/softmmu/cpus.c b/softmmu/cpus.c > index c96a04d7f18..eca57c76c9b 100644 > --- a/softmmu/cpus.c > +++ b/softmmu/cpus.c > @@ -59,7 +59,6 @@ > #include "sysemu/replay.h" > #include "sysemu/runstate.h" > #include "hw/boards.h" > -#include "hw/hw.h" > > #include "sysemu/cpu-throttle.h" > > @@ -910,17 +909,6 @@ static void stop_tcg_kick_timer(void) > } > > /***********************************************************/ > -void hw_error(const char *fmt, ...) > -{ > - va_list ap; > - > - va_start(ap, fmt); > - fprintf(stderr, "qemu: hardware error: "); > - vfprintf(stderr, fmt, ap); > - fprintf(stderr, "\n"); > - va_end(ap); > - abort(); > -} > > void cpu_synchronize_all_states(void) > { > diff --git a/hw/core/meson.build b/hw/core/meson.build > index fc91f980758..99466dc93fd 100644 > --- a/hw/core/meson.build > +++ b/hw/core/meson.build > @@ -1,6 +1,7 @@ > # core qdev-related obj files, also used by *-user and unit tests > hwcore_files = files( > 'bus.c', > + 'error.c', > 'fw-path-provider.c', > 'hotplug.c', > 'qdev-properties.c', > Reviewed-by: Thomas Huth <thuth@redhat.com> Alternative ideas: - Move the function as "static inline" into the header file instead - it's not so big, so an inline function should be ok here. - Add a big fat warning comment to the header that this function should not be used for new code anymore. Thomas ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] hw/core: Move hw_error() out of cpus.c 2020-09-02 6:37 ` Thomas Huth @ 2020-09-02 15:38 ` Richard Henderson 2020-09-02 15:59 ` Philippe Mathieu-Daudé 0 siblings, 1 reply; 11+ messages in thread From: Richard Henderson @ 2020-09-02 15:38 UTC (permalink / raw) To: Thomas Huth, Philippe Mathieu-Daudé, qemu-devel Cc: Paolo Bonzini, Claudio Fontana, Richard Henderson On 9/1/20 11:37 PM, Thomas Huth wrote: > - Move the function as "static inline" into the header file > instead - it's not so big, so an inline function should be > ok here. stdarg and inline do not mix. > - Add a big fat warning comment to the header that this > function should not be used for new code anymore. But certainly this. r~ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] hw/core: Move hw_error() out of cpus.c 2020-09-02 15:38 ` Richard Henderson @ 2020-09-02 15:59 ` Philippe Mathieu-Daudé 2020-09-02 16:02 ` Thomas Huth 0 siblings, 1 reply; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2020-09-02 15:59 UTC (permalink / raw) To: Richard Henderson, Thomas Huth, qemu-devel Cc: Paolo Bonzini, Claudio Fontana, Richard Henderson On 9/2/20 5:38 PM, Richard Henderson wrote: > On 9/1/20 11:37 PM, Thomas Huth wrote: >> - Move the function as "static inline" into the header file >> instead - it's not so big, so an inline function should be >> ok here. > > stdarg and inline do not mix. > >> - Add a big fat warning comment to the header that this >> function should not be used for new code anymore. > > But certainly this. Will do, but this has been proven to not work well... > > > r~ > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] hw/core: Move hw_error() out of cpus.c 2020-09-02 15:59 ` Philippe Mathieu-Daudé @ 2020-09-02 16:02 ` Thomas Huth 2020-09-02 16:13 ` Philippe Mathieu-Daudé 0 siblings, 1 reply; 11+ messages in thread From: Thomas Huth @ 2020-09-02 16:02 UTC (permalink / raw) To: Philippe Mathieu-Daudé, Richard Henderson, qemu-devel Cc: Paolo Bonzini, Claudio Fontana, Richard Henderson On 02/09/2020 17.59, Philippe Mathieu-Daudé wrote: > On 9/2/20 5:38 PM, Richard Henderson wrote: >> On 9/1/20 11:37 PM, Thomas Huth wrote: >>> - Move the function as "static inline" into the header file >>> instead - it's not so big, so an inline function should be >>> ok here. >> >> stdarg and inline do not mix. >> >>> - Add a big fat warning comment to the header that this >>> function should not be used for new code anymore. >> >> But certainly this. > > Will do, but this has been proven to not work well... ... or add a warning to checkpatch.pl ? Thomas ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] hw/core: Move hw_error() out of cpus.c 2020-09-02 16:02 ` Thomas Huth @ 2020-09-02 16:13 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2020-09-02 16:13 UTC (permalink / raw) To: Thomas Huth, Richard Henderson, qemu-devel Cc: Paolo Bonzini, Claudio Fontana, Richard Henderson On 9/2/20 6:02 PM, Thomas Huth wrote: > On 02/09/2020 17.59, Philippe Mathieu-Daudé wrote: >> On 9/2/20 5:38 PM, Richard Henderson wrote: >>> On 9/1/20 11:37 PM, Thomas Huth wrote: >>>> - Move the function as "static inline" into the header file >>>> instead - it's not so big, so an inline function should be >>>> ok here. >>> >>> stdarg and inline do not mix. >>> >>>> - Add a big fat warning comment to the header that this >>>> function should not be used for new code anymore. >>> >>> But certainly this. >> >> Will do, but this has been proven to not work well... > > ... or add a warning to checkpatch.pl ? This certainly works better :) > > Thomas > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/2] hw/core: Move hw_error() out of cpus.c 2020-09-01 11:23 [PATCH 0/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé 2020-09-01 11:23 ` [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() Philippe Mathieu-Daudé 2020-09-01 11:23 ` [PATCH 2/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé @ 2020-09-01 16:44 ` Richard Henderson 2 siblings, 0 replies; 11+ messages in thread From: Richard Henderson @ 2020-09-01 16:44 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: Paolo Bonzini, Thomas Huth, Claudio Fontana, Richard Henderson On 9/1/20 4:23 AM, Philippe Mathieu-Daudé wrote: > Move hw_error() out of cpus.c because we already have cpu_abort() > there. > > Philippe Mathieu-Daudé (2): > cpus: Do not dump CPU state when calling hw_error() > hw/core: Move hw_error() out of cpus.c Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~ ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-09-02 16:13 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-09-01 11:23 [PATCH 0/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé 2020-09-01 11:23 ` [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error() Philippe Mathieu-Daudé 2020-09-02 6:33 ` Thomas Huth 2020-09-02 16:04 ` Philippe Mathieu-Daudé 2020-09-01 11:23 ` [PATCH 2/2] hw/core: Move hw_error() out of cpus.c Philippe Mathieu-Daudé 2020-09-02 6:37 ` Thomas Huth 2020-09-02 15:38 ` Richard Henderson 2020-09-02 15:59 ` Philippe Mathieu-Daudé 2020-09-02 16:02 ` Thomas Huth 2020-09-02 16:13 ` Philippe Mathieu-Daudé 2020-09-01 16:44 ` [PATCH 0/2] " Richard Henderson
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).