linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: linux-crypto@vger.kernel.org,
	"Jason A . Donenfeld" <Jason@zx2c4.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Arnd Bergmann <arnd@arndb.de>,
	Martin Willi <martin@strongswan.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	Eric Biggers <ebiggers@google.com>,
	Samuel Neves <sneves@dei.uc.pt>, Will Deacon <will@kernel.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Andy Lutomirski <luto@kernel.org>, Marc Zyngier <maz@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 09/20] int128: move __uint128_t compiler test to Kconfig
Date: Mon, 30 Sep 2019 20:00:53 +0900	[thread overview]
Message-ID: <CAK7LNARxeskbf2g9YWxD9MvMdfmFjEu2uQXQiC0AansUOmij0A@mail.gmail.com> (raw)
In-Reply-To: <20190929173850.26055-10-ard.biesheuvel@linaro.org>

On Mon, Sep 30, 2019 at 2:41 AM Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
>
> In order to use 128-bit integer arithmetic in C code, the architecture
> needs to have declared support for it by setting ARCH_SUPPORTS_INT128,
> and it requires a version of the toolchain that supports this at build
> time. This is why all existing tests for ARCH_SUPPORTS_INT128 also test
> whether __SIZEOF_INT128__ is defined, since this is only the case for
> compilers that can support 128-bit integers.
>
> Let's fold this additional test into the Kconfig declaration of
> ARCH_SUPPORTS_INT128 so that we can also use the symbol in Makefiles,
> e.g., to decide whether a certain object needs to be included in the
> first place.
>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


Do you still need CONFIG_ARCH_SUPPORTS_INT128 ?

I do not know which part in lib/ubsan.c or crypto/ecc.c
is arch-dependent...





> ---
>  arch/arm64/Kconfig | 2 +-
>  arch/riscv/Kconfig | 2 +-
>  arch/x86/Kconfig   | 2 +-
>  crypto/ecc.c       | 2 +-
>  init/Kconfig       | 4 ++++
>  lib/ubsan.c        | 2 +-
>  lib/ubsan.h        | 2 +-
>  7 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 3adcec05b1f6..a0f764e2f299 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -69,7 +69,7 @@ config ARM64
>         select ARCH_USE_QUEUED_SPINLOCKS
>         select ARCH_SUPPORTS_MEMORY_FAILURE
>         select ARCH_SUPPORTS_ATOMIC_RMW
> -       select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 || CC_IS_CLANG
> +       select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && (GCC_VERSION >= 50000 || CC_IS_CLANG)
>         select ARCH_SUPPORTS_NUMA_BALANCING
>         select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT
>         select ARCH_WANT_FRAME_POINTERS
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 59a4727ecd6c..99be78ac7b33 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -127,7 +127,7 @@ config ARCH_RV32I
>  config ARCH_RV64I
>         bool "RV64I"
>         select 64BIT
> -       select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000
> +       select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000
>         select HAVE_FUNCTION_TRACER
>         select HAVE_FUNCTION_GRAPH_TRACER
>         select HAVE_FTRACE_MCOUNT_RECORD
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 222855cc0158..97f74a2e1cf3 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -24,7 +24,7 @@ config X86_64
>         depends on 64BIT
>         # Options that are inherently 64-bit kernel only:
>         select ARCH_HAS_GIGANTIC_PAGE
> -       select ARCH_SUPPORTS_INT128
> +       select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
>         select ARCH_USE_CMPXCHG_LOCKREF
>         select HAVE_ARCH_SOFT_DIRTY
>         select MODULES_USE_ELF_RELA
> diff --git a/crypto/ecc.c b/crypto/ecc.c
> index dfe114bc0c4a..6e6aab6c987c 100644
> --- a/crypto/ecc.c
> +++ b/crypto/ecc.c
> @@ -336,7 +336,7 @@ static u64 vli_usub(u64 *result, const u64 *left, u64 right,
>  static uint128_t mul_64_64(u64 left, u64 right)
>  {
>         uint128_t result;
> -#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
> +#if defined(CONFIG_ARCH_SUPPORTS_INT128)
>         unsigned __int128 m = (unsigned __int128)left * right;
>
>         result.m_low  = m;
> diff --git a/init/Kconfig b/init/Kconfig
> index bd7d650d4a99..f5566a985b9e 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -780,6 +780,10 @@ config ARCH_SUPPORTS_NUMA_BALANCING
>  config ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
>         bool
>
> +config CC_HAS_INT128
> +       def_bool y
> +       depends on !$(cc-option,-D__SIZEOF_INT128__=0)
> +
>  #
>  # For architectures that know their GCC __int128 support is sound
>  #
> diff --git a/lib/ubsan.c b/lib/ubsan.c
> index e7d31735950d..b652cc14dd60 100644
> --- a/lib/ubsan.c
> +++ b/lib/ubsan.c
> @@ -119,7 +119,7 @@ static void val_to_string(char *str, size_t size, struct type_descriptor *type,
>  {
>         if (type_is_int(type)) {
>                 if (type_bit_width(type) == 128) {
> -#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
> +#if defined(CONFIG_ARCH_SUPPORTS_INT128)
>                         u_max val = get_unsigned_val(type, value);
>
>                         scnprintf(str, size, "0x%08x%08x%08x%08x",
> diff --git a/lib/ubsan.h b/lib/ubsan.h
> index b8fa83864467..7b56c09473a9 100644
> --- a/lib/ubsan.h
> +++ b/lib/ubsan.h
> @@ -78,7 +78,7 @@ struct invalid_value_data {
>         struct type_descriptor *type;
>  };
>
> -#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
> +#if defined(CONFIG_ARCH_SUPPORTS_INT128)
>  typedef __int128 s_max;
>  typedef unsigned __int128 u_max;
>  #else
> --
> 2.17.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2019-09-30 11:01 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-29 17:38 [RFC PATCH 00/20] crypto: wireguard with crypto API library interface Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 01/20] crypto: chacha - move existing library code into lib/crypto Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 02/20] crypto: x86/chacha - expose SIMD ChaCha routine as library function Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 03/20] crypto: arm64/chacha - expose arm64 " Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 04/20] crypto: arm/chacha - expose ARM " Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 05/20] crypto: poly1305 - move into lib/crypto and refactor into library Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 06/20] crypto: x86/poly1305 - expose existing driver as poly1305 library Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 07/20] crypto: arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 08/20] crypto: arm/poly1305 " Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 09/20] int128: move __uint128_t compiler test to Kconfig Ard Biesheuvel
2019-09-30 11:00   ` Masahiro Yamada [this message]
2019-09-30 11:49     ` Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 10/20] crypto: BLAKE2s - generic C library implementation and selftest Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 11/20] crypto: BLAKE2s - x86_64 implementation Ard Biesheuvel
2019-09-30  2:42   ` Jason A. Donenfeld
2019-09-30  2:51     ` Linus Torvalds
2019-09-30  7:35     ` Sebastian Siewior
2019-09-29 17:38 ` [RFC PATCH 12/20] crypto: Curve25519 - generic C library implementations and selftest Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 13/20] crypto: Curve25519 - x86_64 library implementation Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 14/20] crypto: arm - import Bernstein and Schwabe's Curve25519 ARM implementation Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 15/20] crypto: arm/Curve25519 - wire up NEON implementation Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 16/20] crypto: chacha20poly1305 - import construction and selftest from Zinc Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 17/20] crypto: lib/chacha20poly1305 - reimplement crypt_from_sg() routine Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 18/20] net: WireGuard secure network tunnel Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 19/20] netlink: use new strict length types in policy for 5.2 Ard Biesheuvel
2019-09-29 17:38 ` [RFC PATCH 20/20] wg switch to lib/crypto algos Ard Biesheuvel
2019-09-30 11:51 ` [RFC PATCH 00/20] crypto: wireguard with crypto API library interface Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7LNARxeskbf2g9YWxD9MvMdfmFjEu2uQXQiC0AansUOmij0A@mail.gmail.com \
    --to=yamada.masahiro@socionext.com \
    --cc=Jason@zx2c4.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=martin@strongswan.org \
    --cc=maz@kernel.org \
    --cc=sneves@dei.uc.pt \
    --cc=torvalds@linux-foundation.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).