[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190123110850.12433-3-fanc.fnst@cn.fujitsu.com>
Date: Wed, 23 Jan 2019 19:08:45 +0800
From: Chao Fan <fanc.fnst@...fujitsu.com>
To: <linux-kernel@...r.kernel.org>, <x86@...nel.org>, <bp@...en8.de>,
<tglx@...utronix.de>, <mingo@...hat.com>, <hpa@...or.com>,
<keescook@...omium.org>, <bhe@...hat.com>, <msys.mizuma@...il.com>
CC: <indou.takao@...fujitsu.com>, <caoj.fnst@...fujitsu.com>,
<fanc.fnst@...fujitsu.com>, <kasong@...hat.com>
Subject: [PATCH v16 2/7] x86/boot: Introduce get_acpi_rsdp() to parse RSDP in cmdline from KEXEC
KASLR may randomly choose some positions which are located in movable
memory regions. This will make the movable memory chosen by KASLR
can't be removed.
Memory information in SRAT is necessary to fix the conflict between
KASLR and memory-hotremove.
ACPI SRAT (System/Static Resource Affinity Table) shows the details
about memory ranges, including ranges of memory provided by hot-added
memory devices. SRAT is introduced by Root System Description
Pointer(RSDP). So RSDP should be found firstly.
When booting form KEXEC/EFI/BIOS, the methods to find RSDP
are different. When booting from KEXEC, 'acpi_rsdp=' may have been
added to cmdline, so parse cmdline to find RSDP.
Signed-off-by: Chao Fan <fanc.fnst@...fujitsu.com>
---
arch/x86/boot/compressed/acpi.c | 32 ++++++++++++++++++++++++++++++++
arch/x86/boot/compressed/misc.h | 3 +++
2 files changed, 35 insertions(+)
create mode 100644 arch/x86/boot/compressed/acpi.c
diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
new file mode 100644
index 000000000000..bacfc4ea35ac
--- /dev/null
+++ b/arch/x86/boot/compressed/acpi.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+#define BOOT_CTYPE_H
+#include "misc.h"
+#include "error.h"
+#include "../string.h"
+
+#ifdef CONFIG_ACPI
+
+/*
+ * Max length of 64-bit hex address string is 19, prefix "0x" + 16 hex
+ * digits, and '\0' for termination.
+ */
+#define MAX_ADDR_LEN 19
+
+static acpi_physical_address get_acpi_rsdp(void)
+{
+ acpi_physical_address addr = 0;
+
+#ifdef CONFIG_KEXEC
+ char val[MAX_ADDR_LEN] = { };
+ int ret;
+
+ ret = cmdline_find_option("acpi_rsdp", val, MAX_ADDR_LEN);
+ if (ret < 0)
+ return 0;
+
+ if (kstrtoull(val, 16, &addr))
+ return 0;
+#endif
+ return addr;
+}
+#endif /* CONFIG_ACPI */
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index a1d5918765f3..764ad50c0119 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -25,6 +25,9 @@
#include <asm/bootparam.h>
#include <asm/bootparam_utils.h>
+#define BOOT_CTYPE_H
+#include <linux/acpi.h>
+
#define BOOT_BOOT_H
#include "../ctype.h"
--
2.20.1
Powered by blists - more mailing lists