lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1225B7DD-BF29-4091-A956-FC312679E9BE@zytor.com>
Date: Thu, 24 Jul 2025 18:00:58 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: Oleg Nesterov <oleg@...hat.com>,
        David Laight <david.laight.linux@...il.com>
CC: Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "Li,Rongqing" <lirongqing@...du.com>,
        Steven Rostedt <rostedt@...dmis.org>, linux-kernel@...r.kernel.org,
        x86@...nel.org
Subject: Re: [PATCH] x86/math64: handle #DE in mul_u64_u64_div_u64()

On July 24, 2025 4:14:26 AM PDT, Oleg Nesterov <oleg@...hat.com> wrote:
>Finally. If we really want to optimize this function as much as possible,
>we can add the CONFIG_CC_HAS_ASM_GOTO_OUTPUT version as Peter suggests.
>I guess this should work:
>
>	u64 test(u64 a, u64 mul, u64 div)
>	{
>		u64 q;
>
>		asm goto ("mulq %2; 1: divq %3\n"
>			_ASM_EXTABLE(1b, %l[fail])
>			: "=a" (q)
>			: "a" (a), "rm" (mul), "rm" (div)
>			: "rdx"
>			: fail);
>
>		return q;
>	fail:
>		// BUG? WARN?
>		return -1ul;
>	}
>
>I agree with everything ;)
>
>Oleg.
>
>On 07/24, Oleg Nesterov 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@...hat.com> 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.
>>
>> 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;
>> +
>>  	regs->ip = ex_fixup_addr(e);
>>  	return true;
>>  }
>

Seems good to me.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ