All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@mips.com>
To: Corey Minyard <cminyard@mvista.com>
Cc: Matt Redfearn <matt.redfearn@mips.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Matthew Fortune <matthew.fortune@mips.com>,
	<linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>,
	"Jason A. Donenfeld" <jason@zx2c4.com>,
	Paul Burton <paul.burton@imgtec.com>
Subject: Re: [PATCH] MIPS: Fix exception entry when CONFIG_EVA enabled
Date: Tue, 31 Oct 2017 23:48:53 +0000	[thread overview]
Message-ID: <20171031234853.GD15260@jhogan-linux> (raw)
In-Reply-To: <605f6a96-a843-085c-efc6-a2c0f2afd84a@mvista.com>

[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]

On Wed, Oct 11, 2017 at 08:12:31AM -0500, Corey Minyard wrote:
> On 10/11/2017 03:59 AM, Matt Redfearn wrote:
> > Commit 9fef68686317b ("MIPS: Make SAVE_SOME more standard") made several
> > changes to the order in which registers are saved in the SAVE_SOME
> > macro, used by exception handlers to save the processor state. In
> > particular, it removed the
> > move   k1, sp
> > in the delay slot of the branch testing if the processor is already in
> > kernel mode. This is replaced later in the macro by a
> > move   k0, sp
> > When CONFIG_EVA is disabled, this instruction actually appears in the
> > delay slot of the branch. However, when CONFIG_EVA is enabled, instead
> > the RPS workaround of
> > MFC0	k0, CP0_ENTRYHI
> > appears in the delay slot. This results in k0 not containing the stack
> > pointer, but some unrelated value, which is then saved to the kernel
> > stack. On exit from the exception, this bogus value is restored to the
> > stack pointer, resulting in an OOPS.
> >
> > Fix this by moving the save of SP in k0 explicitly in the delay slot of
> > the branch, outside of the CONFIG_EVA section, restoring the expected
> > instruction ordering when CONFIG_EVA is active.
> >
> > Fixes: 9fef68686317b ("MIPS: Make SAVE_SOME more standard")
> > Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
> > Reported-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com>
> 
> I looked this over pretty carefully and it looks correct to me.  It 
> makes no difference
> in the instructions generated by the non-EVA case.  I shouldn't have 
> missed this :(.
> 
> Reviewed-by: Corey Minyard <cminyard@mvista.com>

Yeh, having stared at it for a little while it looks correct to me too.

Reviewed-by: James Hogan <jhogan@kernel.org>

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: James Hogan <james.hogan@mips.com>
To: Corey Minyard <cminyard@mvista.com>
Cc: Matt Redfearn <matt.redfearn@mips.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Matthew Fortune <matthew.fortune@mips.com>,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	"Jason A. Donenfeld" <jason@zx2c4.com>,
	Paul Burton <paul.burton@imgtec.com>
Subject: Re: [PATCH] MIPS: Fix exception entry when CONFIG_EVA enabled
Date: Tue, 31 Oct 2017 23:48:53 +0000	[thread overview]
Message-ID: <20171031234853.GD15260@jhogan-linux> (raw)
Message-ID: <20171031234853.B8Zi4nEASEZG532PWtacuC2nfWquazhA5gNG3nfacTo@z> (raw)
In-Reply-To: <605f6a96-a843-085c-efc6-a2c0f2afd84a@mvista.com>

[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]

On Wed, Oct 11, 2017 at 08:12:31AM -0500, Corey Minyard wrote:
> On 10/11/2017 03:59 AM, Matt Redfearn wrote:
> > Commit 9fef68686317b ("MIPS: Make SAVE_SOME more standard") made several
> > changes to the order in which registers are saved in the SAVE_SOME
> > macro, used by exception handlers to save the processor state. In
> > particular, it removed the
> > move   k1, sp
> > in the delay slot of the branch testing if the processor is already in
> > kernel mode. This is replaced later in the macro by a
> > move   k0, sp
> > When CONFIG_EVA is disabled, this instruction actually appears in the
> > delay slot of the branch. However, when CONFIG_EVA is enabled, instead
> > the RPS workaround of
> > MFC0	k0, CP0_ENTRYHI
> > appears in the delay slot. This results in k0 not containing the stack
> > pointer, but some unrelated value, which is then saved to the kernel
> > stack. On exit from the exception, this bogus value is restored to the
> > stack pointer, resulting in an OOPS.
> >
> > Fix this by moving the save of SP in k0 explicitly in the delay slot of
> > the branch, outside of the CONFIG_EVA section, restoring the expected
> > instruction ordering when CONFIG_EVA is active.
> >
> > Fixes: 9fef68686317b ("MIPS: Make SAVE_SOME more standard")
> > Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
> > Reported-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com>
> 
> I looked this over pretty carefully and it looks correct to me.  It 
> makes no difference
> in the instructions generated by the non-EVA case.  I shouldn't have 
> missed this :(.
> 
> Reviewed-by: Corey Minyard <cminyard@mvista.com>

Yeh, having stared at it for a little while it looks correct to me too.

Reviewed-by: James Hogan <jhogan@kernel.org>

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-10-31 23:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  8:59 [PATCH] MIPS: Fix exception entry when CONFIG_EVA enabled Matt Redfearn
2017-10-11  8:59 ` Matt Redfearn
2017-10-11 13:12 ` Corey Minyard
2017-10-31 23:48   ` James Hogan [this message]
2017-10-31 23:48     ` James Hogan
2017-11-13 10:47     ` Maciej W. Rozycki
2017-11-13 10:47       ` Maciej W. Rozycki
2017-11-15 10:32       ` Matt Redfearn
2017-11-15 10:32         ` Matt Redfearn
2017-11-15 13:48         ` Maciej W. Rozycki
2017-11-15 13:48           ` Maciej W. Rozycki
2017-11-15 14:53           ` Maciej W. Rozycki
2017-11-15 14:53             ` Maciej W. Rozycki
2017-10-18 17:34 ` Maciej W. Rozycki
2017-10-18 17:34   ` Maciej W. Rozycki

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=20171031234853.GD15260@jhogan-linux \
    --to=james.hogan@mips.com \
    --cc=cminyard@mvista.com \
    --cc=jason@zx2c4.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=matt.redfearn@mips.com \
    --cc=matthew.fortune@mips.com \
    --cc=paul.burton@imgtec.com \
    --cc=ralf@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.