From patchwork Fri Dec 20 15:57:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916955 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 D6754E7718B for ; Fri, 20 Dec 2024 15:58:25 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FH4x4KREMM2ALqWrqXCpj1s/KitgCRbVyFoOjwakHAY=; b=j7kiseenjNkm/W QUqwlkORHL8t2C7OXCyWKSZtEMD+2ouvqhsJqI5CFsUNoG2l8MxLCXbaz0RSOPzLhipf4HocatOZ2 N9bK15XlBBc1P6sNZ+On3i9UAkdt85ls8BkxqXFzNGtml8byBf950f2Yd7onedczKw3ziYVhkHGEE ZfsuDel8+6rnwF42JSGVMGCej9/U25icdoOqzjxNeieVzRp3KVsA8MTu0y3Ee/PYIxvMFUPXvoi+S do658DurcqbyGsCRv2sW85mRakYlOSjuRzwmTspQO1Bnvxc6udwseodiZrWxhQiFN9EZgRPLRJFFN U7ShUKHu8tdGBMnW3L8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOP-00000005Nzy-0pgj; Fri, 20 Dec 2024 15:58:21 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005NqW-2hYk for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ruKKFBAzXsfOYIveTHx5A2fel7bTCFu3W2rswFq5xAA=; b=QXEF8Io239Nqj/eRSFfP73K4s+ bmWH1MlljygJdi/TPCYl/Bl5wvoxK30ozisqb1wh3Jzlyb07m0QqnTHM5MMHg8B1hC12C7F3qQJpw lWA9+bel7kRoxmaiLDBJr4YZDaBip+XU0LI87/61zxvQmA6cokkzBzU5rIoJoCRhpBOh+dj8D+fc3 s8HfHp5wyswNikD133r4gOaJI6WhjsJW5kB6lftTeuB30FajO0iyU66hTPfpQlYi4wqRxpI7TJxRI TzwkQ7UmQfIhgHvmxfebTMr9/C85K9T3SuBsJDj7sQhn0y+4PeUQp0WMicakqI30mS7h05D5gbd1p f1TNsMJQ==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfO9-00ADAH-Re; Fri, 20 Dec 2024 15:58:05 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSY-2fyV; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 01/15] riscv: add initial kconfig and build flags for big-endian Date: Fri, 20 Dec 2024 15:57:47 +0000 Message-Id: <20241220155801.1988785-2-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_683375_8D30DBFA X-CRM114-Status: GOOD ( 10.34 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org this is the initial kconfig and makefile updates to get a base big-endian build for arch/riscv. Will require header updates for IO code and features whcih are known to not work. --- arch/riscv/Kconfig | 22 ++++++++++++++++++++++ arch/riscv/Makefile | 15 ++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index fa8f2da87a0a..e352e022ed4a 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -426,6 +426,28 @@ choice bool "medium any code model" endchoice +choice + prompt "Data endian" + default CPU_LITTLE_ENDIAN + help + Configure the endiannes of data access performed by the CPU. + This will require system to be booted from M mode in big endian + and the userland to be compiled for the same endian-ness. + +config CPU_BIG_ENDIAN + bool "Build big-endian kernel" + depends on EXPERT + help + Say Y if you want to run big-endian kernel and userspace + Set for expert as this experimental + +config CPU_LITTLE_ENDIAN + bool "Build little-endian kernel (default)" + help + Say Y if you want to run little-endian kernel and userspace + This is the default for most distributions +endchoice + config MODULE_SECTIONS bool select HAVE_MOD_ARCH_SPECIFIC diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index d469db9f46f4..535cbbb76f5c 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -21,6 +21,11 @@ else endif endif +ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) +KBUILD_CPPFLAGS += -mbig-endian -D__RISCVEB__ +CHECKFLAGS += -D__RISCVEB__ +endif + ifeq ($(CONFIG_CMODEL_MEDLOW),y) KBUILD_CFLAGS_MODULE += -mcmodel=medany endif @@ -28,13 +33,17 @@ endif export BITS ifeq ($(CONFIG_ARCH_RV64I),y) BITS := 64 - UTS_MACHINE := riscv64 + ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) + UTS_MACHINE := riscv64_be + KBUILD_LDFLAGS += -melf64briscv + else + UTS_MACHINE := riscv64 + KBUILD_LDFLAGS += -melf64lriscv + endif KBUILD_CFLAGS += -mabi=lp64 KBUILD_AFLAGS += -mabi=lp64 - KBUILD_LDFLAGS += -melf64lriscv - KBUILD_RUSTFLAGS += -Ctarget-cpu=generic-rv64 --target=riscv64imac-unknown-none-elf \ -Cno-redzone else From patchwork Fri Dec 20 15:57:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916951 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 06327E77190 for ; Fri, 20 Dec 2024 15:58:24 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VIAOqcQyxpsKTIH4VOpLdhoMCdHNOz2a6sXZBvC9TPc=; b=FlBmOhnpLKpS3R 5t9QCm+3bIguwkD+8hihRF4A4n5xiLmEKTUimwpzo6m2VaOgPSiFp9GJLWpzjv0xciGvuuerVUuYi 0fprVGtRJ60cmegKp/2PKvaxu16M7lgz8Xs7FCaC0g65VdhOG2ZGGgZRZjjcLNurULFsErylra2ZE 6bPINZRCs2IXlQB7oRoXzPy/5mzGORGOi9lhsGka6d9Ad9HNLNQQlsqlbNDsD9Yk7+dapA69pVySj XedLlywd9dUaMDa+GKpogam3FUA0v8KA8TxonbooAqLbE+BT9/iuo6cNA5H/pF6fSLmGiI7CBWoTj wgA58WoCq0ELutTPzczg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfON-00000005NyH-172z; Fri, 20 Dec 2024 15:58:19 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005NqU-3Mv6 for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Jd/m4zbR6LWW3A8qCa5nNBThBWahVG9In5EIy65DcuU=; b=4FXHGp+u6J5rXVByg4DE/AT7IG QAbGkteE4+15qLVvGCBvdfaKyXUaxrl5O8kn0odjRbZ3UrwakdyBwyNT2X5j5YJU5SPDIJ+DZtH9c +CzieyX+PJV5f26457HvKO1CIbYC82dp49XVb4O48EVrotXClcjCgSLHOlCHHoB1GNB2Yd/G0hXSm wVnXmI3d2K8VKtfBDgaAMl89bB904S0Oa7O5GR5AU8I2OX9UZboAwepQC913Yr5ppkK8W9cNCDYc7 t2zZRcY/moQRlKHyADXdqnCstfK3dk2+q+YODY264LROfMAcFNO+KRVVgPmwc7UtxywGDr3Q9x4GN bTnZxteA==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfO9-00ADAI-Tk; Fri, 20 Dec 2024 15:58:05 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSb-2lpf; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 02/15] add __RISCVEB__ to byteorder.h Date: Fri, 20 Dec 2024 15:57:48 +0000 Message-Id: <20241220155801.1988785-3-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_842156_FE1409E8 X-CRM114-Status: UNSURE ( 6.70 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org --- arch/riscv/include/uapi/asm/byteorder.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/include/uapi/asm/byteorder.h b/arch/riscv/include/uapi/asm/byteorder.h index f671e16bf6af..61da07ed6b32 100644 --- a/arch/riscv/include/uapi/asm/byteorder.h +++ b/arch/riscv/include/uapi/asm/byteorder.h @@ -7,6 +7,10 @@ #ifndef _UAPI_ASM_RISCV_BYTEORDER_H #define _UAPI_ASM_RISCV_BYTEORDER_H +#ifdef __RISCVEB__ +#include +#else #include +#endif #endif /* _UAPI_ASM_RISCV_BYTEORDER_H */ From patchwork Fri Dec 20 15:57:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916952 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 F2F1BE7718F for ; Fri, 20 Dec 2024 15:58:23 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dUhvP0DfR955jURsd80PDzVPYftBuBfv0g8CeCFsUhQ=; b=kEhw/AGM2OYSfG QQpPeBjMCbEq+LEOeJZRmjf2yRFMzvK3azbfLFElkYPsjVcxY5PttODH65LxCW7+kuvK2a1Chh74a PHCnHHDYiPbinAL+mqgSRdrcfY/nwgWHwBJcPRBonUGUGzeC/c3WEh8Wmq4cxpteOjCfdPe93Mnk1 HDEjeoS0zaWHbzCCyvFIMqDoilwP3c87kOUs/uAHKugCUj9ef37CwVQuceAuG9PUSCwEhc+XBEST8 SEX4iQUusljVPL5KlaOj7XV9aubH4hYhwC0Q301m5HwgtAc6tojlSI+5kUFMHTnP8JYi232DNx0Fp HxIXp1R4GKQwth1IOteg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfON-00000005Nyt-3nOT; Fri, 20 Dec 2024 15:58:19 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005NqV-3NSm for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=BxNHQ+B0HaXyHNwMQnlpMraQTogWmeujailVSyn2wj8=; b=3GScIZWw3YR4JwaudPSHZZZ9SX wcihPzwkDzZdcJgbaHXYFAXVDUTvOYgl0NR7Bu5ZFR9WB4BSlgWEdJQam/N5AgoxE1USqQAAqXSL8 y7Veb5Wv6bEZc8hx0tjqclzjbrfK46ep2LpoJDNlhMw1Trci35A/uG0JHW7U8elFXU6Pz7oKOZnwg wF1CU/dngi6LGAvXStNjPJCWY51UU2xKuuiNdbWBxZgx/+FwNllIlFpNzizKYndGU6CZXALIsOamz Mk/OQP0NGRg9wa6sQt6ofK5dq9gFLwLJFJy8Ie197mNjDY3ygUc+I6hUc4rBJGQ4q2+grlN8rGUC1 HC+9/mOg==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfO9-00ADAJ-Tn; Fri, 20 Dec 2024 15:58:05 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSf-2rBD; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 03/15] riscv: disable vector if big-endian, gcc unsupported option Date: Fri, 20 Dec 2024 15:57:49 +0000 Message-Id: <20241220155801.1988785-4-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_843522_CD0693F8 X-CRM114-Status: UNSURE ( 6.93 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org You can't build with vector enabled at the moment so remove this until gcc is changed. --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index e352e022ed4a..d632bfad190c 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -602,6 +602,7 @@ config RISCV_ISA_V bool "VECTOR extension support" depends on TOOLCHAIN_HAS_V depends on FPU + depends on CPU_LITTLE_ENDIAN select DYNAMIC_SIGFRAME default y help From patchwork Fri Dec 20 15:57:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916950 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 BF09EE77188 for ; Fri, 20 Dec 2024 15:58:23 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t5AvFAKXC89MYtIdhwqa4D/LPEsmedmkedP21ccLtTw=; b=Q+Vg4fdepAnAj7 LpGSlxeo3qGNFuWoXWA56sDBtsOXXkZ+ZNvXnPBS6b/276dyYHtRIjQEWHxmShjwIKyGbby8gaufd vo7TqmP2+MJWbynef5QUgm6xZm2kGwy4OgcXDbrY64BqOMN7ihoKB8f4OaAo76NM0Ds9I/nFkeu3s FwcEv8mqnmW2I8sxxK02wgjYHu7kC4PFwZ5IRrBsQHjy8ZJAHnpoDwitQbkgwZoWJvfroZKfjCEZn NbKF6dKkgbe1T8p+lvRP+U2PllkbRzavSsI2nxFU+8YBckpPLO+jE2/VZdz6p6mFngIRF/ppAs12x c2ZeM/nNWc46DGDhws8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOM-00000005Nxp-1rao; Fri, 20 Dec 2024 15:58:18 +0000 Received: from imap4.hz.codethink.co.uk ([188.40.203.114]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005Nqk-26xt for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap4-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nu7fQAgXUlOppVgqF4FCsVhNZbZKV0RP9V8TletL4wo=; b=n/HHQaYGqjJBSqSbh+lPUPqhEz AQFANHXMVUmd0X5t2/QUMsPsL2JaOD9WeChdWiODLsVXzrvhSRWwYht3fLjDPpy/kNmgJ0bZF/hrk wOjnv/iaD5fQjem7VVOkmKzFypDBxUFSkMOf6G4AMNSO9X1WFdaNKauAw9Vt00G76HQdq1cKwFygD aBA4/bJWft92lfnKUR+dhcxHO4sy8uhbmjyAVyMHjqOkX9M8mo2WaPO+F9FojzeanX5zjzpz+tK1H AwDlzhhSQSgBqtZvMH8zTEat9IfdAqtrT6RATbdnqMshwGpIiIWV0GWWTsepjOGIH4w7FPskFxdWT AZV3TvWQ==; Received: from [167.98.27.226] (helo=rainbowdash) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-006axk-2l; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSj-2wNC; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 04/15] riscv: word-at-atime: move to generic if we're big endian Date: Fri, 20 Dec 2024 15:57:50 +0000 Message-Id: <20241220155801.1988785-5-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_620914_6249E6D8 X-CRM114-Status: UNSURE ( 8.23 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Use the generic word at a time code if we're running in big endian for now otherwise this doesn't work. Add better support later. Signed-off-by: Ben Dooks --- arch/riscv/include/asm/word-at-a-time.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/word-at-a-time.h b/arch/riscv/include/asm/word-at-a-time.h index 3802cda71ab7..436e3588f50f 100644 --- a/arch/riscv/include/asm/word-at-a-time.h +++ b/arch/riscv/include/asm/word-at-a-time.h @@ -8,8 +8,9 @@ #ifndef _ASM_RISCV_WORD_AT_A_TIME_H #define _ASM_RISCV_WORD_AT_A_TIME_H - #include + +#ifndef __RISCVEB__ #include #include @@ -47,6 +48,14 @@ static inline unsigned long find_zero(unsigned long mask) /* The mask we created is directly usable as a bytemask */ #define zero_bytemask(mask) (mask) +#else /* !__RISCVEB__ */ + +/* use the generic one for now */ +#include +#endif /* !__RISCVEB__ */ + + + #ifdef CONFIG_DCACHE_WORD_ACCESS /* From patchwork Fri Dec 20 15:57:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916949 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 9260AE7718E for ; Fri, 20 Dec 2024 15:58:22 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wHpUfDbx1guUl4/FIU01sA3PkriImDbli+deyWWo4uE=; b=yZXDP/109Vg8fN gq/tS/dWpVWJwYtYIbtVb/MRylUSC3M8xzdsCQSRU58lNrWI8ACaEe9aD3FdENztqVAKLEpSL9aDg kPdazh4+EfyvCrP1vP5BDJKou91bK0g1CQZamwjcPAD6jp4wi/oGI8itlLoX3qoU1m5Z8GYRDUtOS XD2MeBJ+ZTeV5hgH9+1lChxu2t6Jb/0pGa43e5olZjIIbEX8gFhO9UbQdA86tg8nEn6D7YmuPazK9 STFYvUxO6KmLTKuUunBvUq6bP/hjp3Gt3RCVB0/3vAqisR2OImTvMAEmJurSYMI+9rlg6jjSbfsYd RbIArnvtDLUdTWuLKrdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOL-00000005Nwz-0Z7c; Fri, 20 Dec 2024 15:58:17 +0000 Received: from imap4.hz.codethink.co.uk ([188.40.203.114]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005Nqg-264W for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap4-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ICpbFOgV9PGl+al5ON3gHos7XEkWEkbRVLI2bTeRW0w=; b=PXo56o5D2ARae08cJnRavtmezV CzMQQkJ4VFlAuvnR4T8/HWrPKaILHMXLMnn0Kay/Hd8grtWZLJ4KANyci+hLg3+1ymdtkPzsi9oyE sO8SIBSQbJz0AqxTwtPYoBzv/lQAUg//WPiGLzp3sMFRucnZmZ6oAr/D+4EijlXMp34Z7C1dE6qXA ZMsbwDCVu5AzJRWM3P70Xm+6lUMwcnJdXOsGXGwJeR6E6KxIbBAc63ngyqMeYeyUqH7TvWdP3dEni 1NVOCYbQhahRKgUOnpp0CNGwbHVi4ipBJMFndSySRgQanM2jJciy6cvTMHAvFxrNcRBUS+1Ii0her cuulUCZw==; Received: from [167.98.27.226] (helo=rainbowdash) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-006axl-4E; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSn-32AK; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 05/15] riscv: asm: use .insn for making custom instructioons Date: Fri, 20 Dec 2024 15:57:51 +0000 Message-Id: <20241220155801.1988785-6-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_597253_6AF2D012 X-CRM114-Status: UNSURE ( 7.23 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Using .word breaks with big endian builds, making something which is not a valid or worse an instruction or pair that does something which is not intended. Signed-off-by: Ben Dooks --- arch/riscv/include/asm/insn-def.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h index 9a913010cdd9..f6dd6d963de9 100644 --- a/arch/riscv/include/asm/insn-def.h +++ b/arch/riscv/include/asm/insn-def.h @@ -196,8 +196,14 @@ INSN_I(OPCODE_MISC_MEM, FUNC3(2), __RD(0), \ RS1(base), SIMM12(4)) +#ifndef CONFIG_AS_HAS_INSN #define RISCV_PAUSE ".4byte 0x100000f" #define ZAWRS_WRS_NTO ".4byte 0x00d00073" #define ZAWRS_WRS_STO ".4byte 0x01d00073" +#else +#define RISCV_PAUSE ".insn 0x100000f" +#define ZAWRS_WRS_NTO ".insn 0x00d00073" +#define ZAWRS_WRS_STO ".insn 0x01d00073" +#endif #endif /* __ASM_INSN_DEF_H */ From patchwork Fri Dec 20 15:57:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916948 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 7A0DAE7718B for ; Fri, 20 Dec 2024 15:58:22 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2UZF2GudvLA5dF+mckvUkU3O9EoZFKpRBrUoaKJpEVU=; b=o7Lo6/C/fzP4/y KjbsOPG/jJLv7CGZvSoD/9kwPOG4Wgr3zt2SBNWvMNHhkAJ3g7dPcd6/i10Ml8AxpiuuoNE1FW9zq gh4ONIULxSiOlOQnrA6mdo10y2sIfAL8z6SX/hMLDAEsdhWoZJ8jeoZJ3XVYDicDVHr5qA3z/P9g0 iH8YidSsvt7f2vtkwYCiOo/3H5AouK42O9Nv2I55zOZe7FUj3ocmzBFZJqQKFrg57adRWYRStR0Ii ROaRrBd1BHNNF/Pizv7zs5lzQcraOxuyBZLdYljsq6Cj1z2BDALdKs1H8rrxwYcovo+sU3EDk8YBl FJcWrmzFWsqExl5qH+5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOL-00000005NxR-3Tvc; Fri, 20 Dec 2024 15:58:17 +0000 Received: from imap4.hz.codethink.co.uk ([188.40.203.114]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005Nqi-26fZ for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap4-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qWYxWU1HG+Hd8irDJvgmQxnrG8DlxvlIVhSBwRExfPc=; b=KQT/wfVqdRmsV+dCgC0ObagiVu M5Mn2u5iHkxP8BFyz8GenL+Vkx9xZ2FM0sNef/lC4JjWqWSdDk72zkoGIDTndc++iCcmGvoJTSR3u GD64zULWdNBTxdcEjerxykJ7OWDq2W+9OgrxrvTPCxpBBn1ozpqZvZRhYIN3p5cidLAUQPCaDcxYS iKEExWaYZS6tbs8A4668Qp68CMd5GFG6shxHXDrOU/1pQHNaRTgJrhE+Ude/JhsRJUxJb7qzchBo7 cGS+/nG/IOG4iG1CXQ1lzAX4Hf7Xsdqmkqq/iph4xD8zIafkMDORC4+tOkFAHzR1DoMG6JyHd8flO S7o+cwFg==; Received: from [167.98.27.226] (helo=rainbowdash) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-006axm-4C; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSr-37Ks; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 06/15] intiial header work Date: Fri, 20 Dec 2024 15:57:52 +0000 Message-Id: <20241220155801.1988785-7-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_596518_224B69EB X-CRM114-Status: UNSURE ( 7.36 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org --- arch/riscv/include/asm/image.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/image.h b/arch/riscv/include/asm/image.h index e0b319af3681..21ffe80aa397 100644 --- a/arch/riscv/include/asm/image.h +++ b/arch/riscv/include/asm/image.h @@ -13,7 +13,8 @@ #define RISCV_IMAGE_FLAG_BE 1 #ifdef CONFIG_CPU_BIG_ENDIAN -#error conversion of header fields to LE not yet implemented +//#error conversion of header fields to LE not yet implemented +#define __HEAD_FLAG_BE RISCV_IMAGE_FLAG_BE #else #define __HEAD_FLAG_BE RISCV_IMAGE_FLAG_LE #endif From patchwork Fri Dec 20 15:57:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916956 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 D9029E7718C for ; Fri, 20 Dec 2024 15:58:26 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n2RzvLVQGapeSaE7zIgrXJLmZeDd2xoznW+x3XwFvxI=; b=K3fYzZrJs5KR/R 6iZ2s6n4WZESOshfskFUVDiPhOr5FZzwOjk+UIAZsXFZS+fWDmOgz/nfeoSYSivYi6MGKeBI9FqY9 b5FYrLwlyb08PAW/QxMd09L/+dQwOVziLwAgwO2sQeg29KhKPAv1FxgP5F9SFCDSPFF+nKiDinf9F 4YqNxUYq3Qu6LQciZMI6F8Pdz8j0OlJ3USukLNADulDTBScbAoM7ubqWR0UmoWywSnlAwN6lKf+0E QV2WnA1/IJeqWe0Ky7PSkJW4QTdZhzrjYGBFel/YNlNRY5exj786WD6UGs3IcvjKzhd1HDEWOCGXN AXm/cwPVQYqWjbzhCibw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOQ-00000005O1q-3TzB; Fri, 20 Dec 2024 15:58:22 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOH-00000005NtR-2c9N for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=b0zfwuxNYdnEHdCMpmoC+InhanfjUJnBFeJN5WvRGw8=; b=k8rGOxQt2HgjDWjubNykKNvYKk G6an+8bzaoUbXLQ6CAAKeYvyQBwQBPAow5hPldA6OJABiypiudl0mXu0pC8bLrSuOHLWON135tZaj N7YOj6yNY5VQ2Ie+9de0VY7QU+Hd38/qyhEbUAa7ph2mKVemcBe27l6g9fS1w/lZQM/IXgJT6vwp9 ClB9kTitkljOzJrRF0ppf53oLRX12CiBObANGQPjrPWx3mjmHn0Zwipokj/iXCabhOm3HyyaYPwb+ lDSx7s0OYaYxlqFpbcfpRBkO0e/JehjWBDoqywf/2yLltFNAnFYoDqi1vCfCYJaXDFksU25HSIv60 QLyBPm6w==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-00ADAK-0x; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSv-3Czt; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 07/15] kconfig: remove CONFIG_COMAPT for big-endian (compat cods doesn't build atm) Date: Fri, 20 Dec 2024 15:57:53 +0000 Message-Id: <20241220155801.1988785-8-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075813_734286_B65A99FA X-CRM114-Status: UNSURE ( 9.09 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org --- arch/riscv/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d632bfad190c..5a72e7b31095 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -930,7 +930,7 @@ config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION config COMPAT bool "Kernel support for 32-bit U-mode" default 64BIT - depends on 64BIT && MMU + depends on 64BIT && MMU && !CPU_BIG_ENDIAN help This option enables support for a 32-bit U-mode running under a 64-bit kernel at S-mode. riscv32-specific components such as system calls, From patchwork Fri Dec 20 15:57:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916953 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 D5884E77191 for ; Fri, 20 Dec 2024 15:58:24 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zpmGOInL5BRbRExsU8KSX9wu0a5mDqzgUigJCw+MrJM=; b=pz0bAGoYHCBbWh YBNmYNX1zovTit2SjbPe8u//o/zrGS+W7BT4ulOq/9+2UUE3pIMxZ1dU6BtNqhv5ABJ82IBwmj+Pm zRn6jO9Rk4/xSeRIRSwynoVcbJp8pAvE2kc5r9jVlUIogJdB1A9CZnP566bjAKL87AbJTdJuSDVUS DwRJR8NzD4G4Sg6OkVf6EUf+dtsAK0SjYMDf0zUy70b72kSeCuBCJZtHNgUDrFmNJ9eRKbX2fxuEl hB8tDq4WhRAYL7re8dk9CB8m7nsSANdYbhj/PVPpbVv8PXJBCJgzAmyvklMqqMD6tJ8DSl5ArLmDL LQwZceiZ2xkia5ZgWg9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOO-00000005NzT-2JqS; Fri, 20 Dec 2024 15:58:20 +0000 Received: from imap4.hz.codethink.co.uk ([188.40.203.114]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005Nqj-26WO for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap4-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=g4Ldg+7uAVjvFAfFSZqwpU5aSKiNNo2G81qDT3t2uCQ=; b=erGSpGBdQNQCMeFje2k7GenkkZ YQKxylZoPLVEMVWvRjKA5bboOOVcq5xTbf6FEqeZBiCk68LliwJEkPaMsXSZngDtTcGplM4nh1z5B pp0cJIA9kxio3jAQztHHl+epdzQ4Lgr4N/ZBmOKlvkiYs8I1hn4LKte230vMgwAg7F3helwUhvRWl QZ5RrXWIcuqzLW8PA0o6Jdi+MFA9pxQ2IAcRCUMc05BAXKU32xV549KPlznJjEKDiy9mpwhIa6uwP x4cxSRgnQd8deL+o812DiABpNb3jK9kNjFimwn7k8yCKFQKEjY90BRCin092u1GGIwYItFXsk0s82 QXV9tqRg==; Received: from [167.98.27.226] (helo=rainbowdash) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-006axn-68; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LSz-3Iy9; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 08/15] defconfig: add our build config Date: Fri, 20 Dec 2024 15:57:54 +0000 Message-Id: <20241220155801.1988785-9-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_687493_DCDAAA1C X-CRM114-Status: GOOD ( 11.80 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org --- arch/riscv/configs/be_defconfig | 344 ++++++++++++++++++++++++++++++++ 1 file changed, 344 insertions(+) create mode 100644 arch/riscv/configs/be_defconfig diff --git a/arch/riscv/configs/be_defconfig b/arch/riscv/configs/be_defconfig new file mode 100644 index 000000000000..89d06b74a1b8 --- /dev/null +++ b/arch/riscv/configs/be_defconfig @@ -0,0 +1,344 @@ +CONFIG_SYSVIPC=y +CONFIG_POSIX_MQUEUE=y +CONFIG_NO_HZ_IDLE=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_BPF_SYSCALL=y +CONFIG_BPF_JIT=y +CONFIG_BPF_JIT_ALWAYS_ON=y +CONFIG_BPF_LSM=y +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +CONFIG_CGROUPS=y +CONFIG_MEMCG=y +CONFIG_BLK_CGROUP=y +CONFIG_CGROUP_SCHED=y +CONFIG_CFS_BANDWIDTH=y +CONFIG_RT_GROUP_SCHED=y +CONFIG_CGROUP_PIDS=y +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_HUGETLB=y +CONFIG_CPUSETS=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_CGROUP_PERF=y +CONFIG_CGROUP_BPF=y +CONFIG_NAMESPACES=y +CONFIG_USER_NS=y +CONFIG_CHECKPOINT_RESTORE=y +CONFIG_BOOT_CONFIG=y +CONFIG_EXPERT=y +# CONFIG_SYSFS_SYSCALL is not set +CONFIG_PROFILING=y +CONFIG_ARCH_MICROCHIP=y +CONFIG_ARCH_RENESAS=y +CONFIG_ARCH_SIFIVE=y +CONFIG_ARCH_SOPHGO=y +CONFIG_SOC_STARFIVE=y +CONFIG_ARCH_SUNXI=y +CONFIG_ARCH_THEAD=y +CONFIG_ARCH_VIRT=y +CONFIG_ARCH_CANAAN=y +CONFIG_CPU_BIG_ENDIAN=y +CONFIG_SMP=y +CONFIG_RISCV_EMULATED_UNALIGNED_ACCESS=y +CONFIG_CMDLINE="earlycon=sbi console=ttyS0,115200,8h1 root=/dev/vda" +CONFIG_CMDLINE_EXTEND=y +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_STAT=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=m +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m +CONFIG_CPUFREQ_DT=y +CONFIG_ACPI_CPPC_CPUFREQ=m +CONFIG_VIRTUALIZATION=y +CONFIG_KVM=m +CONFIG_ACPI=y +CONFIG_KPROBES=y +CONFIG_JUMP_LABEL=y +CONFIG_STATIC_KEYS_SELFTEST=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +CONFIG_BLK_DEV_THROTTLING=y +CONFIG_SPARSEMEM_MANUAL=y +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_XFRM_USER=m +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +CONFIG_IP_PNP_RARP=y +CONFIG_INET_ESP=m +CONFIG_NETFILTER=y +CONFIG_BRIDGE_NETFILTER=m +CONFIG_NF_CONNTRACK=m +CONFIG_NF_CONNTRACK_FTP=m +CONFIG_NF_CONNTRACK_TFTP=m +CONFIG_NETFILTER_XT_MARK=m +CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m +CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m +CONFIG_NETFILTER_XT_MATCH_IPVS=m +CONFIG_IP_VS=m +CONFIG_IP_VS_PROTO_TCP=y +CONFIG_IP_VS_PROTO_UDP=y +CONFIG_IP_VS_RR=m +CONFIG_IP_VS_NFCT=y +CONFIG_NF_LOG_ARP=m +CONFIG_NF_LOG_IPV4=m +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_FILTER=m +CONFIG_IP_NF_TARGET_REJECT=m +CONFIG_IP_NF_NAT=m +CONFIG_IP_NF_TARGET_MASQUERADE=m +CONFIG_IP_NF_TARGET_REDIRECT=m +CONFIG_IP_NF_MANGLE=m +CONFIG_NF_LOG_IPV6=m +CONFIG_IP6_NF_IPTABLES=m +CONFIG_IP6_NF_MATCH_IPV6HEADER=m +CONFIG_IP6_NF_FILTER=m +CONFIG_IP6_NF_TARGET_REJECT=m +CONFIG_IP6_NF_MANGLE=m +CONFIG_BRIDGE=m +CONFIG_BRIDGE_VLAN_FILTERING=y +CONFIG_VLAN_8021Q=m +CONFIG_NET_SCHED=y +CONFIG_NET_CLS_CGROUP=m +CONFIG_NETLINK_DIAG=y +CONFIG_CGROUP_NET_PRIO=y +CONFIG_BPF_STREAM_PARSER=y +CONFIG_CAN=m +CONFIG_NET_9P=y +CONFIG_NET_9P_VIRTIO=y +CONFIG_PCI=y +CONFIG_PCIEPORTBUS=y +CONFIG_PCI_HOST_GENERIC=y +CONFIG_PCIE_XILINX=y +CONFIG_PCIE_FU740=y +CONFIG_PCIE_STARFIVE_HOST=m +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_SIFIVE_CCACHE=y +CONFIG_MTD=y +CONFIG_MTD_BLOCK=y +CONFIG_MTD_CFI=y +CONFIG_MTD_CFI_ADV_OPTIONS=y +CONFIG_MTD_SPI_NOR=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_VIRTIO_BLK=y +CONFIG_BLK_DEV_NVME=m +CONFIG_BLK_DEV_SD=y +CONFIG_BLK_DEV_SR=y +CONFIG_SCSI_VIRTIO=y +CONFIG_ATA=y +CONFIG_SATA_AHCI=y +CONFIG_SATA_AHCI_PLATFORM=y +CONFIG_MD=y +CONFIG_BLK_DEV_DM=m +CONFIG_DM_THIN_PROVISIONING=m +CONFIG_NETDEVICES=y +CONFIG_DUMMY=m +CONFIG_MACVLAN=m +CONFIG_IPVLAN=m +CONFIG_VXLAN=m +CONFIG_VETH=m +CONFIG_VIRTIO_NET=y +CONFIG_MACB=y +CONFIG_E1000E=y +CONFIG_R8169=y +CONFIG_RAVB=y +CONFIG_STMMAC_ETH=m +CONFIG_MICREL_PHY=y +CONFIG_MICROSEMI_PHY=y +CONFIG_MOTORCOMM_PHY=y +CONFIG_CAN_RCAR_CANFD=m +CONFIG_INPUT_MOUSEDEV=y +CONFIG_KEYBOARD_SUN4I_LRADC=m +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_DW=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIAL_EARLYCON_RISCV_SBI=y +CONFIG_SERIAL_SH_SCI=y +CONFIG_VIRTIO_CONSOLE=y +CONFIG_HW_RANDOM=y +CONFIG_HW_RANDOM_VIRTIO=y +CONFIG_HW_RANDOM_JH7110=m +CONFIG_I2C=y +CONFIG_I2C_CHARDEV=m +CONFIG_I2C_DESIGNWARE_CORE=y +CONFIG_I2C_MV64XXX=m +CONFIG_I2C_RIIC=y +CONFIG_SPI=y +CONFIG_SPI_CADENCE_QUADSPI=m +CONFIG_SPI_PL022=m +CONFIG_SPI_RSPI=m +CONFIG_SPI_SIFIVE=y +CONFIG_SPI_SUN6I=y +# CONFIG_PTP_1588_CLOCK is not set +CONFIG_GPIO_SIFIVE=y +CONFIG_GPIO_ADP5585=y +CONFIG_POWER_RESET_GPIO_RESTART=y +CONFIG_SENSORS_SFCTEMP=m +CONFIG_SENSORS_SG2042_MCU=m +CONFIG_CPU_THERMAL=y +CONFIG_DEVFREQ_THERMAL=y +CONFIG_RZG2L_THERMAL=y +CONFIG_WATCHDOG=y +CONFIG_SUNXI_WATCHDOG=y +CONFIG_MFD_ADP5585=y +CONFIG_MFD_AXP20X_I2C=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_REGULATOR_AXP20X=y +CONFIG_REGULATOR_GPIO=y +CONFIG_MEDIA_SUPPORT=m +CONFIG_VIDEO_CADENCE_CSI2RX=m +CONFIG_DRM=m +CONFIG_DRM_RADEON=m +CONFIG_DRM_NOUVEAU=m +CONFIG_DRM_SUN4I=m +CONFIG_DRM_VIRTIO_GPU=m +CONFIG_FB=y +CONFIG_SOUND=y +CONFIG_SND=y +CONFIG_SND_UTIMER=y +CONFIG_SND_SOC=y +CONFIG_SND_DESIGNWARE_I2S=m +CONFIG_SND_SOC_STARFIVE=m +CONFIG_SND_SOC_JH7110_PWMDAC=m +CONFIG_SND_SOC_JH7110_TDM=m +CONFIG_SND_SOC_WM8978=m +CONFIG_SND_SOC_MT6357=y +CONFIG_SND_SIMPLE_CARD=m +CONFIG_USB=y +CONFIG_USB_OTG=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PLATFORM=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_HCD_PLATFORM=y +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_HCD_PLATFORM=y +CONFIG_USB_RENESAS_USBHS=m +CONFIG_USB_STORAGE=y +CONFIG_USB_UAS=y +CONFIG_USB_CDNS_SUPPORT=m +CONFIG_USB_CDNS3=m +CONFIG_USB_CDNS3_GADGET=y +CONFIG_USB_CDNS3_HOST=y +CONFIG_USB_CDNS3_STARFIVE=m +CONFIG_USB_MUSB_HDRC=m +CONFIG_USB_MUSB_SUNXI=m +CONFIG_NOP_USB_XCEIV=m +CONFIG_USB_GADGET=y +CONFIG_USB_RENESAS_USBHS_UDC=m +CONFIG_USB_CONFIGFS=m +CONFIG_USB_CONFIGFS_SERIAL=y +CONFIG_USB_CONFIGFS_ACM=y +CONFIG_USB_CONFIGFS_OBEX=y +CONFIG_USB_CONFIGFS_NCM=y +CONFIG_USB_CONFIGFS_ECM=y +CONFIG_USB_CONFIGFS_ECM_SUBSET=y +CONFIG_USB_CONFIGFS_RNDIS=y +CONFIG_USB_CONFIGFS_EEM=y +CONFIG_USB_CONFIGFS_MASS_STORAGE=y +CONFIG_USB_CONFIGFS_F_FS=y +CONFIG_MMC=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_PLTFM=y +CONFIG_MMC_SDHCI_OF_DWCMSHC=y +CONFIG_MMC_SDHCI_CADENCE=y +CONFIG_MMC_SPI=y +CONFIG_MMC_SDHI=y +CONFIG_MMC_DW=y +CONFIG_MMC_DW_STARFIVE=y +CONFIG_MMC_SUNXI=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_SUN6I=y +CONFIG_DMADEVICES=y +CONFIG_DMA_SUN6I=m +CONFIG_DW_AXI_DMAC=y +CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_BALLOON=y +CONFIG_VIRTIO_INPUT=y +CONFIG_VIRTIO_MMIO=y +CONFIG_CLK_SOPHGO_CV1800=y +CONFIG_SUN8I_DE2_CCU=m +CONFIG_RENESAS_OSTM=y +CONFIG_SUN50I_IOMMU=y +CONFIG_RPMSG_CHAR=y +CONFIG_RPMSG_CTRL=y +CONFIG_RPMSG_VIRTIO=y +CONFIG_PM_DEVFREQ=y +CONFIG_IIO=y +CONFIG_PHY_SUN4I_USB=m +CONFIG_PHY_RCAR_GEN3_USB2=y +CONFIG_PHY_STARFIVE_JH7110_DPHY_RX=m +CONFIG_PHY_STARFIVE_JH7110_PCIE=m +CONFIG_PHY_STARFIVE_JH7110_USB=m +CONFIG_LIBNVDIMM=y +CONFIG_NVMEM_SUNXI_SID=y +CONFIG_EXT4_FS=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +CONFIG_BTRFS_FS=m +CONFIG_BTRFS_FS_POSIX_ACL=y +CONFIG_AUTOFS_FS=y +CONFIG_OVERLAY_FS=m +CONFIG_ISO9660_FS=y +CONFIG_JOLIET=y +CONFIG_ZISOFS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_HUGETLBFS=y +CONFIG_NFS_FS=y +CONFIG_NFS_V4=y +CONFIG_NFS_V4_1=y +CONFIG_NFS_V4_2=y +CONFIG_ROOT_NFS=y +CONFIG_9P_FS=y +CONFIG_NLS_CODEPAGE_437=y +CONFIG_NLS_ISO8859_1=m +CONFIG_SECURITY=y +CONFIG_SECURITY_SELINUX=y +CONFIG_SECURITY_APPARMOR=y +CONFIG_SECURITY_IPE=y +CONFIG_DEFAULT_SECURITY_DAC=y +CONFIG_LSM="landlock,lockdown,yama,loadpin,safesetid,bpf" +CONFIG_CRYPTO_USER_API_HASH=y +CONFIG_CRYPTO_DEV_VIRTIO=y +CONFIG_PRINTK_TIME=y +CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y +CONFIG_DEBUG_FS=y +CONFIG_DEBUG_PAGEALLOC=y +CONFIG_SCHED_STACK_END_CHECK=y +CONFIG_DEBUG_VM=y +CONFIG_DEBUG_VM_PGFLAGS=y +CONFIG_DEBUG_MEMORY_INIT=y +CONFIG_DEBUG_PER_CPU_MAPS=y +CONFIG_SOFTLOCKUP_DETECTOR=y +CONFIG_WQ_WATCHDOG=y +CONFIG_DEBUG_TIMEKEEPING=y +CONFIG_DEBUG_RT_MUTEXES=y +CONFIG_DEBUG_SPINLOCK=y +CONFIG_DEBUG_MUTEXES=y +CONFIG_DEBUG_RWSEMS=y +CONFIG_DEBUG_ATOMIC_SLEEP=y +CONFIG_DEBUG_LIST=y +CONFIG_DEBUG_PLIST=y +CONFIG_DEBUG_SG=y +# CONFIG_RCU_TRACE is not set +CONFIG_RCU_EQS_DEBUG=y +CONFIG_FTRACE_SYSCALLS=y +CONFIG_USER_EVENTS=y +CONFIG_TRACE_EVENT_INJECT=y +CONFIG_KPROBE_EVENT_GEN_TEST=m +CONFIG_RV=y +CONFIG_TEST_BPF=y +CONFIG_FIND_BIT_BENCHMARK=y +CONFIG_TEST_STATIC_KEYS=m +CONFIG_MEMTEST=y From patchwork Fri Dec 20 15:57:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916947 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 A8085E7718D for ; Fri, 20 Dec 2024 15:58:21 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=18mdsxLNEHTjFXh4UBsRiYapVKuxDbCLf17yxk0VuVI=; b=hmt7UgV7YISjtQ QMuzKQ1brqCvx4gE765lexLMHaVSkeOlRJ5R6+GPpfJQ7b8/+3F+q/B+OEHNAO+m6wZq3xXFKVOnT Lbe5EBNGUzFu3CPcCWT8YYx7ZMRBMN7QvEUdY379eWtPm0OEf64Za7JSqKhgWR22n6Ym17X6IoIs7 0WR3lLvY6V1gF7rW6C+1IatTbrlRcqD5D/BDqhvvnSJk7T6erviH8GZ4ab5SuMVqz3lMWDiMAsFjl FlzXReRHWkn6m1zREQJ/++8zPmJkLU2czSBjjQemhM91fYcqlLkvqC9xYHsictmx8h95U321VJDez MCviwRBQkm+fzwgMPJlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOK-00000005NwK-1fWf; Fri, 20 Dec 2024 15:58:16 +0000 Received: from imap4.hz.codethink.co.uk ([188.40.203.114]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005Nqh-26bI for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap4-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AuhkpriSa43or7c14nqod3pbLZV+TBelgd27m0CLnto=; b=lhCnL2Dg5qytf1Rg+poMdXhoxr eYaHQTeXWcRRwBPW7UzAsYE27ExGC/XVT/veUGSfVys5WmmMKepXkCCzozqCBSEFzLBkTltsHXJBZ BSuc3k4JZ+NB0a9Dz96BZauqMOrgFGHKAgNsNZa3qliIF/cdcF8gek6d0yHD/FnFh9ONfqsCEmvjY bMDjHLuh7QjHwYBY/67TBdzwZXePWhCbcgcOKX8E2C4Kz4siLGBhIV8uPgsYqVzKY2e7AgWgsDZvh MDcha1Bc/7ihsHwVYFqsUebMLTvzP+PeWArc3MOQWNobYJx+eyazFePl6lwDGGTnYbFlZpWYrHDYc hopNLV4Q==; Received: from [167.98.27.226] (helo=rainbowdash) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-006axo-6F; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LT3-3OxI; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 09/15] temp: remove various library optimisations Date: Fri, 20 Dec 2024 15:57:55 +0000 Message-Id: <20241220155801.1988785-10-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_607364_2D462E5E X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org These either need fixing or checking for big endian. - memove is deifentyl not working - ignore memset and memcpy optimisation for now - uaccess code needs fixing --- arch/riscv/lib/memcpy.S | 22 +++++++++++++++++++++- arch/riscv/lib/memmove.S | 2 +- arch/riscv/lib/memset.S | 1 + arch/riscv/lib/strlen.S | 2 +- arch/riscv/lib/uaccess.S | 7 +++++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/riscv/lib/memcpy.S b/arch/riscv/lib/memcpy.S index 44e009ec5fef..b51380f06204 100644 --- a/arch/riscv/lib/memcpy.S +++ b/arch/riscv/lib/memcpy.S @@ -7,12 +7,15 @@ #include /* void *memcpy(void *, const void *, size_t) */ -SYM_FUNC_START(__memcpy) +SYM_FUNC_START(__memcpy1) move t6, a0 /* Preserve return value */ /* Defer to byte-oriented copy for small sizes */ sltiu a3, a2, 128 + j 4f /* for now just always use bytes */ + bnez a3, 4f + /* Use word-oriented copy only if low-order bits match */ andi a3, t6, SZREG-1 andi a4, a1, SZREG-1 @@ -87,6 +90,7 @@ SYM_FUNC_START(__memcpy) or a5, a5, a3 andi a5, a5, 3 bnez a5, 5f + j 5f /* skip word */ 7: lw a4, 0(a1) addi a1, a1, 4 @@ -104,6 +108,22 @@ SYM_FUNC_START(__memcpy) bltu a1, a3, 5b 6: ret + +SYM_FUNC_START(__memcpy) + move t6, a0 /* Preserve return value */ + beqz a2, 6f + add a3, a1, a2 + +5: + lb a4, 0(a1) + addi a1, a1, 1 + sb a4, 0(t6) + addi t6, t6, 1 + bltu a1, a3, 5b +6: + ret + + SYM_FUNC_END(__memcpy) SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy) SYM_FUNC_ALIAS(__pi_memcpy, __memcpy) diff --git a/arch/riscv/lib/memmove.S b/arch/riscv/lib/memmove.S index cb3e2e7ef0ba..c51475e4f3ce 100644 --- a/arch/riscv/lib/memmove.S +++ b/arch/riscv/lib/memmove.S @@ -60,7 +60,7 @@ SYM_FUNC_START(__memmove) */ andi t0, a2, -(2 * SZREG) beqz t0, .Lbyte_copy - + j .Lbyte_copy /* * Now solve for t5 and t6. */ diff --git a/arch/riscv/lib/memset.S b/arch/riscv/lib/memset.S index da23b8347e2d..a3cd79cb33b4 100644 --- a/arch/riscv/lib/memset.S +++ b/arch/riscv/lib/memset.S @@ -14,6 +14,7 @@ SYM_FUNC_START(__memset) /* Defer to byte-oriented fill for small sizes */ sltiu a3, a2, 16 bnez a3, 4f + j 4f /* disabel optimised for now */ /* * Round to nearest XLEN-aligned address diff --git a/arch/riscv/lib/strlen.S b/arch/riscv/lib/strlen.S index 962983b73251..bea650fd24af 100644 --- a/arch/riscv/lib/strlen.S +++ b/arch/riscv/lib/strlen.S @@ -8,7 +8,7 @@ /* int strlen(const char *s) */ SYM_FUNC_START(strlen) - ALTERNATIVE("nop", "j strlen_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB) + /*ALTERNATIVE("nop", "j strlen_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB)*/ /* * Returns diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 6a9f116bb545..3d7da86277bb 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -46,7 +46,8 @@ SYM_FUNC_START(fallback_scalar_usercopy) */ li a3, 9*SZREG-1 /* size must >= (word_copy stride + SZREG-1) */ bltu a2, a3, .Lbyte_copy_tail - + j .Lbyte_copy_tail + /* * Copy first bytes until dst is aligned to word boundary. * a0 - start of dst @@ -73,7 +74,9 @@ SYM_FUNC_START(fallback_scalar_usercopy) */ /* a1 - start of src */ andi a3, a1, SZREG-1 - bnez a3, .Lshift_copy + /* bnez a3, .Lshift_copy */ + /* for now, ignore shift copy until fixed */ + bnez a3, .Lbyte_copy_tail .Lword_copy: /* From patchwork Fri Dec 20 15:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916946 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 A52EFE7718C for ; Fri, 20 Dec 2024 15:58:20 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iQqyEG77QGrzjXeZVsnLpFeBjzjJjfIPKtPDi2aP0lw=; b=fnVAik9zyLgtva OFZYv7BGakR1vdttZTMOKPFLxsQNFjXo9AiOFgxodswbOh9epVhxggpkPtkFJZmjklyF1ub8v9/kr llx5HX1y+GhA3+7NU4j7wmq+AknuNXaXwJlMpLN7+K1irYvMQfrjTZ39sAKcW4qFjH7wAlK4uAYkv 9CsabHIFvy/wsb2AkqRA0oh4+mEEDFuyCtNFwm/Nq5AdUZKejq9QXeA7HQAvw/LYbF75pd+mnAB67 1Cgjv69W+ik5ScexRXeieL6otL24sDBEUjxy7lUEDLVkG/yE2G8WBKwXW9E8fTjXIHGf8whMMAMwK x9klX7om/W+YlLj7/IFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOI-00000005NuU-0E2x; Fri, 20 Dec 2024 15:58:14 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005NqX-0fLh for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZnXGFCpfCP9HiAZ+IkE+2YmSsqzx9QwNJVZS7AaXEzw=; b=lIX2V++SU6VFKrxoUeUTqjnNMj 5ZgR84MQ0L5pUl7hugPjWJxpTxQMqyTUayX/oZ8rpO5ZO1HewsFNO9E+av1HXHgoCXHqWJpDGKAKf KZ9QBKraG1vDFs0Mp53jsGm9TGDbFeLdzyIIdgZAukPGsbJNE0FgVTunD4PDXGoUCwlb+aDo3/2Cz IuIl5FaL0TLZIMkDQfHxo4HvPCfXJqyqFg2l1dZvuOeHQh28suWW4HwSqZMNinoD3TB0qk6g+S+8H A5ROe5Zu4yQU4dqr6v3Kw1WW7O2+9rqEhKlzzGAv7ZPyBrXHcPXz15wqHGR3QQ6qVWnqt+FUw+o54 yShUigUg==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-00ADAM-3D; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LT7-3VT1; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 10/15] riscv: fixup use of natural endian on instructions Date: Fri, 20 Dec 2024 15:57:56 +0000 Message-Id: <20241220155801.1988785-11-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_277309_38F3AA35 X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The priveldged ISA spec says that all instructions should be treated as little endian, so if we load them from memory we should do le{16,32}_to_cpu on these and the reverse when storing. This fixes jump_label, bug and related functions for big endian builds. Signed-off-by: Ben Dooks --- arch/riscv/kernel/alternative.c | 10 +++++++++- arch/riscv/kernel/cfi.c | 3 ++- arch/riscv/kernel/jump_label.c | 3 ++- arch/riscv/kernel/traps.c | 2 ++ arch/riscv/kernel/traps_misaligned.c | 3 +++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/alternative.c b/arch/riscv/kernel/alternative.c index 0128b161bfda..a2c8f0a5bca9 100644 --- a/arch/riscv/kernel/alternative.c +++ b/arch/riscv/kernel/alternative.c @@ -62,11 +62,16 @@ static void riscv_fill_cpu_mfr_info(struct cpu_manufacturer_info_t *cpu_mfr_info } } +static u32 get_u16(u16 *ptr) +{ + return le16_to_cpu(*ptr); +} + static u32 riscv_instruction_at(void *p) { u16 *parcel = p; - return (u32)parcel[0] | (u32)parcel[1] << 16; + return (u32)get_u16(parcel+0) | (u32)get_u16(parcel+1) << 16; } static void riscv_alternative_fix_auipc_jalr(void *ptr, u32 auipc_insn, @@ -83,6 +88,8 @@ static void riscv_alternative_fix_auipc_jalr(void *ptr, u32 auipc_insn, riscv_insn_insert_utype_itype_imm(&call[0], &call[1], imm); /* patch the call place again */ + call[0] = cpu_to_le32(call[0]); + call[1] = cpu_to_le32(call[1]); patch_text_nosync(ptr, call, sizeof(u32) * 2); } @@ -98,6 +105,7 @@ static void riscv_alternative_fix_jal(void *ptr, u32 jal_insn, int patch_offset) riscv_insn_insert_jtype_imm(&jal_insn, imm); /* patch the call place again */ + jal_insn = cpu_to_le32(jal_insn); patch_text_nosync(ptr, &jal_insn, sizeof(u32)); } diff --git a/arch/riscv/kernel/cfi.c b/arch/riscv/kernel/cfi.c index 64bdd3e1ab8c..bd35ddbcbcee 100644 --- a/arch/riscv/kernel/cfi.c +++ b/arch/riscv/kernel/cfi.c @@ -37,15 +37,16 @@ static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target, */ if (get_kernel_nofault(insn, (void *)regs->epc - 4)) return false; + insn = le32_to_cpu(insn); if (!riscv_insn_is_beq(insn)) return false; - *type = (u32)regs_ptr[RV_EXTRACT_RS1_REG(insn)]; if (get_kernel_nofault(insn, (void *)regs->epc) || get_kernel_nofault(insn, (void *)regs->epc + GET_INSN_LENGTH(insn))) return false; + insn = le32_to_cpu(insn); if (riscv_insn_is_jalr(insn)) rs1_num = RV_EXTRACT_RS1_REG(insn); else if (riscv_insn_is_c_jalr(insn)) diff --git a/arch/riscv/kernel/jump_label.c b/arch/riscv/kernel/jump_label.c index 11ad789c60c6..e8a9301ec0bf 100644 --- a/arch/riscv/kernel/jump_label.c +++ b/arch/riscv/kernel/jump_label.c @@ -19,7 +19,7 @@ bool arch_jump_label_transform_queue(struct jump_entry *entry, enum jump_label_type type) { void *addr = (void *)jump_entry_code(entry); - u32 insn; + __le32 insn; if (type == JUMP_LABEL_JMP) { long offset = jump_entry_target(entry) - jump_entry_code(entry); @@ -36,6 +36,7 @@ bool arch_jump_label_transform_queue(struct jump_entry *entry, insn = RISCV_INSN_NOP; } + insn = cpu_to_le32(insn); mutex_lock(&text_mutex); patch_insn_write(addr, &insn, sizeof(insn)); mutex_unlock(&text_mutex); diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 51ebfd23e007..a475fd9310fd 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -253,6 +253,7 @@ static inline unsigned long get_break_insn_length(unsigned long pc) if (get_kernel_nofault(insn, (bug_insn_t *)pc)) return 0; + insn = le32_to_cpu(insn); return GET_INSN_LENGTH(insn); } @@ -399,6 +400,7 @@ int is_valid_bugaddr(unsigned long pc) return 0; if (get_kernel_nofault(insn, (bug_insn_t *)pc)) return 0; + insn = cpu_to_le32(insn); if ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) return (insn == __BUG_INSN_32); else diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c index 1b9867136b61..21b2a4df185f 100644 --- a/arch/riscv/kernel/traps_misaligned.c +++ b/arch/riscv/kernel/traps_misaligned.c @@ -290,6 +290,7 @@ static inline int get_insn(struct pt_regs *regs, ulong epc, ulong *r_insn) * below with the upper 16 bits half. */ insn &= GENMASK(15, 0); + insn = le16_to_cpu(insn); if ((insn & __INSN_LENGTH_MASK) != __INSN_LENGTH_32) { *r_insn = insn; return 0; @@ -297,12 +298,14 @@ static inline int get_insn(struct pt_regs *regs, ulong epc, ulong *r_insn) epc += sizeof(u16); if (__read_insn(regs, tmp, epc, u16)) return -EFAULT; + tmp = le16_to_cpu(tmp); *r_insn = (tmp << 16) | insn; return 0; } else { if (__read_insn(regs, insn, epc, u32)) return -EFAULT; + insn = le32_to_cpu(insn); if ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) { *r_insn = insn; return 0; From patchwork Fri Dec 20 15:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916957 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 5BBD5E7718E for ; Fri, 20 Dec 2024 15:58:27 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OvJWVNUkzlm651TvvoNBcPnoecpWn3ggi5kC1JwXJTo=; b=dHQuFE9JvqSY+3 WcDRtL9qrgdhG1AHfBmzts/zDK8cn/WyxNTMBp/5sW0Smvn9dz1CQ4MdNfx27Y0jgRfd38HGOiELp 1L5tVjnLTouuPsN+0WuONvgw+7sgwRFrJAzeDMbOza0BHwUJ/NlWTL6qTnmT2McpyL4GL+LNncEME HiY7Nfzn1Z+jAkYheu/fiCgNM/0WesD1mjHbIEHEO9aY/HXl1XTd/WlMYM/Jdp48gdjDGY92ukhBZ CnXJ0d9w2M4gXY6yoPfwz+m545YyrMz4V5k7V4XU1d8G5iREoc1RLhB6DV2aPJ3jhVTxn4/VZzWXF F39fr5gc8L4WR5ms7ddw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOI-00000005Nuh-3Evo; Fri, 20 Dec 2024 15:58:14 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005Nqa-1jj1 for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wrx10QwzuqCnRW3M8oiJ8RSWqLjQ58jslwZa+sNGfa0=; b=1gUQ2ZDtufTmt6okEhqUqqOxHF ZLJQoDFyIVjTvLU5Cf7xQBeye2YeKBVMrctIa6aNSfP5lKCV3mnioH9QZkfoPLbzmb6dO1FJ7ZpVV +YM4Rqe41G8H3WyGiZSmJX7GNCKQ4BOJMSmV8LIIlHqnM2yvOh3gX3WpGck6Sdt1kyKR+cEub5xiR vOEF3EmdGHIdLxvh0pX9cS2Ny7iYQcnBmR70jqnHug2dp31T0AZiUXc+1LC/EpvRoQ+2YU00msw5b lDZ/5gcDqT5jxyRjSl70PJ3+zrc1XbsheKqFAgO5exB0StukVMDv8nzKAEPRMNfbnRt1kVMhNSbu/ o7GviuuA==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-00ADAN-3F; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LTB-3bSK; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 11/15] add todo on fpu Date: Fri, 20 Dec 2024 15:57:57 +0000 Message-Id: <20241220155801.1988785-12-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_448424_43D4DAB6 X-CRM114-Status: UNSURE ( 7.06 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org --- arch/riscv/kernel/traps_misaligned.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c index 21b2a4df185f..fdf12dc579d4 100644 --- a/arch/riscv/kernel/traps_misaligned.c +++ b/arch/riscv/kernel/traps_misaligned.c @@ -154,6 +154,7 @@ #define PRECISION_D 1 #ifdef CONFIG_FPU +// todo - is fpu going to be big or little endian #define FP_GET_RD(insn) (insn >> 7 & 0x1F) From patchwork Fri Dec 20 15:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916945 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 2EE3FE77188 for ; Fri, 20 Dec 2024 15:58:20 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EaYAfrjgmbUTKoG8g52vuSqIDdA5oeOMpOUmUrautbc=; b=RPQXvxI9cyfV63 KISWJXNxzLVg8bkjkB4WdgchfNhnE0rB1FeNm3xy+10SWXfDxKdInt3wjCdlX7HbMVUDqvVRnYPqH MYgcpV4tZjVzViSe8YUxqAONFFSl0X9RnIOv9oNf5v1aU0KrPAFvCAJZNEjZZnMphpyPr6uoYPgsK Ijlsramlde+Uq8LTAyYHacT6aFcJya1/ysyoeJlKMzUtWceo3V356t2dMsuoeTgX3Q9Qr2uZueNBS YEC9mkbKSx6w4m8Y52HGyDcjFN4kGHBTi0lsUGfdyLkqa6RKM4LgSOnHq0oUPK4vw2jugVTg9zVJ7 pWNTcqqJCf4XRkhndHaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOJ-00000005NvZ-2cc8; Fri, 20 Dec 2024 15:58:15 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOF-00000005NqY-1lRO for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kRvzRkr5gY/5pQR/YZDxLWbtpc+EzjrXZMVpv2FaDuE=; b=7LR5nXrrSIlqdn+O334qwTvYV5 MbPi7i4s4eNT+MWfDv6vQrQk5KzJ9bGGeoZTBehC24hFCgOCx/I4wyo1vV5qj0X2G7UcO4RqU5mtN pnzPDwMMolGWGSMR0djJE1wyOT0Kqz4szvHiCWenVck4dT8PzkMnfO14Cmag4ouQXrBJ5e1lD3sDU f43eVSpROiAfPezeHTIIQ7rdlLGKigICym+lRtmPUGzLgp8L5rE3z7ShaPUEwhf5+sJF1UYmNKL/v wiSuHJw7KftBRYdZk7WrGkdHMKjowWwJgIv2iXZvX+4AecY9IH748bSt3R9e6zW6hC/Xidsj4x6Hl cdmyv1lQ==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-00ADAO-3J; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LTF-3hiI; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 12/15] riscv: bpf: big endian fixes, updated BPF_ALU ops Date: Fri, 20 Dec 2024 15:57:58 +0000 Message-Id: <20241220155801.1988785-13-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075811_453404_70720C8C X-CRM114-Status: GOOD ( 11.83 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org If running big endian then the instruction stream needs to be written le16/le323 and the BPF BSWAP instrictions need to correctly set the endian. Signed-off-by: Ben Dooks --- arch/riscv/net/bpf_jit.h | 14 +++++++++----- arch/riscv/net/bpf_jit_comp64.c | 29 +++++++++++++++++------------ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/arch/riscv/net/bpf_jit.h b/arch/riscv/net/bpf_jit.h index 1d1c78d4cff1..eb2908cc42fd 100644 --- a/arch/riscv/net/bpf_jit.h +++ b/arch/riscv/net/bpf_jit.h @@ -28,6 +28,12 @@ static inline bool rvzbb_enabled(void) return IS_ENABLED(CONFIG_RISCV_ISA_ZBB) && riscv_has_extension_likely(RISCV_ISA_EXT_ZBB); } +static inline bool alu_end_should_swap(u32 code) +{ + u32 endian = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) ? BPF_FROM_BE : BPF_FROM_LE; + return (code & BPF_FROM_BE) != endian; +} + enum { RV_REG_ZERO = 0, /* The constant value 0 */ RV_REG_RA = 1, /* Return address */ @@ -117,10 +123,8 @@ static inline void bpf_flush_icache(void *start, void *end) /* Emit a 4-byte riscv instruction. */ static inline void emit(const u32 insn, struct rv_jit_context *ctx) { - if (ctx->insns) { - ctx->insns[ctx->ninsns] = insn; - ctx->insns[ctx->ninsns + 1] = (insn >> 16); - } + if (ctx->insns) + put_unaligned_le32(insn, ctx->insns+ctx->ninsns); ctx->ninsns += 2; } @@ -131,7 +135,7 @@ static inline void emitc(const u16 insn, struct rv_jit_context *ctx) BUILD_BUG_ON(!rvc_enabled()); if (ctx->insns) - ctx->insns[ctx->ninsns] = insn; + ctx->insns[ctx->ninsns] = cpu_to_le16(insn); ctx->ninsns++; } diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c index 4cc631fa7039..05f5b1a88423 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -1273,20 +1273,25 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx, /* dst = BSWAP##imm(dst) */ case BPF_ALU | BPF_END | BPF_FROM_LE: - switch (imm) { - case 16: - emit_zexth(rd, rd, ctx); - break; - case 32: - if (!aux->verifier_zext) - emit_zextw(rd, rd, ctx); - break; - case 64: - /* Do nothing */ - break; + case BPF_ALU | BPF_END | BPF_FROM_BE: + if (alu_end_should_swap(code)) { + emit_bswap(rd, imm, ctx); + } else { + switch (imm) { + case 16: + emit_zexth(rd, rd, ctx); + break; + case 32: + if (!aux->verifier_zext) + emit_zextw(rd, rd, ctx); + break; + case 64: + /* Do nothing */ + break; + } } break; - case BPF_ALU | BPF_END | BPF_FROM_BE: + case BPF_ALU64 | BPF_END | BPF_FROM_LE: emit_bswap(rd, imm, ctx); break; From patchwork Fri Dec 20 15:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916959 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 BFEF7E77188 for ; Fri, 20 Dec 2024 15:58:30 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pm5r57j6rsYAQw1GodceJfCppPguvIexRBl5L+8ToD0=; b=BrA9gEvHQPyKTe Yw7NxX+rK7Q8K5Ges3dxNUUYlwMhDoFrfyOwg5Jn2a5Qnz6WZZUKCCbd/gR72tbQ4Xh6JsAqQ71Rj /1cVUBSkJEoFc2aeKpeUvxf8usy3sov5slnpsvIDDxHlwy7Nnk6G+qiF6idEESyOlkzRzTzRDIkP6 ING5EgbosGZgTq2Ui7qyez3P7B2iQEnBDN67ortvbkXlxnquQQE9t9QYQnWmg1oPpc9FoC8XCJSxK Tfaw1o+maUsc6hHXX5GV8bkcc1RgwRHxGCa9tZrYY3Ab1183U8XHVAzrl6b71vIjV+zADY4AOEj4P AZuZZpGpKwkmy0ZfhTHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOU-00000005O6w-2WLX; Fri, 20 Dec 2024 15:58:26 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOT-00000005O4N-0Dkg for linux-riscv@bombadil.infradead.org; Fri, 20 Dec 2024 15:58:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=zPhaTsY4qCL9woinVqGvqyBBtfuDqS0FIL6nGwEOfcA=; b=ZOEF8RcDnIhKvRgAwXOAo8AJK4 aDDDqf4tMbHLbbtf+lA5xgH5wixdetKvP+lDmj4CFBmMTjG9DMeBoZUS4l82c9QcmlgCaRx4jqtuP R0uBGkyleEeFZpbM2CRSMRg5GEgoL0AtquzBHLh8Q1wy0S7JFb8z4bXNdhnfcbJvNRxiePCpMrLCE 0cQMcJEZEY/p/nhKE9MGBWwkhXmQb1HiH8R7mHTL1UK4iPpjXwn2+9kEdfA47KfVuyyNR3B0FnW7n chk+YOyj+5SgeOpTGiXZY6wyZjSPC14UOyfsTXGGSNBaQUc4fRvgvBbkqOjvyDdGZ2uFOZA//CpLK H04AU5UA==; Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by casper.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOP-00000001Urf-4462 for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zPhaTsY4qCL9woinVqGvqyBBtfuDqS0FIL6nGwEOfcA=; b=n2/AIh7xFYFviRyoRSt4fvi2IB gxeNj2wRODlsIVN6HP9KD2/f2/qIM0BJeqo0wtu8zmF56tIqfmx+ZLBcz6CHXjuWMBs05P8EbzaSe b6f8Y56gTpf0Fb1hwM/AfVwmWzkGOv5tonSMsIbM6uWTpbaq1fc8+2czGaosLygEZvSAx+6mEzNqr 4w/Dqa6regrv9X4YzH0NJGmCn9GxjcVOCYKm01I5+qgKr6Gt6U/91a+O6HhwkwFRj/MvIHpeQoIL0 3ap7e3CgBnrXdHiwJM/xmnYnD8WI8M9NK4H2qBnPXC3uyFmBNHu8ysOS0Z8IO9pYajyUdPg9VUwIu zF2zAymQ==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-00ADAR-5A; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LTK-3nAj; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 13/15] riscv: probes: sort out endian-ness Date: Fri, 20 Dec 2024 15:57:59 +0000 Message-Id: <20241220155801.1988785-14-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_155822_294642_25B6216E X-CRM114-Status: GOOD ( 13.18 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Updated {k,u}probe code to deal with big endian mode where the instruction stream is always in little endian. Signed-off-by: Ben Dooks --- arch/riscv/kernel/probes/decode-insn.c | 2 +- arch/riscv/kernel/probes/decode-insn.h | 5 +++++ arch/riscv/kernel/probes/kprobes.c | 30 ++++++++++++++++---------- arch/riscv/kernel/probes/uprobes.c | 10 ++++----- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/arch/riscv/kernel/probes/decode-insn.c b/arch/riscv/kernel/probes/decode-insn.c index 65d9590bfb9f..5f30c10f7d8d 100644 --- a/arch/riscv/kernel/probes/decode-insn.c +++ b/arch/riscv/kernel/probes/decode-insn.c @@ -16,7 +16,7 @@ enum probe_insn __kprobes riscv_probe_decode_insn(probe_opcode_t *addr, struct arch_probe_insn *api) { - probe_opcode_t insn = *addr; + probe_opcode_t insn = le32_to_cpu(*addr); /* * Reject instructions list: diff --git a/arch/riscv/kernel/probes/decode-insn.h b/arch/riscv/kernel/probes/decode-insn.h index 42269a7d676d..0515deb204b5 100644 --- a/arch/riscv/kernel/probes/decode-insn.h +++ b/arch/riscv/kernel/probes/decode-insn.h @@ -15,4 +15,9 @@ enum probe_insn { enum probe_insn __kprobes riscv_probe_decode_insn(probe_opcode_t *addr, struct arch_probe_insn *asi); +static inline int read_insn_length(void *ptr) +{ + return GET_INSN_LENGTH(le16_to_cpu(*(__le16 *)ptr)); +} + #endif /* _RISCV_KERNEL_KPROBES_DECODE_INSN_H */ diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c index 474a65213657..aba684938284 100644 --- a/arch/riscv/kernel/probes/kprobes.c +++ b/arch/riscv/kernel/probes/kprobes.c @@ -24,13 +24,13 @@ post_kprobe_handler(struct kprobe *, struct kprobe_ctlblk *, struct pt_regs *); static void __kprobes arch_prepare_ss_slot(struct kprobe *p) { - size_t len = GET_INSN_LENGTH(p->opcode); - u32 insn = __BUG_INSN_32; + size_t len = read_insn_length(&p->opcode); + u32 insn = cpu_to_le32(__BUG_INSN_32); p->ainsn.api.restore = (unsigned long)p->addr + len; patch_text_nosync(p->ainsn.api.insn, &p->opcode, len); - patch_text_nosync(p->ainsn.api.insn + len, &insn, GET_INSN_LENGTH(insn)); + patch_text_nosync((void *)p->ainsn.api.insn + len, &insn, GET_INSN_LENGTH(__BUG_INSN_32)); } static void __kprobes arch_prepare_simulate(struct kprobe *p) @@ -58,7 +58,7 @@ static bool __kprobes arch_check_kprobe(struct kprobe *p) if (tmp == addr) return true; - tmp += GET_INSN_LENGTH(*(u16 *)tmp); + tmp += read_insn_length((u16 *)tmp); } return false; @@ -75,9 +75,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) return -EILSEQ; /* copy instruction */ - p->opcode = (kprobe_opcode_t)(*insn++); - if (GET_INSN_LENGTH(p->opcode) == 4) - p->opcode |= (kprobe_opcode_t)(*insn) << 16; + *((u16 *)&p->opcode) = (*insn++); + if (read_insn_length(&p->opcode) == 4) + p->opcode = (kprobe_opcode_t)(*(u32 *)p->addr); /* decode instruction */ switch (riscv_probe_decode_insn(p->addr, &p->ainsn.api)) { @@ -107,16 +107,24 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) /* install breakpoint in text */ void __kprobes arch_arm_kprobe(struct kprobe *p) { - size_t len = GET_INSN_LENGTH(p->opcode); - u32 insn = len == 4 ? __BUG_INSN_32 : __BUG_INSN_16; + size_t len = read_insn_length(&p->opcode); + u32 insn; + + if (len == 4) + insn = cpu_to_le32(__BUG_INSN_32); + else { + insn = cpu_to_le16(__BUG_INSN_16); + insn |= cpu_to_le16(__BUG_INSN_16) << 16; + } + pr_info("%s: patching %px (%d bytes)\n", __func__, p->addr, (int)len); patch_text(p->addr, &insn, len); } /* remove breakpoint from text */ void __kprobes arch_disarm_kprobe(struct kprobe *p) { - size_t len = GET_INSN_LENGTH(p->opcode); + size_t len = read_insn_length(&p->opcode); patch_text(p->addr, &p->opcode, len); } @@ -336,7 +344,7 @@ kprobe_single_step_handler(struct pt_regs *regs) struct kprobe *cur = kprobe_running(); if (cur && (kcb->kprobe_status & (KPROBE_HIT_SS | KPROBE_REENTER)) && - ((unsigned long)&cur->ainsn.api.insn[0] + GET_INSN_LENGTH(cur->opcode) == addr)) { + ((unsigned long)&cur->ainsn.api.insn[0] + read_insn_length(&cur->opcode) == addr)) { kprobes_restore_local_irqflag(kcb, regs); post_kprobe_handler(cur, kcb, regs); return true; diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c index 4b3dc8beaf77..e31c1dd337d5 100644 --- a/arch/riscv/kernel/probes/uprobes.c +++ b/arch/riscv/kernel/probes/uprobes.c @@ -12,9 +12,9 @@ bool is_swbp_insn(uprobe_opcode_t *insn) { #ifdef CONFIG_RISCV_ISA_C - return (*insn & 0xffff) == UPROBE_SWBP_INSN; + return (*(u16 *)insn) == cpu_to_le16(UPROBE_SWBP_INSN); #else - return *insn == UPROBE_SWBP_INSN; + return *insn == cpu_to_le32(UPROBE_SWBP_INSN); #endif } @@ -35,7 +35,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, opcode = *(probe_opcode_t *)(&auprobe->insn[0]); - auprobe->insn_size = GET_INSN_LENGTH(opcode); + auprobe->insn_size = GET_INSN_LENGTH(le32_to_cpu(opcode)); switch (riscv_probe_decode_insn(&opcode, &auprobe->api)) { case INSN_REJECTED: @@ -172,8 +172,8 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, /* Add ebreak behind opcode to simulate singlestep */ if (vaddr) { - dst += GET_INSN_LENGTH(*(probe_opcode_t *)src); - *(uprobe_opcode_t *)dst = __BUG_INSN_32; + dst += read_insn_length(src); + *(uprobe_opcode_t *)dst = cpu_to_le32(__BUG_INSN_32); } kunmap_atomic(kaddr); From patchwork Fri Dec 20 15:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916958 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 479D3E77188 for ; Fri, 20 Dec 2024 15:58:28 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SI0kKSspk1+c+ipYSdjbX+ybb1qd5ESsgqt81UQBZUs=; b=jOrFAe9AJHO6gP Wn5CPSia9kjBhRMoizMKDIlauhmPLsfY27bbLrWB0n5DpBeAWp9JBTojBe1U3zcUPwSILFgwkiGYP AlDrYsLmaZKRwIA7JyLfOnRpXYp/mUgN2yQLmm5xM3exzmVXWSq4TVPguj0jK7ZJYi5hZmylmaYN6 nbR1HFZkTylQPWeR9TeMiz+GX1u3lBfoPPTQKwLGCWAAfBanI6OYGxtUDjtK84WLKw25QOquUUcdI YVyRdXgoO2X4MhuPMvh6JkgQzqBR8/6FABt2m9BNB7UXTciXmPA51Ewv+ClvAWTeoQrXsZjQ8J4fc py5y1u7Pb1kDCsnbA0aQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOR-00000005O3L-3Aej; Fri, 20 Dec 2024 15:58:23 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOH-00000005NtQ-2jOD for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rHgLYuhxcz/DTJlLYQV+se4GUhr8DJUj10zY4CoFS08=; b=aa74y86bKv2+VdnSn0pEUID0t8 HbQatCkUuJnIYff/XRnb/hzt3yUUGWrxUyz00C1zX8YGLcuCeJl2EXmmaQDYpfBuvxFVkEkAl4xfN NvhiKabCw4AJjIuzlA/iG1lXU/YsM4r/J9zxvFClr4VDqXu2XYa7YXuGgIE1vNsjqP46WSM4hHBGC WejOmv/VH1dinIwPWd4M6hXBrr3FP3nxzbHkhC47tlyoZd/ZAaGiifTcz51HbiffmXs+UVq0VlWtd 3cpX0JYCOfiuEvrAhvzyY7+8VWASklu6dLl3wkCpsKD4SiG523toiccva0YCzLL1tea/R5zQPDW1a epX2el/g==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-00ADAS-5Q; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LTO-3tIn; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 14/15] riscv: ftrace big endian updates Date: Fri, 20 Dec 2024 15:58:00 +0000 Message-Id: <20241220155801.1988785-15-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075813_809174_01487C87 X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Make the ftrace code work with big endian by ensuring the instruction stream is accessed little endian. Signed-off-by: Ben Dooks --- arch/riscv/include/asm/ftrace.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h index 2cddd79ff21b..233428aeab1d 100644 --- a/arch/riscv/include/asm/ftrace.h +++ b/arch/riscv/include/asm/ftrace.h @@ -79,7 +79,7 @@ struct dyn_arch_ftrace { #define AUIPC_RA (0x00000097) #define JALR_T0 (0x000282e7) #define AUIPC_T0 (0x00000297) -#define NOP4 (0x00000013) +#define NOP4 (le32_to_cpu(0x00000013)) #define to_jalr_t0(offset) \ (((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_T0) @@ -93,8 +93,8 @@ struct dyn_arch_ftrace { do { \ unsigned int offset = \ (unsigned long) callee - (unsigned long) caller; \ - call[0] = to_auipc_t0(offset); \ - call[1] = to_jalr_t0(offset); \ + call[0] = cpu_to_le32(to_auipc_t0(offset)); \ + call[1] = cpu_to_le32(to_jalr_t0(offset)); \ } while (0) #define to_jalr_ra(offset) \ @@ -109,8 +109,8 @@ do { \ do { \ unsigned int offset = \ (unsigned long) callee - (unsigned long) caller; \ - call[0] = to_auipc_ra(offset); \ - call[1] = to_jalr_ra(offset); \ + call[0] = cpu_to_le32(to_auipc_ra(offset)); \ + call[1] = cpu_to_le32(to_jalr_ra(offset)); \ } while (0) /* From patchwork Fri Dec 20 15:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13916954 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 EACA8E7718D for ; Fri, 20 Dec 2024 15:58:25 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tC+gvlqcOS3vQ6loD/PzlMf4tyw++GCZPF9Qs/IDVAQ=; b=KKCT/nA2Fiv8Bx +VvV4eWpeOUjHGFm2Ol1BA+vfLpgteXyxXkdPbx7MQOzuz+kfvCMQTK7YpufGziOi6KOhbEryKTmd V6A8FgG0Ilo1LJnUt0hSQt+kok9mFXDYwtFDFis1gl7ihz/4BB7z3PxuwwRDxl5fRP+ZHaz65EXGR YL6gJr+0Po/RoPrgf1fzzKtZ5j+UlkMH8b58GGX6CpkI3iFhl3lyFrhr75CK3eHlR4cLaNE10BCHI o18UXAZgZXgZcDc3KLBHFwDoxSL2UkObzgRvksfGdAS1FLPbsdOBddqjYSkvrpDCiOwA8EDHI/9LE GKDA5Zl/6qqJnT9JAVhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOP-00000005O0d-3jVq; Fri, 20 Dec 2024 15:58:21 +0000 Received: from imap5.colo.codethink.co.uk ([78.40.148.171]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOfOH-00000005NtN-2DIj for linux-riscv@lists.infradead.org; Fri, 20 Dec 2024 15:58:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=E6Cvl+CmVX6/psQST7J+RL1e1pZwMBpeyyec77Ez6rM=; b=nBafdhbLpa+Ca5tWntqfRP28qr 6h5N0lBoh+ObPrK4AAyld/80dz8Kxkt5VOWsc9qY7N6pizkq9K/nGpF6QoGm/dKr64t+bdA9roqMw IsIvQe+Ol416AQFNuym9TomijNdLdTqxtuZbSUgW9cdlHxaVaawvhuul2nPnVxjGwbKe++C/gVDJ5 03rtu0ulFN8zZnXIWzhXZO5Eq+qZcYuvOxf6JLQib1L5C1YcWW3/6w7YFDQ+mAQrW2f2g8VlfH2ew nSmUrpssaZPNydsMQplIzRFIy9LYhbEw0BNSvjFlSb8zLqMMo/rJmWSAXNidDjy/IaQohbpHDMzu1 YHZARb6g==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1tOfOA-00ADAT-5F; Fri, 20 Dec 2024 15:58:06 +0000 Received: from ben by rainbowdash with local (Exim 4.98) (envelope-from ) id 1tOfO9-00000008LTS-3zRi; Fri, 20 Dec 2024 15:58:05 +0000 From: Ben Dooks To: felix.chong@codethink.co.uk, lawrence.hunter@codethink.co.uk, roan.richmond@codethink.co.uk, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [RFC 15/15] riscv: traps: make insn fetch common in unknown instruction Date: Fri, 20 Dec 2024 15:58:01 +0000 Message-Id: <20241220155801.1988785-16-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 In-Reply-To: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> References: <20241220155801.1988785-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_075813_634065_91CD36F1 X-CRM114-Status: GOOD ( 12.37 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the trapped instruction (insn) as the second argument to riscv_v_first_use_handler() from the trap handler so when we add more handlers we can do the fetch of the instruction just once. Signed-off-by: Ben Dooks --- - fixed wording of patch from rfc v2: - fixed todo by going to illegal instruction error if get_user fails - added pointer print for failed read - fixed issues with rebasing onto main branch v3: - removed print from v2 --- arch/riscv/include/asm/vector.h | 5 +++-- arch/riscv/kernel/traps.c | 13 +++++++++++-- arch/riscv/kernel/vector.c | 11 +---------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h index be7d309cca8a..24f77a56ac57 100644 --- a/arch/riscv/include/asm/vector.h +++ b/arch/riscv/include/asm/vector.h @@ -21,7 +21,7 @@ extern unsigned long riscv_v_vsize; int riscv_v_setup_vsize(void); -bool riscv_v_first_use_handler(struct pt_regs *regs); +bool riscv_v_first_use_handler(struct pt_regs *regs, u32 insn); void kernel_vector_begin(void); void kernel_vector_end(void); void get_cpu_vector_context(void); @@ -268,7 +268,8 @@ struct pt_regs; static inline int riscv_v_setup_vsize(void) { return -EOPNOTSUPP; } static __always_inline bool has_vector(void) { return false; } -static inline bool riscv_v_first_use_handler(struct pt_regs *regs) { return false; } +static __always_inline bool insn_is_vector(u32 insn_buf) { return false; } +static inline bool riscv_v_first_use_handler(struct pt_regs *regs, u32 insn) { return false; } static inline bool riscv_v_vstate_query(struct pt_regs *regs) { return false; } static inline bool riscv_v_vstate_ctrl_user_allowed(void) { return false; } #define riscv_v_vsize (0) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index a475fd9310fd..5ef418b0b7b2 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -169,17 +169,26 @@ DO_ERROR_INFO(do_trap_insn_fault, asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *regs) { - bool handled; + bool handled = false; if (user_mode(regs)) { + u32 __user *epc = (u32 __user *)regs->epc; + u32 insn = (u32)regs->badaddr; + irqentry_enter_from_user_mode(regs); local_irq_enable(); - handled = riscv_v_first_use_handler(regs); + if (!insn) { + if (__get_user(insn, epc)) + goto no_insn; + } + + handled = riscv_v_first_use_handler(regs, insn); local_irq_disable(); + no_insn: if (!handled) do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->epc, "Oops - illegal instruction"); diff --git a/arch/riscv/kernel/vector.c b/arch/riscv/kernel/vector.c index 682b3feee451..b852648cb8d5 100644 --- a/arch/riscv/kernel/vector.c +++ b/arch/riscv/kernel/vector.c @@ -168,11 +168,8 @@ bool riscv_v_vstate_ctrl_user_allowed(void) } EXPORT_SYMBOL_GPL(riscv_v_vstate_ctrl_user_allowed); -bool riscv_v_first_use_handler(struct pt_regs *regs) +bool riscv_v_first_use_handler(struct pt_regs *regs, u32 insn) { - u32 __user *epc = (u32 __user *)regs->epc; - u32 insn = (u32)regs->badaddr; - if (!has_vector()) return false; @@ -184,12 +181,6 @@ bool riscv_v_first_use_handler(struct pt_regs *regs) if (riscv_v_vstate_query(regs)) return false; - /* Get the instruction */ - if (!insn) { - if (__get_user(insn, epc)) - return false; - } - /* Filter out non-V instructions */ if (!insn_is_vector(insn)) return false;