From patchwork Mon Aug 27 11:02:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10576959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 088F917DE for ; Mon, 27 Aug 2018 11:05:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED79929523 for ; Mon, 27 Aug 2018 11:05:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E066629741; Mon, 27 Aug 2018 11:05:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 111B529523 for ; Mon, 27 Aug 2018 11:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QxGDWR3t7/sxkQ3eHTCc8Sfu+2bG/HRKoBcLDv3HbWA=; b=lGdE7pUSDZsR/mrqd4b4JVjfTT aC/M9Z4GW0otMTim5jcOQhrikx6+Z9NLC6AGW47MWBmFArwh4+WOKHT9ZbPDTwI3Vj7ZbgYU1dssE J5u82amVT5PB5oc2XkAECA7HbjjzzMkejjTYFtClP40OZW0pmXCDkwTTvdrGJDsZoIEcyei3vIzaJ 4nWEAwDhL2hvIoHRdthxU37XrrbPI9EzWxS++9y3TVvPbiK+tO68VUwBwJyOnq5cdi7GO0V2R1n9s fNZRHhGS9ywnZPOEFFbf+XoDtlUsbsqzdsY9d6nIlYW8kdwlk20QNXQmacEr2jBbMy9so5dlE/3ny rFtyZobQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuFKD-0003aS-Fi; Mon, 27 Aug 2018 11:04:49 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuFIf-0002cT-WB for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 11:03:18 +0000 Received: by mail-ed1-x543.google.com with SMTP id h33-v6so7564116edb.5 for ; Mon, 27 Aug 2018 04:03:02 -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; bh=oAg2MIWmTiuQXPRQuCyO90mfns13N4bEQB8aeiZWMRk=; b=cG7Q1DVRhliFRC8rJwRTg+THv+BiFvRwXTWg1V/D5US8FJeQ4S8g1iZjRWiU1cB6Yg pnN/Eqx672jHY0XGP/sMDnYqgPKA+BeqiEppEibgXI/eilA6YfVG/MI3xdsKprL0hTIA Z2HFE6udh9LVAs+JAlXU8eVwDKuwVnhfdslLw= 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; bh=oAg2MIWmTiuQXPRQuCyO90mfns13N4bEQB8aeiZWMRk=; b=pahJys2Gp4nBmb3kz0FmakcG/cB8fLx4m+OuAodRQX5Qle503LIVcWX3/deg2Ho76/ 4Q9/R1oD3ks9A8++SXf/3Uc3Ojwgq69y91PFJEg8zJKoRQXwsnh8gxzKcXq3CkgVgujv BheAsyPztSdHXHXItYK0tuNi4g/CHhe65QC+q6e42HGcziToKNloKas0zvLKsIF68MLh CzOmj7Keg50XqVBWmFSK01oZHuO/pTbBs6jO9tmeHWd96yg5u87QNIx0n7V5A03VWD0y NNij7gmKzXuPIEEE0CWjGL9t81bV2ABlLjS7vSdJUZkyo/RqCpMwUYrX1hCJLja230WD PltA== X-Gm-Message-State: APzg51D7drOvJCzIzBg2QyLu/SFoLqW5Ycy9OHbsYKmX2MZRnXWc/7O9 kBXY6kaw3Z2Q8XHtz/vs/2BOfMin804xE/Fv X-Google-Smtp-Source: ANB0Vdb+9LZIseQp6Ydcf1ZGBXMYl0a9yHTImbAWDfdX7s88PcO5TleHrR877p4KMeQchjl52sLPSQ== X-Received: by 2002:a50:a38a:: with SMTP id s10-v6mr16286374edb.99.1535367781188; Mon, 27 Aug 2018 04:03:01 -0700 (PDT) Received: from rev02.home ([2a02:a212:9283:9800:24b9:e2d6:9acc:50dd]) by smtp.gmail.com with ESMTPSA id r2-v6sm3114344eda.89.2018.08.27.04.03.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 04:03:00 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org Subject: [PATCH 1/4] lib/crc32: make core crc32() routines weak so they can be overridden Date: Mon, 27 Aug 2018 13:02:42 +0200 Message-Id: <20180827110245.14812-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827110245.14812-1-ard.biesheuvel@linaro.org> References: <20180827110245.14812-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_040314_094649_BBE8E92F X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , herbert@gondor.apana.org.au, suzuki.poulose@arm.com, catalin.marinas@arm.com, ebiggers@google.com, will.deacon@arm.com, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Allow architectures to drop in accelerated CRC32 routines by making the crc32_le/__crc32c_le entry points weak, and exposing non-weak aliases for them that may be used by the accelerated versions as fallbacks in case the instructions they rely upon are not available. Signed-off-by: Ard Biesheuvel Acked-by: Herbert Xu --- lib/crc32.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/crc32.c b/lib/crc32.c index a6c9afafc8c8..45b1d67a1767 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -183,21 +183,21 @@ static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p, } #if CRC_LE_BITS == 1 -u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len) +u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len) { return crc32_le_generic(crc, p, len, NULL, CRC32_POLY_LE); } -u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) +u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len) { return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE); } #else -u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len) +u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len) { return crc32_le_generic(crc, p, len, (const u32 (*)[256])crc32table_le, CRC32_POLY_LE); } -u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) +u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len) { return crc32_le_generic(crc, p, len, (const u32 (*)[256])crc32ctable_le, CRC32C_POLY_LE); @@ -206,6 +206,9 @@ u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) EXPORT_SYMBOL(crc32_le); EXPORT_SYMBOL(__crc32c_le); +u32 crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le); +u32 __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le); + /* * This multiplies the polynomials x and y modulo the given modulus. * This follows the "little-endian" CRC convention that the lsbit