x86: fix section mismatch warning - apic_x2apic_uv_x
[safe/jmp/linux-2.6] / arch / x86 / kernel / i387.c
index e0ed59f..1f20608 100644 (file)
@@ -468,9 +468,23 @@ static int save_i387_fxsave(struct _fpstate_ia32 __user *buf)
 
 static int save_i387_xsave(void __user *buf)
 {
+       struct task_struct *tsk = current;
        struct _fpstate_ia32 __user *fx = buf;
        int err = 0;
 
+       /*
+        * For legacy compatible, we always set FP/SSE bits in the bit
+        * vector while saving the state to the user context.
+        * This will enable us capturing any changes(during sigreturn) to
+        * the FP/SSE bits by the legacy applications which don't touch
+        * xstate_bv in the xsave header.
+        *
+        * xsave aware applications can change the xstate_bv in the xsave
+        * header as well as change any contents in the memory layout.
+        * xrestore as part of sigreturn will capture all the changes.
+        */
+       tsk->thread.xstate->xsave.xsave_hdr.xstate_bv |= XSTATE_FPSSE;
+
        if (save_i387_fxsave(fx) < 0)
                return -1;
 
@@ -552,18 +566,17 @@ static int restore_i387_xsave(void __user *buf)
                (struct i387_fxsave_struct __user *) &fx_user->_fxsr_env[0];
        struct xsave_hdr_struct *xsave_hdr =
                                &current->thread.xstate->xsave.xsave_hdr;
-       unsigned int lmask, hmask;
+       u64 mask;
        int err;
 
        if (check_for_xstate(fx, buf, &fx_sw_user))
                goto fx_only;
 
-       lmask = fx_sw_user.xstate_bv;
-       hmask = fx_sw_user.xstate_bv >> 32;
+       mask = fx_sw_user.xstate_bv;
 
        err = restore_i387_fxsave(buf, fx_sw_user.xstate_size);
 
-       xsave_hdr->xstate_bv &=  (pcntxt_lmask | (((u64) pcntxt_hmask) << 32));
+       xsave_hdr->xstate_bv &= pcntxt_mask;
        /*
         * These bits must be zero.
         */
@@ -573,9 +586,8 @@ static int restore_i387_xsave(void __user *buf)
         * Init the state that is not present in the memory layout
         * and enabled by the OS.
         */
-       lmask = ~(pcntxt_lmask & ~lmask);
-       hmask = ~(pcntxt_hmask & ~hmask);
-       xsave_hdr->xstate_bv &=  (lmask | (((u64) hmask) << 32));
+       mask = ~(pcntxt_mask & ~mask);
+       xsave_hdr->xstate_bv &= mask;
 
        return err;
 fx_only: