aboutsummaryrefslogtreecommitdiff
path: root/target/i386/hvf/hvf.c
diff options
context:
space:
mode:
authorDavid Edmondson <david.edmondson@oracle.com>2021-07-05 11:46:31 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2021-07-06 08:33:48 +0200
commitfea4500841024195ec701713e05b92ebf667f192 (patch)
tree7901cb3679ee3b1177ff80493f874bade24d63ea /target/i386/hvf/hvf.c
parent3568987f78faff90829ea6c885bbdd5b083dc86c (diff)
target/i386: Populate x86_ext_save_areas offsets using cpuid where possible
Rather than relying on the X86XSaveArea structure definition, determine the offset of XSAVE state areas using CPUID leaf 0xd where possible (KVM and HVF). Signed-off-by: David Edmondson <david.edmondson@oracle.com> Message-Id: <20210705104632.2902400-8-david.edmondson@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/hvf/hvf.c')
-rw-r--r--target/i386/hvf/hvf.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index e62e8df028..79ba4ed93a 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -270,6 +270,12 @@ int hvf_arch_init_vcpu(CPUState *cpu)
x86cpu->env.xsave_buf_len = 4096;
x86cpu->env.xsave_buf = qemu_memalign(4096, x86cpu->env.xsave_buf_len);
+ /*
+ * The allocated storage must be large enough for all of the
+ * possible XSAVE state components.
+ */
+ assert(hvf_get_supported_cpuid(0xd, 0, R_ECX) <= x86cpu->env.xsave_buf_len);
+
hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_STAR, 1);
hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_LSTAR, 1);
hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_CSTAR, 1);