Re: [Bug report] __arch_hweight32/64 x86

From: Sebastian Sumpf
Date: Tue Jun 27 2023 - 12:57:55 EST


On 6/27/23 06:25, Borislav Petkov wrote:
On Mon, Jun 26, 2023 at 03:41:27PM -0700, Dave Hansen wrote:
I'm not even sure that UML needs GENERIC_HWEIGHT. From a quick glance,
it looks like x86 used to use GENERIC_HWEIGHT, but got arch-specific
versions later. UML just never moved over to the arch-specific versions.

Thanks - that could very well be the explanation.

That bug report made me blink a couple of times since I did take extra
precaution to not clobber regs in arch/x86/lib/hweight.S as this was
part of the whole pain back then with calling a function from asm where
gcc doesn't even know we're calling a function, see:

f5967101e9de ("x86/hweight: Get rid of the special calling convention")

I _think_ the attached patch might just fix the problems with the C
version and bring the x86/UML implementation back in line with the rest
of x86.

Thoughts?

diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig
index 186f13268401..76d507860be4 100644
--- a/arch/x86/um/Kconfig
+++ b/arch/x86/um/Kconfig
@@ -44,6 +44,3 @@ config ARCH_HAS_SC_SIGNALS
config ARCH_REUSE_HOST_VSYSCALL_AREA
def_bool !64BIT
-
-config GENERIC_HWEIGHT
- def_bool y

Yeah, we should do it. UML should not do anything different wrt calling
conventions so it should be able to handle the arch/x86/lib/hweight.S
versions just fine.

Thank you for the quick resolution! It fixes the problem for me and sorry for not explaining well enough.

Richi?


--
Sebastian Sumpf
Genode Labs

http://www.genode-labs.com · http://genode.org

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth