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: <CAAhV-H76ty7nkMffbgTgH-ByBdVc-HsST87ghubTDEWZUhmLuQ@mail.gmail.com>
Date:   Sun, 28 Aug 2022 22:15:54 +0800
From:   Huacai Chen <chenhuacai@...nel.org>
To:     Xi Ruoyao <xry111@...111.site>
Cc:     loongarch@...ts.linux.dev, LKML <linux-kernel@...r.kernel.org>,
        WANG Xuerui <kernel@...0n.name>,
        Youling Tang <tangyouling@...ngson.cn>,
        Jinyang He <hejinyang@...ngson.cn>
Subject: Re: [PATCH 6/8] LoongArch: Use model("extreme") attribute for per-CPU
 variables in module if CONFIG_CC_HAS_EXPLICIT_RELOCS

Hi, Ruoyao,

On Sun, Aug 28, 2022 at 1:56 AM Xi Ruoyao <xry111@...111.site> wrote:
>
> On LoongArch, The "address" of a per-CPU variable symbol is actually an
> offset from $r21.  The value is nearing the loading address of main
> kernel image, but far from the address of modules.  We need to tell the
> compiler that a PC-relative addressing with 32-bit offset is not
> sufficient for local per-CPU variables.
>
> After some discussion with GCC maintainers, we implemented this
> attribute to indicate that a PC-relative addressing with 64-bit offset
> should be used.
>
> This attribute should be available in GCC 13 release.  Some early GCC 13
> snapshots may support -mexplicit-relocs but lack this attribute, we
> simply reject them.
>
> Link: https://gcc.gnu.org/r13-2199
> Signed-off-by: Xi Ruoyao <xry111@...111.site>
> ---
>  arch/loongarch/include/asm/percpu.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/arch/loongarch/include/asm/percpu.h b/arch/loongarch/include/asm/percpu.h
> index 0bd6b0110198..91d4026b074e 100644
> --- a/arch/loongarch/include/asm/percpu.h
> +++ b/arch/loongarch/include/asm/percpu.h
> @@ -8,6 +8,19 @@
>  #include <asm/cmpxchg.h>
>  #include <asm/loongarch.h>
>
> +#if defined(MODULE) && defined(CONFIG_CC_HAS_EXPLICIT_RELOCS)
> +# if __has_attribute(model)
> +/* The "address" (in fact, offset from $r21) of a per-CPU variable is close
> + * to the load address of main kernel image, but far from where the modules are
> + * loaded.  Tell the compiler this fact.
> + */
> +#  define PER_CPU_ATTRIBUTES __attribute__((model("extreme")))
> +# else /* __has_attribute(model) */
> +/* This should only happen with early GCC 13 snapshots. */
Can we judge this case in Makefile to quit earlier and make code simpler here?


Huacai

> +#  error "Compiler with explicit relocs but no model attribute is not supported"
> +# endif /* __has_attribute(model) */
> +#endif
> +
>  /* Use r21 for fast access */
>  register unsigned long __my_cpu_offset __asm__("$r21");
>
> --
> 2.37.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ