From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86AC4C433ED for ; Sat, 17 Apr 2021 04:56:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59043611C2 for ; Sat, 17 Apr 2021 04:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbhDQE5L (ORCPT ); Sat, 17 Apr 2021 00:57:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:54376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbhDQE5K (ORCPT ); Sat, 17 Apr 2021 00:57:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 396886113D; Sat, 17 Apr 2021 04:56:43 +0000 (UTC) Subject: Re: [PATCH v4 2/2] riscv: Disable data start offset in flat binaries To: Damien Le Moal , uclinux-dev@uclinux.org, Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Anup Patel , Christoph Hellwig References: <20210417011009.54569-1-damien.lemoal@wdc.com> <20210417011009.54569-3-damien.lemoal@wdc.com> From: Greg Ungerer Message-ID: Date: Sat, 17 Apr 2021 14:56:41 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210417011009.54569-3-damien.lemoal@wdc.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/4/21 11:10 am, Damien Le Moal wrote: > uclibc/gcc combined with elf2flt riscv linker file fully resolve the > PC relative __global_pointer$ value at compile time and do not generate > a relocation entry to set a correct value of the gp register at runtime. > As a result, if the flatbin loader offsets the start of the data > section, the relative position change between the text and data sections > compared to the compile time positions results in an incorrect gp value > being used. This causes flatbin executables to crash. > > Avoid this problem by enabling CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET > automatically when CONFIG_RISCV is enabled and CONFIG_MMU is disabled. > > Signed-off-by: Damien Le Moal > Acked-by: Palmer Dabbelt Acked-by: Greg Ungerer Palmer do you want me to take this via my tree with 1/2 in the series, or are you going to pick it up? Regards Greg > --- > arch/riscv/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 4515a10c5d22..add528eb9235 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -33,6 +33,7 @@ config RISCV > select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU > select ARCH_WANT_FRAME_POINTERS > select ARCH_WANT_HUGE_PMD_SHARE if 64BIT > + select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU > select CLONE_BACKWARDS > select CLINT_TIMER if !MMU > select COMMON_CLK >