Re: [PATCH 01/14] iommu: Implement IOMMU LU FLB callbacks

From: Jason Gunthorpe

Date: Fri Apr 10 2026 - 09:51:51 EST


On Wed, Mar 11, 2026 at 09:07:00PM +0000, Pranjal Shrivastava wrote:
> > + if (!obj)
> > + return -ENOMEM;
> > +
> > + mutex_init(&obj->lock);
> > + BUG_ON(!kho_restore_folio(argp->data));
>
> The use of BUG_ON in new code is heavily discouraged [1].
> If KHO can't restore the folio for whatever reason, we can be treat it
> as a corruption of the handover data. I believe crashing the kernel for
> it would be an overkill?

There should not be any new BUG_ON's added at least they need some
better wrapper function or design so they are not in end-users like
this.

But these cases need to fail by preventing the kernel from leaving the
initial safe boot memory space (ie it is going to crash anyhow). If we
can't recover things then we can't guarentee memory is not being
scribbled on and we can't use it.

This is the general logic why these are made very fatal.

Jason