From: Scott Wood <scottwood@freescale.com>
To: Bhushan Bharat-R65777 <R65777@freescale.com>
Cc: Wood Scott-B07421 <B07421@freescale.com>,
Michael Neuling <mikey@neuling.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: BOOKE KVM calling load_up_fpu from C?
Date: Tue, 12 Feb 2013 12:33:08 -0600 [thread overview]
Message-ID: <1360693988.24612.4@snotra> (raw)
In-Reply-To: <6A3DF150A5B70D4F9B66A25E3F7C888D0659EF89@039-SN2MPN1-023.039d.mgd.msft.net> (from R65777@freescale.com on Tue Feb 12 03:01:07 2013)
On 02/12/2013 03:01:07 AM, Bhushan Bharat-R65777 wrote:
>=20
>=20
> > -----Original Message-----
> > From: Michael Neuling [mailto:mikey@neuling.org]
> > Sent: Tuesday, February 12, 2013 9:46 AM
> > To: Bhushan Bharat-R65777
> > Cc: Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org
> > Subject: Re: BOOKE KVM calling load_up_fpu from C?
> >
> > Bhushan Bharat-R65777 <R65777@freescale.com> wrote:
> >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Michael Neuling [mailto:mikey@neuling.org]
> > > > Sent: Tuesday, February 12, 2013 9:16 AM
> > > > To: Bhushan Bharat-R65777
> > > > Cc: Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org
> > > > Subject: Re: BOOKE KVM calling load_up_fpu from C?
> > > >
> > > > Look further down...
> > > >
> > > > #ifdef CONFIG_PPC32
> > > > mfspr r5,SPRN_SPRG_THREAD /* current =20
> task's THREAD (phys) */
> > > > lwz r4,THREAD_FPEXC_MODE(r5)
> > > > ori r9,r9,MSR_FP /* enable FP for =20
> current */
> > > > or r9,r9,r4
> > > > #else
> > > > ld r4,PACACURRENT(r13)
> > > > addi r5,r4,THREAD /* Get THREAD */
> > > > lwz r4,THREAD_FPEXC_MODE(r5)
> > > > ori r12,r12,MSR_FP
> > > > or r12,r12,r4
> > > > std r12,_MSR(r1)
> > > > #endif
> > > >
> > > > R12 is loaded with SRR1 in the exception prolog before =20
> load_up_fpu is
> > called.
> > >
> > > Yes it is SRR1 not MSR.
> >
> > Yes, SRR1 =3D=3D the MSR of the user process, not the current MSR.
> >
> > > Also on 32bit it looks like that R9 is assumed to have SRR1.
> >
> > Yep that too.
> >
> > So any idea how it's suppose to work or is it broken?
>=20
> To me this looks wrong. And this seems to works because the =20
> thread->reg->msr is not actually used to write SRR1 (and eventually =20
> the thread MSR) when doing rfi to enter guest. Infact =20
> Guest(shadow_msr) MSR is used as SRR1 and which will have proper MSR =20
> (including FP set).
>=20
> But Yes, Scott is right person to comment, So let us wait for him =20
> comment.
I don't think it's actually a problem on 32-bit, since r9 is modified =20
but never actually used for anything. On 64-bit, though, there's a =20
store to the caller's stack frame (yuck) which the kvm/booke.h caller =20
is not prepared for. Indeed, book3s's kvmppc_load_up_fpu creates an =20
interrupt-like stack frame, but does not load r9 or r12.
It would be really nice if assumptions like these were put in a code =20
comment above load_up_fpu... and if we didn't have so many random =20
differences between 32-bit and 64-bit. :-P
-Scott=
next prev parent reply other threads:[~2013-02-12 18:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-12 3:29 BOOKE KVM calling load_up_fpu from C? Michael Neuling
2013-02-12 3:37 ` Bhushan Bharat-R65777
2013-02-12 3:46 ` Michael Neuling
2013-02-12 3:58 ` Bhushan Bharat-R65777
2013-02-12 4:16 ` Michael Neuling
2013-02-12 9:01 ` Bhushan Bharat-R65777
2013-02-12 18:33 ` Scott Wood [this message]
2013-02-12 22:51 ` Michael Neuling
2013-02-13 1:18 ` Bhushan Bharat-R65777
2013-02-13 1:23 ` Scott Wood
2013-02-13 1:26 ` Bhushan Bharat-R65777
2013-02-13 4:17 ` Bhushan Bharat-R65777
2013-02-13 17:37 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360693988.24612.4@snotra \
--to=scottwood@freescale.com \
--cc=B07421@freescale.com \
--cc=R65777@freescale.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).