From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH] target/i386: Only allow injecting MCE on x86 CPUs
Date: Mon, 30 Oct 2023 11:21:22 +0100 [thread overview]
Message-ID: <20231030102122.67105-1-philmd@linaro.org> (raw)
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
next reply other threads:[~2023-10-30 10:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 10:21 Philippe Mathieu-Daudé [this message]
2023-10-31 22:30 ` [PATCH] target/i386: Only allow injecting MCE on x86 CPUs Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231030102122.67105-1-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=armbru@redhat.com \
--cc=eduardo@habkost.net \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).