Skip to content

Commit 5dd076a

Browse files
Dovgalyukmdroth
authored andcommitted
exec: Save CPUState::exception_index field
This patch adds a subsection with exception_index field to the VMState for correct saving the CPU state. Without this patch, simulator could miss the pending exception in the saved virtual machine state. Signed-off-by: Pavel Dovgalyuk <[email protected]> Cc: [email protected] Signed-off-by: Andreas Färber <[email protected]> (cherry picked from commit 6c3bff0) Signed-off-by: Michael Roth <[email protected]>
1 parent 257e9cf commit 5dd076a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

exec.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,15 +430,50 @@ static int cpu_common_post_load(void *opaque, int version_id)
430430
return 0;
431431
}
432432

433+
static int cpu_common_pre_load(void *opaque)
434+
{
435+
CPUState *cpu = opaque;
436+
437+
cpu->exception_index = 0;
438+
439+
return 0;
440+
}
441+
442+
static bool cpu_common_exception_index_needed(void *opaque)
443+
{
444+
CPUState *cpu = opaque;
445+
446+
return cpu->exception_index != 0;
447+
}
448+
449+
static const VMStateDescription vmstate_cpu_common_exception_index = {
450+
.name = "cpu_common/exception_index",
451+
.version_id = 1,
452+
.minimum_version_id = 1,
453+
.fields = (VMStateField[]) {
454+
VMSTATE_INT32(exception_index, CPUState),
455+
VMSTATE_END_OF_LIST()
456+
}
457+
};
458+
433459
const VMStateDescription vmstate_cpu_common = {
434460
.name = "cpu_common",
435461
.version_id = 1,
436462
.minimum_version_id = 1,
463+
.pre_load = cpu_common_pre_load,
437464
.post_load = cpu_common_post_load,
438465
.fields = (VMStateField[]) {
439466
VMSTATE_UINT32(halted, CPUState),
440467
VMSTATE_UINT32(interrupt_request, CPUState),
441468
VMSTATE_END_OF_LIST()
469+
},
470+
.subsections = (VMStateSubsection[]) {
471+
{
472+
.vmsd = &vmstate_cpu_common_exception_index,
473+
.needed = cpu_common_exception_index_needed,
474+
} , {
475+
/* empty */
476+
}
442477
}
443478
};
444479

0 commit comments

Comments
 (0)