Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2022735lqb; Mon, 27 May 2024 05:37:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9l3nnKS5Fe7R9csA5gxPfTo5W5UjnYq8C+Qq6m0TvMDlYG9QpNXisCYwxHegXbx4hqP4IAoMBqrTymP+L5FAD/ZGctrvVQJbMev0+WA== X-Google-Smtp-Source: AGHT+IH129wKJaloffk28jPME+Jm0MrJUGiXj2PIZVWJSF6it3EWjA6fVHakp5Y4/U6SRO+SMpyJ X-Received: by 2002:a05:6808:3a82:b0:3c9:963b:7f84 with SMTP id 5614622812f47-3d1a5c3141emr8707414b6e.25.1716813445406; Mon, 27 May 2024 05:37:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716813445; cv=pass; d=google.com; s=arc-20160816; b=f2SrsBWDfEyNh7vcWFLZLFYBBQbJe7fnvmwgYKfEyKCe8Izo5hEMfKOJp2xcP7bqDr fjjU1znuvrWD0Gy5hYHdCWw07QQZO9eCfxZf9mG8j5KE2VGayjJgL2QOGskcpUzXFI3r 6atRnSoT5lJxB0UHhDIwJQnRNoSPsFE86iErDHjPvK7vtGqHfU4XxBrjA8R4iY4ACesr ytbe27i4kN9nFv4AaRUO4xZM40Bnl+c9p8klvKyuayEQPxB2h+lWy0gdC2VRkYUR1U9t bbe3ALBmXDtIdjvVJSv9fOBqdql0Hxa8b3o0ecwpGEIZ5uiVgSv1TgBrOFNGRZT8pSjm iTWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=dAEQ90DzAKh4ngPkE23wwlFtEAGwHseneloWfArPrEM=; fh=lgqf/2hPwG2M7gRtKgFgMgxVxmGbeZObC5Z3x8Y7aow=; b=Jqm7Sex9unsb3DUByXdIkpLygzEF//h52RbmNo263bCWk84Zwfau8R5ThprM8mvzLy AHuS5pkvYPg9LyHGi3FMaqVp6oSENVeixRnn+qQpVPy1Xj2/CYwm4AleFe+mNhBFBWx4 3z8KLydYSfL1EmyguA9VTeFacvmRwmFf18WMLWEHOgeTiN2LeJ8eMbCyq/AHHjLBnNAO pPnIMgPppxljV4KSNvTKl7zawsyheO0FRFva/bBT8Qr7UNCLFd+LpAFGWiavxmX1A35K L4er6qfDOd0+X77b+MRkdAXGWauDvdgGKooVXJ+LfWFxEBmAG198DlaBnjvhw1TawtGn QIBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-190592-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190592-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac1616ae02si79234666d6.361.2024.05.27.05.37.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190592-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-190592-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190592-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1FC7E1C2146D for ; Mon, 27 May 2024 12:37:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A59015E5B7; Mon, 27 May 2024 12:37:20 +0000 (UTC) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 A573215E5AF for ; Mon, 27 May 2024 12:37:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813439; cv=none; b=QiYITgrMsjOQDndk+Wye6BJI3Dq7ISJ/FDisKwvGYiTpaPaRk3+/QIeHg8B5o75KKqLHhV5kzKVJYgAPKhuI2RuCfiSDUC+0Y2KsCDL6xlTwDnll/OH9agR9qQRGHVdDk/sXkV+6WjCRkLMaSm3JGjZgs+x036T6aNvvlfDSUwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813439; c=relaxed/simple; bh=7+3IF3MN92ZTyrUu1kSOkIobd/fuy1IKeSNBJml1ZsQ=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=XtHEiqE7PDAu4NITD8ac6tFU3ch2VkeXbJLOyazTeAtFcx/E083DrGzHqAVoYY0o+khNevFHpa0yYG/TNcRfgvZtqAXesgWEFgJ6jjp1kxai699/L0jyvWoyMcqWnRhMNdb3oOr7RJsYTh9RiSIHQUunZ2wvOfVT0LoEPgaQIas= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr; spf=pass smtp.mailfrom=ghiti.fr; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id B34BAE0005; Mon, 27 May 2024 12:37:13 +0000 (UTC) Message-ID: <0030930d-dbee-4a65-8ab9-5c96bd2aeeea@ghiti.fr> Date: Mon, 27 May 2024 14:37:13 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/7] riscv: drop the use of XIP_OFFSET in XIP_FIXUP_OFFSET Content-Language: en-US To: Nam Cao , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: From: Alexandre Ghiti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr On 10/05/2024 08:28, Nam Cao wrote: > 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_OFFSET. Instead, use CONFIG_PHYS_RAM_BASE and > _sdata to do the same thing. > > While at it, also add a description for XIP_FIXUP_OFFSET. > > Signed-off-by: Nam Cao > --- > arch/riscv/include/asm/xip_fixup.h | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/include/asm/xip_fixup.h b/arch/riscv/include/asm/xip_fixup.h > index b65bf6306f69..9ed2cfae09e0 100644 > --- a/arch/riscv/include/asm/xip_fixup.h > +++ b/arch/riscv/include/asm/xip_fixup.h > @@ -9,8 +9,19 @@ > > #ifdef CONFIG_XIP_KERNEL > .macro XIP_FIXUP_OFFSET reg > - REG_L t0, _xip_fixup > + /* Fix-up address in Flash into address in RAM early during boot before > + * MMU is up. Because generated code "thinks" data is in Flash, but it > + * is actually in RAM (actually data is also in Flash, but Flash is > + * read-only, thus we need to use the data residing in RAM). > + * > + * The start of data in Flash is _sdata and the start of data in RAM is > + * CONFIG_PHYS_RAM_BASE. So this fix-up essentially does this: > + * reg += CONFIG_PHYS_RAM_BASE - _start > + */ > + li t0, CONFIG_PHYS_RAM_BASE > add \reg, \reg, t0 > + la t0, _sdata > + sub \reg, \reg, t0 > .endm > .macro XIP_FIXUP_FLASH_OFFSET reg > la t0, __data_loc > @@ -19,7 +30,6 @@ > add \reg, \reg, t0 > .endm > > -_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET > _xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET > #else > .macro XIP_FIXUP_OFFSET reg Reviewed-by: Alexandre Ghiti Thanks, Alex