Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1281123lqt; Fri, 7 Jun 2024 13:23:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuwhI5yDztIWyWvMEF6kisHt7LB0Vh9CX3RMOvpavQBAkS+K7N1UO9rt5EfVRn0ZnA7l4v//SaC4xYUp7iEkZLzBX9pRq5IrRS7mTBFw== X-Google-Smtp-Source: AGHT+IE8HQ2h/DeI5fZFHdeWHAEit5KK030+vFI1FhxZrYhIZZdePMIn0xw3A7eeznvaU7aKLa6s X-Received: by 2002:a05:622a:450:b0:43d:dd37:d067 with SMTP id d75a77b69052e-44041bbaab6mr39831281cf.16.1717791819450; Fri, 07 Jun 2024 13:23:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717791819; cv=pass; d=google.com; s=arc-20160816; b=l6n325O92f54MLWRw17tIKZLuA/BE51atVsEDjKDZlVMNpuB4TwRVi9t8kNOYTWGFg EokDbkKKhNi7ZzQXnJyaU6DbUsJWEpmZiSPhMbkGl9FiGSGjsM1/Z30uHOt9hPBjrLt7 O2R30mvbOHxQcw4kl3GRXvCQeij+Cibx5C2n3LgRLYIOB0muWH9GAwAY6JXTsTvUDNCC bvBVKT+6VswBd+uxnnBbl1S1NXQq2aIpbJNH3k7sHURPoLVHoqV9u/nKkQkPqYxQeMUP mX5m+HIAg9z4T49ydIPB2fsjcrlnyhEmej49K0HhcPi7geEM86qSKEznt1h/R5onrZj6 IxQw== 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:to:dkim-signature:dkim-signature:from; bh=TP0ssdDAE0NqzBzFQW76UUCVj0BXnEtRoVuuQq7wR+A=; fh=NjSy9ELbZGh6EjCqOzE+qeF+VS4OABBeZf5VHCmpp/4=; b=nj4bHbHD1bk+agO2hIsC/jcNs8JK1Ou4cSmeVRugnTpBlbYlLXImkee6Wqd3UsK3aN O6nY1THPXPByCMw7J+2dEfvbBLdNsRyoICY22i3NR6paLADKYDFACx6QABpl/ZZcr2Ig 62+tm+er5KF6xRNgzOSL3I1UBk6JF1J1bymnfAWnG0840m5K6t4l3+ms2LzQI0hJcGVF C0B2qsoWVG/9AZUPzrV57M0WWNQ0lqJpxfKmlFlTdHTMbLjsB0C/DKDA70EcME4q92Qu vqmAMw9wllQYN1IaosUzqacdPutUxz2skOzGGYz8LvsB1VMRAQEfDxMUPQjCz5wklLqK AG3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cQzPkJdt; 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-206698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206698-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-44038b69b28si43404581cf.648.2024.06.07.13.23.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 13:23:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206698-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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cQzPkJdt; 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-206698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206698-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7764D1C21305 for ; Fri, 7 Jun 2024 20:23:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A82E51553A2; Fri, 7 Jun 2024 20:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cQzPkJdt"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="baW3tS6A" 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 2448E153BF6 for ; Fri, 7 Jun 2024 20:22:18 +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=1717791740; cv=none; b=WobZyfo0Okc5thKyvNxuRZ9n1OsteYlFwD/ohGptvYJ0/E5pQHyk9Y5xezjuzH3HvqOEbvINmVLW7/+dpm8D7VtCo1Y9UNHcqflxST1yz2XeWEBQjjUJTTPipgQ9OBmD319ahhE8GHe1wT7QhJjwej725rIJuhcNq42UpYjnKNQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717791740; c=relaxed/simple; bh=rqgphNpvAIswvOtuYW+jmZOKl/Ada8Dg9FW1BkMfDMY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FwJEfeQrNaDiEbvMhsPb8GqneMJ7xqIX2MiUSwJeQva8fDh2NDXRagCziX1wXw/tmjegOsVopZmFvBtrfL6aB7kdB4MUhLU43BDd1ExQyaIRfkB/7OuYRGyJFp7Al3l0iV05lox2rgkYNzCqVnDYQ9nT1KTDDWT7t9HQz5Rn6XE= 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=cQzPkJdt; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=baW3tS6A; 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=1717791734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TP0ssdDAE0NqzBzFQW76UUCVj0BXnEtRoVuuQq7wR+A=; b=cQzPkJdtRWilbFwWhEzmOk8wKwdQTdbrjtndb3Y+dC72TGNip7QyeYIf1ym/rDYhKOvXAV g994mSyBhfaKP0VLrAYutCQeOoCRfCg3/c6N7Ooiiq4J42a9dL9ikGhDy2gI6+VwOgig6o LYu3oKF2qoHLTrsZH8sR0rxBHpp8GagcYhHJIsZXck56+Cdwfd0Aa8CQEFLVTWCk9QjPh0 q+Iqu8K+S5rKHIJEE14bL/y5+hvGLNoNxkVCmmTGF6o41jKT3C/ObAx1aCE9nVgByBznCn NOGPBxuG1TyxM5shHTfhaE3dQBGBZBWyROq3eLWp0auUC3K3Use7X6JyaPCRjQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1717791734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TP0ssdDAE0NqzBzFQW76UUCVj0BXnEtRoVuuQq7wR+A=; b=baW3tS6AU1ouireVhMZXJaC7HqFegaRe4WIoi/evjK5RZHILiI6VHVnu0W4qgXHjbRUBRY DcR18wEhRuGd6mDA== To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] riscv: drop the use of XIP_OFFSET in kernel_mapping_va_to_pa() Date: Fri, 7 Jun 2024 22:22:11 +0200 Message-Id: <644c13d9467525a06f5d63d157875a35b2edb4bc.1717789719.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 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 Reviewed-by: Alexandre Ghiti --- 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 b1fcf0d733c4..cda4a917f90a 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_text_pa_offset) : \ (_y - kernel_map.va_kernel_xip_data_pa_offset); \ }) -- 2.39.2