* [PATCH] target/i386: Only allow injecting MCE on x86 CPUs
@ 2023-10-30 10:21 Philippe Mathieu-Daudé
2023-10-31 22:30 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-30 10:21 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, Richard Henderson,
Markus Armbruster, Philippe Mathieu-Daudé
When using heterogeneous machines, we can try to inject a MCE on
a non-x86 CPU. Filter the CPU is injectable, otherwise display a
hint.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/i386/monitor.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 6512846327..7ef540eda7 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -579,7 +579,6 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict)
void hmp_mce(Monitor *mon, const QDict *qdict)
{
- X86CPU *cpu;
CPUState *cs;
int cpu_index = qdict_get_int(qdict, "cpu_index");
int bank = qdict_get_int(qdict, "bank");
@@ -593,11 +592,17 @@ void hmp_mce(Monitor *mon, const QDict *qdict)
flags |= MCE_INJECT_BROADCAST;
}
cs = qemu_get_cpu(cpu_index);
- if (cs != NULL) {
- cpu = X86_CPU(cs);
- cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,
- flags);
+ if (cs == NULL) {
+ monitor_printf(mon, "CPU #%d not found\n", cpu_index);
+ return;
}
+ if (!object_dynamic_cast(OBJECT(cs), TYPE_X86_CPU)) {
+ monitor_printf(mon, "Can only inject MCE on x86 CPU (CPU #%d is %s)\n",
+ cpu_index, object_get_typename(OBJECT(cs)));
+ return;
+ }
+ cpu_x86_inject_mce(mon, X86_CPU(cs), bank, status, mcg_status, addr, misc,
+ flags);
}
static target_long monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] target/i386: Only allow injecting MCE on x86 CPUs
2023-10-30 10:21 [PATCH] target/i386: Only allow injecting MCE on x86 CPUs Philippe Mathieu-Daudé
@ 2023-10-31 22:30 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2023-10-31 22:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, Markus Armbruster
On 10/30/23 03:21, Philippe Mathieu-Daudé wrote:
> When using heterogeneous machines, we can try to inject a MCE on
> a non-x86 CPU. Filter the CPU is injectable, otherwise display a
> hint.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/i386/monitor.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
I guess this or somtthing like it is required, though that's certainly not the end of it.
Everything in that file, as well as every other target/*/monitor.c is target-specific.
Do we have a general plan for the monitor?
r~
>
> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
> index 6512846327..7ef540eda7 100644
> --- a/target/i386/monitor.c
> +++ b/target/i386/monitor.c
> @@ -579,7 +579,6 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict)
>
> void hmp_mce(Monitor *mon, const QDict *qdict)
> {
> - X86CPU *cpu;
> CPUState *cs;
> int cpu_index = qdict_get_int(qdict, "cpu_index");
> int bank = qdict_get_int(qdict, "bank");
> @@ -593,11 +592,17 @@ void hmp_mce(Monitor *mon, const QDict *qdict)
> flags |= MCE_INJECT_BROADCAST;
> }
> cs = qemu_get_cpu(cpu_index);
> - if (cs != NULL) {
> - cpu = X86_CPU(cs);
> - cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,
> - flags);
> + if (cs == NULL) {
> + monitor_printf(mon, "CPU #%d not found\n", cpu_index);
> + return;
> }
> + if (!object_dynamic_cast(OBJECT(cs), TYPE_X86_CPU)) {
> + monitor_printf(mon, "Can only inject MCE on x86 CPU (CPU #%d is %s)\n",
> + cpu_index, object_get_typename(OBJECT(cs)));
> + return;
> + }
> + cpu_x86_inject_mce(mon, X86_CPU(cs), bank, status, mcg_status, addr, misc,
> + flags);
> }
>
> static target_long monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-31 22:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 10:21 [PATCH] target/i386: Only allow injecting MCE on x86 CPUs Philippe Mathieu-Daudé
2023-10-31 22:30 ` 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).