Re: [PATCH] rewrite restore_fp_context/save_fp_context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 18 Nov 2006 23:27:17 +0900 (JST), Atsushi Nemoto <anemo@xxxxxxxxxxxxx> wrote:
> So, we still should very careful to using fp instruction in kernel
> even if the instruction did not change the fpu state.  The last part
> of setup_sigcontext() should become something like this:
> 
> 	err |= __put_user(!!used_math(), &sc->sc_used_math);
> 
> 	/*
> 	 * Save FPU state to signal context.  Signal handler will "inherit"
> 	 * current FPU state.
> 	 */
> 	if (used_math()) {
> 		preempt_disable();
> 		if (!is_fpu_owner()) {
> 			own_fpu();
> 			restore_fp(current);
> 		}
> 		preempt_enable();
> 		err |= save_fp_context(sc);
> 	}
> 	return err;

Unfortunately, still this is not safe.  preempt_enable() might call
local_irq_enable() so it might lose fpu ownership without clearing CU1
bit...

So something like this ugly check should be needed.

 		preempt_disable();
 		if (!is_fpu_owner()) {
 			own_fpu();
 			restore_fp(current);
 		}
 		preempt_enable();
		/* make sure CU1 and FPU ownership are consistent */
		if (!__is_fpu_owner() && (read_c0_status() & ST0_CU1))
			__disable_fpu();
 		err |= save_fp_context(sc);



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux