public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nam Cao <namcaov@gmail.com>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	guoren@kernel.org
Subject: Re: [PATCH] riscv: provide riscv-specific is_trap_insn()
Date: Mon, 28 Aug 2023 15:50:06 +0200	[thread overview]
Message-ID: <ZOymDqhE9STgx4Mm@nam-dell> (raw)
In-Reply-To: <ZOyhozSq3S36eRSq@nam-dell>

On Mon, Aug 28, 2023 at 03:31:15PM +0200, Nam Cao wrote:
> On Mon, Aug 28, 2023 at 02:48:06PM +0200, Björn Töpel wrote:
> > Nam Cao <namcaov@gmail.com> writes:
> > 
> > > uprobes expects is_trap_insn() to return true for any trap instructions,
> > > not just the one used for installing uprobe. The current default
> > > implementation only returns true for 16-bit c.ebreak if C extension is
> > > enabled. This can confuse uprobes if a 32-bit ebreak generates a trap
> > > exception from userspace: uprobes asks is_trap_insn() who says there is no
> > > trap, so uprobes assume a probe was there before but has been removed, and
> > > return to the trap instruction. This cause an infinite loop of entering
> > > and exiting trap handler.
> > >
> > > Instead of using the default implementation, implement this function
> > > speficially for riscv which checks for both ebreak and c.ebreak.
> > 
> > I took this for a spin, and it indeed fixes this new hang! Nice!
> 
> Great! Thanks for testing it.
>  
> > However, when I tried setting an uprobe on the ebreak instruction
> > (offset 0x118) from your example [1], the probe does not show up in the
> > trace buffer.
> > 
> > Any ideas?
> 
> >From my understanding, both uprobes and kprobes refuse to install break points
> into existing trap instructions. Otherwise, we may conflict with something else
> that is also using trap instructions.

I just realize you probably ask this because uprobe can still be installed before
applying the patch. But I think that is another bug that my patch also
accidentally fix: uprobes should not install breakpoint into ebreak instructions,
but it incorrectly does so because it does not even know about the existence of
32-bit ebreak.

Best regards,
Nam

  reply	other threads:[~2023-08-28 13:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-27 20:56 [PATCH] riscv: provide riscv-specific is_trap_insn() Nam Cao
2023-08-28 12:48 ` Björn Töpel
2023-08-28 13:31   ` Nam Cao
2023-08-28 13:50     ` Nam Cao [this message]
2023-08-29  6:14       ` Björn Töpel
2023-08-29 18:54         ` Nam Cao
2023-08-30  7:32           ` Björn Töpel
2023-08-30  7:46             ` Nam Cao
2023-08-30  7:56               ` Nam Cao
2023-08-29  5:56 ` Guo Ren
2023-08-29  6:26   ` Conor Dooley
2023-08-29  8:12     ` Nam Cao
2023-08-29  8:18     ` Nam Cao
2023-08-31 16:29       ` Conor Dooley

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=ZOymDqhE9STgx4Mm@nam-dell \
    --to=namcaov@gmail.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=bjorn@kernel.org \
    --cc=guoren@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@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