mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
target-i386: post memory failure event to QMP
Post memory failure event through QMP to handle hardware memory corrupted event. Rather than simply printing to the log, QEMU could report more effective message to the client. For example, if a guest receives an MCE, evacuating the host could be a good idea. Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20200930100440.1060708-4-pizhenwei@bytedance.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
77b285f7f6
commit
8efc4e5150
2 changed files with 32 additions and 5 deletions
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/qapi-events-run-state.h"
|
||||
#include "cpu.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "qemu/qemu-print.h"
|
||||
|
@ -851,6 +852,15 @@ typedef struct MCEInjectionParams {
|
|||
int flags;
|
||||
} MCEInjectionParams;
|
||||
|
||||
static void emit_guest_memory_failure(MemoryFailureAction action, bool ar,
|
||||
bool recursive)
|
||||
{
|
||||
MemoryFailureFlags mff = {.action_required = ar, .recursive = recursive};
|
||||
|
||||
qapi_event_send_memory_failure(MEMORY_FAILURE_RECIPIENT_GUEST, action,
|
||||
&mff);
|
||||
}
|
||||
|
||||
static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
|
||||
{
|
||||
MCEInjectionParams *params = data.host_ptr;
|
||||
|
@ -859,16 +869,18 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
|
|||
uint64_t *banks = cenv->mce_banks + 4 * params->bank;
|
||||
g_autofree char *msg = NULL;
|
||||
bool need_reset = false;
|
||||
bool recursive;
|
||||
bool ar = !!(params->status & MCI_STATUS_AR);
|
||||
|
||||
cpu_synchronize_state(cs);
|
||||
recursive = !!(cenv->mcg_status & MCG_STATUS_MCIP);
|
||||
|
||||
/*
|
||||
* If there is an MCE exception being processed, ignore this SRAO MCE
|
||||
* unless unconditional injection was requested.
|
||||
*/
|
||||
if (!(params->flags & MCE_INJECT_UNCOND_AO)
|
||||
&& !(params->status & MCI_STATUS_AR)
|
||||
&& (cenv->mcg_status & MCG_STATUS_MCIP)) {
|
||||
if (!(params->flags & MCE_INJECT_UNCOND_AO) && !ar && recursive) {
|
||||
emit_guest_memory_failure(MEMORY_FAILURE_ACTION_IGNORE, ar, recursive);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -896,7 +908,7 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
|
|||
return;
|
||||
}
|
||||
|
||||
if (cenv->mcg_status & MCG_STATUS_MCIP) {
|
||||
if (recursive) {
|
||||
need_reset = true;
|
||||
msg = g_strdup_printf("CPU %d: Previous MCE still in progress, "
|
||||
"raising triple fault", cs->cpu_index);
|
||||
|
@ -909,6 +921,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
|
|||
}
|
||||
|
||||
if (need_reset) {
|
||||
emit_guest_memory_failure(MEMORY_FAILURE_ACTION_RESET, ar,
|
||||
recursive);
|
||||
monitor_printf(params->mon, "%s", msg);
|
||||
qemu_log_mask(CPU_LOG_RESET, "%s\n", msg);
|
||||
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
||||
|
@ -934,6 +948,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
|
|||
} else {
|
||||
banks[1] |= MCI_STATUS_OVER;
|
||||
}
|
||||
|
||||
emit_guest_memory_failure(MEMORY_FAILURE_ACTION_INJECT, ar, recursive);
|
||||
}
|
||||
|
||||
void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue