Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2342704rwd; Fri, 19 May 2023 04:37:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4skaNeRiNuSk1YlRcCUVUMry79tFSjqDMmM8h+R/xKrej8JrZZVpc4Ck2KaoDJeDGDRalD X-Received: by 2002:a17:903:451:b0:1a1:c7b2:e7c7 with SMTP id iw17-20020a170903045100b001a1c7b2e7c7mr1833783plb.49.1684496254229; Fri, 19 May 2023 04:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684496254; cv=none; d=google.com; s=arc-20160816; b=aSsc9DVb0fKUc35eUe7GJwFqVOf3LbfnXXMkD4c5Nj0n92hEF3yYYpSy5JstyTjj/W 6sjQi5DBfTUXM/UEs2kXJmAtWEIaDUR4SRtplwpp9cRlwJwgAvJQg1CcpWwJqVgrlJko mZO9bkcP9YQ/81pc9LJmCY4hxlzgzSgGTmdDu6jmVxLamXxN+32eNcDDbjfngdHhnAX8 d0i9nXq9VQ9dqiJG6dV4BeHf2VrCvEl7HhQPfJyKw5D/UDz3RztEgLRzwJXet34uNmh0 08wyGn6ASaU65n2DFLKjiqH4Ao9l/11gb3kr7Z50SSVqU0D30zscxUIYUW/kPlQhCNfc UI9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=CefLqjHZOi+Xzl77L9jWO9UU6Enu52xxP8pa6wvUHxA=; b=zjNvUmrAn5kGXplBPBOe8Xg+6pyk0VSs5YnibFYfyVl6hSx//5c7W6ndhfiaMOJtNi tSPX2icZXmRlds+YMGIwzCA5XOu9hhppvG9TxfGgRYFJaazKtvLi9b23h4gEGfc1ypsi +w4zhJf8dGF1xMQDgl0A7Q3C877a4HeIHVtG8/qUN7CKny8b5jlkN0OvAuJdByt2He/+ R4ITmDoW+gHX8Cbndn5/dYOLBsLlntCDm1Pd5nuJSTuYqjzKs8GhGG0xMYAUlAsK0fo6 /fwgdtCkhUSSMPu54vzcpsxZnFkniDKwk/w4H8MkuT4cmKOAIgzykkrv5Mq47SLRiPND CVrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a170902c3c600b001ab08e28e0dsi3511364plj.50.2023.05.19.04.37.21; Fri, 19 May 2023 04:37:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbjESLIV (ORCPT + 99 others); Fri, 19 May 2023 07:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbjESLIU (ORCPT ); Fri, 19 May 2023 07:08:20 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E9A9D7 for ; Fri, 19 May 2023 04:08:18 -0700 (PDT) Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id CF7CAE000B; Fri, 19 May 2023 11:08:12 +0000 (UTC) Message-ID: <6fc7f0e1-0dde-9b41-0d60-6b0bd65bb630@ghiti.fr> Date: Fri, 19 May 2023 13:08:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE Content-Language: en-US To: Andreas Schwab Cc: Alexandre Ghiti , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org References: <20230215143626.453491-1-alexghiti@rivosinc.com> <20230215143626.453491-2-alexghiti@rivosinc.com> <87wn1h5nne.fsf@igel.home> <4adb27d2-325d-3ce0-23b1-ec69a973b4bf@ghiti.fr> <87ttwi91g0.fsf@igel.home> From: Alexandre Ghiti In-Reply-To: <87ttwi91g0.fsf@igel.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/11/23 20:18, Andreas Schwab wrote: > On Mai 09 2023, Alexandre Ghiti wrote: > >> On 5/9/23 21:07, Andreas Schwab wrote: >>> That does not work with UEFI booting: >>> >>> Loading Linux 6.4.0-rc1-1.g668187d-default ... >>> Loading initial ramdisk ... >>> Unhandled exception: Instruction access fault >>> EPC: ffffffff80016d56 RA: 000000008020334e TVAL: 0000007f80016d56 >>> EPC: ffffffff002d1d56 RA: 00000000004be34e reloc adjusted >>> Unhandled exception: Load access fault >>> EPC: 00000000fff462d4 RA: 00000000fff462d0 TVAL: ffffffff80016d56 >>> EPC: 00000000802012d4 RA: 00000000802012d0 reloc adjusted >>> >>> Code: c825 8e0d 05b3 40b4 d0ef 0636 7493 ffe4 (d783 0004) >>> UEFI image [0x00000000fe65e000:0x00000000fe6e3fff] '/efi\boot\bootriscv64.efi' >>> UEFI image [0x00000000daa82000:0x00000000dcc2afff] >>> >> I need more details please, as I have a UEFI bootflow and it works great >> (KASLR is based on a relocatable kernel and works fine in UEFI too). > It also crashes without UEFI. Disabling CONFIG_RELOCATABLE fixes that. > This was tested on the HiFive Unmatched board. > The kernel image I tested is available from > . The > same kernel with CONFIG_RELOCATABLE disabled is available from > . > I have tested the following patch successfully, can you give it a try while I make sure this is the only place I forgot to add the -fno-pie flag? diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index fbdccc21418a..153864e4f399 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -23,6 +23,10 @@ ifdef CONFIG_FTRACE  CFLAGS_REMOVE_alternative.o = $(CC_FLAGS_FTRACE)  CFLAGS_REMOVE_cpufeature.o = $(CC_FLAGS_FTRACE)  endif +ifdef CONFIG_RELOCATABLE +CFLAGS_alternative.o += -fno-pie +CFLAGS_cpufeature.o += -fno-pie +endif  ifdef CONFIG_KASAN  KASAN_SANITIZE_alternative.o := n  KASAN_SANITIZE_cpufeature.o := n Thanks Alex