All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Himanshu Chauhan <himanshu.chauhan@oss.qualcomm.com>
Cc: opensbi@lists.infradead.org,
	 Himanshu Chauhan <hchauhan@ventanamicro.com>
Subject: Re: [PATCH 06/18] dbtr: Improve trigger update error checking
Date: Mon, 25 May 2026 21:38:28 -0700	[thread overview]
Message-ID: <ahUjIlb-fwx_rtP2@lima-default> (raw)
In-Reply-To: <afi55pkq49uS6KAx@hu-himchau-blr.qualcomm.com>

On Mon, May 04, 2026 at 08:53:18PM +0530, Himanshu Chauhan wrote:
> On Fri, Mar 13, 2026 at 03:19:35PM +1000, Nicholas Piggin wrote:
> > Trigger updates should ensure all triggers can be upated without failure
> > before making any changes. Updates that change the trigger type must
> > also be disallowed according to SBI specification.
> > 
> > Change the style of shmem access and checking to match the trigger
> > install code and perform all checks first. Add the missing check to
> > prevent type change.
> > 
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >  lib/sbi/sbi_dbtr.c | 33 ++++++++++++++++++++++++++-------
> >  1 file changed, 26 insertions(+), 7 deletions(-)
> > 
> > diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
> > index 224f2350..d2845fec 100644
> > --- a/lib/sbi/sbi_dbtr.c
> > +++ b/lib/sbi/sbi_dbtr.c
> > @@ -727,9 +727,9 @@ int sbi_dbtr_enable_trig(unsigned long trig_idx_base,
> >  int sbi_dbtr_update_trig(unsigned long smode,
> >  			 unsigned long trig_count, unsigned long *out)
> >  {
> > -	unsigned long trig_idx;
> >  	struct sbi_dbtr_trigger *trig;
> >  	union sbi_dbtr_shmem_entry *entry;
> > +	struct sbi_dbtr_data_msg *recv;
> >  	void *shmem_base = NULL;
> >  	struct sbi_dbtr_hart_triggers_state *hs = NULL;
> >  
> > @@ -744,30 +744,49 @@ int sbi_dbtr_update_trig(unsigned long smode,
> >  		return SBI_ERR_NO_SHMEM;
> >  
> >  	shmem_base = hart_shmem_base(hs);
> > +	sbi_hart_protection_map_range((unsigned long)shmem_base,
> > +				      trig_count * sizeof(*entry));
> Hi Nicholas,
> 
> I would suggest to verify the value of trig_count before making a large map entry.
> It would also help in the two loops below.
> 
> >  
> > +	/* Check requested triggers configuration */
> >  	for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
> > -		sbi_hart_protection_map_range((unsigned long)entry, sizeof(*entry));
> > -		trig_idx = entry->id.idx;
> > +		unsigned long trig_idx, tdata1;
> >  
> > +		trig_idx = entry->id.idx;
> >  		if (trig_idx >= hs->total_trigs) {
> > -			sbi_hart_protection_unmap_range((unsigned long)entry, sizeof(*entry));
> >  			*out = _idx;
> > +			sbi_hart_protection_unmap_range((unsigned long)shmem_base,
> > +							trig_count * sizeof(*entry));
> 
> A forward goto to bailout in success/error condition would be better.

Hey Himanshu,

Thanks for the reviews, I'll take a look at these suggestions and see
how they look.

I should repost this series soon, I will do so after hearing from David
about the tdata2/tdata3 issue.

Thanks,
Nick

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

  reply	other threads:[~2026-05-26  4:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13  5:19 [PATCH 00/18] dbtr: Fixes and heterogeneous trigger types Nicholas Piggin
2026-03-13  5:19 ` [PATCH 01/18] dbtr: Add consistent range checks to trigger ecalls Nicholas Piggin
2026-03-20 12:46   ` Ilya Mamay
2026-04-24  1:37     ` Nicholas Piggin
2026-04-07  5:22   ` Himanshu Chauhan
2026-03-13  5:19 ` [PATCH 02/18] dbtr: Trigger update should set sbiret.value on failure Nicholas Piggin
2026-05-04 15:00   ` Himanshu Chauhan
2026-03-13  5:19 ` [PATCH 03/18] dbtr: Fix endian conversion in trigger install handler Nicholas Piggin
2026-05-04 15:03   ` Himanshu Chauhan
2026-03-13  5:19 ` [PATCH 04/18] dbtr: Return correct error on install not supported Nicholas Piggin
2026-05-04 15:10   ` Himanshu Chauhan
2026-03-13  5:19 ` [PATCH 05/18] dbtr: Do not support chain bit Nicholas Piggin
2026-05-04 15:15   ` Himanshu Chauhan
2026-05-26  4:35     ` Nicholas Piggin
2026-03-13  5:19 ` [PATCH 06/18] dbtr: Improve trigger update error checking Nicholas Piggin
2026-05-04 15:23   ` Himanshu Chauhan
2026-05-26  4:38     ` Nicholas Piggin [this message]
2026-03-13  5:19 ` [PATCH 07/18] dbtr: Check for invalid and unsupported triggers in update Nicholas Piggin
2026-03-13  5:19 ` [PATCH 08/18] dbtr: Improve error handling for trigger enable, disable, uninstall Nicholas Piggin
2026-03-13  5:19 ` [PATCH 09/18] dbtr: Read triggers should not read HW trigger if not mapped Nicholas Piggin
2026-03-13  5:19 ` [PATCH 10/18] dbtr: Avoid crash in sbi_debug_read_triggers Nicholas Piggin
2026-03-13  5:19 ` [PATCH 11/18] dbtr: Succeed operations with no triggers in mask Nicholas Piggin
2026-03-13  5:19 ` [PATCH 12/18] dbtr: Move hardware trigger probing to a function Nicholas Piggin
2026-03-13  5:19 ` [PATCH 13/18] dbtr: Rework install and update error handling Nicholas Piggin
2026-03-13  5:19 ` [PATCH 14/18] dbtr: Decouple dbtr trigger index from hardware trigger number Nicholas Piggin
2026-03-13  5:19 ` [PATCH 15/18] dbtr: Move trigger feature support test into a function Nicholas Piggin
2026-03-13  5:19 ` [PATCH 16/18] dbtr: Heterogeneous trigger type support Nicholas Piggin
2026-03-13  5:19 ` [PATCH 17/18] dbtr: Heterogeneous access type matching for mcontrol triggers Nicholas Piggin
2026-03-13  5:19 ` [PATCH 18/18] dbtr: Work around specification bug in range checks Nicholas Piggin

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=ahUjIlb-fwx_rtP2@lima-default \
    --to=npiggin@gmail.com \
    --cc=hchauhan@ventanamicro.com \
    --cc=himanshu.chauhan@oss.qualcomm.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.