Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp122247pxb; Wed, 18 Nov 2020 18:32:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8PPF1WP72PVjQIOqQ+yezM7UXhStRJNRrbxgHVNRmlxShCvpRxwtOn3Qb/EcOXxizjiPj X-Received: by 2002:a05:6402:144b:: with SMTP id d11mr29028920edx.195.1605753145285; Wed, 18 Nov 2020 18:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605753145; cv=none; d=google.com; s=arc-20160816; b=Pl2B463llzpq21e4zjEYLrTQDOa/eoakrBYERmFLxKYWOJNgg8Q7g2Hw1S3YLTyK56 t1rd/gB3qQJc5VoMFqltHKnmkAVFkwQ3vGfsTkBnZ85Ubwg2f6hKJLAx32HFDeXlKo39 +Ixdji0Opajkb7e6czYrN+utNnDqrMpY6+ewo/h0vivGf6ffobnE+d2j70yHptFFWXGF fM2LkqZ3n0WKv9p/S3BMFBkOKXk8+H2w/RbcvG+vwfsXtRGOaX2gkzJ+BRwyCv+byyC3 LhfeGW0RB0JWBbhMhqSvnjFjF+8NlhBLQX+FzsSYNWkH6Q/FWf4PY7EuGYpjsIr87ypo 26Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=aooOtvOt3OUX/AqBZIZbj5SAdSJokk5fgbQz94mtrD4=; b=vVlpgyuTxDy6gY3qzcCfeBtMKmarTcYYsoPY5MZVcSRsR9QcftGqq5wBqQ9lp2PMrx mTfwqVoV5FVGKDs5HJId9ckcin0AhG9cJCwPY8D8wcGYoXV3I8oTQSrEFZi8WWBrR5du AaBhR39zdN/Tq9MYf+bNbno7j7iizKK5yP2lPLaVhkR7J1/86z71Hojkhd1Jj6qseRFp 4pmTm8xWxLnqm1XwHNiq+xoDBlSZ4vXhEW/VdsmgWSGCoSNfVHOvXUmbeParLOJfTArZ D8sn79+CkPgWa+ZDsVZsBxrK/PXYD+IhqgIWxvbQNjIXc5U3Fz8/e96E9CXLNBICJMWw 8orw== 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 s12si15941145ejd.753.2020.11.18.18.31.46; Wed, 18 Nov 2020 18:32:25 -0800 (PST) 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 S1727187AbgKSC3X (ORCPT + 99 others); Wed, 18 Nov 2020 21:29:23 -0500 Received: from mail.loongson.cn ([114.242.206.163]:52816 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726316AbgKSC3W (ORCPT ); Wed, 18 Nov 2020 21:29:22 -0500 Received: from bogon.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxytF62LVfImASAA--.42816S4; Thu, 19 Nov 2020 10:29:16 +0800 (CST) From: Jinyang He To: Thomas Bogendoerfer , Huacai Chen , Jiaxun Yang Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] MIPS: KASLR: Make relocation_address can be configured Date: Thu, 19 Nov 2020 10:29:14 +0800 Message-Id: <1605752954-10368-3-git-send-email-hejinyang@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1605752954-10368-1-git-send-email-hejinyang@loongson.cn> References: <1605752954-10368-1-git-send-email-hejinyang@loongson.cn> X-CM-TRANSID: AQAAf9AxytF62LVfImASAA--.42816S4 X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2KfnxnUUI43ZEXa7IU5uwZ3UUUUU== X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_RANDOMIZE_BASE is not set, determine_relocation_address() always returns a constant. It is not friendly to users if the address cannot be used. Make it can be configured at Kconfig. Signed-off-by: Jinyang He --- arch/mips/Kconfig | 5 +++++ arch/mips/kernel/relocate.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 1508829..1c95478 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2803,6 +2803,11 @@ config RELOCATION_TABLE_SIZE If unsure, leave at the default value. +config RELOCATE_DESTINATION + hex "Relocate address when RANDOMIZE_BASE is not set" + depends on RELOCATABLE && !RANDOMIZE_BASE + default "0xffffffff81000000" + config RANDOMIZE_BASE bool "Randomize the address of the kernel image" depends on RELOCATABLE diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c index 709cfa0..b7ea6ff 100644 --- a/arch/mips/kernel/relocate.c +++ b/arch/mips/kernel/relocate.c @@ -276,7 +276,7 @@ static inline void __init *determine_relocation_address(void) * Choose a new address for the kernel * For now we'll hard code the destination */ - return (void *)0xffffffff81000000; + return (void *)CONFIG_RELOCATE_DESTINATION; } #endif -- 2.1.0