All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Matyukevich <geomatsi@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH RFC v1 1/1] lib: sbi: add support for debug triggers
Date: Tue, 1 Nov 2022 19:25:05 +0300	[thread overview]
Message-ID: <Y2FIYXGkrWtPIzQm@curiosity> (raw)
In-Reply-To: <CAAhSdy3SUVook-K4xMdh7R_dGRF0teo0BThYMreEPMJYHuBWMg@mail.gmail.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 RISC-V hardware triggers consists of the
> > > > following major components:
> > > > - U-mode: gdb support for setting hw breakpoints/watchpoints
> > > > - S/VS-mode: hardware breakpoints framework in Linux kernel
> > > > - M-mode: SBI firmware code to handle triggers
> > > >
> > > > SBI Debug Trigger extension proposal (draft v4) 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:
> > > > - only mcontrol6 trigger type is supported
> > > > - no support for chained triggers
> > > > - trigger update supports only address change
> >
> > ...
> >
> > > > +union riscv_dbtr_tdata1 {
> > > > +   unsigned long value;
> > > > +   struct {
> > > > +#if __riscv_xlen == 64
> > > > +           unsigned long data:59;
> > > > +#elif __riscv_xlen == 32
> > > > +           unsigned long data:27;
> > > > +#else
> > > > +#error "Unexpected __riscv_xlen"
> > > > +#endif
> > > > +           unsigned long dmode:1;
> > > > +           unsigned long type:4;
> > > > +   };
> > > > +};
> > >
> > > Bitfield order depends on endianness (type is in the MSBs for
> > > little-endian but LSBs for big-endian).
> >
> > Do we need to support non-standard BE cases as well ? If so, then
> > accessing fields in shared memory messages between OpenSBI and kernel
> > will have to be wrapped by cpu_to_le/le_to_cpu macros on both sides.
> 
> Yes, in the long term we might support BE in both Linux and OpenSBI
> so better to avoid bitfield for data structures in shared memory.

Do we have to avoid using bitfields in this context ?
How about using a Linux approach with appropriate defines:

union riscv_dbtr_tdata1_mcontrol6 {
	unsigned long value;
	struct {
#if defined(__LITTLE_ENDIAN_BITFIELD)
		unsigned long load:1;
		unsigned long store:1;
		...
#elif defined (__BIG_ENDIAN_BITFIELD)
		...
		unsigned long store:1;
		unsigned long load:1;
#endif
	};


Regards,
Sergey


  reply	other threads:[~2022-11-01 16:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 21:18 [PATCH RFC v1 1/1] lib: sbi: add support for debug triggers Sergey Matyukevich
2022-10-31 21:37 ` Jessica Clarke
2022-11-01 10:55   ` Sergey Matyukevich
2022-11-01 11:01     ` Anup Patel
2022-11-01 16:25       ` Sergey Matyukevich [this message]
2022-11-01 15:32     ` Jessica Clarke
2022-11-01  2:58 ` Xiang W
2022-11-01 10:20   ` Sergey Matyukevich
2022-11-01  4:11 ` Bin Meng
2022-11-01  9:39   ` 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=Y2FIYXGkrWtPIzQm@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 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.