OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Matyukevich <geomatsi@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH RFC v2 2/2] lib: sbi: add support for debug triggers
Date: Tue, 13 Dec 2022 22:43:20 +0300	[thread overview]
Message-ID: <Y5jV2CPg9nDmOvfO@curiosity> (raw)
In-Reply-To: <cd24a0c91272bf5e636c90c2071f6e22bd500cf9.camel@126.com>

> > > > RISC-V Debug specification includes Sdtrig ISA extension.
> > > > This extension describes Trigger Module. Triggers can cause
> > > > a breakpoint exception, entry into Debug Mode, or a trace
> > > > action without having to execute a special instruction. For
> > > > native debugging triggers can be used to implement hardware
> > > > breakpoints and watchpoints.
> > > > 
> > > > Software support for triggers consists of the following
> > > > major components:
> > > > - U-mode: gdb
> > > > - S-mode: hardware breakpoints framework in Linux kernel
> > > > - M-mode: SBI firmware code to handle triggers
> > > > 
> > > > SBI Debug Trigger extension proposal has been posted by
> > > > Anup Patel to lists.riscv.org tech-debug mailing list:
> > > > https://lists.riscv.org/g/tech-debug/topic/92375492
> > > > 
> > > > This patch provides initial implementation of SBI Debug
> > > > Trigger Extension in OpenSBI library based on the
> > > > suggested extension proposal.
> > > > 
> > > > Initial implementation has the following limitations:
> > > > - supported triggers: mcontrol, mcontrol6
> > > > - no support for chained triggers
> > > > - only build test for RV32
> > 
> > ... [snip]
> > 
> > > > +struct sbi_dbtr_trig_info {
> > > > +???????unsigned long type_mask;
> > > > +???????union sbi_dbtr_trig_state state;
> > > > +???????unsigned long tdata1;
> > > > +???????unsigned long tdata2;
> > > > +???????unsigned long tdata3;
> > > tdata1~tdata3 can be removed and written directly to scr during install
> > 
> > We need to write those values not only when we install triggers. We have
> > to rewrite them when we re-enable triggers after disabling or updating.
> > So I think it is more convenient to keep the whole state at hand.
> 
> when install, write directly to tdata1~data3
> when read, read from tdata1~tdata3, and OR the vs/vu/s/u bits in trig_status with tdata1  
> when disable, clear vs/vu/s/u in tdata1 
> when enable, write vs/vu/s/u in trig_state to tdata1

Ok for these four.

> when updat, Only need write recv to tdata2

Not for this one. You may need to update tdata1 as well. Besides, nothing
in spec requires hardware to support partial trigger updates on the fly.
On the other hand, we can read all CSRs, update some, and write back.
Ok, I agree that there is a value in saving quite a few extra bytes.
I will double-check this approach for v3.

Regards,
Sergey


  reply	other threads:[~2022-12-13 19:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-03 21:39 [PATCH RFC v2 0/2] lib: sbi: add support for debug triggers Sergey Matyukevich
2022-12-03 21:39 ` [PATCH RFC v2 1/2] include: sbi: endianness conversion macros Sergey Matyukevich
2022-12-03 21:39 ` [PATCH RFC v2 2/2] lib: sbi: add support for debug triggers Sergey Matyukevich
2022-12-04 11:56   ` Xiang W
2022-12-05 20:34     ` Sergey Matyukevich
2022-12-08 12:49   ` Himanshu Chauhan
2022-12-10 20:42     ` Sergey Matyukevich
2022-12-10 16:54   ` Xiang W
2022-12-10 19:15     ` Sergey Matyukevich
2022-12-11  1:40       ` Xiang W
2022-12-13 19:43         ` Sergey Matyukevich [this message]
2022-12-03 21:59 ` [PATCH RFC v2 0/2] " Sergey Matyukevich

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=Y5jV2CPg9nDmOvfO@curiosity \
    --to=geomatsi@gmail.com \
    --cc=opensbi@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox