target/i386: Add support save/load HWCR MSR

KVM commit 191c8137a939 ("x86/kvm: Implement HWCR support")
introduced support for emulating HWCR MSR.

Add support for QEMU to save/load this MSR for migration purposes.

Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
Signed-off-by: Wang Liang <wangliang44@baidu.com>
Link: https://lore.kernel.org/r/20241009095109.66843-1-gaoshiyuan@baidu.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Gao Shiyuan 2024-10-09 17:51:09 +08:00 committed by Paolo Bonzini
parent 10eaf9c0fb
commit b5151ace58
3 changed files with 37 additions and 0 deletions

View file

@ -1543,6 +1543,25 @@ static const VMStateDescription vmstate_msr_xfd = {
}
};
static bool msr_hwcr_needed(void *opaque)
{
X86CPU *cpu = opaque;
CPUX86State *env = &cpu->env;
return env->msr_hwcr != 0;
}
static const VMStateDescription vmstate_msr_hwcr = {
.name = "cpu/msr_hwcr",
.version_id = 1,
.minimum_version_id = 1,
.needed = msr_hwcr_needed,
.fields = (VMStateField[]) {
VMSTATE_UINT64(env.msr_hwcr, X86CPU),
VMSTATE_END_OF_LIST()
}
};
#ifdef TARGET_X86_64
static bool intel_fred_msrs_needed(void *opaque)
{
@ -1773,6 +1792,7 @@ const VMStateDescription vmstate_x86_cpu = {
&vmstate_msr_intel_sgx,
&vmstate_pdptrs,
&vmstate_msr_xfd,
&vmstate_msr_hwcr,
#ifdef TARGET_X86_64
&vmstate_msr_fred,
&vmstate_amx_xtile,