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: <20250725101201.GA8700@redhat.com>
Date: Fri, 25 Jul 2025 12:12:02 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: "H. Peter Anvin" <hpa@...or.com>
Cc: David Laight <david.laight.linux@...il.com>,
	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 07/24, H. Peter Anvin wrote:
>
> 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:

...

> >> 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.

...

> Seems good to me.

Thanks, but which one? "asm goto" or EX_FLAG_XXX_AX hack?

As for the latter. I took another look at asm/extable_fixup_types.h
and it turns out we don't need a new EX_FLAG_, this version

	static inline u64 mul_u64_u64_div_u64(u64 a, u64 mul, u64 div)
	{
		u64 q;

		asm ("mulq %2; 1: divq %3; 2:\n"
			_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_IMM_REG | EX_DATA_IMM(-1))
			: "=a" (q)
			: "a" (a), "rm" (mul), "rm" (div)
			: "rdx");

		return q;
	}

seems to work and I guess it is the absolute winner performance wise.

But to me the main question is: Peter, David, do we want to add
BUG and/or WARN into mul_u64_u64_div_u64??? If yes, then this version
won't work.

Oleg.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ