Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3540552rwd; Mon, 29 May 2023 12:17:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+gYv++7sEvIXpoAm7Gw25CWvrRnQs1Fb0Zv2TLeaie5t+WqWKs9uy3MpIQqFLglXQu1vb X-Received: by 2002:a17:902:efc5:b0:1ad:fa2e:17f8 with SMTP id ja5-20020a170902efc500b001adfa2e17f8mr164277plb.12.1685387825442; Mon, 29 May 2023 12:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685387825; cv=none; d=google.com; s=arc-20160816; b=axap/Kkane4+X02+RYpcvpAT65YA1l849BhZYtCRFYfpQdW0wbJ/UubOpvJRTjZ64E dI0SGJIhE8kNEcasIB3selWJtS2lrZTY2QBiHEHwo5JMQOYulqZ5qkNPf+3K8osCdJrr 4kQEDkdmt6JyD2X0Vt8wLq6yD02j2MKsVUi4opACki+Ek6Vx6HnsmgHmEsuPo8IF/81/ 2sYk+RrHzajFjIjjGubOp4SNd61v7scbRswUsUZHIFMi/gNYa5bqS5i+kQJrIOnpF3jh NGBKF/MQ6YKNQ+o+SqjjGplZl4pJQ0laxhw+1BH5jWERYzBR2OflaJPBHpMcxVePWAON ekaw== 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=iXvMkjVktJwdEvMOTxsXjTfiut0JKPbtcXthhyF0iZ0=; b=OvA1eaf9Z9+gF6b5pUlGaV6KAvwqxHIrDg3EY2BZiFL0MU1KY5gCYU/nAiP1m0FMCC sRkSLaB3JeL0G4FlGKSbedsbzhqUaplkMqni21vvkL2CtjM5dSVZS1k0gtwWtre8CXpP XC9pZxxLHzoGjiv1nIAigzoxe1OyYlB/BoCDY5dZmyUmNtT2bUmTH09m8Z6IuqpSKaGY RGjnBg1LLGJpgJIpYjffc0zHITajzsc22yIEyr/wlGaWYZEstjMR4Tdq9TkUIJDPmFsf QCkuu07fJsZY0IUPoPVS404VExsxX1YMvU1qSs0s+JJKipgTkgJWUa3G97haKu6oIOvJ +2HA== 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 k6-20020a170902c40600b001b017b563a0si2264183plk.27.2023.05.29.12.16.53; Mon, 29 May 2023 12:17:05 -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 S229591AbjE2SwL (ORCPT + 99 others); Mon, 29 May 2023 14:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjE2SwK (ORCPT ); Mon, 29 May 2023 14:52:10 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DFD6C4 for ; Mon, 29 May 2023 11:52:07 -0700 (PDT) X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id CFB821BF203; Mon, 29 May 2023 18:52:00 +0000 (UTC) Message-ID: Date: Mon, 29 May 2023 20:51:57 +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 -fixes] riscv: Fix relocatable kernels with early alternatives using -fno-pie Content-Language: en-US To: Conor Dooley Cc: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andreas Schwab , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org 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> <20230528-uneatable-earpiece-3f8673548863@spud> From: Alexandre Ghiti In-Reply-To: <20230528-uneatable-earpiece-3f8673548863@spud> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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 On 28/05/2023 15:56, Conor Dooley wrote: > 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) Ok, I don't get much info without the symbols, can you also provide the vmlinux please? But at least your image does not boot, not during the early boot though because the mmu is enabled. I tried with gcc-12 and it still works fine on my end, so frustrating! > | git show > | commit 3bd124485ed55d8ee6c1ff3532c8f617b24aa6ef (HEAD) > | Author: Alexandre Ghiti > | Date: Fri May 26 17:46:30 2023 +0200 > | > | riscv: Fix relocatable kernels with early alternatives using -fno-pie > | > | Early alternatives are called with the mmu disabled, and then should not > | access any global symbols through the GOT since it requires relocations, > | relocations that we do before but *virtually*. So only use medany code > | model for this early code. > | > | Signed-off-by: Alexandre Ghiti > | Signed-off-by: Conor Dooley > | > | 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 += -fno-pie > | +endif > | + > | obj-$(CONFIG_ERRATA_SIFIVE) += sifive/ > | obj-$(CONFIG_ERRATA_THEAD) += 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 = $(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 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv