BOOKE KVM calling load_up_fpu from C?

Scott Wood scottwood at freescale.com
Thu Feb 14 04:37:27 EST 2013


On 02/12/2013 10:17:00 PM, Bhushan Bharat-R65777 wrote:
> 
> 
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Wednesday, February 13, 2013 6:53 AM
> > To: Bhushan Bharat-R65777
> > Cc: Wood Scott-B07421; Michael Neuling;  
> linuxppc-dev at lists.ozlabs.org
> > Subject: Re: BOOKE KVM calling load_up_fpu from C?
> >
> > On 02/12/2013 07:18:14 PM, Bhushan Bharat-R65777 wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Wood Scott-B07421
> > > > Sent: Wednesday, February 13, 2013 12:03 AM
> > > > To: Bhushan Bharat-R65777
> > > > Cc: Michael Neuling; Wood Scott-B07421;
> > > linuxppc-dev at lists.ozlabs.org
> > > > Subject: Re: BOOKE KVM calling load_up_fpu from C?
> > > >
> > > >  On 64-bit, though, there's a store to the caller's stack frame
> > > > (yuck) which the kvm/booke.h caller is not prepared for.
> > >
> > > So if caller is using r12 then it can lead to come corruption,  
> right ?
> >
> > No, r12 is a volatile register in the ABI, as is r9.  The issue is  
> that the
> > stack can be corrupted.
> 
> What do you mean by stack is corrupted?

load_up_fpu() makes assumptions about the caller's stack frame that  
aren't true when called from C code.

> My understanding is that when calling the assembly function from C  
> function then stack frame will not be pushed and assembly function  
> uses the caller stack frame.

Huh?  Assembly functions obey the same ABI as C functions (at least,  
asm functions meant to be callable from C do).  If the above were true,  
how would C code know that it's calling an asm function, and how would  
it know how much stack to create and which portions would be clobbered?

The issue with load_up_fpu() is that it was apparently not meant to be  
called directly from C code.

-Scott


More information about the Linuxppc-dev mailing list