From patchwork Fri Feb 20 00:19:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1903 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546787; bh=WEInh3Bo6Dfbk8qStxwpFqJULFGeLHAlMDeGOELWvFU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=OZI7kf77o+5McGGRwbUxeSjHDUR/wQKx5OGQHkOtp4FzgpbnDEVWnyPpeb3/8mwRD MjZfrvU+0HE/GjTUtWfhA1c04jhF+0mMWS5S5DcW0y0KegWClBaJG749dq4RZK6Qn0 fm0hoPZ6+PucOEpzJWv8vFQSJOxdxrLBH+Nlmc0EdawDh+mLtSAq9Ut+rJRK2QeCDk Q9j0F84abF79H1zvJ7aicrEsDbmYqOA6r41r6rCjrAN4TZstud9pIxTqW+6Z9AaLXd 89ri5YsVjTgZUBjshpLB4RXdBHQ/61ITTLe8y+q0yD4kZkXksZRyJsBDUTlywT1xOv p7oCmuvJi9Cjw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C096B69C8C for ; Thu, 19 Feb 2026 17:19:47 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id yrV0fe2HntUo for ; Thu, 19 Feb 2026 17:19:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546787; bh=WEInh3Bo6Dfbk8qStxwpFqJULFGeLHAlMDeGOELWvFU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=OZI7kf77o+5McGGRwbUxeSjHDUR/wQKx5OGQHkOtp4FzgpbnDEVWnyPpeb3/8mwRD MjZfrvU+0HE/GjTUtWfhA1c04jhF+0mMWS5S5DcW0y0KegWClBaJG749dq4RZK6Qn0 fm0hoPZ6+PucOEpzJWv8vFQSJOxdxrLBH+Nlmc0EdawDh+mLtSAq9Ut+rJRK2QeCDk Q9j0F84abF79H1zvJ7aicrEsDbmYqOA6r41r6rCjrAN4TZstud9pIxTqW+6Z9AaLXd 89ri5YsVjTgZUBjshpLB4RXdBHQ/61ITTLe8y+q0yD4kZkXksZRyJsBDUTlywT1xOv p7oCmuvJi9Cjw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ADC6E69C87 for ; Thu, 19 Feb 2026 17:19:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546785; bh=aKXhQWJZ7cjZcKkKGzaM59lVgDCUDS0w5ZdvrBvHX30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v2cMdvR68P2ZnQ6zAr6odJN8x3IuwV+IZHviHYMgJZLTd8ixxdPlZmbPiWpYg9dkO at0RYAO5q0+jlzEzN9uK8IhY59dmwUwBXr44fFeIUETh+zR0kjZQHfc3fTb30yPnhO 3xoWbGJH3UrvjW29VqEChdFcjMkjRQ5FSdm3ik0G5tzL695nWyoRRosoQBfXwVOb6u 5v90UzDotvRQUulXyR4wv4U6DDs1xIUhbNP9wq4UzBdcdBpCc4003etPAlHZLJH7AO UfHyi/zmMnz7UGsno7IrZDmgJ8V1FHf/PSfQTbFvjmxfEuApy77pau0akA+F2PQwNZ kD0WOmN4m/7JA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E113369C85; Thu, 19 Feb 2026 17:19:45 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id C38HqHP8Nrxk; Thu, 19 Feb 2026 17:19:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546781; bh=E8W3Yn7n+LNSC66eTDRyzUcPV3pFPptvj+UKr8zW1/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u6yBeHmAgus1hBlnFUGHwDhiJ1ksns5Vks+wtljs4uGAQ2nmRIeibV1fpUoaN5Epb IjVrCZa284F8+zgMNTF6zqH/Cn1kHvjxKplKuas39f+bwpywryLXPmUPuXqDWAVKD8 PshqA+GuyRDRphuqi/DZtMHS1Yf52HVijOFqeBgDNN9UgA6yXw6hlecEVpAjak/xTV iAkbeRiPByWlFxeY0mX3nnADMIU6G1O4gAhYeoRGE7lJs1RWX4ilADx8DRjbgzRS4i 8SaOh49dhb4p6PuUIvTC3z2tNjZdaAzSQtucxH72w6mt9Y+FFDVBsul/+gxJs+OH9D a1y9KZiCpqo3A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8AC9469C7C; Thu, 19 Feb 2026 17:19:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 19 Feb 2026 17:19:09 -0700 Message-ID: <20260220001926.2366140-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260220001926.2366140-1-sjg@u-boot.org> References: <20260220001926.2366140-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 37DW3FZIPPU5WWT4DUPHDZBNCWA2YBD2 X-Message-ID-Hash: 37DW3FZIPPU5WWT4DUPHDZBNCWA2YBD2 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/13] ulib: x86: Disable regparm when Rust examples are enabled List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The regparm=3 calling convention is incompatible with Rust's extern "C" ABI, which uses cdecl (all arguments on the stack). Rather than adding an inline-assembly bridge for every non-variadic C call, automatically disable regparm when CONFIG_RUST_EXAMPLES is set by defaulting X86_NO_REGPARM to y. Also update setjmp.S to use the stack-based calling convention when regparm is disabled, since its _REGPARM define was unconditional. This is somewhat less efficient but is a worthwhile trade-off when using Rust. Signed-off-by: Simon Glass --- arch/x86/Kconfig | 11 +++++------ arch/x86/cpu/i386/setjmp.S | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 4fdfe5b90fe..14ee4a6d400 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -755,16 +755,15 @@ config X86_HARDFP config X86_NO_REGPARM bool "Disable register parameters (regparm=3)" depends on !X86_64 + default y if RUST_EXAMPLES help By default, U-Boot on 32-bit x86 uses -mregparm=3 to pass the first three function arguments in registers (EAX, EDX, ECX) rather than on - the stack. This is more efficient but can cause issues with debugging - tools or when interfacing with code that expects the standard calling - convention. + the stack. This is more efficient but is incompatible with Rust's + extern "C" ABI which uses the standard cdecl convention. - Select this option to disable regparm and use the standard i386 - calling convention where all arguments are passed on the stack. This - may be useful for debugging or for running in certain emulators. + This is automatically enabled when RUST_EXAMPLES is set. It may + also be useful for debugging or for running in certain emulators. config HAVE_ITSS bool "Enable ITSS" diff --git a/arch/x86/cpu/i386/setjmp.S b/arch/x86/cpu/i386/setjmp.S index eceeafa7c8b..f699850680c 100644 --- a/arch/x86/cpu/i386/setjmp.S +++ b/arch/x86/cpu/i386/setjmp.S @@ -5,7 +5,9 @@ * From Linux arch/um/sys-i386/setjmp.S */ +#ifndef CONFIG_X86_NO_REGPARM #define _REGPARM +#endif /* * The jmp_buf is assumed to contain the following, in order: