Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp3489887ybg; Sun, 7 Jun 2020 01:03:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYMPc3iv3PemCSoLLfuYDwV3L2bcJP73Z0iuMGKAcWahNKgJaxaG6dTITVNZFPMst/4zrl X-Received: by 2002:a17:906:1dce:: with SMTP id v14mr15855552ejh.46.1591516993458; Sun, 07 Jun 2020 01:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591516993; cv=none; d=google.com; s=arc-20160816; b=fHEollpm0sl/8wCmpq/fvN79vZFH2GPP5vS8uzDt2IZMFkxZcNwGl1pP+MJzRg1Vti MHvn/DEhLA9wPh0eKxvIMQj6n5S4L3cJshXt2RPuXbf9X/SXlyhNjMBEZnMCs65EvoBY TcZMGmYdtNTWyNX7iC7rIFc0a/DkVVpFixPwTIal1bKFPEnbSAv7lTDGIP5YOKzETzgx SZTgv0LOKqRUzrgB+uEPW6D0ee4/9leeKQZgLaRsvvaLb6PexOCDqjGtLp/lmSkvfzcI /FRz6YVP+FMJKptjTgiax6Sorx335m3/r8P21FQH99X0IiRslWKgwP6bZvUY+qVbEqqK pqKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=u3PAf9XxE84juVjJE7JO3JV9EhJ5dIdUFg4I07nft+g=; b=uDFCxvEP7R4OKXsqsVLB1pVamR5Q00LS3YSt3z4pV7r+5nVDdy6DtG1O52cP/s77rN O0AjmBpstQcXlFbX/q3OokGfpDnK+WfoQOYmdHy8sExZ14bvOOtU1rzHCoqGCBwxlBFI fd4wjRbS/owzEy3MNfJlN1lJy5APZ6pWBx7N3jB2PpROLYPmYXdVe0w8QZ1SDma60CW/ vY5egLDZNOLbQsSNv+2HxN8uw3AKhBadyz/JaeMtGu5hjear1xvIKZeYvJ6GnaE6dTpE n06XidKtwJkXsXduD3jxgbdylIcnQr2tS3BAjsganiTXEpZ+618dYZjwrJDZpwhNPIAw GFpg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si7138329edl.221.2020.06.07.01.02.38; Sun, 07 Jun 2020 01:03:13 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726375AbgFGIAC (ORCPT + 99 others); Sun, 7 Jun 2020 04:00:02 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:46367 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgFGIAB (ORCPT ); Sun, 7 Jun 2020 04:00:01 -0400 Received: from localhost.localdomain (lfbn-gre-1-325-105.w90-112.abo.wanadoo.fr [90.112.45.105]) (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id A5B6B240003; Sun, 7 Jun 2020 07:59:50 +0000 (UTC) From: Alexandre Ghiti To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , Zong Li , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org Cc: Alexandre Ghiti Subject: [PATCH v5 0/4] vmalloc kernel mapping and relocatable kernel Date: Sun, 7 Jun 2020 03:59:45 -0400 Message-Id: <20200607075949.665-1-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchset originally implemented relocatable kernel support but now also moves the kernel mapping into the vmalloc zone. The first patch explains why we need to move the kernel into vmalloc zone (instead of memcpying it around). That patch should ease KASLR implementation a lot. The second patch allows to build relocatable kernels but is not selected by default. The third and fourth patches take advantage of an already existing powerpc script that checks relocations at compile-time, and uses it for riscv. 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 (4): riscv: Move kernel mapping to vmalloc zone 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 | 5 +- arch/riscv/Makefile.postlink | 36 +++++++++ arch/riscv/boot/loader.lds.S | 3 +- arch/riscv/include/asm/page.h | 10 ++- arch/riscv/include/asm/pgtable.h | 38 ++++++--- arch/riscv/kernel/head.S | 3 +- arch/riscv/kernel/module.c | 4 +- arch/riscv/kernel/vmlinux.lds.S | 9 ++- arch/riscv/mm/Makefile | 4 + arch/riscv/mm/init.c | 121 +++++++++++++++++++++++++---- arch/riscv/mm/physaddr.c | 2 +- arch/riscv/tools/relocs_check.sh | 26 +++++++ scripts/relocs_check.sh | 20 +++++ 15 files changed, 259 insertions(+), 52 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.20.1