Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: gregkh@linuxfoundation.org
Cc: vincent.chen@sifive.com, david.abdurachmanov@sifive.com,
	palmer@sifive.com, paul.walmsley@sifive.com,
	stable@vger.kernel.org
Subject: Re: FAILED: patch "[PATCH] riscv: Avoid interrupts being erroneously enabled in" failed to apply to 5.3-stable tree
Date: Tue, 8 Oct 2019 20:52:52 -0400	[thread overview]
Message-ID: <20191009005252.GQ1396@sasha-vm> (raw)
In-Reply-To: <1570555664182195@kroah.com>

On Tue, Oct 08, 2019 at 07:27:44PM +0200, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 5.3-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From c82dd6d078a2bb29d41eda032bb96d05699a524d Mon Sep 17 00:00:00 2001
>From: Vincent Chen <vincent.chen@sifive.com>
>Date: Mon, 16 Sep 2019 16:47:41 +0800
>Subject: [PATCH] riscv: Avoid interrupts being erroneously enabled in
> handle_exception()
>
>When the handle_exception function addresses an exception, the interrupts
>will be unconditionally enabled after finishing the context save. However,
>It may erroneously enable the interrupts if the interrupts are disabled
>before entering the handle_exception.
>
>For example, one of the WARN_ON() condition is satisfied in the scheduling
>where the interrupt is disabled and rq.lock is locked. The WARN_ON will
>trigger a break exception and the handle_exception function will enable the
>interrupts before entering do_trap_break function. During the procedure, if
>a timer interrupt is pending, it will be taken when interrupts are enabled.
>In this case, it may cause a deadlock problem if the rq.lock is locked
>again in the timer ISR.
>
>Hence, the handle_exception() can only enable interrupts when the state of
>sstatus.SPIE is 1.
>
>This patch is tested on HiFive Unleashed board.
>
>Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
>Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
>[paul.walmsley@sifive.com: updated to apply]
>Fixes: bcae803a21317 ("RISC-V: Enable IRQ during exception handling")
>Cc: David Abdurachmanov <david.abdurachmanov@sifive.com>
>Cc: stable@vger.kernel.org
>Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
>
>diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
>index 74ccfd464071..da7aa88113c2 100644
>--- a/arch/riscv/kernel/entry.S
>+++ b/arch/riscv/kernel/entry.S
>@@ -166,9 +166,13 @@ ENTRY(handle_exception)
> 	move a0, sp /* pt_regs */
> 	tail do_IRQ
> 1:
>-	/* Exceptions run with interrupts enabled */
>+	/* Exceptions run with interrupts enabled or disabled
>+	   depending on the state of sstatus.SR_SPIE */
>+	andi t0, s1, SR_SPIE
>+	beqz t0, 1f
> 	csrs CSR_SSTATUS, SR_SIE
>
>+1:

I might be missing something here, but wasn't the label "1" already
declared a few lines above?

--
Thanks,
Sasha

  reply	other threads:[~2019-10-09  0:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 17:27 FAILED: patch "[PATCH] riscv: Avoid interrupts being erroneously enabled in" failed to apply to 5.3-stable tree gregkh
2019-10-09  0:52 ` Sasha Levin [this message]
2019-10-09  1:00   ` Paul Walmsley
2019-10-09  1:23     ` Sasha Levin
2019-10-09  1:46       ` Paul Walmsley

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=20191009005252.GQ1396@sasha-vm \
    --to=sashal@kernel.org \
    --cc=david.abdurachmanov@sifive.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=palmer@sifive.com \
    --cc=paul.walmsley@sifive.com \
    --cc=stable@vger.kernel.org \
    --cc=vincent.chen@sifive.com \
    /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