diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-11-28 16:30:29 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-11-28 17:46:32 +0100 |
commit | b885c5ea26fb3c2f2d91b6e9a1495070da429ea4 (patch) | |
tree | 787f167688bf7518b62241fa55c539da3fa53ed5 /i386/include | |
parent | 44e3fb20a17dac403ec022a9c4d41dc237f3c79d (diff) | |
download | gnumach-b885c5ea26fb3c2f2d91b6e9a1495070da429ea4.tar.gz gnumach-b885c5ea26fb3c2f2d91b6e9a1495070da429ea4.tar.bz2 gnumach-b885c5ea26fb3c2f2d91b6e9a1495070da429ea4.zip |
x86: Add XSAVE support
* i386/i386/fpu.h (CPU_XCR0_X87, CPU_XCR0_SSE, CPU_XCR0_AVX,
CPU_XCR0_MPX, CPU_XCR0_AVX512): New macros.
(xsave): Pass fp_xsave_support to xsave.
(fpu_save_context): When fp_kind is FP_387X, use xsave.
(fp_xsave_support): New variable declaration.
* i386/i386/proc_reg.h (cpuid): New macro.
* linux/src/include/asm-i386/processor.h (cpuid): Disable macro.
* i386/include/mach/i386/fp_reg.h: Include <stdint.h>
(i386_xfp_xstate_header): New structure.
(i386_xfp_save): Add xsave fields.
* i386/i386/fpu.c (fp_xsave_support): New variable.
(init_fpu): Look for XSAVE feature; if available, get the supported
parts and set fp_kind to FP_387X.
(fpu_module_init): Set ifps_cache alignment to alignof(struct
i386_fpsave_state).
(fpu_set_state): Make sure to clear all the ifps structure.
Reuse the FP_387FX for the FP_387X case.
(fpu_get_state, fpexterrflt, fpastintr, fp_state_alloc): Reuse the FP_387FX
for the FP_387X case.
(fp_save): When fp_kind is FP_387X, use xsave.
(fp_load): When fp_kind is FP_387X, use xrstor.
Reuse the FP_387FX for the FP_387X case.
Diffstat (limited to 'i386/include')
-rw-r--r-- | i386/include/mach/i386/fp_reg.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/i386/include/mach/i386/fp_reg.h b/i386/include/mach/i386/fp_reg.h index 648511ad..5992ea78 100644 --- a/i386/include/mach/i386/fp_reg.h +++ b/i386/include/mach/i386/fp_reg.h @@ -26,6 +26,9 @@ #ifndef _MACH_I386_FP_REG_H_ #define _MACH_I386_FP_REG_H_ + +#include <stdint.h> + /* * Floating point registers and status, as saved * and restored by FP save/restore instructions. @@ -50,17 +53,24 @@ struct i386_fp_regs { /* space for 8 80-bit FP registers */ }; +struct i386_xfp_xstate_header { + uint64_t xfp_features; + uint64_t xcomp_bv; + uint64_t reserved[6]; +} __attribute__((packed, aligned(64))); +_Static_assert(sizeof(struct i386_xfp_xstate_header) == 8*8); + struct i386_xfp_save { unsigned short fp_control; /* control */ unsigned short fp_status; /* status */ unsigned short fp_tag; /* register tags */ unsigned short fp_opcode; /* opcode of failed instruction */ unsigned int fp_eip; /* eip at failed instruction */ - unsigned short fp_cs; /* cs at failed instruction */ - unsigned short fp_unused_1; + unsigned short fp_cs; /* cs at failed instruction / eip high */ + unsigned short fp_eip3; /* eip higher */ unsigned int fp_dp; /* data address */ - unsigned short fp_ds; /* data segment */ - unsigned short fp_unused_2; + unsigned short fp_ds; /* data segment / dp high */ + unsigned short fp_dp3; /* dp higher */ unsigned int fp_mxcsr; /* MXCSR */ unsigned int fp_mxcsr_mask; /* MXCSR_MASK */ unsigned char fp_reg_word[8][16]; @@ -68,8 +78,13 @@ struct i386_xfp_save { unsigned char fp_xreg_word[16][16]; /* space for 16 128-bit XMM registers */ unsigned int padding[24]; -} __attribute__((aligned(16))); -_Static_assert(sizeof(struct i386_xfp_save) == 512); + struct i386_xfp_xstate_header header; + + unsigned char fp_yreg_word[16][16]; + /* space for the high part of the + * 16 256-bit YMM registers */ +} __attribute__((packed, aligned(64))); +_Static_assert(sizeof(struct i386_xfp_save) == 512 + 8*8 + 16*16); /* * Control register |