Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2028627lqb; Mon, 27 May 2024 05:50:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhSZKnICKyQwFT1vWb5oF/fRmFYTxXpfjtnlVvCtMtGOfVZOjRTf7aZgZoa5X4qwiI3kOd/7B2UwxAdRDPzk7fWsJJtQffT2V/MS15mw== X-Google-Smtp-Source: AGHT+IF8Z11SG84SGFNLTGKkgD7wAzFMsuraZPXeTBRvynyf8JFViOYtoupVAKtbFFOvUr4ZGkw/ X-Received: by 2002:a05:622a:2cf:b0:43c:7598:676 with SMTP id d75a77b69052e-43fb0e88b23mr119283071cf.38.1716814208271; Mon, 27 May 2024 05:50:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716814208; cv=pass; d=google.com; s=arc-20160816; b=OitWTFHrDhhpOs9N5v8RCDp6E65dqE/ax6ol7YrPHmtEyOMgUBJpFNaVwWeUi/nFrz 8Zh/mH4fWowpSr3g5K0UMD6nH8DZ3qNe4ELPrtcIWmfWBcrLraQqsVkzuxelAqdqD92h xYqF83TMpCEjlDHusvwbZ4rUxFzHNT5WGKwvNeeSXMwEyOAB0jG04OhjdSAak/XO+Jq6 jDyHXIBzhzWk2mooxnb7gNjyTp2xF8tmxJBldReNJnlzN5JIIdUh1Gfv9DQ4cw7WHpqE IGe/SuiXb42s7/+DNOkwhgzflYEY446oH1jIm0fmnqvco5ISd2gEFLYBZ4Ns7arE4+5X CCNQ== 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=NxL3b7YjzVLQk6qalcvhLuED4+GIhgv0T6/E8ukugRE=; fh=lgqf/2hPwG2M7gRtKgFgMgxVxmGbeZObC5Z3x8Y7aow=; b=LU967SnizqhMPN7zBI0bqeaUrmwzcKtMm+h2TyiIMWdYu3AiLHCjLHe347V7MVJWRC jGki1jXR+Wsjq2aF6aKfHJOMaF0MaXR2pV/F3NEDlHn802tq86ZrFMtDlp2bw3ylrY7N x3p6I8pVyL0AY3AMoZbJYPYj/0yXE2f+USPoqdrpLr5ea1ePKA+DJawDcVwpNCQtZitz 5SvTNyTrg0DYAmBG7/lfo5n/oI5mgcZ0Bi0uG9bs0u4xJQkZPi2iyoVKSJ/QVjMYo3di BLPob/I6ePwoKyNxS+qKBLDms0DjxEto2e8+E4sglQP8spmjPfqBwrlvx0Hq4QtQPfsb fnQg==; 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-190608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190608-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 d75a77b69052e-43fb18c5a78si89417891cf.585.2024.05.27.05.50.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190608-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-190608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190608-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 E56551C222DA for ; Mon, 27 May 2024 12:50:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF8AD15E5C8; Mon, 27 May 2024 12:50:03 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 459194D5A2 for ; Mon, 27 May 2024 12:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814203; cv=none; b=VOzkATnwKfsAecOVchNRnqZwWBEBk/Ir+1Bfx0b/CUUmycaagUuD/ZoWTnWZd7a/2x74UeUUEds5HNuC055lXLkO8BNuQZpD0K3iFUx6x3nWDtyv38/XvIqp4oz9pkAkhhXeY1KNSt2OlC+37jUxmZ8khw3FpaxGg4iCio+qtik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814203; c=relaxed/simple; bh=qmoXTNHUYcQhTTkK7zjwu5RydcbhSzwSS0Qq7JNAFmA=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=PF98EFvBs2ndHOOFVEOynoCy4Gm3sd3PGvhzU3RMHWptQPshkEX7ub077gZl1jc5nMzNb935RFL8iLJ2ktOEKyPTkIfK8KNmEwveaNcIJ9V1gqsWK+RRA4mH1MyLKmgtcDb3WJS3NrjJzb/H94ChK5ZHI7pIFlugjPOFLh8vBhs= 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.197 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 2EE121C000C; Mon, 27 May 2024 12:49:57 +0000 (UTC) Message-ID: <187d7992-e2a7-446c-9f53-d0e7bf6a5843@ghiti.fr> Date: Mon, 27 May 2024 14:49:57 +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 5/7] riscv: drop the use of XIP_OFFSET in kernel_mapping_va_to_pa() Content-Language: en-US To: Nam Cao , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <5439a181cdd7ba185d55457200ddda2d2efa5eb1.1715286093.git.namcao@linutronix.de> From: Alexandre Ghiti In-Reply-To: <5439a181cdd7ba185d55457200ddda2d2efa5eb1.1715286093.git.namcao@linutronix.de> 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, > remove the use of XIP_OFFSET in kernel_mapping_va_to_pa(). The macro > XIP_OFFSET is used in this case to check if the virtual address is mapped > to Flash or to RAM. The same check can be done with kernel_map.xiprom_sz. > > Signed-off-by: Nam Cao > --- > arch/riscv/include/asm/page.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h > index 14d0de928f9b..bcd77df15835 100644 > --- a/arch/riscv/include/asm/page.h > +++ b/arch/riscv/include/asm/page.h > @@ -159,7 +159,7 @@ phys_addr_t linear_mapping_va_to_pa(unsigned long x); > #ifdef CONFIG_XIP_KERNEL > #define kernel_mapping_va_to_pa(y) ({ \ > unsigned long _y = (unsigned long)(y); \ > - (_y < kernel_map.virt_addr + XIP_OFFSET) ? \ > + (_y < kernel_map.virt_addr + kernel_map.xiprom_sz) ? \ > (_y - kernel_map.va_kernel_xip_pa_offset) : \ > (_y - kernel_map.va_kernel_data_pa_offset); \ > }) Reviewed-by: Alexandre Ghiti Thanks, Alex