From patchwork Sat Jul 16 00:16:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 12919933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A04EBC433EF for ; Sat, 16 Jul 2022 00:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:From:Subject:Mime-Version:Message-Id :Date:Reply-To:To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=aPHPazNZCF4HVDcH+HZsn35amoTBBrQcfCA/RjztXOI=; b=W1eXl8DG3rMqLJ ONV1SFMnEkr/scu5zRfq78imHpgC/p7KF7m3eyZTzcWMzRTYHN01J8q4cZEjiZFy/3jSJZlkosE6c mRPO4pT+EzMYhwbT27//qO1f0SV45HpQ9taOTaTZIeM5bX3QMy19BAov+/a1XcIIe5voDpBxNk+i2 AJY7i7S4Q15aHWjWzVBcJn0ipSxHyA+C44/pKGlrCtGw7DuZ9H+2Ru/vv4+e4mkLFvxnP58jsgEGI xf0LfWte5jdR2Vtn4uglcv34CCc11orFIiluZ4K7y0RM1e4+kKfkvzblwksfsln/IsBaph0vzxYy4 9vVVmZEo+2goHU1N0djQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCVTz-00BQCd-1e; Sat, 16 Jul 2022 00:16:31 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCVTw-00BQBn-Hi for linux-arm-kernel@lists.infradead.org; Sat, 16 Jul 2022 00:16:29 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-31c9f68d48cso50641447b3.0 for ; Fri, 15 Jul 2022 17:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:cc; bh=K1u/08k1kHvQ8RIYk0HRaqbL2NYdWoYTw1DMyhtc5Cw=; b=ho4U6QwUwXhpx81KMHiBsPWFgJd29KTWTUHZtpCpwKlYMTwBhoeXodak0kOIHbZ2ir BpGSx7gVS1PPG+NQ2aAFqq0AgMA50X8mXFaW1ql992pf9L3w8vLyF+bdZIWnGJW/YoLX AbeXy+d/mGyc7jUiCNNruhVn6Jf2pqOxbsHLu73faBNIGntKz8usvZy4DSJg/H3MKTUn JhBVt3Rq48h/YgiVHWle7KeEFSaA643KcJxCmU6VsNG8YnWxYm/mkeKg77U6RANWhbUj /xj0aGtFI6Y3ga4QKFY/czxZXcottGTH5osym5cpiBTDhHQmr1mlaIAwSvBJTThmUSRB /LNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:cc; bh=K1u/08k1kHvQ8RIYk0HRaqbL2NYdWoYTw1DMyhtc5Cw=; b=PNHyM3UN2hcKqOa/Og6p3Vf8UwW9ClBnOAae9cd8h1PJ9K5K6GLx+jvMbjhe1NoCx5 aa3HglhAJhhJG2IWJIvUaQ4ndIPfzIxe9jQd9Fe2FtM9iat5fNPAOC4nJiJKeFgMcE/H wUe497geEnyeB4vyKT2FI16NN1qwmHEX8ha17vCd1nj4IxHW7GZ800+jS2g9xP7mzfcs 8m1++YdOwmOevpD466OurI/wifV3J7kkZy7UQv+Teo10J6jO/2J3jMK/eoGXYzG6vR73 0sO4YGVv7/FQj1AEKigk3K33oictZiy14evBYGT2Ix1q5trlbk8JlprLDcblaKYvBdkJ hNbA== X-Gm-Message-State: AJIora/AcQdf8JmmZ3/cRSbU+HeWqYtSM0+y1UzAOzhEejQnjrgRIXJJ FH0aBkbU+PXWQosTO1l/gFcSzi+IY+MCwg+Wv/o= X-Google-Smtp-Source: AGRyM1sIdHPQVqAztkcQa3o63z7bs2yVKH4jL3uicRwyLHqvXlO1IHuc1+cZsIt5Hj1UM8MMx63bfZSooMS6oiNnaDU= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:a3e6:c68c:2c0c:ebf6]) (user=ndesaulniers job=sendgmr) by 2002:a5b:ecc:0:b0:66e:da0a:7736 with SMTP id a12-20020a5b0ecc000000b0066eda0a7736mr15615949ybs.587.1657930585734; Fri, 15 Jul 2022 17:16:25 -0700 (PDT) Date: Fri, 15 Jul 2022 17:16:07 -0700 Message-Id: <20220716001616.4052225-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Developer-Key: i=ndesaulniers@google.com; a=ed25519; pk=lvO/pmg+aaCb6dPhyGC1GyOCvPueDrrc8Zeso5CaGKE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1657930566; l=1743; i=ndesaulniers@google.com; s=20211004; h=from:subject; bh=QIu9o/mxb9btODsh6DZRIF2F1BpZvwkAJQhLHDs2c4Y=; b=QdWV52FzNZq1EiGz28q4F2oq+2dQcFXBgbMNZYK/TVuExNteLEHksMhp5aGDF1c1JydpYzq8AL8R O+7hwHWKAJsuMWHDosqLDtYAeYA9XElDWzKsyB0obqe7JCPyMRWB X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH] arm: lib: implement aeabi_uldivmod via div64_u64_rem From: Nick Desaulniers Cc: llvm@lists.linux.dev, Arnd Bergmann , Nathan Chancellor , Miguel Ojeda , Ard Biesheuval , Nick Desaulniers , Gary Guo , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_171628_610506_C586785F X-CRM114-Status: GOOD ( 13.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Compilers frequently need to defer 64b division to a libcall with this symbol name. It essentially is div64_u64_rem, just with a different signature. Kernel developers know to call div64_u64_rem, but compilers don't. Link: https://lore.kernel.org/lkml/20220524004156.0000790e@garyguo.net/ Suggested-by: Gary Guo Signed-off-by: Nick Desaulniers Reported-by: kernel test robot --- arch/arm/lib/Makefile | 1 + arch/arm/lib/aeabi_uldivmod.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 arch/arm/lib/aeabi_uldivmod.c diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 6d2ba454f25b..3fa273219312 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -29,6 +29,7 @@ endif obj-$(CONFIG_UACCESS_WITH_MEMCPY) += uaccess_with_memcpy.o lib-$(CONFIG_MMU) += $(mmu-y) +lib-$(CONFIG_AEABI) += aeabi_uldivmod.o ifeq ($(CONFIG_CPU_32v3),y) lib-y += io-readsw-armv3.o io-writesw-armv3.o diff --git a/arch/arm/lib/aeabi_uldivmod.c b/arch/arm/lib/aeabi_uldivmod.c new file mode 100644 index 000000000000..310427893195 --- /dev/null +++ b/arch/arm/lib/aeabi_uldivmod.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Unsigned 64b division with remainder, as is typically provided by libgcc or + * compiler-rt. + * + * Copyright (C) 2023 Google, LLC. + * + * Author: Nick Desaulniers + */ + +#include + +struct result { + u64 quot, rem; +}; + +struct result __aeabi_uldivmod(u64 numerator, u64 denominator) +{ + struct result res; + + res.quot = div64_u64_rem(numerator, denominator, &res.rem); + return res; +}