Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1819019ybn; Thu, 26 Sep 2019 02:42:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIh5CyrvJmmYtmnZJBQ4SgeBFvjRusyo3Z3IRkrzr9n8ajo1xKbsKxBDFr3Z8BT/ROxw8y X-Received: by 2002:aa7:d9d5:: with SMTP id v21mr2509672eds.106.1569490927089; Thu, 26 Sep 2019 02:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569490927; cv=none; d=google.com; s=arc-20160816; b=PtdfbBeMa2PG2bqqLuc32gAKaZFqoTwoQBSFFhjv7waRSMWnNoOLpJtq7SRQsWG11/ mNRKOROBoUJ7FDkGUdO+lPKU6ECsdJ9OCmRkX5+8iZj3Rog1NTlOOOPp/p4q0LzzgYJP yZF8z2g/V3qzVTcBWHzkUV37joqPG4K+4lc394G5yZG4TI8DNLqF30oHuD1ft+ikOQkJ wcVWlDa7V+K83VyhHHYhuF3vp1aKyTljIaZj7wF8hMSe74Veiup+zODtP3HLkDrIMeRl rfWwijqX82FLu4w12dk6tZs5j2+2pDx0s0pgg6a0Q3fFncsV+HDcxwwnxiO5EoIIIwwM jIyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GHZTUsgGCCxhaUqhh6GFmynzyGA2xAGilsSBrwWL8Ec=; b=z9EtOl8piFbMACZHvuSO4YUp2gt96ckrPR+kLyk6Mhx5OovbthUkMFb6SAqVuzHsZV VBErXo75H8CPYlOtdYqKAM7f2TOb1KywdSKP+24mnOTnho/H7RRUhQXcFAgSkJY4Xhm6 wteRdRMaXpBqgoJFVIUjaOYBMBEchAPYjbgaYi1HoPOoXvMDSo9lQ2KpbtuOwdLVP46m c8kclfVQPI5G9gXgIXiLOCS2F//1X3uWO1lMIISB26CpN7IW9G/80b4ftC63BdXC65aE Mrg1U8+zTPJBnJWY3qGpa7aYzKO9ojHSv8aHCZFwlGFAUHjLPqZEbk6QFvcixn4CXshH EH9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EZelB1bm; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7si1012106edm.74.2019.09.26.02.41.42; Thu, 26 Sep 2019 02:42:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EZelB1bm; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387965AbfIYQOF (ORCPT + 99 others); Wed, 25 Sep 2019 12:14:05 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33312 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388050AbfIYQOF (ORCPT ); Wed, 25 Sep 2019 12:14:05 -0400 Received: by mail-wr1-f68.google.com with SMTP id b9so7650017wrs.0 for ; Wed, 25 Sep 2019 09:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GHZTUsgGCCxhaUqhh6GFmynzyGA2xAGilsSBrwWL8Ec=; b=EZelB1bmBbVqkj69RFWzhZDiyl+QrRS1Ld/4jAK9o8wa+U3Y4C9KupSUIqj2czhl7k ITiHGURXEqXrMJmGJNB9KMIUGwxFnx7bIhXwPlyP3otwQoRuaqODihXzE3AhyE+SuMOe Eupyf7hjZZlON1Utlzp/RmQMPvLJn2rjU8LmbXlYIzGZ+eXKz+3lmREZnr2u+zWgdOnC DnAE1RwkIUI90BBXqLfP2SQt/xl177ryb9XkpwBkxrUMcHJChPVU9vFbBntefNklJgCR eMbWcs4UmklFy7RjjpAUH6gGYaPbUv9a9jmIlTOejjFpzVISicNuFbq7E+U5L0HF88Yg IqzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GHZTUsgGCCxhaUqhh6GFmynzyGA2xAGilsSBrwWL8Ec=; b=PKJYWQnQKCXS+nktF7hzgWv9njLa5LaL6/EbqUeXVmnkEWgPwqaKCu1iUx6gedbxM4 BTQGpyWgosStPi723MzNUmb92YlztxwLYjNwzTidojMDo1wVcZOv3MKFJibDyqxmSwzZ AlNj4oHWkvqmgSaDipgLvb1AJD4rC5GHktoawJz+uNZrcg19pcTLGDOz8nfGpgKicgkU yODFHDZFrEmzBIIesODAmq/k4SQzWsSFYUxu7u0Vx5+8ZhjWB2vahzNf1M2O3Xvf/jIV OjP8lmbjK8g+5b6yr4yhOmVFTMgx7ziOlmO8MHmNol0DIP9IKemnCAycbcZ/RBWW1Hal Jthg== X-Gm-Message-State: APjAAAWIojzUrjU1etvZ4CBJDRTAJW+8o4EflYwyGtkoAET9mZ1jG1qx J80H3JyH8PjPAwTfYXZXlo1SAIOoQBGK3BEJ X-Received: by 2002:a5d:62c6:: with SMTP id o6mr9945348wrv.243.1569428043029; Wed, 25 Sep 2019 09:14:03 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id o70sm4991085wme.29.2019.09.25.09.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 09:14:02 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Herbert Xu , David Miller , Greg KH , Linus Torvalds , "Jason A . Donenfeld" , Samuel Neves , Dan Carpenter , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Will Deacon , Marc Zyngier , Catalin Marinas Subject: [RFC PATCH 11/18] int128: move __uint128_t compiler test to Kconfig Date: Wed, 25 Sep 2019 18:12:48 +0200 Message-Id: <20190925161255.1871-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190925161255.1871-1-ard.biesheuvel@linaro.org> References: <20190925161255.1871-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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. Signed-off-by: Ard Biesheuvel --- crypto/ecc.c | 2 +- init/Kconfig | 1 + lib/ubsan.c | 2 +- lib/ubsan.h | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) 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..e66f64a26d7d 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -785,6 +785,7 @@ config ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH # config ARCH_SUPPORTS_INT128 bool + depends on !$(cc-option,-D__SIZEOF_INT128__=0) # For architectures that (ab)use NUMA to represent different memory regions # all cpu-local but of different latencies, such as SuperH. 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.20.1