From patchwork Mon Apr 12 12:28:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyang He X-Patchwork-Id: 12197895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C378C433B4 for ; Mon, 12 Apr 2021 12:28:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E1AC61278 for ; Mon, 12 Apr 2021 12:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239097AbhDLM2v (ORCPT ); Mon, 12 Apr 2021 08:28:51 -0400 Received: from mail.loongson.cn ([114.242.206.163]:59210 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238414AbhDLM2u (ORCPT ); Mon, 12 Apr 2021 08:28:50 -0400 Received: from loongson.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxzcjsPHRgCyoHAA--.9793S2; Mon, 12 Apr 2021 20:28:28 +0800 (CST) From: Jinyang He To: Thomas Bogendoerfer , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/5] MIPS: relocate: Add automatic relocation to CONFIG_RELOCATABLE Date: Mon, 12 Apr 2021 20:28:09 +0800 Message-Id: <1618230494-6207-1-git-send-email-hejinyang@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9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U X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org 1, To get the address the kernel is linked to, use PC-region(static) + offset(dynamic) way. See detail at [PATCH v2 3/5] 2, To deal with smp cpu in kernel entry, e.g. cavium-octeon platform, move smp cpu handle later than jump to the address kernel linked to. See detail at [PATCH v2 4/5] Jinyang He (5): MIPS: relocate: Only compile relocs when CONFIG_RELOCATABLE is enabled MIPS: relocate: Use CONFIG_RANDOMIZE_BASE to enable kaslr MIPS: Jump to kernel linked address by PC relative way MIPS: cavium-octeon: Execute the smp handle after jumping to kernel linked address MIPS: relocate: Add support to auto relocate kernel arch/mips/Makefile | 2 + arch/mips/cavium-octeon/smp.c | 9 +- arch/mips/generic/init.c | 4 +- arch/mips/include/asm/bootinfo.h | 4 +- .../asm/mach-cavium-octeon/kernel-entry-init.h | 24 ++- arch/mips/kernel/Makefile | 2 +- arch/mips/kernel/head.S | 185 ++++++++++++++++++++- arch/mips/kernel/{relocate.c => kaslr.c} | 15 -- 8 files changed, 214 insertions(+), 31 deletions(-) rename arch/mips/kernel/{relocate.c => kaslr.c} (97%)