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] [day] [month] [year] [list]
Message-ID: <20250726095543.GA21780@redhat.com>
Date: Sat, 26 Jul 2025 11:55:44 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: David Laight <david.laight.linux@...il.com>
Cc: "H. Peter Anvin" <hpa@...or.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/25, David Laight wrote:
>
> On Fri, 25 Jul 2025 12:12:02 +0200
> Oleg Nesterov <oleg@...hat.com> wrote:
>
> > 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))
>
> That should be _ASM_EXTABLE_TYPE_REG() with an extra %%rax parameter.

Not at all. EX_TYPE_IMM_REG needs a simple EX_DATA_REG().

> It works because ax is register zero.

Yes, just like other users of EX_TYPE_IMM_REG which use the "default" regs->ax.
But I won't mind to add the unnecessary EX_DATA_REG(0) if you want it.


> > 			: "a" (a), "rm" (mul), "rm" (div)
>
> The "rm" should both be ASM_INPUT_RM

You have already mentioned this before, but I disagree.

I mean, this needs another patch. IIUC, this change is not needed for correctness,
and the same arch/x86/include/asm/div64.h file has a lot more "rm"'s. So that
patch should probably change them all and check the generated code with clang.

> > 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.
>
> Looking through the code in extable.[ch] there is actually scope for adding
> an extra EX_TYPE that is the same as IMM_REG but contains a WARN_ONCE().

I thought about this too. I think a new EX_FLAG_ makes more sense.

> It would be a 'global' ONCE for all such traps,

Yes, unfortunately. But lets discuss this later.

Oleg.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ