mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yinghai Lu" <yhlu.kernel@gmail.com>
To: "Ingo Molnar" <mingo@elte.hu>, "Huang, Ying" <ying.huang@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	andi@firstfloor.org, mingo@redhat.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] x86 boot: add E820_RESVD_KERN
Date: Mon, 30 Jun 2008 16:20:54 -0700	[thread overview]
Message-ID: <86802c440806301620hafa3ee3k8c5dbe6c45188d69@mail.gmail.com> (raw)
In-Reply-To: <86802c440806301553y240b020bh9dc448e8085fe60d@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

On Mon, Jun 30, 2008 at 3:53 PM, Yinghai Lu <yhlu.kernel@gmail.com> wrote:
> On Mon, Jun 30, 2008 at 12:16 PM, Ingo Molnar <mingo@elte.hu> wrote:
>>
>> * Yinghai Lu <yhlu.kernel@gmail.com> wrote:
>>
>>> > For find_e820_area, this is safe enough. But what about conflict
>>> > between setup_data and ebda or ramdisk?
>>>
>>> can you have setup_data and ebda at the same time?
>>>
>>> setup_data and ramdisk should be ok, because bootloader is supposed to
>>> make them not to be conflicts.
>>
>> the more sanity checks we do before relying on some crutial data, the
>> better. It's easier to panic or sanitize data in some structured way and
>> complain about it in the syslog than to let things get corrupted. Boot
>> loaders are ... not unknown to be have bugs too, at times.
>
> to address Ying's concern, we could let reserve_setup_data
> call reserve_early in addition to e820_update_range...
>
> reserve_early will panic if RAMDISK overlap efi setup_data...
>

Ying,
please check the attached patch

YH

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: reserve_setup_data_v3.patch --]
[-- Type: text/x-patch; name=reserve_setup_data_v3.patch, Size: 6085 bytes --]

[PATCH] x86: move reserve_setup_data to setup.c

Ying Huang want to setup_data to be reserved, but not included in no save
range.

here try to modify e820 table to reserve that range as early.
also add that in early_res in case bootloader mess up it with ramdisk.

other solution would be
1. add early_res_to_highmem...
2. early_res_to_e820...
but they could reserve wrongly other type memory, if early_res has some resource reserved early,
and not need later, but it is not removed from early_res in time.
like the RAMDISK (already handled).

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

---
 arch/x86/kernel/e820.c      |    4 +++-
 arch/x86/kernel/head.c      |   18 ------------------
 arch/x86/kernel/head64.c    |    1 -
 arch/x86/kernel/setup.c     |   34 ++++++++++++++++++++++++++++------
 include/asm-x86/bootparam.h |    2 --
 include/asm-x86/e820.h      |    3 +++
 6 files changed, 34 insertions(+), 28 deletions(-)

Index: linux-2.6/arch/x86/kernel/e820.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/e820.c
+++ linux-2.6/arch/x86/kernel/e820.c
@@ -120,6 +120,7 @@ void __init e820_print_map(char *who)
 		       (e820.map[i].addr + e820.map[i].size));
 		switch (e820.map[i].type) {
 		case E820_RAM:
+		case E820_RESERVED_KERN:
 			printk(KERN_CONT "(usable)\n");
 			break;
 		case E820_RESERVED:
@@ -611,7 +612,7 @@ void __init e820_mark_nosave_regions(uns
 			register_nosave_region(pfn, PFN_UP(ei->addr));
 
 		pfn = PFN_DOWN(ei->addr + ei->size);
-		if (ei->type != E820_RAM)
+		if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
 			register_nosave_region(PFN_UP(ei->addr), pfn);
 
 		if (pfn >= limit_pfn)
@@ -1207,6 +1208,7 @@ void __init e820_reserve_resources(void)
 	res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map);
 	for (i = 0; i < e820.nr_map; i++) {
 		switch (e820.map[i].type) {
+		case E820_RESERVED_KERN:
 		case E820_RAM:	res->name = "System RAM"; break;
 		case E820_ACPI:	res->name = "ACPI Tables"; break;
 		case E820_NVS:	res->name = "ACPI Non-volatile Storage"; break;
Index: linux-2.6/arch/x86/kernel/head.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/head.c
+++ linux-2.6/arch/x86/kernel/head.c
@@ -53,21 +53,3 @@ void __init reserve_ebda_region(void)
 	/* reserve all memory between lowmem and the 1MB mark */
 	reserve_early_overlap_ok(lowmem, 0x100000, "BIOS reserved");
 }
-
-void __init reserve_setup_data(void)
-{
-	struct setup_data *data;
-	u64 pa_data;
-	char buf[32];
-
-	if (boot_params.hdr.version < 0x0209)
-		return;
-	pa_data = boot_params.hdr.setup_data;
-	while (pa_data) {
-		data = early_ioremap(pa_data, sizeof(*data));
-		sprintf(buf, "setup data %x", data->type);
-		reserve_early(pa_data, pa_data+sizeof(*data)+data->len, buf);
-		pa_data = data->next;
-		early_iounmap(data, sizeof(*data));
-	}
-}
Index: linux-2.6/arch/x86/kernel/head64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/head64.c
+++ linux-2.6/arch/x86/kernel/head64.c
@@ -123,7 +123,6 @@ void __init x86_64_start_kernel(char * r
 #endif
 
 	reserve_ebda_region();
-	reserve_setup_data();
 
 	/*
 	 * At this point everything still needed from the boot loader
Index: linux-2.6/arch/x86/kernel/setup.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup.c
+++ linux-2.6/arch/x86/kernel/setup.c
@@ -389,14 +389,34 @@ static void __init parse_setup_data(void
 		default:
 			break;
 		}
-#ifndef CONFIG_DEBUG_BOOT_PARAMS
-		free_early(pa_data, pa_data+sizeof(*data)+data->len);
-#endif
 		pa_data = data->next;
 		early_iounmap(data, PAGE_SIZE);
 	}
 }
 
+static void __init reserve_setup_data(void)
+{
+	struct setup_data *data;
+	u64 pa_data;
+	char buf[32];
+
+	if (boot_params.hdr.version < 0x0209)
+		return;
+	pa_data = boot_params.hdr.setup_data;
+	while (pa_data) {
+		data = early_ioremap(pa_data, sizeof(*data));
+		sprintf(buf, "setup data %x", data->type);
+		reserve_early(pa_data, pa_data+sizeof(*data)+data->len, buf);
+		e820_update_range(pa_data, sizeof(*data)+data->len,
+			 E820_RAM, E820_RESERVED_KERN);
+		pa_data = data->next;
+		early_iounmap(data, sizeof(*data));
+	}
+	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+	printk(KERN_INFO "extended physical RAM map:\n");
+	e820_print_map("reserve setup_data");
+}
+
 /*
  * --------- Crashkernel reservation ------------------------------
  */
@@ -524,7 +544,6 @@ void __init setup_arch(char **cmdline_p)
 	pre_setup_arch_hook();
 	early_cpu_init();
 	early_ioremap_init();
-	reserve_setup_data();
 #else
 	printk(KERN_INFO "Command line: %s\n", boot_command_line);
 #endif
@@ -566,6 +585,8 @@ void __init setup_arch(char **cmdline_p)
 	ARCH_SETUP
 
 	setup_memory_map();
+	parse_setup_data();
+
 	copy_edd();
 
 	if (!boot_params.hdr.root_flags)
@@ -592,10 +613,11 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
-	parse_setup_data();
-
 	parse_early_param();
 
+	/* after early param, so could get panic from serial */
+	reserve_setup_data();
+
 	if (acpi_mps_check()) {
 #ifdef CONFIG_X86_LOCAL_APIC
 		disable_apic = 1;
Index: linux-2.6/include/asm-x86/bootparam.h
===================================================================
--- linux-2.6.orig/include/asm-x86/bootparam.h
+++ linux-2.6/include/asm-x86/bootparam.h
@@ -108,6 +108,4 @@ struct boot_params {
 	__u8  _pad9[276];				/* 0xeec */
 } __attribute__((packed));
 
-void reserve_setup_data(void);
-
 #endif /* _ASM_BOOTPARAM_H */
Index: linux-2.6/include/asm-x86/e820.h
===================================================================
--- linux-2.6.orig/include/asm-x86/e820.h
+++ linux-2.6/include/asm-x86/e820.h
@@ -44,6 +44,9 @@
 #define E820_ACPI	3
 #define E820_NVS	4
 
+/* reserved RAM used by kernel itself */
+#define E820_RESERVED_KERN        128
+
 #ifndef __ASSEMBLY__
 struct e820entry {
 	__u64 addr;	/* start of memory segment */

  reply	other threads:[~2008-06-30 23:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-26  6:32 Huang, Ying
2008-06-26  7:25 ` Yinghai Lu
2008-06-26  7:48   ` Huang, Ying
2008-06-26  9:47     ` Yinghai Lu
2008-06-27  2:22       ` Yinghai Lu
2008-06-27  2:48         ` Huang, Ying
2008-06-27  2:52           ` Yinghai Lu
2008-06-27  3:03             ` Huang, Ying
2008-06-27  5:36               ` Yinghai Lu
2008-06-27 22:05           ` Yinghai Lu
2008-06-30  7:03             ` Huang, Ying
2008-06-30  7:34               ` Yinghai Lu
2008-06-30  7:51                 ` Huang, Ying
2008-06-30  9:15                   ` Yinghai Lu
2008-06-30  9:31                     ` Yinghai Lu
2008-06-30  9:38                     ` Huang, Ying
2008-06-30 19:05                       ` Yinghai Lu
2008-06-30 19:16                         ` Ingo Molnar
2008-06-30 22:53                           ` Yinghai Lu
2008-06-30 23:20                             ` Yinghai Lu [this message]
2008-07-01  1:09                               ` Huang, Ying
2008-07-01  1:21                                 ` Yinghai Lu
2008-07-01  8:34                                   ` Ingo Molnar
2008-07-01  2:45                               ` Huang, Ying
2008-07-01  8:39                                 ` Ingo Molnar
2008-06-30  8:28             ` Ingo Molnar

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=86802c440806301620hafa3ee3k8c5dbe6c45188d69@mail.gmail.com \
    --to=yhlu.kernel@gmail.com \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=ying.huang@intel.com \
    /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

all inboxes | Powered by JetHome®