Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2033113rwd; Sun, 28 May 2023 07:02:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ObuH/999K5c155lrORGdZ4gpXkq+mkDS3w5HdRgy0oPWVZXqXjMLWnrT2Nu17/bEXwZxW X-Received: by 2002:a05:6a20:3ca6:b0:106:9266:4448 with SMTP id b38-20020a056a203ca600b0010692664448mr6374898pzj.16.1685282533806; Sun, 28 May 2023 07:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685282533; cv=none; d=google.com; s=arc-20160816; b=PtpuUc0Ttm7oRU45menehLLfbCdsXjA1CxL8uZuZunY0U5PY27mXflfE5Z3W3l5vuW 3VoTGHgv44JNb34D/dbuIxSavgECehNrJEiwNViqHpk7RuWYKGtn4TRprjkJfdfn1K8j VaN/Um7kg0eEhTAz6Oep+EHLAOFnGkHxe9yyaDCw9D/6JfAxRIYRdFaSbSPGJuRjhSYV pJc92qyHWpSa7d/Mtri9bKIGNz1o94OWo55X7OJAY4TkXFLyyQmRqmCtxQNzQMJ1SW9L ufh+HPU/J5VcvzrcqelhwldnY/AsKairOXwgPuw/Q8TVopln5lqj8dGd5tHdxml1logL 7zzA== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=pznH2f4UAtjdvkSGNiByqnu8yE/YVKkqihCVx9dJrHI=; b=nRBx/cx0jdEuWDI1OkrtJxyfAeFMYbMD5TB4VRphXBsXoqiOZQxh+4n0XiNejB5P0N 20LDqRbryL87Xed0gctWx4GMyMKDT3WrvTtsjBCopXTrOk6FhWrj6krwhSsmh9wj9ffM NXeNKmNoRDUvN6fMEPQRCv44J07TElook4at7cNkYEzaHwqKLMbZOZIfX+bxJQ33hCHK lZUVxkfm2Oxmr0j/U6eXVAGvwpPkOSMhq2bt0QrqC7bi+LbgRWSIEUi6YOSDdj7/v/rQ Y9bFZNvd+3DVAR8FMCEK4vrX/v78B0Iwxnz2WsNkCw7CJTiNX8Mcxe+eFV9MTD/lkXKm /3aQ== 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 b81-20020a621b54000000b0064d62bda46bsi3269883pfb.212.2023.05.28.07.01.55; Sun, 28 May 2023 07:02:13 -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 S229552AbjE1NnJ (ORCPT + 99 others); Sun, 28 May 2023 09:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjE1NnI (ORCPT ); Sun, 28 May 2023 09:43:08 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2F6B1 for ; Sun, 28 May 2023 06:43:06 -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 928C6240002; Sun, 28 May 2023 13:43:00 +0000 (UTC) Message-ID: Date: Sun, 28 May 2023 15:42:59 +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 To: Conor Dooley , Alexandre Ghiti Cc: 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> Content-Language: en-US From: Alexandre Ghiti In-Reply-To: <20230528-darkness-grandly-6cb9e014391d@spud> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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:12, Conor Dooley wrote: > On Sun, May 28, 2023 at 03:00:57PM +0200, Alexandre Ghiti wrote: >> On Sat, May 27, 2023 at 12:02 PM Conor Dooley wrote: >>> On Sat, May 27, 2023 at 11:13:18AM +0200, Alexandre Ghiti wrote: >>>> On 26/05/2023 18:35, Conor Dooley wrote: >>>>> On Fri, May 26, 2023 at 05:24:41PM +0100, Conor Dooley wrote: >>>>>> On Fri, May 26, 2023 at 05:46:30PM +0200, Alexandre Ghiti wrote: >>>>>>> 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 >>>>>>> --- >>>>>>> >>>>>>> Note that I'm not very happy with this fix, I think we need to put more >>>>>>> effort into "harmonizing" this very early code (ie before the mmu is >>>>>>> enabled) as it is spread between different locations and compiled >>>>>>> differently. >>>>>> Totally & I'll happily spend the time trying to review that work. >>>>>> >>>>>>> I'll work on that later, but for now, this fix does what is >>>>>>> needed to work (from my testing at least). Any Tested-by on the Unmatched >>>>>>> and T-head boards is welcome! >>>>>> On 6.4-rc1 & v6.4-rc1 + this patch, with CONFIG_RELOCATABLE added to my >>>>>> config, my Nezha fails to boot. There is no output whatsoever from the >>>>>> kernel. Turning off CONFIG_RELOCATABLE boots again. >>>>> I don't know if this is better or worse news, but same thing happens on >>>>> an icicle kit. What systems, other than QEMU, has the relocatable >>>>> eries been tested with, btw? >>>> >>>> I tested it on the Unmatched (Andreas did too). >>> Cool. I cracked out my unmatched and it has the same issue as the >>> icicle. Ditto my Visionfive v2. Here's my config. >>> https://raw.githubusercontent.com/ConchuOD/riscv-env/dev/conf/defconfig >>> >>> A ~default qemu virt doesn't work either. (-m 2G -smp 5) >> I can boot with this config using: >> >> $ sudo ~/qemu/build/qemu-system-riscv64 -machine virt -cpu >> rv64,sv48=off -nographic -m 2G -smp 5 -kernel >> build_conor/arch/riscv/boot/Image -s > Just in case, that is my normal config that I use for testing random > stuff on LKML, I added CONFIG_RELOCATABLE in addition to that. > >> I noticed when trying to add this to our internal CI that I had local >> failures that did not happen in the CI because the CI was not using >> the same toolchain: can you give me the full .config? So that I can >> see if the compiler added stack guards or some other things I did not >> think of. > https://gist.githubusercontent.com/ConchuOD/655f9cc19fb3be63f1c9da7e7e3ab717/raw/a1aad3c0d307609b2062fd3a66705166aede9f9f/.config > > 90% of what I test for upstream stuff uses clang, since clang appears to > be a minority choice - but I could reproduce this with gcc-12 as well, > using the same defconfig as linked above + CONFIG_RELOCATABLE. Hmmm, it still works for me with both clang and gcc-9. 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! Thanks for being so quick Conor! > Cheers, > Conor. > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv