[PATCH v11 0/8] lib and lib/cmdline enhancements

Dmitry Antipov posted 8 patches 5 days, 7 hours ago
arch/riscv/Kconfig                      |   3 -
arch/riscv/include/asm/asm-prototypes.h |   4 +
arch/riscv/kernel/image-vars.h          |   9 ++
arch/riscv/lib/Makefile                 |   1 +
arch/riscv/lib/ashldi3.S                |  36 +++++
arch/riscv/lib/ashrdi3.S                |  36 +++++
arch/riscv/lib/lshrdi3.S                |  36 +++++
drivers/firmware/efi/libstub/Makefile   |   3 +-
lib/Kconfig.debug                       |  10 ++
lib/cmdline.c                           |  30 ++--
lib/kstrtox.c                           |  37 +++--
lib/test-kstrtox.c                      |   6 +
lib/tests/Makefile                      |   1 +
lib/tests/cmdline_kunit.c               |  56 ++++++++
lib/tests/shdi3_kunit.c                 | 175 ++++++++++++++++++++++++
15 files changed, 414 insertions(+), 29 deletions(-)
create mode 100644 arch/riscv/lib/ashldi3.S
create mode 100644 arch/riscv/lib/ashrdi3.S
create mode 100644 arch/riscv/lib/lshrdi3.S
create mode 100644 lib/tests/shdi3_kunit.c
[PATCH v11 0/8] lib and lib/cmdline enhancements
Posted by Dmitry Antipov 5 days, 7 hours ago
This series is a merge of the recently posted [1] and [2]. The first
one is intended to adjust '_parse_integer_limit()' and 'memparse()' to
not ignore overflows, extend string to 64-bit integer conversion tests,
add KUnit-based test for 'memparse()' and fix kernel-doc glitches found
in lib/cmdline.c. The second one was originated from RISCV-specific
build fixes needed to integrate the former and now aims to provide
platform-specific double-word shifts and corresponding KUnit test.

This series was briefly tested on X86, RISCV32, ARM, and MIPS using QEMU,
and compile-tested for LoongArch32 as well.

Getting feedback from RISCV core maintainers would be very helpful.

Special thanks to Andy Shevchenko, Charlie Jenkins, and Andrew Morton.

[1] https://lore.kernel.org/linux-riscv/20260403103338.1122415-1-dmantipov@yandex.ru
[2] https://lore.kernel.org/linux-riscv/20260427090105.705529-1-dmantipov@yandex.ru

Dmitry Antipov (8):
  lib: fix _parse_integer_limit() to handle overflow
  lib: fix memparse() to handle overflow
  lib: add more string to 64-bit integer conversion overflow tests
  lib/cmdline_kunit: add test case for memparse()
  lib/cmdline: adjust a few comments to fix kernel-doc -Wreturn warnings
  riscv: add platform-specific double word shifts for riscv32
  lib: kunit: add tests for __ashldi3(), __ashrdi3(), and __lshrdi3()
  riscv: fix building compressed EFI image

 arch/riscv/Kconfig                      |   3 -
 arch/riscv/include/asm/asm-prototypes.h |   4 +
 arch/riscv/kernel/image-vars.h          |   9 ++
 arch/riscv/lib/Makefile                 |   1 +
 arch/riscv/lib/ashldi3.S                |  36 +++++
 arch/riscv/lib/ashrdi3.S                |  36 +++++
 arch/riscv/lib/lshrdi3.S                |  36 +++++
 drivers/firmware/efi/libstub/Makefile   |   3 +-
 lib/Kconfig.debug                       |  10 ++
 lib/cmdline.c                           |  30 ++--
 lib/kstrtox.c                           |  37 +++--
 lib/test-kstrtox.c                      |   6 +
 lib/tests/Makefile                      |   1 +
 lib/tests/cmdline_kunit.c               |  56 ++++++++
 lib/tests/shdi3_kunit.c                 | 175 ++++++++++++++++++++++++
 15 files changed, 414 insertions(+), 29 deletions(-)
 create mode 100644 arch/riscv/lib/ashldi3.S
 create mode 100644 arch/riscv/lib/ashrdi3.S
 create mode 100644 arch/riscv/lib/lshrdi3.S
 create mode 100644 lib/tests/shdi3_kunit.c

-- 
2.54.0
Re: [PATCH v11 0/8] lib and lib/cmdline enhancements
Posted by Andrew Morton 5 days, 6 hours ago
On Tue, 19 May 2026 20:22:51 +0300 Dmitry Antipov <dmantipov@yandex.ru> wrote:

> This series is a merge of the recently posted [1] and [2]. The first
> one is intended to adjust '_parse_integer_limit()' and 'memparse()' to
> not ignore overflows, extend string to 64-bit integer conversion tests,
> add KUnit-based test for 'memparse()' and fix kernel-doc glitches found
> in lib/cmdline.c. The second one was originated from RISCV-specific
> build fixes needed to integrate the former and now aims to provide
> platform-specific double-word shifts and corresponding KUnit test.
> 
> This series was briefly tested on X86, RISCV32, ARM, and MIPS using QEMU,
> and compile-tested for LoongArch32 as well.
> 
> Getting feedback from RISCV core maintainers would be very helpful.
> 
> Special thanks to Andy Shevchenko, Charlie Jenkins, and Andrew Morton.
> 
> [1] https://lore.kernel.org/linux-riscv/20260403103338.1122415-1-dmantipov@yandex.ru
> [2] https://lore.kernel.org/linux-riscv/20260427090105.705529-1-dmantipov@yandex.ru

Thanks.  I updated mm.git's mm-nonmm-unstable branch to this version.

Below is how v11 altered mm.git.  Please note that it's conventional to
changelog the updates in the [0/N].  I see it there in the [6/8] and
[7/8] changelogs:

v11: add prototypes to arch/riscv/include/asm/asm-prototypes.h (Sashiko)
v11: explicitly depends on arm/xtensa/microblaze or 32-bit riscv/sparc (Sashiko)


 arch/riscv/include/asm/asm-prototypes.h |    4 ++++
 lib/Kconfig.debug                       |    2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

--- a/arch/riscv/include/asm/asm-prototypes.h~b
+++ a/arch/riscv/include/asm/asm-prototypes.h
@@ -5,6 +5,10 @@
 #include <linux/ftrace.h>
 #include <asm-generic/asm-prototypes.h>
 
+long long __lshrdi3(long long a, int b);
+long long __ashrdi3(long long a, int b);
+long long __ashldi3(long long a, int b);
+
 long long __lshrti3(long long a, int b);
 long long __ashrti3(long long a, int b);
 long long __ashlti3(long long a, int b);
--- a/lib/Kconfig.debug~b
+++ a/lib/Kconfig.debug
@@ -2974,7 +2974,7 @@ config BITS_TEST
 config SHDI3_KUNIT_TEST
 	tristate "KUnit test for __ashldi3(), __ashrdi3(), and __lshrdi3()"
 	depends on KUNIT
-	depends on (32BIT || ARM)
+	depends on ARM || XTENSA || MICROBLAZE || ((RISCV || SPARC) && !64BIT)
 	help
 	  This builds the unit test for __ashldi3(), __ashrdi3(), and
 	  __lshrdi3() helper functions used to implement 64-bit arithmetic
_