x86: add linux kernel support for YMM state

Impact: save/restore Intel-AVX state properly between tasks

Intel Advanced Vector Extensions (AVX) introduce 256-bit vector processing
capability. More about AVX at http://software.intel.com/sites/avx

Add OS support for YMM state management using xsave/xrstor infrastructure
to support AVX.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <1239402084.27006.8057.camel@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Suresh Siddha 2009-04-10 15:21:24 -07:00 committed by Ingo Molnar
parent 1ee4bd92a7
commit a30469e792
4 changed files with 15 additions and 2 deletions

View File

@ -352,6 +352,11 @@ struct i387_soft_struct {
u32 entry_eip; u32 entry_eip;
}; };
struct ymmh_struct {
/* 16 * 16 bytes for each YMMH-reg = 256 bytes */
u32 ymmh_space[64];
};
struct xsave_hdr_struct { struct xsave_hdr_struct {
u64 xstate_bv; u64 xstate_bv;
u64 reserved1[2]; u64 reserved1[2];
@ -361,6 +366,7 @@ struct xsave_hdr_struct {
struct xsave_struct { struct xsave_struct {
struct i387_fxsave_struct i387; struct i387_fxsave_struct i387;
struct xsave_hdr_struct xsave_hdr; struct xsave_hdr_struct xsave_hdr;
struct ymmh_struct ymmh;
/* new processor state extensions will go here */ /* new processor state extensions will go here */
} __attribute__ ((packed, aligned (64))); } __attribute__ ((packed, aligned (64)));

View File

@ -269,6 +269,11 @@ struct _xsave_hdr {
__u64 reserved2[5]; __u64 reserved2[5];
}; };
struct _ymmh_state {
/* 16 * 16 bytes for each YMMH-reg */
__u32 ymmh_space[64];
};
/* /*
* Extended state pointed by the fpstate pointer in the sigcontext. * Extended state pointed by the fpstate pointer in the sigcontext.
* In addition to the fpstate, information encoded in the xstate_hdr * In addition to the fpstate, information encoded in the xstate_hdr
@ -278,6 +283,7 @@ struct _xsave_hdr {
struct _xstate { struct _xstate {
struct _fpstate fpstate; struct _fpstate fpstate;
struct _xsave_hdr xstate_hdr; struct _xsave_hdr xstate_hdr;
struct _ymmh_state ymmh;
/* new processor state extensions go here */ /* new processor state extensions go here */
}; };

View File

@ -7,6 +7,7 @@
#define XSTATE_FP 0x1 #define XSTATE_FP 0x1
#define XSTATE_SSE 0x2 #define XSTATE_SSE 0x2
#define XSTATE_YMM 0x4
#define XSTATE_FPSSE (XSTATE_FP | XSTATE_SSE) #define XSTATE_FPSSE (XSTATE_FP | XSTATE_SSE)
@ -15,7 +16,7 @@
/* /*
* These are the features that the OS can handle currently. * These are the features that the OS can handle currently.
*/ */
#define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE) #define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
#define REX_PREFIX "0x48, " #define REX_PREFIX "0x48, "

View File

@ -324,7 +324,7 @@ void __ref xsave_cntxt_init(void)
} }
/* /*
* for now OS knows only about FP/SSE * Support only the state known to OS.
*/ */
pcntxt_mask = pcntxt_mask & XCNTXT_MASK; pcntxt_mask = pcntxt_mask & XCNTXT_MASK;
xsave_init(); xsave_init();