From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2B1C30BF52 for ; Sun, 26 Apr 2026 22:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777241053; cv=none; b=QR5NuiLUQAX6rnrlvDXn71npqVsCN+wnrajl36LjhJ3Kcj1qKMWWouk/JYLoYHpjpUF8zEAq708yIppUDa/SdCiKQtCKeZ5Z1LGk+fHqH1TGoatwAnkoBExBAopC2oqmZye2cp1W8VMbHPo1MsNziqZTjkd4n5KJdZYw9UaqIhE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777241053; c=relaxed/simple; bh=bchPTyFZ9H1PCbGJT7Y+DuDtB6LGefR0py0MYE/4h2I=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EswaSzsqMFHpz5AhGnQ+cyEo40dMh4exa8ENvy+yA5Hp6NcrrdteBYXNnEH5DZkc8f2SNekuffNR8yQcrZyuf8p9HQrYPxbxLgZDPrPANBVxZsLJ44zyJr3kPsYQ6zV/72H0ULX2QNP3oyRUFzbxL5hPxRi2NM353fCvoXYf5kI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZYX3tGe9; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZYX3tGe9" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4891f625344so84330225e9.0 for ; Sun, 26 Apr 2026 15:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777241050; x=1777845850; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=TOSUyfe/TldkyeaDzXd5HdT1X+MuNFQMhpVSGu+NHxw=; b=ZYX3tGe9yoe1nOTlatjRQOQc61ib2Tm7S+GZGqjBRtWe95krlLqihRJLAnw55Z20Gj fYOUqBLpNt9/rx96m/8jaGHe0uGf2j6QOR3g5PORyWAuKv8Ujh39LUCy5va7LUWmV2GC agB0bUO11Mx/D3ScJlsYEqvGfu7JH9ZgqD2bC7nPGEmKfac/uIqu7J5xVd7IDqzfpU0S PhpvDFg06y1L8eqdkre4eam/hRzVIEi/nc5dtS5WvqiqxESXnZW5AUdtfjL0poJ5x5HC smTDPldQEIoJe9L8ESElcy2drGo5jbQ0dZ1GYsEuolSFImlEhiaJpjVzbp/75MfQzrGO rKoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777241050; x=1777845850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TOSUyfe/TldkyeaDzXd5HdT1X+MuNFQMhpVSGu+NHxw=; b=YOmkYarvJoEHiGOUUrxs9Neeozu1ouDS/GITmJWMAFBRfX2vbOYB1SUdQ24jvA+PXp tzQnL1x55d8KuPGr5DHwat4oU4DdF33vX30A50DfGSx1VDi/8ttWKP6d8IxghgRrnBql IBe07XBLOewoMCkaoU09hBUhmDLVQzIZ1LcVV7L3oWtlU8FxOGAzOXfDPDhMNZRT423p vsYK5ajd043VQMrHTS+R6K/PwIDdpghpDEyE7gZhEtiiy9iVbp5gqgld7ll46x+oDwZN 1T1MPQRQRCZg/kILLVnzxLLIKMyElQJQ8xI51pBI6jFJQ0GR3BFmkeUpEyJgHO73HcV4 zTOw== X-Forwarded-Encrypted: i=1; AFNElJ/5KEpEkXn9gKFchU9ARX7Vrm09y2SAhdp6s70+kx0PodLPBRJEmpYH5ZUP2CohWaM74W0fMXAWnzhtHxEFVg==@vger.kernel.org X-Gm-Message-State: AOJu0YwuhsZNpW/qKwbmrPUWowP2Y85Kvp0MpuhwMNbdyWwyUTGkn5h0 sGH3U4sRj5+jqqZZ10unx7jALV2Hl7ru+YKyTxZVHTULCW95zlgCLr+k X-Gm-Gg: AeBDiesC+5lcwltJ+XoEvWJsouxREwdyKhcJapAPrfHdHvM04S7jbcmyEiNjBzuQELx wyLmYh0brM/uoS101w90RSCVH03cfr1/JEp8HZO9+za+lTXRgslb5V/C3meNn/Lu3/pv3fWCPSK PWLtWwcBOqo0ChnpwmvLehxuG2zFOKxKwD+8qJ7LZvUYJM4lVqTMoL0QJqon1aL5goB3CRWTxME OsVKZPoMBeQ3vMxvYpXEBbLDoRX2GzDypRv6xeMd8ofQ6z5Ovqmcsd06MZNqZi1Ya7Y0kg30TsT GHIitcQ9mhI4W9kX9jLzb5obLvhzUCon6hCM2cCz0LN8G9+i3aZGC1ygIzMRBISsDOe+yBEilCs tbXBhB4P0hEQ/RdmS9sCMf4/d65lrJytn6zt2paFErWJWZRFaAGk0b2tOWTdP0HvWT7zgi+55pu fp1dKMBMeR0DZEzW0MGBb2SzEl3NfvUHMlPvLHlzJvOi1l0ktUmJL0Wqf0cP2GYM86Qv77VLuGD Fs= X-Received: by 2002:a05:600c:3150:b0:485:3cef:d6ea with SMTP id 5b1f17b1804b1-488fb8b9debmr118860245e9.13.1777241050182; Sun, 26 Apr 2026 15:04:10 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a55743c06sm137051075e9.2.2026.04.26.15.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 15:04:09 -0700 (PDT) Date: Sun, 26 Apr 2026 23:04:08 +0100 From: David Laight To: "Gary Guo" Cc: "Mukesh Kumar Chaurasiya" , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , "Link Mauve" Subject: Re: [PATCH V13 5/7] rust: Make __udivdi3() and __umoddi3() panic Message-ID: <20260426230408.489c68c3@pumpkin> In-Reply-To: References: <20260424054742.45832-1-mkchauras@gmail.com> <20260424054742.45832-6-mkchauras@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sun, 26 Apr 2026 15:20:31 +0100 "Gary Guo" wrote: > On Sun Apr 26, 2026 at 8:52 AM BST, Mukesh Kumar Chaurasiya wrote: > > On Fri, Apr 24, 2026 at 01:43:43PM +0100, Gary Guo wrote: =20 > >> On Fri Apr 24, 2026 at 6:47 AM BST, Mukesh Kumar Chaurasiya (IBM) wrot= e: =20 > >> > From: Link Mauve > >> > > >> > The core crate currently depends on these two functions for i64/u64/ > >> > i128/u128/core::time::Duration formatting, but we shouldn=E2=80=99t = use that in > >> > the kernel so let=E2=80=99s panic if they are ever called. > >> > > >> > This doesn=E2=80=99t yet fix drm_panic_qr.rs, which also uses __udiv= di3 when > >> > CONFIG_CC_OPTIMIZE_FOR_SIZE=3Dy, but at least makes the rest of the = kernel > >> > build on PPC32. =20 > >>=20 > >> Can we always build libcore with `-C opt-level=3D2` even if > >> `CONFIG_CC_OPTIMIZE_FOR_SIZE` is specified? It feels like a better fix= than > >> stubbing things out. > >>=20 > >> Best, > >> Gary > >> =20 > > The issue is not coming from libcore itself. It's the driver that's > > causing this. =20 >=20 > Sorry. I quoted the wrong part. I was asking if compiling libcore with O2= gets > rid of its use of the builtins, as that's what the change this commit is = for. >=20 > Formatting of u64 will be needed, so we should make sure that these works= as > intended. This code (from nolibc) will convert u64 to ascii in any base: #define _U64TOA_RECIP(base) ((base) & 1 ? ~0ull / (base) : (1ull << 63) / (= (base) / 2)) static int _u64toa_base(u64 in, char *buffer, unsigned int base, u64 recip) { unsigned int digits =3D 0; unsigned int dig; u64 q; char *p; =20 /* Generate least significant digit first */ do { #if defined(__SIZEOF_INT128__) && !defined(__mips__) q =3D ((unsigned __int128)in * recip) >> 64; #else u64 p =3D (u32)in * (recip >> 32); q =3D (in >> 32) * (recip >> 32) + (p >> 32); p =3D (u32)p + (in >> 32) * (u32)recip; q +=3D p >> 32; #endif dig =3D in - q * base; /* Correct for any rounding errors */ if (dig >=3D base) { dig -=3D base; q++; } if (dig > 9) dig +=3D 'a' - '0' - 10; buffer[digits++] =3D '0' + dig; } while ((in =3D q)); =20 buffer[digits] =3D 0; /* Order reverse to result */ for (p =3D buffer + digits - 1; p > buffer; buffer++, p--) { dig =3D *buffer; *buffer =3D *p; *p =3D dig; } return digits; } int u64toa_r(u64 in, char *buffer) { return _u64toa_base(in, buffer, 10, _U64TOA_RECIP(10)); } Not hard to do without any divides at all. David