diff mbox

[v2,2/3] ppc64: Avoid rfid if no need to clear MSR_LE

Message ID 1444172150-29493-2-git-send-email-scottwood@freescale.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Scott Wood Oct. 6, 2015, 10:55 p.m. UTC
Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
fatal exception on book3e.

Purgatory is an isolated environment which makes importing information
about the subarch awkward, so instead rely on the fact that MSR_LE
should never be set on book3e, and the rfid is only needed if MSR_LE is
set (and thus needs to be cleared).  In theory that MSR bit is reserved
on book3e, rather than zero, but in practice I have not seen it set.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
---
v2: new patch

 purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Simon Horman Oct. 16, 2015, 1:48 a.m. UTC | #1
On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> fatal exception on book3e.
> 
> Purgatory is an isolated environment which makes importing information
> about the subarch awkward, so instead rely on the fact that MSR_LE
> should never be set on book3e, and the rfid is only needed if MSR_LE is
> set (and thus needs to be cleared).  In theory that MSR bit is reserved
> on book3e, rather than zero, but in practice I have not seen it set.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> ---
> v2: new patch

Could I get a review of this from at lest one ppc person?

>  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> index 179ade9..3534080 100644
> --- a/purgatory/arch/ppc64/v2wrap.S
> +++ b/purgatory/arch/ppc64/v2wrap.S
> @@ -116,9 +116,17 @@ master:
>  	stw	7,0x5c(4)	# and patch it into the kernel
>  	mr      3,16            # restore dt address
>  
> +	mfmsr	5
> +	andi.	10,5,1		# test MSR_LE
> +	bne	little_endian
> +
> +	li	5,0		# r5 will be 0 for kernel
> +	mtctr	4		# prepare branch to
> +	bctr			# start kernel
> +	
> +little_endian:			# book3s-only
>  	mtsrr0	4		# prepare branch to
>  
> -	mfmsr	5
>  	clrrdi	5,5,1		# clear MSR_LE
>  	mtsrr1	5
>  
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
>
Scott Wood Oct. 30, 2015, 12:16 a.m. UTC | #2
On Fri, 2015-10-16 at 10:48 +0900, Simon Horman wrote:
> On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > fatal exception on book3e.
> > 
> > Purgatory is an isolated environment which makes importing information
> > about the subarch awkward, so instead rely on the fact that MSR_LE
> > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > on book3e, rather than zero, but in practice I have not seen it set.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > ---
> > v2: new patch
> 
> Could I get a review of this from at lest one ppc person?

Michael, can you comment on this as well as patch 3/3?

-Scott

> 
> >  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> > index 179ade9..3534080 100644
> > --- a/purgatory/arch/ppc64/v2wrap.S
> > +++ b/purgatory/arch/ppc64/v2wrap.S
> > @@ -116,9 +116,17 @@ master:
> >     stw     7,0x5c(4)       # and patch it into the kernel
> >     mr      3,16            # restore dt address
> >  
> > +   mfmsr   5
> > +   andi.   10,5,1          # test MSR_LE
> > +   bne     little_endian
> > +
> > +   li      5,0             # r5 will be 0 for kernel
> > +   mtctr   4               # prepare branch to
> > +   bctr                    # start kernel
> > +   
> > +little_endian:                     # book3s-only
> >     mtsrr0  4               # prepare branch to
> >  
> > -   mfmsr   5
> >     clrrdi  5,5,1           # clear MSR_LE
> >     mtsrr1  5
> >
Sam Mendoza-Jonas Nov. 1, 2015, 10:55 p.m. UTC | #3
On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> fatal exception on book3e.
> 
> Purgatory is an isolated environment which makes importing information
> about the subarch awkward, so instead rely on the fact that MSR_LE
> should never be set on book3e, and the rfid is only needed if MSR_LE is
> set (and thus needs to be cleared).  In theory that MSR bit is reserved
> on book3e, rather than zero, but in practice I have not seen it set.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> ---
> v2: new patch

Looks good to me, thanks for catching this!
I'll ping Michael too if you'd like his reviewed-by.

Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

> 
>  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> index 179ade9..3534080 100644
> --- a/purgatory/arch/ppc64/v2wrap.S
> +++ b/purgatory/arch/ppc64/v2wrap.S
> @@ -116,9 +116,17 @@ master:
>  	stw	7,0x5c(4)	# and patch it into the kernel
>  	mr      3,16            # restore dt address
>  
> +	mfmsr	5
> +	andi.	10,5,1		# test MSR_LE
> +	bne	little_endian
> +
> +	li	5,0		# r5 will be 0 for kernel
> +	mtctr	4		# prepare branch to
> +	bctr			# start kernel
> +	
> +little_endian:			# book3s-only
>  	mtsrr0	4		# prepare branch to
>  
> -	mfmsr	5
>  	clrrdi	5,5,1		# clear MSR_LE
>  	mtsrr1	5
>  
> -- 
> 2.1.4
Sam Mendoza-Jonas Nov. 2, 2015, 12:21 a.m. UTC | #4
On Mon, Nov 02, 2015 at 09:55:53AM +1100, Sam Mendoza-Jonas wrote:
> On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > fatal exception on book3e.
> > 
> > Purgatory is an isolated environment which makes importing information
> > about the subarch awkward, so instead rely on the fact that MSR_LE
> > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > on book3e, rather than zero, but in practice I have not seen it set.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > ---
> > v2: new patch
> 
> Looks good to me, thanks for catching this!
> I'll ping Michael too if you'd like his reviewed-by.
> 
> Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

Following up, also add my

Tested-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

> 
> > 
> >  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> > index 179ade9..3534080 100644
> > --- a/purgatory/arch/ppc64/v2wrap.S
> > +++ b/purgatory/arch/ppc64/v2wrap.S
> > @@ -116,9 +116,17 @@ master:
> >  	stw	7,0x5c(4)	# and patch it into the kernel
> >  	mr      3,16            # restore dt address
> >  
> > +	mfmsr	5
> > +	andi.	10,5,1		# test MSR_LE
> > +	bne	little_endian
> > +
> > +	li	5,0		# r5 will be 0 for kernel
> > +	mtctr	4		# prepare branch to
> > +	bctr			# start kernel
> > +	
> > +little_endian:			# book3s-only
> >  	mtsrr0	4		# prepare branch to
> >  
> > -	mfmsr	5
> >  	clrrdi	5,5,1		# clear MSR_LE
> >  	mtsrr1	5
> >  
> > -- 
> > 2.1.4
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
Simon Horman Nov. 2, 2015, 2:06 a.m. UTC | #5
On Mon, Nov 02, 2015 at 11:21:43AM +1100, Sam Mendoza-Jonas wrote:
> On Mon, Nov 02, 2015 at 09:55:53AM +1100, Sam Mendoza-Jonas wrote:
> > On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > > fatal exception on book3e.
> > > 
> > > Purgatory is an isolated environment which makes importing information
> > > about the subarch awkward, so instead rely on the fact that MSR_LE
> > > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > > on book3e, rather than zero, but in practice I have not seen it set.
> > > 
> > > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > > ---
> > > v2: new patch
> > 
> > Looks good to me, thanks for catching this!
> > I'll ping Michael too if you'd like his reviewed-by.
> > 
> > Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> 
> Following up, also add my
> 
> Tested-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

Thanks, I have queued this up for v2.0.11.
diff mbox

Patch

diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
index 179ade9..3534080 100644
--- a/purgatory/arch/ppc64/v2wrap.S
+++ b/purgatory/arch/ppc64/v2wrap.S
@@ -116,9 +116,17 @@  master:
 	stw	7,0x5c(4)	# and patch it into the kernel
 	mr      3,16            # restore dt address
 
+	mfmsr	5
+	andi.	10,5,1		# test MSR_LE
+	bne	little_endian
+
+	li	5,0		# r5 will be 0 for kernel
+	mtctr	4		# prepare branch to
+	bctr			# start kernel
+	
+little_endian:			# book3s-only
 	mtsrr0	4		# prepare branch to
 
-	mfmsr	5
 	clrrdi	5,5,1		# clear MSR_LE
 	mtsrr1	5