On 12/08/2015 02:58 PM, Christian Borntraeger wrote: [...9 >>> >>> Not a compiler bug. gcc uses a floating point register 8 to spill >>> the pointer of blk (which is call saved) submit_request will later >>> on call qemu_coroutine_enter and after returning from >>> qemu_coroutine_enter, the fpr8 contains junk. Not sure yet, what happened. >> >> Coroutines don't save the FPU state, so you're not supposed to use >> floating point operations inside coroutines. That the compiler spills >> some integer value into a floating point register is a bit nasty... > > Just checked. bdrv_aligned_preadv does also use fprs (also for filling > and spilling). Some versions of gcc seem to like that as the LDGR and LGDR > instructions are pretty cheap and move the content from/to fprs in a bitwise > fashion. So this coroutine DOES trash floating point registers. > > Without the patch gcc seems to be fine with the 16 gprs and does not > spilling/filling from/to fprs in bdrv_aligned_preadv. > > Christian
Kevin, I am wondering. gcc saves/restores f8 in the generated code for the coroutine and setjmp/longjmp also save/restore the fprs. why do coroutines do not save the FPU state (which code does a light weight switching) Christian