Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp563223rwd; Sat, 27 May 2023 02:40:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Tr7ZYx9pMXZXIgLTujVfbWW+cJA9tCuhhmPZU38OBsntP5TgCGLGLE/H0PB+Aj/K2ZSAq X-Received: by 2002:a05:6a20:7350:b0:10b:9db0:b03f with SMTP id v16-20020a056a20735000b0010b9db0b03fmr1926294pzc.18.1685180438782; Sat, 27 May 2023 02:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685180438; cv=none; d=google.com; s=arc-20160816; b=qyKJPUkzzVpnq+tr/hsErX7YExluOmjTNwzza++8YC5S8ArNeS2ubhamT8WhA6tYJU FxRoKuknlw3QonanUe40zCGFxjUk+91jQFMETWcrPjvHHZugKwhVro9FHbAFqfhgZwjM sgTn/VAu2sUtn1yj8cMjDC9QPaPzDRT02RUDy6mzbbHJkBITHjHvEwm29UPjNI4i4Ygb I8bei3PgZeDI7RG2IFcjGp0dxKdy3fgAnzmu71pLRr8hw88xcqD/Jc2G5BiaFCDjwx/Z Oocfu+zuI4VSpaX3GPHI2VaDeV6PEfP7ha1sDeXQSP3Y14sbfSjVwJIQBG+3BY2IZ5ri kIWA== 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=W98vQOjRi0l2gx0gVUnburE8uC46FVcvuarjsRhseVY=; b=NpP87eDV/p9YObqVc+mcl9MVk67712XtPNIx/vg5ydKEOHLbbeeZG5hrc+lFXJ/EaQ hyAOKH0Z/EevP4Qo3SD6ysEIhAORApwWVBfdsKiVym1i+a1FtSAzFU2C71U1K2ZAx09I j4AwdDdsM9Mla2YqTOJ8QJgYboa/EO/w2gQDn4Gg/lklt+ekRK2l+M88RErSUojFsHd8 1z8rAOVYCistDeiVdz7IUo1+fzBxDZcTZWsB7fJTKxhxCU/J0uOEzghqxfJsvgoClCm5 uOgijsMe985JEGm8zjotnTfYUpX1lEfqLo4Rly0+yJuS4o5TBi2go49RHiD5xdGgVKyN qwTg== 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 q11-20020a632a0b000000b005309e9ab3b8si5609657pgq.795.2023.05.27.02.40.26; Sat, 27 May 2023 02:40:38 -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 S231433AbjE0JN2 (ORCPT + 99 others); Sat, 27 May 2023 05:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbjE0JN1 (ORCPT ); Sat, 27 May 2023 05:13:27 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694BBE3 for ; Sat, 27 May 2023 02:13:25 -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 336871C0004; Sat, 27 May 2023 09:13:20 +0000 (UTC) Message-ID: Date: Sat, 27 May 2023 11:13:18 +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 , 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> From: Alexandre Ghiti In-Reply-To: <20230526-rockfish-moody-f6d3e71f9d24@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 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). Very weird it does not work on the icicle kit, there is no errata for this soc, so what gets executed this early for this soc? Do you know where it fails to boot? If you can debug, you should break on the address of the entry point (usually 0x8020_0000) since this is the stvec address, so when you get a trap, you will branch there, and then could you dump $sepc, $ra and $stval when you get there? Regarding the thead issue, I think the following should fix it: diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile index b85e9e82f082..a9bf3f8c7cb4 100644 --- a/arch/riscv/mm/Makefile +++ b/arch/riscv/mm/Makefile @@ -3,6 +3,7 @@  CFLAGS_init.o := -mcmodel=medany  ifdef CONFIG_RELOCATABLE  CFLAGS_init.o += -fno-pie +CFLAGS_dma-noncoherent.o += -fno-pie  endif  ifdef CONFIG_FTRACE > > Cheers, > Conor. > >> I didn't test on my unmatched. >> >> Thanks, >> Conor. > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv