Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Jinyang He <hejinyang@loongson.cn>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Huacai Chen <chenhc@lemote.com>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>
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	[thread overview]
Message-ID: <1605752954-10368-3-git-send-email-hejinyang@loongson.cn> (raw)
In-Reply-To: <1605752954-10368-1-git-send-email-hejinyang@loongson.cn>

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 <hejinyang@loongson.cn>
---
 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


  parent reply	other threads:[~2020-11-19  2:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19  2:29 [PATCH 1/3] MIPS: KASLR: Correcte valid bits in apply_r_mips_26_rel Jinyang He
2020-11-19  2:29 ` [PATCH 2/3] MIPS: Loongson64: Add KASLR support Jinyang He
2020-11-19  2:29 ` Jinyang He [this message]
2020-11-19  8:06   ` [PATCH 3/3] MIPS: KASLR: Make relocation_address can be configured Sergei Shtylyov
2020-11-19  9:31     ` Jinyang He
2020-11-19 12:45   ` Thomas Bogendoerfer
2020-11-20  2:43     ` Jinyang He
2020-11-19 12:36 ` [PATCH 1/3] MIPS: KASLR: Correcte valid bits in apply_r_mips_26_rel Thomas Bogendoerfer
2020-11-20  2:48   ` Jinyang He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1605752954-10368-3-git-send-email-hejinyang@loongson.cn \
    --to=hejinyang@loongson.cn \
    --cc=chenhc@lemote.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox