From: guoren@kernel.org
To: palmerdabbelt@google.com, paul.walmsley@sifive.com,
anup@brainfault.org, greentime.hu@sifive.com, zong.li@sifive.com,
atish.patra@wdc.com
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
guoren@kernel.org, Guo Ren <guoren@linux.alibaba.com>,
Palmer Dabbelt <palmer@sifive.com>,
Vincent Chen <vincent.chen@sifive.com>
Subject: [PATCH 1/2] riscv: Fixup do_page_fault warning in uprobe_xol
Date: Mon, 23 Nov 2020 15:39:39 +0000 [thread overview]
Message-ID: <1606145980-5153-1-git-send-email-guoren@kernel.org> (raw)
From: Guo Ren <guoren@linux.alibaba.com>
[ 670.922295] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1491
[ 670.930853] in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 96, name: hello
[ 670.938446] CPU: 0 PID: 96 Comm: hello Tainted: G W 5.9.3-00875-gaf1498803464-dirty #31
[ 670.947775] Call Trace:
[ 670.950236] [<ffffffe000203dc8>] walk_stackframe+0x0/0xc2
[ 670.955650] [<ffffffe000204078>] show_stack+0x46/0x52
[ 670.960716] [<ffffffe0005a3fce>] dump_stack+0x90/0xb6
[ 670.965783] [<ffffffe0002336b2>] ___might_sleep+0xf8/0x10c
[ 670.971284] [<ffffffe000233716>] __might_sleep+0x50/0x7e
[ 670.976613] [<ffffffe000a71498>] down_read+0x32/0xe0
[ 670.981592] [<ffffffe000207798>] do_page_fault+0xf0/0x3d8
[ 670.987006] [<ffffffe000201de8>] ret_from_exception+0x0/0x14
When CONFIG_DEBUG_ATOMIC_SLEEP is enabled:
mmap_read_lock()->down_read()->might_sleep->___might_sleep() will
check irqs_disabled() is 0 or Not. If irqs disabled, kernel prints
the BUG warning.
Uprobe need prepare a xol_slot to emulate single-step the instruction
for uprobe with irqs-off in user context. So it's the only case for
us to meet a irqs-off user context situation.
Second:
/* Enable interrupts if they were enabled in the parent context. */
if (likely(regs->status & SR_PIE))
local_irq_enable();
It's duplicate with the patch by Vincent commit: c82dd6d078a2 ("
riscv: Avoid interrupts being erroneously enabled in
handle_exception()")
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Vincent Chen <vincent.chen@sifive.com>
---
arch/riscv/mm/fault.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index e889e65..a9d1f12 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -55,10 +55,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
if (unlikely((addr >= VMALLOC_START) && (addr <= VMALLOC_END)))
goto vmalloc_fault;
- /* Enable interrupts if they were enabled in the parent context. */
- if (likely(regs->status & SR_PIE))
- local_irq_enable();
-
/*
* If we're in an interrupt, have no user context, or are running
* in an atomic region, then we must not take the fault.
@@ -71,6 +67,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
+ /* Enable interrupts for user context. */
+ local_irq_enable();
retry:
mmap_read_lock(mm);
vma = find_vma(mm, addr);
--
2.7.4
next reply other threads:[~2020-11-23 15:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-23 15:39 guoren [this message]
2020-11-23 15:39 ` [PATCH 2/2] riscv: Fixup trace_hardirqs_on in entry.S guoren
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=1606145980-5153-1-git-send-email-guoren@kernel.org \
--to=guoren@kernel.org \
--cc=anup@brainfault.org \
--cc=atish.patra@wdc.com \
--cc=greentime.hu@sifive.com \
--cc=guoren@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@sifive.com \
--cc=palmerdabbelt@google.com \
--cc=paul.walmsley@sifive.com \
--cc=vincent.chen@sifive.com \
--cc=zong.li@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