Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1281113lqt; Fri, 7 Jun 2024 13:23:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXInDk9v9ioXZjorSnn8M3vawAfXCCAUsvnu8Nbj6gfPioQr+gdSHkjjL8Hk0q54+McGqFgc8TtK4uix/Ul6FrMoBj3ouxNWD4B33dqbg== X-Google-Smtp-Source: AGHT+IHCByIIv+9Ww7ZW+iIRX/wh6FPfxnZLOOg9JsRjDCn1hZqnpT0yXlXU/ZKw6IAWkE7ck5+w X-Received: by 2002:a50:a685:0:b0:57a:1aa8:b4ae with SMTP id 4fb4d7f45d1cf-57c50864ad3mr2881929a12.3.1717791819130; 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=TMk81KKZZcCqk8zg5UferzdFmtUIIqZA41/esj3Z6JL9MEitfb9FaFluhIJNDZCFw3 sOtULYrtFr0rJXRgl7Amjct62qB4NO+h8zsiDFE34gvIkQX6Bpc7WSSHbhxu0rMYtF6c 3pL3vLrHkKQqjRcnjf170MB2gzPtdum7LMq+LjWeFdNRylSKXpTmc7GKvqc69cr3CCYI ICw14uX3kV8yQa/gAC34TkjwxkBwHmDRTWrl1CdQJbeDl+2fgSLiabx0RZgZqMuw1fHh S3bZkeBtqryVBdzR7caCqoKi77YNbi8ONZbknVBfKv/Knaf9OtPRiFbR4kptOjzhkEkm bYlQ== 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=QlQGR+tGoioFd255pa4F2M3do0QPDjAAVJR0Ox/2Zbw=; fh=NjSy9ELbZGh6EjCqOzE+qeF+VS4OABBeZf5VHCmpp/4=; b=w1iXgdNqL/tE3aXoedCUsmfJ1WDmKi/xSplAwa3TVe65r6r7DpYCcy6BjqsqjcfOBm zl+i7U2mmnyLQgWirDFDj217HH6uTuV6KQrgxTp0iEc8db0SiPZ8f+GbzqaPMhz/VWrY aJBg3VkbH8EA9UKziY4RYz2QFldJ+3SGKCoHVoMS8Pz14xyw5tLzyx1XwgxGH9BUobQ8 ER8LOXdYri2mnqAjxUyaJ0IKfQA1U5LZruRalXF5x6fhu89kPGhXoX4OG6PoqXcO3+Ag RyzydDoRPn6XO9pSkVmDsR8/Wj8dnScmTeN7CT+OC9E0BWJ61NR7VpdHxc6oPV4MoRXc XxZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0npk3eVU; 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-206697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206697-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c5f711cd2si744620a12.256.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-206697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0npk3eVU; 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-206697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206697-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D67EF1F20632 for ; Fri, 7 Jun 2024 20:23:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC7271553A7; 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="0npk3eVU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pAOWJZp1" 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 DCDEF1527BC 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=N3ogryFuRRBwCr5jYAh6nAGHqB9fOEMbBBCpfL1dBBsCtJYP7PyTL1sB/4JHlSY5LES0vW6ePvrpV/AnL+p9qMFSdTk8DFNWSWwRaQklpkI63yEhQrC3dQzTmjOptr0SvwXr9FA1wg/CcXNIBQHLzD0o+IDQvpBv2otjujUtQkM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717791740; c=relaxed/simple; bh=b3kfaE3B5DqZl7RCPFsX8KN1jUPY+NVq9KI1mO6MnV8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WCK3f0py09WEzGocR3R68zfHckPQdYvHQJ5MfSzpFmfi7Y8fK/xS0sKHkIRd2vMJaWXPTmWsmHIkiCaheOxHs7ytE08ROll7STybeYi49g9RT5GNui/5tB7m9Zyd3iOjUPUhjy8rGJFCmZ5BSndPOl+l9iODRkkTnmZe7e6C0BE= 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=0npk3eVU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pAOWJZp1; 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=QlQGR+tGoioFd255pa4F2M3do0QPDjAAVJR0Ox/2Zbw=; b=0npk3eVUOmUI1nJgJEXVN/ccbreM702IcCn9WYf4K/Oxj9tGeMxddKkJDGTLsUd6jU2Hld 86Xue89Ax+FDFdr9bi4qq0TZILDFEK4O0vrkSSqjw0jrpsUrochYd1ry6G8v8Lp3515Rpi 9Cn3A2N9JjNeldDor7FOPGDDYDVkBHeClap9PF2sTvYFqwn/F7PxWsn+/8ABx8JEdvzbGE PX6YLMMZVGxgy+nAhy0qy6DK607Dm1xO0FXBnf5odNFkK+MwvNBSvHhaM36oP+IVSTu7R0 rgtqlU1JZaXDFC4dQJbF6bx8ZEJ21UxJuL5aMpyOjGfOAkB7alyW5ynRxbMVXQ== 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=QlQGR+tGoioFd255pa4F2M3do0QPDjAAVJR0Ox/2Zbw=; b=pAOWJZp1PU/dlsrZNLVkbeFP89DsN/O4sOSeJ+S3UZsBgLwdnT58Oc5YLEFIvS5di+cZG4 vW6wJ5f0wxgfC1Cg== To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] riscv: remove limit on the size of read-only section for XIP kernel Date: Fri, 7 Jun 2024 22:22:13 +0200 Message-Id: <3bf3a77be10ebb0d8086c028500baa16e7a8e648.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. This causes build failures if the kernel gets too big [1]. Remove this limit. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202404211031.J6l2AfJk-lkp@intel.com [1] Signed-off-by: Nam Cao Reviewed-by: Alexandre Ghiti --- arch/riscv/include/asm/pgtable.h | 7 ------- arch/riscv/include/asm/set_memory.h | 2 +- arch/riscv/kernel/vmlinux-xip.lds.S | 5 +++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 1bc103aa9b74..bf4afffe0c53 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -107,13 +107,6 @@ #endif -#ifdef CONFIG_XIP_KERNEL -#define XIP_OFFSET SZ_32M -#define XIP_OFFSET_MASK (SZ_32M - 1) -#else -#define XIP_OFFSET 0 -#endif - #ifndef __ASSEMBLY__ #include diff --git a/arch/riscv/include/asm/set_memory.h b/arch/riscv/include/asm/set_memory.h index ec11001c3fe0..ab92fc84e1fc 100644 --- a/arch/riscv/include/asm/set_memory.h +++ b/arch/riscv/include/asm/set_memory.h @@ -46,7 +46,7 @@ bool kernel_page_present(struct page *page); #endif /* __ASSEMBLY__ */ -#ifdef CONFIG_STRICT_KERNEL_RWX +#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_XIP_KERNEL) #ifdef CONFIG_64BIT #define SECTION_ALIGN (1 << 21) #else diff --git a/arch/riscv/kernel/vmlinux-xip.lds.S b/arch/riscv/kernel/vmlinux-xip.lds.S index 8c3daa1b0531..a7611789bad5 100644 --- a/arch/riscv/kernel/vmlinux-xip.lds.S +++ b/arch/riscv/kernel/vmlinux-xip.lds.S @@ -14,6 +14,7 @@ #include #include #include +#include OUTPUT_ARCH(riscv) ENTRY(_start) @@ -65,10 +66,10 @@ SECTIONS * From this point, stuff is considered writable and will be copied to RAM */ __data_loc = ALIGN(PAGE_SIZE); /* location in file */ - . = KERNEL_LINK_ADDR + XIP_OFFSET; /* location in memory */ + . = ALIGN(SECTION_ALIGN); /* location in memory */ #undef LOAD_OFFSET -#define LOAD_OFFSET (KERNEL_LINK_ADDR + XIP_OFFSET - (__data_loc & XIP_OFFSET_MASK)) +#define LOAD_OFFSET (KERNEL_LINK_ADDR + _sdata - __data_loc) _sdata = .; /* Start of data section */ _data = .; -- 2.39.2