|
|
e2f3ee |
From 007e162cc8332faa132568656e0defc509ba658c Mon Sep 17 00:00:00 2001
|
|
|
e2f3ee |
From: David Edmondson <david.edmondson@oracle.com>
|
|
|
e2f3ee |
Date: Mon, 5 Jul 2021 11:46:26 +0100
|
|
|
e2f3ee |
Subject: [PATCH 2/7] target/i386: Consolidate the X86XSaveArea offset checks
|
|
|
e2f3ee |
|
|
|
e2f3ee |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
e2f3ee |
RH-MergeRequest: 113: non-av 8.5z: Fix XSAVE on newer CPUs
|
|
|
e2f3ee |
RH-Commit: [2/7] 308e45b88a5e8501947466d4cf11d1ae0a68e0d8
|
|
|
e2f3ee |
RH-Bugzilla: 2065239
|
|
|
e2f3ee |
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
e2f3ee |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
e2f3ee |
RH-Acked-by: Bandan Das <None>
|
|
|
e2f3ee |
|
|
|
e2f3ee |
Rather than having similar but different checks in cpu.h and kvm.c,
|
|
|
e2f3ee |
move them all to cpu.h.
|
|
|
e2f3ee |
Message-Id: <20210705104632.2902400-3-david.edmondson@oracle.com>
|
|
|
e2f3ee |
|
|
|
e2f3ee |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
e2f3ee |
(cherry picked from commit 436463b84b75fad6ff962e45a2220a7d1d17557e)
|
|
|
e2f3ee |
---
|
|
|
e2f3ee |
target/i386/cpu.h | 22 +++++++++++++++-------
|
|
|
e2f3ee |
target/i386/kvm.c | 39 ---------------------------------------
|
|
|
e2f3ee |
2 files changed, 15 insertions(+), 46 deletions(-)
|
|
|
e2f3ee |
|
|
|
e2f3ee |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
|
e2f3ee |
index 1fac5170a6..7c81d4bd6d 100644
|
|
|
e2f3ee |
--- a/target/i386/cpu.h
|
|
|
e2f3ee |
+++ b/target/i386/cpu.h
|
|
|
e2f3ee |
@@ -1308,21 +1308,29 @@ typedef struct X86XSaveArea {
|
|
|
e2f3ee |
XSavePKRU pkru_state;
|
|
|
e2f3ee |
} X86XSaveArea;
|
|
|
e2f3ee |
|
|
|
e2f3ee |
-QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, avx_state) != XSAVE_AVX_OFFSET);
|
|
|
e2f3ee |
QEMU_BUILD_BUG_ON(sizeof(XSaveAVX) != 0x100);
|
|
|
e2f3ee |
-QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, bndreg_state) != XSAVE_BNDREG_OFFSET);
|
|
|
e2f3ee |
QEMU_BUILD_BUG_ON(sizeof(XSaveBNDREG) != 0x40);
|
|
|
e2f3ee |
-QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, bndcsr_state) != XSAVE_BNDCSR_OFFSET);
|
|
|
e2f3ee |
QEMU_BUILD_BUG_ON(sizeof(XSaveBNDCSR) != 0x40);
|
|
|
e2f3ee |
-QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, opmask_state) != XSAVE_OPMASK_OFFSET);
|
|
|
e2f3ee |
QEMU_BUILD_BUG_ON(sizeof(XSaveOpmask) != 0x40);
|
|
|
e2f3ee |
-QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, zmm_hi256_state) != XSAVE_ZMM_HI256_OFFSET);
|
|
|
e2f3ee |
QEMU_BUILD_BUG_ON(sizeof(XSaveZMM_Hi256) != 0x200);
|
|
|
e2f3ee |
-QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, hi16_zmm_state) != XSAVE_HI16_ZMM_OFFSET);
|
|
|
e2f3ee |
QEMU_BUILD_BUG_ON(sizeof(XSaveHi16_ZMM) != 0x400);
|
|
|
e2f3ee |
-QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, pkru_state) != XSAVE_PKRU_OFFSET);
|
|
|
e2f3ee |
QEMU_BUILD_BUG_ON(sizeof(XSavePKRU) != 0x8);
|
|
|
e2f3ee |
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, legacy.fcw) != XSAVE_FCW_FSW_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, legacy.ftw) != XSAVE_FTW_FOP_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, legacy.fpip) != XSAVE_CWD_RIP_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, legacy.fpdp) != XSAVE_CWD_RDP_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, legacy.mxcsr) != XSAVE_MXCSR_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, legacy.fpregs) != XSAVE_ST_SPACE_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, legacy.xmm_regs) != XSAVE_XMM_SPACE_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, avx_state) != XSAVE_AVX_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, bndreg_state) != XSAVE_BNDREG_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, bndcsr_state) != XSAVE_BNDCSR_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, opmask_state) != XSAVE_OPMASK_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, zmm_hi256_state) != XSAVE_ZMM_HI256_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, hi16_zmm_state) != XSAVE_HI16_ZMM_OFFSET);
|
|
|
e2f3ee |
+QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, pkru_state) != XSAVE_PKRU_OFFSET);
|
|
|
e2f3ee |
+
|
|
|
e2f3ee |
typedef enum TPRAccess {
|
|
|
e2f3ee |
TPR_ACCESS_READ,
|
|
|
e2f3ee |
TPR_ACCESS_WRITE,
|
|
|
e2f3ee |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
e2f3ee |
index f5c17e0028..215487b17d 100644
|
|
|
e2f3ee |
--- a/target/i386/kvm.c
|
|
|
e2f3ee |
+++ b/target/i386/kvm.c
|
|
|
e2f3ee |
@@ -2350,45 +2350,6 @@ static int kvm_put_fpu(X86CPU *cpu)
|
|
|
e2f3ee |
return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_FPU, &fpu;;
|
|
|
e2f3ee |
}
|
|
|
e2f3ee |
|
|
|
e2f3ee |
-#define XSAVE_FCW_FSW 0
|
|
|
e2f3ee |
-#define XSAVE_FTW_FOP 1
|
|
|
e2f3ee |
-#define XSAVE_CWD_RIP 2
|
|
|
e2f3ee |
-#define XSAVE_CWD_RDP 4
|
|
|
e2f3ee |
-#define XSAVE_MXCSR 6
|
|
|
e2f3ee |
-#define XSAVE_ST_SPACE 8
|
|
|
e2f3ee |
-#define XSAVE_XMM_SPACE 40
|
|
|
e2f3ee |
-#define XSAVE_XSTATE_BV 128
|
|
|
e2f3ee |
-#define XSAVE_YMMH_SPACE 144
|
|
|
e2f3ee |
-#define XSAVE_BNDREGS 240
|
|
|
e2f3ee |
-#define XSAVE_BNDCSR 256
|
|
|
e2f3ee |
-#define XSAVE_OPMASK 272
|
|
|
e2f3ee |
-#define XSAVE_ZMM_Hi256 288
|
|
|
e2f3ee |
-#define XSAVE_Hi16_ZMM 416
|
|
|
e2f3ee |
-#define XSAVE_PKRU 672
|
|
|
e2f3ee |
-
|
|
|
e2f3ee |
-#define XSAVE_BYTE_OFFSET(word_offset) \
|
|
|
e2f3ee |
- ((word_offset) * sizeof_field(struct kvm_xsave, region[0]))
|
|
|
e2f3ee |
-
|
|
|
e2f3ee |
-#define ASSERT_OFFSET(word_offset, field) \
|
|
|
e2f3ee |
- QEMU_BUILD_BUG_ON(XSAVE_BYTE_OFFSET(word_offset) != \
|
|
|
e2f3ee |
- offsetof(X86XSaveArea, field))
|
|
|
e2f3ee |
-
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_FCW_FSW, legacy.fcw);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_FTW_FOP, legacy.ftw);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_CWD_RIP, legacy.fpip);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_CWD_RDP, legacy.fpdp);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_MXCSR, legacy.mxcsr);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_ST_SPACE, legacy.fpregs);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_XMM_SPACE, legacy.xmm_regs);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_XSTATE_BV, header.xstate_bv);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_YMMH_SPACE, avx_state);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_BNDREGS, bndreg_state);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_BNDCSR, bndcsr_state);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_OPMASK, opmask_state);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_ZMM_Hi256, zmm_hi256_state);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_Hi16_ZMM, hi16_zmm_state);
|
|
|
e2f3ee |
-ASSERT_OFFSET(XSAVE_PKRU, pkru_state);
|
|
|
e2f3ee |
-
|
|
|
e2f3ee |
static int kvm_put_xsave(X86CPU *cpu)
|
|
|
e2f3ee |
{
|
|
|
e2f3ee |
CPUX86State *env = &cpu->env;
|
|
|
e2f3ee |
--
|
|
|
e2f3ee |
2.27.0
|
|
|
e2f3ee |
|