Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp303964lqo; Thu, 9 May 2024 23:29:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXAtOroOGea6qnyFzXkEiCJmXD9XtGAKYXhQCxk6V0uZ0IsGiqzxuu4+gsPsnOQYl2EqnHw6bp9lX+qxJduFeLOZJihj46nxm14Xj90UQ== X-Google-Smtp-Source: AGHT+IHDvBDSuv9zwYsd5FdQHU8YT6+It6tuQrnMYecvCgtZ2zdm9RzfrU/rdF3/dZ/YK3HQ01bA X-Received: by 2002:a05:6830:12cf:b0:6f0:5a91:bce0 with SMTP id 46e09a7af769-6f0e92c8f78mr1923997a34.25.1715322549362; Thu, 09 May 2024 23:29:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715322549; cv=pass; d=google.com; s=arc-20160816; b=ZOVRVBy2TXEeYMBJMkGhKkj3eFfoV8X1eR4CR9sf73+Amq/4BnN/ylpLRF2OV/9ZwL NLu2n4u+lZvJWdc/BgDoB4d7iAO6KI4lV1o1d/SD9RllrL4tgnZlj64KvTu6eM9nVi0z V68cJw4eyeZT4+ybmCALXABvN50PvGaQY+Y4HWsj9VS6LDmCtdg5r61XaxRPFZnDGERO 30RW9l4ND3dgSdaiBCbnVvPsf4koV5fI2PgpafT4DwdV/D6x6MFYqT2nrW54CMRH0RKq QAWHzjdXO5Sy4Q4iGETKwOAhSz9NvA1xHZP+T7Ck43V2py6d84oaeimYLBAF4Ia7nKGK KvlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=PHH4si6HFtRU8b7XLsqZ3Kjry/eLFHCUpKXqXT+XYYE=; fh=8eVhtEKG9nNQVrYy5mUyY8MxQMB5T6hiievcYor8Kok=; b=VtzCMPed/Z5h56Siek9GT+mAJczgihNZrxoTS7g0dubfpmSbZgJe6LBG9QuqhDff/y uShWykCYpBfsrrn6AyFhhhKS9cp0ndVoIA6Gi096IA2cBSNqDg0H8zCCER3j0sgc1nDD mTctrmBwro94YFNmqBrxCiUe/zN1knD4G/VPmu4hRzUqYU6Sbz8KJ1YVmlZHiwtpGFPU aKHEf//DjIMfH+nd1oTCgWM7nI6xcHz5CnXoHNHgUmbrQDNY7clqTgXdW6L7elY/HhRQ yb5/vIhEl2E7EBphVlQcmbbKvmdaWBXB76IcBqMlLmn2G6FrP0T1tf1Ql4z3e5kWgqa9 1/2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pJH6m5nr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-175325-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175325-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6340a06d760si3014706a12.49.2024.05.09.23.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:29:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175325-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pJH6m5nr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-175325-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175325-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F2C21282A2A for ; Fri, 10 May 2024 06:29:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CF041607A3; Fri, 10 May 2024 06:28:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pJH6m5nr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2Lo9Nf1I" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A2431527B2 for ; Fri, 10 May 2024 06:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322535; cv=none; b=g6T9LPT0HOZ4cz3e1diAY3ZzD/ebOXNVKtq33NyjV06oNncMQVJ8mh6TbhG3apgDy8FVLMjib0YBg6AjPm5Yy6AfrKqJyGgsagAlV/wlbM2/lE33NNLxrF1wpiXsQzyBqJL7NJK3r5vJ2dPc7K5I7kFd4G/5OypSg3j7f7eCIXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322535; c=relaxed/simple; bh=jpWzwYfxDhgX9lTfHrYOKEauu3510cZvHENSGgR/BGk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=psRebgazij0xww237yhiMC8tdmVpYQONr68Ko4ETcNQHC+Ou3fpE/Xx/gNvYuKLvZrfYkgQM8dUiecPhM1HD1X4SnBAN34X1VHCSq0fGmJF2FNRGa0noEYIcZNuoVdcNbwcw0PnbAP+kBOpEixQP1zEcSz/a6N2U6kVJvudekzo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pJH6m5nr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2Lo9Nf1I; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715322531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PHH4si6HFtRU8b7XLsqZ3Kjry/eLFHCUpKXqXT+XYYE=; b=pJH6m5nrkDt3+jD3PIkIMz8VBpZ/9+k99dffmckcKtKwiuuaD+8TsfYWRZfXVAcQNG2nt5 NlUFIBbQQWT8F6Zrx71jV7YqKNmTFF/+PUDWuecv/Viz5S5KWlM3+QE8vQOTtHPibmOZPS wLzc7GWC8GRQc3z3773AWuVSSsFE120Fk/Xm8A/7WgCmp+5kJlHayekS0/K4t2qDk5BCst +kNj3l8Dn1yE30RRbxhU8W/inDJj5FjgsJpLGBfhxo1g0dgzVXIn1h0N08S8DoVxncnR0g NpkkcsH1IHedk8aPfOnloFWRjlhKtUKYz59QFj0zzmRzztVuly1wtc9uf7URhg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715322531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PHH4si6HFtRU8b7XLsqZ3Kjry/eLFHCUpKXqXT+XYYE=; b=2Lo9Nf1Ifnp4bxdW9nkeaSAmtEmKy9Oi9r3EaIijAJh2luo9NqMhHCeyyYg22CUMqEjmY2 mKXahnaTxjw4PoCA== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 4/7] riscv: drop the use of XIP_OFFSET in XIP_FIXUP_FLASH_OFFSET Date: Fri, 10 May 2024 08:28:42 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit XIP_OFFSET is the hard-coded offset of writable data section within the kernel. By hard-coding this value, the read-only section of the kernel (which is placed before the writable data section) is restricted in size. As a preparation to remove this hard-coded macro XIP_OFFSET entirely, stop using XIP_OFFSET in XIP_FIXUP_FLASH_OFFSET. Instead, use __data_loc and _sdata to do the same thing. While at it, also add a description for XIP_FIXUP_FLASH_OFFSET. Signed-off-by: Nam Cao --- arch/riscv/include/asm/xip_fixup.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/xip_fixup.h b/arch/riscv/include/asm/xip_fixup.h index 9ed2cfae09e0..f3d56299bc22 100644 --- a/arch/riscv/include/asm/xip_fixup.h +++ b/arch/riscv/include/asm/xip_fixup.h @@ -24,13 +24,21 @@ sub \reg, \reg, t0 .endm .macro XIP_FIXUP_FLASH_OFFSET reg + /* In linker script, at the transition from read-only section to + * writable section, the VMA is increased while LMA remains the same. + * (See in linker script how _sdata, __data_loc and LOAD_OFFSET is + * changed) + * + * Consequently, early during boot before MMU is up, the generated code + * reads the "writable" section at wrong addresses, because VMA is used + * by compiler to generate code, but the data is located in Flash using + * LMA. + */ + la t0, _sdata + sub \reg, \reg, t0 la t0, __data_loc - REG_L t1, _xip_phys_offset - sub \reg, \reg, t1 add \reg, \reg, t0 .endm - -_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET #else .macro XIP_FIXUP_OFFSET reg .endm -- 2.39.2