Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp15586187rwb; Mon, 28 Nov 2022 13:30:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xYXuLuUywdmgtsh5WYEOIfnQr9yzVrEA44062nNyjuxurglsQAfpQZbPpButDwwHPyWH/ X-Received: by 2002:a17:90b:1117:b0:218:f5d3:61f3 with SMTP id gi23-20020a17090b111700b00218f5d361f3mr25692033pjb.222.1669671015504; Mon, 28 Nov 2022 13:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669671015; cv=none; d=google.com; s=arc-20160816; b=iHbHPKHwDR1iO+a5Q0gkWmVrylWlMhUzGH2ldgh3NgWX2CGPsoZa0SxBOF8qrRiBVQ 19oaT/KWQP8uMjGwtSeBCOtBCeoVedoULIkhH4n/vYBhKNnOBdPVWqoYBwsI1oKEg/9T MhALuZLGLuwrBE1SEUbjZewhm0e0jAE46viJEFDWmQUsrcKuACQY7gQFyj32ooFyYR9W JIju8HZN2XuKTHSm/Ihe2vN5PMsFzracg1zG/qXGZF9JwPKXXu9x6BGMn6H/1bFBb8yH D+x5hKXQ0ViJv0hW/9ydbtGgEfJz9RiDS4OudmozQRZg7aVRw1KQ5YiHl308CzZgqq7H vNHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=M3hsvZmsRJ+Zyf2Ap7EqB/ctmjyXnmHpZWJb10knc0k=; b=SFRUThw4/rkC5Fi7fvrfbqbpWcW8O7keEGtYCy0LkzbdK0vK4r0x9ZgE8gSU/27WAk ua7zMDO/0dpx2Y4XalsqUkIgf7AiozmtZysyeoSmpLQCqkqA015sGCE28BboVFz5EXGj cvhbZlByKHTuI4Y0FCOBT0hSI/nrXLMmHx5nciQW4aT7Jl5Wdg3qrLztaFyPtr9neAfy VDFO/4fpjkt3FM7HmvRGdQxKvNvbSQzyqPoOQS3U31SBfs6QnVTXw4niDtmkTcO2fGJH xtXyO5IGKFOXZl6sOjRPQj7Bd6qSG3l2FNBTXmxIiM5yRFzea4NVcmLrR63d3kFvXQDv Xd/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=WOaJzEsc; 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 s14-20020a170902988e00b0017b3392ca72si11549386plp.323.2022.11.28.13.30.05; Mon, 28 Nov 2022 13:30:15 -0800 (PST) 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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=WOaJzEsc; 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 S233440AbiK1UMF (ORCPT + 84 others); Mon, 28 Nov 2022 15:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232231AbiK1UME (ORCPT ); Mon, 28 Nov 2022 15:12:04 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D1A22B3B for ; Mon, 28 Nov 2022 12:12:00 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id w37so5804986pga.5 for ; Mon, 28 Nov 2022 12:12:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=M3hsvZmsRJ+Zyf2Ap7EqB/ctmjyXnmHpZWJb10knc0k=; b=WOaJzEscT0ssf37HvQjaxXmBSVsyI9lnys/H5psU1t6RKkI9snj3nnO4+e5Unbb6Pu CFuhxV7d7DWcdUat+VBlt6p5HHLEj2Ji03eG1f+SYRrKctRvdXshO8I76ReqC/xtw2SP P9RGNKGhf6KJOqnfghUtHWWnxL+eAegWiTrf6Y2O6ec9cGeFMTuugLZMffI6D0gSGpE4 2OqgMzn19m/pN09ZQFe7Cw/t5+ax9a1g9JiP+uzKPT4zgQQXY939nQGnIyBoDc4yY7Bj wpf9ll9V3UYODruZ1kfu2RlVU50c/2tyn38dnXZFPibI8BAHyQMSJP5QmSrEtGJagrjv VmGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=M3hsvZmsRJ+Zyf2Ap7EqB/ctmjyXnmHpZWJb10knc0k=; b=Ogcbxwvjs19ksqawq0OS9aCrYvVofMxTAcyOXlzPRkHTE3Q9CkhtMH4BeuhgWBKJk5 mQEX3lIHanuND22yXVv+72PwfaK2rXnDdJctEIsC4d41CI9N2k7pwyy4c+p6T1v57XNh XRQ0A5xn8fGMu2iGSV/D7pLEKRqftYk6O4sbZgUNIrTvRS5qY4I8DVi1MgDUA9iYzUJa bDSXzgNsDKf7GdhyL+tffbVZvVjGxxsnRgpBeBHSV1g1FdEplKrjGueRLyszXf8SWQ2E LxxkfYYMH6Qv3/WqnT3V/mlH6mlaDo5ksQ7SHyfx/xgCijo+qMW5vSrx8X4EqKgbfcbh hU7g== X-Gm-Message-State: ANoB5plNyO0k3AAm+ZCsk8Mu5t1IV3BlUjrbxSu6R9uUAR/j3ixj3oMD 84iPJau1An0mYbZMteD9g637/GV93Sj8BkJCzOEDgw== X-Received: by 2002:aa7:820a:0:b0:574:a642:ad40 with SMTP id k10-20020aa7820a000000b00574a642ad40mr20302955pfi.42.1669666319934; Mon, 28 Nov 2022 12:11:59 -0800 (PST) MIME-Version: 1.0 References: <20221128152442.3403-1-jszhang@kernel.org> In-Reply-To: <20221128152442.3403-1-jszhang@kernel.org> From: Atish Kumar Patra Date: Mon, 28 Nov 2022 12:11:49 -0800 Message-ID: Subject: Re: [PATCH] riscv: head: use 0 as the default text_offset To: Jisheng Zhang Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Mon, Nov 28, 2022 at 7:34 AM Jisheng Zhang wrote: > > Commit 0f327f2aaad6 ("RISC-V: Add an Image header that boot loader can > parse.") adds an image header which "is based on ARM64 boot image > header and provides an opportunity to combine both ARM64 & RISC-V > image headers in future.". At that time, arm64's default text_offset > is 0x80000, this is to give "512 KB of guaranteed BSS space to put > the swapper page tables" as commit cfa7ede20f13 ("arm64: set TEXT_OFFSET > to 0x0 in preparation for removing it entirely") pointed out, but > riscv doesn't need the space, so use 0 as the default text_offset. > > Before this patch, booting linux kernel on Sipeed bl808 M1s Dock > with u-boot booti cmd: > [ 0.000000] OF: fdt: Ignoring memory range 0x50000000 - 0x50200000 > ... > [ 0.000000] DMA32 [mem 0x0000000050200000-0x0000000053ffffff] > As can be seen, 2MB DDR(0x50000000 - 0x501fffff) can't be used by > linux. > > After this patch, the 64MB DDR is fully usable by linux > [ 0.000000] DMA32 [mem 0x0000000050000000-0x0000000053ffffff] > > Signed-off-by: Jisheng Zhang > --- > arch/riscv/kernel/head.S | 12 +----------- > 1 file changed, 1 insertion(+), 11 deletions(-) > > diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S > index b865046e4dbb..ef95943f7a70 100644 > --- a/arch/riscv/kernel/head.S > +++ b/arch/riscv/kernel/head.S > @@ -38,18 +38,8 @@ ENTRY(_start) > .word 0 > #endif > .balign 8 > -#ifdef CONFIG_RISCV_M_MODE > - /* Image load offset (0MB) from start of RAM for M-mode */ > + /* Image load offset (0MB) from start of RAM */ > .dword 0 > -#else > -#if __riscv_xlen == 64 > - /* Image load offset(2MB) from start of RAM */ > - .dword 0x200000 > -#else > - /* Image load offset(4MB) from start of RAM */ > - .dword 0x400000 > -#endif > -#endif NACK. RV64 needs to boot at a 2MB aligned address and RV32 needs to boot at a 4MB aligned address. The firmware is assumed to live at the start of DRAM for Linux running in S-mode. > /* Effective size of kernel image */ > .dword _end - _start > .dword __HEAD_FLAGS > -- > 2.37.2 >