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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b1617fe221f137b49b9a2ba9c864e6b85f89de81.camel@xry111.site>
Date:   Fri, 04 Aug 2023 23:56:07 +0800
From:   Xi Ruoyao <xry111@...111.site>
To:     Nick Desaulniers <ndesaulniers@...gle.com>,
        Huacai Chen <chenhuacai@...nel.org>
Cc:     WANG Xuerui <kernel@...0n.name>,
        Nathan Chancellor <nathan@...nel.org>,
        loongarch@...ts.linux.dev, llvm@...ts.linux.dev,
        linux-kernel@...r.kernel.org, WANG Xuerui <git@...0n.name>
Subject: Re: [PATCH] LoongArch: Drop -ffreestanding from CFLAGS

On Fri, 2023-08-04 at 08:46 -0700, Nick Desaulniers wrote:
> > Not all processors support unaligned access, so we need the
> > alternative mechanism to select memset/memcpy/memmove implementations.
> > If remove -ffreestanding, the builtin implementation cannot be used on
> > all hardware.
> 
> That sounds like a compiler bug in that compiler's implementation of
> string.h builtins then; it should default to the safest implementation
> (aligned accesses) until instructed otherwise.  Have you filed a bug
> against your compiler vendor for which compiler you observe that
> behavior from?

AFAIK there is no such bug in GCC.

But GCC indeed has a bug about builtin expansion: it generates really
stupid code for __builtin_memcpy and friends.  See
https://gcc.gnu.org/PR109465.  The bug is fixed for GCC 14, but GCC 14
won't be released soon.

> At the very least, there should be a comment above the addition of
> -ffreestanding justifying why it's being used, probably with a link to
> the above bug report.
> 
> I would expect either -mcpu or perhaps some other -m flag to guide the
> compiler when it is safe to emit memcpy (and friends) in terms of
> unaligned access or not.

It's controlled by -m{no-,}strict-align.  LoongArch kernel defaults to -
mstrict-align, with this the compiler should not generate unaligned
access.  -mno-strict-align is hidden behind CONFIG_EXPERT (FWIW I
personally dislike the decision to hide it).

-- 
Xi Ruoyao <xry111@...111.site>
School of Aerospace Science and Technology, Xidian University

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ