Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2030145lqb; Mon, 27 May 2024 05:53:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXj+Xr9smKJINIMbE2Yiy5NA/kXQdcgthskFKHuu6cVHJQRg/12r9mjYRzDwlsjxQajcJOGiMLMCck3U0qNWGXvjPSIv0CbPUtd/lr/wg== X-Google-Smtp-Source: AGHT+IE1akxfW2arRGvHxrJr0iqlGVgVj7qoC0rdCRKeT+ta7ntinNlWN/iedXtc7M76653HD4jp X-Received: by 2002:a05:622a:14:b0:43f:a084:590d with SMTP id d75a77b69052e-43fb0e7f34fmr104618431cf.28.1716814420822; Mon, 27 May 2024 05:53:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716814420; cv=pass; d=google.com; s=arc-20160816; b=weTx2pE3tKlPh8dUWFSN9HKSuI+On01Ytijd2fVrZjhF8xISX4ef4QdHK+OdeBKO2s o64oMSD7efcAXm4vXUZJwwAcaINnpuuPiQTrWZin47G+Y40yEfbN/HShPl7DMbGacLNx QVRLSnBTLdXoX+Fgw4D+r2zqPBpA0x1DiE9PLI4DiorEHIB5qGrbU6MOd3RC2OiHDqst yq4BnBR9DQsye+QpJdzce1HfphGFQB+QzZwQb4jpMG5UITQOXUImWeO5DnFiPmZSLPNc HTUb04kyKnInGK0qRdWNnDAEjXnfAROiTZc8K9srFB8F5FblSJCcqA1fe8Yp/WCxgM3K Ssjw== 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=1ehrgUgel/i5gQ4vUPsvUTbHqcb4qsPLv2SBgXeM3o4=; fh=lgqf/2hPwG2M7gRtKgFgMgxVxmGbeZObC5Z3x8Y7aow=; b=f23T9iHwFi74+gMo1hnP9Gu8JSFNV2IhNqY2/FJ6C5OCRl9GkcdgwBx0kp36U7MhaN n8rvZu0FNdsjxJWOrka1Xzv1S0u5JD2VF27lWBQViWmMI8/nq4ibySSD+lC9f5ZC9xpV V4Mgm7pAOUrECS/zQ6n67beIEoPhLqKyeun0nG7GxDsdR6CEID/bkpdauM9sHWd0P3CU 2a/Aq88hhNFHbYr3ncaVsaTdZqfGhv3THEj2mK7YCLSsTlDVLZ4C2xd6t10TyaqywbWl 32RQbuSUiwJrUEbC0P37nrRE3YwaIGaj54EBWyrJFb1Lq4XBKxQeOaTTZ1jwddN0XhDr uTLw==; 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-190614-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190614-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-43fb18ed9e1si78839131cf.806.2024.05.27.05.53.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190614-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-190614-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190614-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 79BBB1C22302 for ; Mon, 27 May 2024 12:53:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4082715E5D1; Mon, 27 May 2024 12:53:35 +0000 (UTC) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 F07211DDC9 for ; Mon, 27 May 2024 12:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814414; cv=none; b=Nrloo0PsInPcSlIZfE7Cg2SvQk/mncrjz9jbFJ68h2xii5PFHYsyd+FblncGdzDHejybi5pI5u8TfocaM7DyriYCAXf57L16fvnPeJXDeMVv64djY2RFImkBsOv4XXh+z4KgHEZrGEAPCeq32vUse9EUBlTd3zGKBU7PLj087JA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814414; c=relaxed/simple; bh=5Bybq8cKJlG0qEa1Ub7/CJsdd3PAgncbujsxxqAVJvM=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=iTO4279iUiFx9+w0tKnhaYZmROXzt0xbKtYbLN0t6mM0gmpuphHS7kh3ARuwlsrTtRCrR6SGcfjOf3JRLuw5qJNbKBu3AROaX8TXEb/Vyw/aJGee8p0X5X9HkT07yc/RwNQrBGiVI2PACx4pL9M+01zfrWO8XYcez1qs+lc8oJ4= 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.199 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 21968FF808; Mon, 27 May 2024 12:53:29 +0000 (UTC) Message-ID: <19a87876-70f3-40d3-996e-ea8b1862de0d@ghiti.fr> Date: Mon, 27 May 2024 14:53:29 +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 6/7] riscv: drop the use of XIP_OFFSET in create_kernel_page_table() Content-Language: en-US To: Nam Cao , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <8748eab99d76e466a44a0bb81d836ff1c9ad9879.1715286093.git.namcao@linutronix.de> From: Alexandre Ghiti In-Reply-To: <8748eab99d76e466a44a0bb81d836ff1c9ad9879.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 value entirely, stop using > XIP_OFFSET in create_kernel_page_table(). Instead use _sdata and _start to > do the same thing. > > Signed-off-by: Nam Cao > --- > arch/riscv/mm/init.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 9846c6924509..62ff4aa2be96 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -907,7 +907,7 @@ static void __init relocate_kernel(void) > static void __init create_kernel_page_table(pgd_t *pgdir, > __always_unused bool early) > { > - uintptr_t va, end_va; > + uintptr_t va, start_va, end_va; > > /* Map the flash resident part */ > end_va = kernel_map.virt_addr + kernel_map.xiprom_sz; > @@ -917,10 +917,11 @@ static void __init create_kernel_page_table(pgd_t *pgdir, > PMD_SIZE, PAGE_KERNEL_EXEC); > > /* Map the data in RAM */ > + start_va = kernel_map.virt_addr + (uintptr_t)&_sdata - (uintptr_t)&_start; > end_va = kernel_map.virt_addr + kernel_map.size; > - for (va = kernel_map.virt_addr + XIP_OFFSET; va < end_va; va += PMD_SIZE) > + for (va = start_va; va < end_va; va += PMD_SIZE) > create_pgd_mapping(pgdir, va, > - kernel_map.phys_addr + (va - (kernel_map.virt_addr + XIP_OFFSET)), > + kernel_map.phys_addr + (va - start_va), > PMD_SIZE, PAGE_KERNEL); > } > #else Reviewed-by: Alexandre Ghiti Thanks, Alex