KVM: use KVM_{GET|SET}_SREGS2 when supported.

This allows to make PDPTRs part of the migration
stream and thus not reload them after migration which
is against X86 spec.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20211101132300.192584-2-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Maxim Levitsky 2021-11-01 15:22:58 +02:00 committed by Paolo Bonzini
parent b7a75c8c42
commit 8f515d3869
3 changed files with 138 additions and 2 deletions

View file

@ -1451,6 +1451,34 @@ static const VMStateDescription vmstate_msr_intel_sgx = {
.needed = intel_sgx_msrs_needed,
.fields = (VMStateField[]) {
VMSTATE_UINT64_ARRAY(env.msr_ia32_sgxlepubkeyhash, X86CPU, 4),
VMSTATE_END_OF_LIST()
}
};
static bool pdptrs_needed(void *opaque)
{
X86CPU *cpu = opaque;
CPUX86State *env = &cpu->env;
return env->pdptrs_valid;
}
static int pdptrs_post_load(void *opaque, int version_id)
{
X86CPU *cpu = opaque;
CPUX86State *env = &cpu->env;
env->pdptrs_valid = true;
return 0;
}
static const VMStateDescription vmstate_pdptrs = {
.name = "cpu/pdptrs",
.version_id = 1,
.minimum_version_id = 1,
.needed = pdptrs_needed,
.post_load = pdptrs_post_load,
.fields = (VMStateField[]) {
VMSTATE_UINT64_ARRAY(env.pdptrs, X86CPU, 4),
VMSTATE_END_OF_LIST()
}
};
@ -1593,6 +1621,7 @@ const VMStateDescription vmstate_x86_cpu = {
#endif
&vmstate_msr_tsx_ctrl,
&vmstate_msr_intel_sgx,
&vmstate_pdptrs,
NULL
}
};