Re: [PATCH] x86/math64: handle #DE in mul_u64_u64_div_u64()
From: David Laight
Date: Thu Jul 24 2025 - 08:00:54 EST
On Thu, 24 Jul 2025 10:25:48 +0200
Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> On 07/24, Oleg Nesterov wrote:
> > On 07/23, David Laight wrote:
> > >
> > > On Wed, 23 Jul 2025 11:38:25 +0200
> > > Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> > > >
> > > > to remove the conditional branch and additional variable. Your version
> > > > is probably beterr... But this is without WARN/BUG.
> > >
> > > I wish there was a way of doing a WARN_ONCE from asm with a single instruction.
> > > Then you could put one after your 2:
> > > Otherwise is it a conditional and a load of inlined code.
> > >
> > > > So, which version do you prefer?
> > >
> > > I wish I knew :-)
> >
> > ;-)
> >
> > David, you understand this asm magic indefinitely better than me. Plus you are
> > working on the generic code. Can you send the patch which looks right to you?
> > I agree in advance with anything you do.
> >
> > I got lost. Now I don't even understand if we want to add BUG and/or WARN into
> > mul_u64_u64_div_u64().
>
> Forgot to mention... Not that I think this is a good idea, but if we don't
> use BUG/WARN, we can probably add EX_FLAG_ and do something like below.
I'd not looked there.
That is certainly best if WARN/BUG is deemed unnecessary.
(That is the type of question I'd defer to 'management'!)
>
> Oleg.
>
> --- a/arch/x86/mm/extable.c
> +++ b/arch/x86/mm/extable.c
> @@ -38,6 +38,9 @@ static bool ex_handler_default(const struct exception_table_entry *e,
> if (e->data & EX_FLAG_CLEAR_DX)
> regs->dx = 0;
>
> + if (e->data & EX_FLAG_XXX_AX)
> + regs->ax = -1ul;
That would need to set %eax to a 64bit ~0u;
I don't think the above would sign extend the value.
Makes me think - always bad.
I wonder how hard it would be to implement EX_FLAG_WARN_ONCE.
Mostly it would need a writeable bitmap with one bit for each
extable entry.
David
> +
> regs->ip = ex_fixup_addr(e);
> return true;
> }
>