diff options
author | David Edmondson <david.edmondson@oracle.com> | 2021-07-05 11:46:28 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-07-06 07:54:53 +0200 |
commit | c0198c5f87b6db25712672292e01ab710d6ef631 (patch) | |
tree | 02d5f74c30df3fc21fd78d3a75875f7c99992305 /target/i386/xsave_helper.c | |
parent | fde74821006472f40fee9a094e6da86cd39b5623 (diff) | |
download | qemu-c0198c5f87b6db25712672292e01ab710d6ef631.zip qemu-c0198c5f87b6db25712672292e01ab710d6ef631.tar.gz qemu-c0198c5f87b6db25712672292e01ab710d6ef631.tar.bz2 |
target/i386: Pass buffer and length to XSAVE helper
In preparation for removing assumptions about XSAVE area offsets, pass
a buffer pointer and buffer length to the XSAVE helper functions.
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
Message-Id: <20210705104632.2902400-5-david.edmondson@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/xsave_helper.c')
-rw-r--r-- | target/i386/xsave_helper.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/target/i386/xsave_helper.c b/target/i386/xsave_helper.c index 818115e..b16c6ac 100644 --- a/target/i386/xsave_helper.c +++ b/target/i386/xsave_helper.c @@ -6,14 +6,16 @@ #include "cpu.h" -void x86_cpu_xsave_all_areas(X86CPU *cpu, X86XSaveArea *buf) +void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen) { CPUX86State *env = &cpu->env; X86XSaveArea *xsave = buf; - uint16_t cwd, swd, twd; int i; - memset(xsave, 0, sizeof(X86XSaveArea)); + + assert(buflen >= sizeof(*xsave)); + + memset(xsave, 0, buflen); twd = 0; swd = env->fpus & ~(7 << 11); swd |= (env->fpstt & 7) << 11; @@ -56,17 +58,17 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, X86XSaveArea *buf) 16 * sizeof env->xmm_regs[16]); memcpy(&xsave->pkru_state, &env->pkru, sizeof env->pkru); #endif - } -void x86_cpu_xrstor_all_areas(X86CPU *cpu, const X86XSaveArea *buf) +void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *buf, uint32_t buflen) { - CPUX86State *env = &cpu->env; const X86XSaveArea *xsave = buf; - int i; uint16_t cwd, swd, twd; + + assert(buflen >= sizeof(*xsave)); + cwd = xsave->legacy.fcw; swd = xsave->legacy.fsw; twd = xsave->legacy.ftw; @@ -108,5 +110,4 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const X86XSaveArea *buf) 16 * sizeof env->xmm_regs[16]); memcpy(&env->pkru, &xsave->pkru_state, sizeof env->pkru); #endif - } |