From: Zide Chen <[email protected]> Add a VMStateDescription to migrate APX EGPRs.
Tested-by: Xudong Hao <[email protected]> Signed-off-by: Zide Chen <[email protected]> Co-developed-by: Zhao Liu <[email protected]> Signed-off-by: Zhao Liu <[email protected]> --- Changes since v1: * Use CPUX86State.regs instead of a new array. --- target/i386/machine.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/i386/machine.c b/target/i386/machine.c index 0882dc3eb09e..df550dec4749 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -1741,6 +1741,28 @@ static const VMStateDescription vmstate_cet = { }, }; +#ifdef TARGET_X86_64 +static bool apx_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + + return !!(env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_APX); +} + +static const VMStateDescription vmstate_apx = { + .name = "cpu/apx", + .version_id = 1, + .minimum_version_id = 1, + .needed = apx_needed, + .fields = (VMStateField[]) { + VMSTATE_UINTTL_SUB_ARRAY(env.regs, X86CPU, CPU_NB_REGS, + CPU_NB_EREGS - CPU_NB_REGS), + VMSTATE_END_OF_LIST() + } +}; +#endif + const VMStateDescription vmstate_x86_cpu = { .name = "cpu", .version_id = 12, @@ -1892,6 +1914,9 @@ const VMStateDescription vmstate_x86_cpu = { &vmstate_triple_fault, &vmstate_pl0_ssp, &vmstate_cet, +#ifdef TARGET_X86_64 + &vmstate_apx, +#endif NULL } }; -- 2.34.1
