Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2045560rwd; Sun, 28 May 2023 07:10:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7naMjfiLRFAE5Is+NR2nPwqwEckd+QXYOJpFKCL42jzWnr2SAJYRzoYRVOCz72EO4tCYvf X-Received: by 2002:a17:90a:1f8f:b0:247:8ce1:996e with SMTP id x15-20020a17090a1f8f00b002478ce1996emr7468589pja.29.1685283050037; Sun, 28 May 2023 07:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685283050; cv=none; d=google.com; s=arc-20160816; b=cAiD5vzoZHqEvTFjSpk1vTQV4PiCg2ykjIE2xqoVL6U4ASzdtJ1go4LymmLYS7hlJW SrOaA5y4oNGW5KfhPnhskfEilBNOvrHf3/qShVfJ3/OKC1QXXiwHx6Je21PZgWj0Sebh J+0bNWkaGY0qDlqt6Hwbg0Z8Cqn6pYDp5rMCasHXuFo3tq22q7n30AkDsfCGt+hxecEI KzH+4KtwTHqjc3jG+b6uTQ5WB/YlCQeG1FdO9FMMrpRPth9NsrSdrwlnRdxKKeZn7jpX MxdmnDJb5SALiH7HNU4YkVFSj+wnsXbzKIej7BweBxqormQ42xdB33Gaiz0aiesSv3hm oCbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RhM3o1rSFh/V/y/0r67t3nZJSpqH0JgPSfLaWcpVD5E=; b=qyeFjGpfFy565hWSJrbHvDsArI9BFiX4DnOD5mIR1iWtpL/o6O2zWUSBSwwLS0LDqP mcBTGq141kJQk9XlykXX5ItoaRFzUJaN0hj610s2jvY/SEZy8i0eNVokjoqhmfKxuqx9 GhgA9fgATDs3beehtqXHaWLpopxPx+mzChh331yC6HMoIWgxozHpi4lF5zoo3Y7qTCzE OjjNKW4E2EulNa/Q7c0KKs5sRpIupRKzq5uKWP7qblAo3KJ8mBelSnSRwh9NJCcrGBDp CnjxsdcoYEPdSGxii9T6VMEUz5UtlChzBph8gDEzLtADCKCrekz60Ma1g22YB9YeBP70 yNDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WiLbmPxI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg15-20020a17090b300f00b002567ea157e6si285361pjb.136.2023.05.28.07.10.32; Sun, 28 May 2023 07:10:50 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WiLbmPxI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbjE1N4x (ORCPT + 99 others); Sun, 28 May 2023 09:56:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjE1N4u (ORCPT ); Sun, 28 May 2023 09:56:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C2AF4 for ; Sun, 28 May 2023 06:56:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9163B60B09 for ; Sun, 28 May 2023 13:56:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51ADFC433D2; Sun, 28 May 2023 13:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685282203; bh=U3GojuCuoXYfWzcEEea0OZvAAyMV4nTAAdmCAqb/5K4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WiLbmPxIdViLKmIkD5gfoxXwhcWxALd7JUAghhpXkvD4zlhu1pNx5jwUS+Gq/p0Dm CsE//CLrdLGOAqaa4U28W3JdG9mv3mZdpK2pPcKCSqLPvcZ8q99UznkrS2mYlsYT7V 6MrJKjhfgvqAIZa6sIas1YZIEOK7IvAIcGjoMCFcJs86S23c2jCKb54eWZDEn/EJ2K C2oocvFibDsnMkKdOM7Ir6+JLJZCDuhGmJkp28zlcZqxEeoueRqa0vchzjrurxeODS OKuRqVfZ+pvxf1I5cajtmN2Jfs5BLGJHonC9kY5IXZiEi9kfuubYY0XfXu8uK2ScCd jR7ikbC0vD1Rw== Date: Sun, 28 May 2023 14:56:38 +0100 From: Conor Dooley To: Alexandre Ghiti Cc: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andreas Schwab , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -fixes] riscv: Fix relocatable kernels with early alternatives using -fno-pie Message-ID: <20230528-uneatable-earpiece-3f8673548863@spud> References: <20230526154630.289374-1-alexghiti@rivosinc.com> <20230526-clergyman-wriggly-accc659a3fad@spud> <20230526-rockfish-moody-f6d3e71f9d24@spud> <20230527-hyperlink-doctrine-ef22cfcb508a@spud> <20230528-darkness-grandly-6cb9e014391d@spud> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="/v0GigUCXOkKo7H6" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 --/v0GigUCXOkKo7H6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 28, 2023 at 03:42:59PM +0200, Alexandre Ghiti wrote: > Hmmm, it still works for me with both clang and gcc-9. gcc-9 is a bit of a relic, do you have more recent compilers lying around? If not, I can try some older compilers at some point. > You don't have to do that now but is there a way I could get your compiled > image? With the sha1 used to build it? Sorry, I don't see what happens, I > need to get my hands dirty in some debug! What do you mean by "sha1"? It falls with v6.4-rc1 which is a stable hash, if that's what you're looking for. Otherwise, https://github.com/ConchuOD/riscv-env/releases/download/v2022.03/vmlinux.bin (ignore the release crap haha, too lazy to find a proper hosting mechanism) | git show | commit 3bd124485ed55d8ee6c1ff3532c8f617b24aa6ef (HEAD) | Author: Alexandre Ghiti | Date: Fri May 26 17:46:30 2023 +0200 |=20 | riscv: Fix relocatable kernels with early alternatives using -fno-pie | =20 | Early alternatives are called with the mmu disabled, and then should = not | access any global symbols through the GOT since it requires relocatio= ns, | relocations that we do before but *virtually*. So only use medany code | model for this early code. | =20 | Signed-off-by: Alexandre Ghiti | Signed-off-by: Conor Dooley |=20 | diff --git a/arch/riscv/errata/Makefile b/arch/riscv/errata/Makefile | index a1055965fbee..7b2637c8c332 100644 | --- a/arch/riscv/errata/Makefile | +++ b/arch/riscv/errata/Makefile | @@ -1,2 +1,6 @@ | +ifdef CONFIG_RELOCATABLE | +KBUILD_CFLAGS +=3D -fno-pie | +endif | + | obj-$(CONFIG_ERRATA_SIFIVE) +=3D sifive/ | obj-$(CONFIG_ERRATA_THEAD) +=3D thead/ | 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 =3D $(CC_FLAGS_FTRACE) | CFLAGS_REMOVE_cpufeature.o =3D $(CC_FLAGS_FTRACE) | endif | +ifdef CONFIG_RELOCATABLE | +CFLAGS_alternative.o +=3D -fno-pie | +CFLAGS_cpufeature.o +=3D -fno-pie | +endif | ifdef CONFIG_KASAN | KASAN_SANITIZE_alternative.o :=3D n | KASAN_SANITIZE_cpufeature.o :=3D n --/v0GigUCXOkKo7H6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZHNdlgAKCRB4tDGHoIJi 0jVpAQCsS3J3dOetH/LmA47QbQsKg8DEoynoHEWFevPQHP5wDQD+PFcSq+flgTvG uvSeTue8wERrHQty97tsjtLHWFMCPgg= =GXTx -----END PGP SIGNATURE----- --/v0GigUCXOkKo7H6--