Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3434612pxb; Sat, 9 Oct 2021 10:15:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN8uWC3GYLxqwf+155X/Yr9zmlxgMYVq9LsJmbAgz2eaAmggyAJ86AamxWztJUJU6Mr532 X-Received: by 2002:a17:906:4e89:: with SMTP id v9mr6515597eju.354.1633799715895; Sat, 09 Oct 2021 10:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633799715; cv=none; d=google.com; s=arc-20160816; b=ywGfMwlOpsRdBWKYuG4BF5dyuSyu9o/ZLXzzQKI+qlwXjNQfPsVtDxw1r555zukQaG aWTHZqmV3gEcUyhMOeY/NrttgpnH+OTGiaO/XM0yh8tuTPc8eN+caMxiWi2em95IZXFK 4StVrfA9GkhcaNsBorTsvieDKIxfvQlUyHUjJTlix7X2XFn6EPmGtZlfQtZNO5hSaffw oTJQ/fKKQJVpCtuvjlhxJIiDivj7nBjeJxSQ+P/GRbSwh532E+asYBgH5vtlZERHJ7rO nQFa35Y0pluTbUBAWoe4Cs1++4ETLCpmVJFco3YDGqVIJaio4+wFpMR7NBQDZwVu+m63 qbEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=WlnsdBvmh6jB3zaGmtX239WQSxypvAEoGKVB7yMuLZk=; b=yfcI2XU00/w2Y8D6HGe89Q3xY2mQjDvQ/uPEzKc7VtNZtwUFNArx3OwAIPnLCJXHgD g42JtDltWWpR8GEH/b73BjFIjxbLV+IBs589p0qZ6wJp2GA13T+P0qv+TXmMJ6Q5/OGC bVtrDjhIF0OJ8H8M2RMTgjnZy3UgIiqcyu9a9VrUM/Ghuh6TDQ4aB+5cFP/5KOAoGRmi 3osKrpXBy3xHPmbqDcPbHI6B5vl99TgLyTtKM8xLg8Rfqgg5VIwuDklfYLbDPszKxXD4 PyfK6vE2NTRZFEQFqa8VYLRqxBgejdBosRsusXFWIS4NNE9mJcIs94mHtGn8IjWGwPMo oPNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si4049282edh.30.2021.10.09.10.14.32; Sat, 09 Oct 2021 10:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231433AbhJIRPP (ORCPT + 99 others); Sat, 9 Oct 2021 13:15:15 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:55641 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbhJIRPO (ORCPT ); Sat, 9 Oct 2021 13:15:14 -0400 Received: (Authenticated sender: alex@ghiti.fr) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 9AA7F60006; Sat, 9 Oct 2021 17:13:09 +0000 (UTC) From: Alexandre Ghiti To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Alexandre Ghiti Subject: [PATCH v7 0/3] Introduce 64b relocatable kernel Date: Sat, 9 Oct 2021 19:12:56 +0200 Message-Id: <20211009171259.2515351-1-alexandre.ghiti@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After multiple attempts, this patchset is now based on the fact that the 64b kernel mapping was moved outside the linear mapping. The first patch allows to build relocatable kernels but is not selected by default. That patch should ease KASLR implementation a lot. The second and third patches take advantage of an already existing powerpc script that checks relocations at compile-time, and uses it for riscv. This patchset was tested on: * qemu riscv64 defconfig: OK * Unmatched ubuntu config: OK Changes in v7: * Rebase on top of v5.15 * Fix LDFLAGS_vmlinux which was overriden when CONFIG_DYNAMIC_FTRACE was set * Make relocate_kernel static * Add Ack from Michael Changes in v6: * Remove the kernel move to vmalloc zone * Rebased on top of for-next * Remove relocatable property from 32b kernel as the kernel is mapped in the linear mapping and would then need to be copied physically too * CONFIG_RELOCATABLE depends on !XIP_KERNEL * Remove Reviewed-by from first patch as it changed a bit Changes in v5: * Add "static __init" to create_kernel_page_table function as reported by Kbuild test robot * Add reviewed-by from Zong * Rebase onto v5.7 Changes in v4: * Fix BPF region that overlapped with kernel's as suggested by Zong * Fix end of module region that could be larger than 2GB as suggested by Zong * Fix the size of the vm area reserved for the kernel as we could lose PMD_SIZE if the size was already aligned on PMD_SIZE * Split compile time relocations check patch into 2 patches as suggested by Anup * Applied Reviewed-by from Zong and Anup Changes in v3: * Move kernel mapping to vmalloc Changes in v2: * Make RELOCATABLE depend on MMU as suggested by Anup * Rename kernel_load_addr into kernel_virt_addr as suggested by Anup * Use __pa_symbol instead of __pa, as suggested by Zong * Rebased on top of v5.6-rc3 * Tested with sv48 patchset * Add Reviewed/Tested-by from Zong and Anup Alexandre Ghiti (3): riscv: Introduce CONFIG_RELOCATABLE powerpc: Move script to check relocations at compile time in scripts/ riscv: Check relocations at compile time arch/powerpc/tools/relocs_check.sh | 18 ++-------- arch/riscv/Kconfig | 12 +++++++ arch/riscv/Makefile | 7 ++-- arch/riscv/Makefile.postlink | 36 ++++++++++++++++++++ arch/riscv/kernel/vmlinux.lds.S | 6 ++++ arch/riscv/mm/Makefile | 4 +++ arch/riscv/mm/init.c | 54 +++++++++++++++++++++++++++++- arch/riscv/tools/relocs_check.sh | 26 ++++++++++++++ scripts/relocs_check.sh | 20 +++++++++++ 9 files changed, 164 insertions(+), 19 deletions(-) create mode 100644 arch/riscv/Makefile.postlink create mode 100755 arch/riscv/tools/relocs_check.sh create mode 100755 scripts/relocs_check.sh -- 2.30.2