Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp304300lqo; Thu, 9 May 2024 23:30:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXThc4Wu7aYFmIEi2t+Eh+Tq2ZgrwPqXg/b85muhwVVv6Q/Yq2r9C1rah6tMkzuBbXE4Qm7cTEIF645pkr1T7T4be/FAHfwQSfRaMWgxA== X-Google-Smtp-Source: AGHT+IE6Mgs4y5ALshJbeo3JffIYLTJBN87pLX02mUQ0Qw2yO+qvlpy6bN8NlLI+w7DABWBLrh8s X-Received: by 2002:a05:6a20:7348:b0:1af:baf9:feee with SMTP id adf61e73a8af0-1afde0fba34mr2325691637.26.1715322611801; Thu, 09 May 2024 23:30:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715322611; cv=pass; d=google.com; s=arc-20160816; b=EzGWotXL0i3dCI3uKkt+Fa9O8Tt+bXAewGGfN0kisFs8ZykMJGCb1TB2ajRhu10Ddy NTtgTYSwoTLG892gMljpVCLgNV75qpXVi09piMa7N/2x+gLbzFsPJ4UWc25fKA7F5lh7 uvyEU1eGdQk7kZJHnUBdIfdksLgNJcLoOelbH8JcafWdGo8V41Leufdt5SbVLZ5V2KPt oIeBej1D6yKS1jyqLbHGM2udvAioqzHJVVq6yscDJTcrzkFQDiDLxtmE713FCYs6aeOy ck+wjARhbThTp0PjaQ7N5x60J1FBwNEU8Gr4ZbMJxT/Hw1N7vBF7njsTcJP6n6b8mYtD +nGA== 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=klI6/ArsoUUqM1dHkfkXFimVv/Utnrzo9cziv0cncTY=; fh=8eVhtEKG9nNQVrYy5mUyY8MxQMB5T6hiievcYor8Kok=; b=KjFUuHxzPE3VaAYEk6VcTzqK7C4I/el9azq5Op2TdiZwBdLBuyDP28MaQJue8q87oO z8Z2KaILdPa7J2hEaqiJQ2W3uWr/gml0i441ZKNpDFlPUoZ/LXD7SwB3oSJmbWTr+JYx tUGrjiIjmkt+fGvbN5e/vR7tdsPIKycRtCx+pZBcmK/jOF74/0bGc+q3/m3JN1fUzLzh I+tIguSlK7dpQYlJpwt+jpiFvMEyLqdMR2HxNMyAV7Qs86Fco6OuxmLDZtREc40LALJ0 z2Zr07cJmhEQUnT1kHwJIR+Zrx7b+yqT3OJLPEpNLD1S+RWGlghfA37HV0EG68Yu822k oegQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vUci3mxs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=E9NLekMt; 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-175330-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175330-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c137f4dsi30737635ad.445.2024.05.09.23.30.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175330-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vUci3mxs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=E9NLekMt; 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-175330-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175330-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 62ECFB20BD8 for ; Fri, 10 May 2024 06:30:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9E96168AF4; Fri, 10 May 2024 06:28:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vUci3mxs"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="E9NLekMt" 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 1B0CB16133B for ; Fri, 10 May 2024 06:28:56 +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=1715322538; cv=none; b=YcvCuhLs+WRQaFgNLZh/qNgMrEfwOExrdqi5QxWuGC+kmyzd3PacemF+wr8W+rGD/KJ1uWKgD4fVqOckRd1dtCTS4bCVmC9oksyGozzUYDhP19iNkovBkdXdf+0W5EiVb0xjFHw2pVACLJ0Rmai5PGIzgIkaCVDGIvaudaH+KJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322538; c=relaxed/simple; bh=CNpdEK3MJv43HW1yYZPberffHKHd6wwAinUzJcICKdg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XbknMt4+/sxIA7mUyNt7tvNZdk7pvqvrYvje2KNbIWWbKBkB687RJ8ieOWGLmOswl8E2YLaVfY4StCUBubsAnAD/T8P7KymFIDIN2rTl7h9gWecp+TPFz2g7HdXjVIXtzXg8JQtey6ag3h0MHCLa7SHBF52TaAqkdRd02ezw/bk= 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=vUci3mxs; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=E9NLekMt; 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=klI6/ArsoUUqM1dHkfkXFimVv/Utnrzo9cziv0cncTY=; b=vUci3mxsVRkrS+PdrHpT4mSD+AuQXFTlpS/Cp66iSbOTbRw1Yc14DiTxc5OFSYWwCzZS9v xu3+PRzERyR5CVCZVS97bHq9ZPKUbTyU9xpMg1yVKEhJtw+3h5Nhs8kj73NIQ6JwpSEh6I TtEXrdkkrfSdVyylXSe8LrANkF3XeXG9jBtWvxAzIJI5Ohh7QWivHZTl1G/bVwF6d1tKAP gO3wacbTFb7dfqy9/vi/ogfBDWwywW3dFX8C7bG91S5Ggh8pE0G/kPcKwIH9OfyY3WIbrJ 3KZLb0qX+Dw1l01Qh7jxAQSGB3j9qxyEVlwWEkhCNjQiG9cXTQr0FhAaXQ8hYw== 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=klI6/ArsoUUqM1dHkfkXFimVv/Utnrzo9cziv0cncTY=; b=E9NLekMt7HVvwSbWb2yg+E0ZsWU/PWXTBilGU3G5C04v2aon3LtmJ9VbZOToLP9+yDAYLF W0uNWoYSrn3DaqAA== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 6/7] riscv: drop the use of XIP_OFFSET in create_kernel_page_table() Date: Fri, 10 May 2024 08:28:44 +0200 Message-Id: <8748eab99d76e466a44a0bb81d836ff1c9ad9879.1715286093.git.namcao@linutronix.de> 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 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 -- 2.39.2