debuggers.hg

view xen/include/asm-x86/i387.h @ 22797:58304c1cc725

x86 fpu: Code clean up. Eliminate per-cpu xsave init verbosity.

Signed-off-by: Keir Fraser <keir@xen.org>
author Keir Fraser <keir@xen.org>
date Fri Jan 14 09:11:28 2011 +0000 (2011-01-14)
parents 4b7cb21caf0e
children
line source
1 /*
2 * include/asm-i386/i387.h
3 *
4 * Copyright (C) 1994 Linus Torvalds
5 *
6 * Pentium III FXSR, SSE support
7 * General FPU state handling cleanups
8 * Gareth Hughes <gareth@valinux.com>, May 2000
9 */
11 #ifndef __ASM_I386_I387_H
12 #define __ASM_I386_I387_H
14 #include <xen/sched.h>
15 #include <asm/processor.h>
17 extern unsigned int xsave_cntxt_size;
18 extern u64 xfeature_mask;
20 void xsave_init(void);
21 int xsave_alloc_save_area(struct vcpu *v);
22 void xsave_free_save_area(struct vcpu *v);
24 #define XSTATE_FP (1ULL << 0)
25 #define XSTATE_SSE (1ULL << 1)
26 #define XSTATE_YMM (1ULL << 2)
27 #define XSTATE_LWP (1ULL << 62) /* AMD lightweight profiling */
28 #define XSTATE_FP_SSE (XSTATE_FP | XSTATE_SSE)
29 #define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_LWP)
30 #define XSTATE_YMM_OFFSET (512 + 64)
31 #define XSTATE_YMM_SIZE 256
32 #define XSAVEOPT (1 << 0)
34 struct xsave_struct
35 {
36 struct { char x[512]; } fpu_sse; /* FPU/MMX, SSE */
38 struct {
39 u64 xstate_bv;
40 u64 reserved[7];
41 } xsave_hdr; /* The 64-byte header */
43 struct { char x[XSTATE_YMM_SIZE]; } ymm; /* YMM */
44 char data[]; /* Future new states */
45 } __attribute__ ((packed, aligned (64)));
47 #define XCR_XFEATURE_ENABLED_MASK 0
49 #ifdef CONFIG_X86_64
50 #define REX_PREFIX "0x48, "
51 #else
52 #define REX_PREFIX
53 #endif
55 DECLARE_PER_CPU(uint64_t, xcr0);
57 static inline void xsetbv(u32 index, u64 xfeatures)
58 {
59 u32 hi = xfeatures >> 32;
60 u32 lo = (u32)xfeatures;
62 asm volatile (".byte 0x0f,0x01,0xd1" :: "c" (index),
63 "a" (lo), "d" (hi));
64 }
66 static inline void set_xcr0(u64 xfeatures)
67 {
68 this_cpu(xcr0) = xfeatures;
69 xsetbv(XCR_XFEATURE_ENABLED_MASK, xfeatures);
70 }
72 static inline uint64_t get_xcr0(void)
73 {
74 return this_cpu(xcr0);
75 }
77 extern void setup_fpu(struct vcpu *v);
78 extern void save_init_fpu(struct vcpu *v);
80 #endif /* __ASM_I386_I387_H */