All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 8/8] 2.6.17: scan DMI early
@ 2007-02-14 16:00 Jan Beulich
  2007-03-05 15:51 ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2007-02-14 16:00 UTC (permalink / raw)
  To: xen-devel

While shuffling quite a few things around, this gets us closer to native,
which clearly had a reason to do the DMI scan early.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

Index: head-2007-02-08/arch/i386/mm/ioremap-xen.c
===================================================================
--- head-2007-02-08.orig/arch/i386/mm/ioremap-xen.c	2007-02-08 17:07:13.000000000 +0100
+++ head-2007-02-08/arch/i386/mm/ioremap-xen.c	2007-02-08 17:09:47.000000000 +0100
@@ -374,8 +374,6 @@ void iounmap(volatile void __iomem *addr
 }
 EXPORT_SYMBOL(iounmap);
 
-#ifdef __i386__
-
 void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
 {
 	unsigned long offset, last_addr;
@@ -443,5 +441,3 @@ void __init bt_iounmap(void *addr, unsig
 		--nrpages;
 	}
 }
-
-#endif /* __i386__ */
Index: head-2007-02-08/arch/x86_64/kernel/setup-xen.c
===================================================================
--- head-2007-02-08.orig/arch/x86_64/kernel/setup-xen.c	2007-02-08 17:07:13.000000000 +0100
+++ head-2007-02-08/arch/x86_64/kernel/setup-xen.c	2007-02-08 17:09:47.000000000 +0100
@@ -681,7 +681,8 @@ void __init setup_arch(char **cmdline_p)
 
 	init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
 
-	/* dmi_scan_machine(); */
+	if (is_initial_xendomain())
+		dmi_scan_machine();
 
 #ifdef CONFIG_ACPI_NUMA
 	/*
@@ -1630,13 +1629,6 @@ struct seq_operations cpuinfo_op = {
 	.show =	show_cpuinfo,
 };
 
-static int __init run_dmi_scan(void)
-{
-	dmi_scan_machine();
-	return 0;
-}
-core_initcall(run_dmi_scan);
-
 #if defined(CONFIG_INPUT_PCSPKR) || defined(CONFIG_INPUT_PCSPKR_MODULE)
 #include <linux/platform_device.h>
 static __init int add_pcspkr(void)
Index: head-2007-02-08/arch/x86_64/mm/init-xen.c
===================================================================
--- head-2007-02-08.orig/arch/x86_64/mm/init-xen.c	2007-02-08 17:07:13.000000000 +0100
+++ head-2007-02-08/arch/x86_64/mm/init-xen.c	2007-02-08 17:09:47.000000000 +0100
@@ -208,7 +208,11 @@ static __init void *spp_getpage(void)
 	void *ptr;
 	if (after_bootmem)
 		ptr = (void *) get_zeroed_page(GFP_ATOMIC); 
-	else
+	else if (start_pfn < table_end) {
+		ptr = __va(start_pfn << PAGE_SHIFT);
+		start_pfn++;
+		memset(ptr, 0, PAGE_SIZE);
+	} else
 		ptr = alloc_bootmem_pages(PAGE_SIZE);
 	if (!ptr || ((unsigned long)ptr & ~PAGE_MASK))
 		panic("set_pte_phys: cannot allocate page data %s\n", after_bootmem?"after bootmem":"");
@@ -436,17 +441,34 @@ static inline int make_readonly(unsigned
 	return readonly;
 }
 
+#ifndef CONFIG_XEN
 /* Must run before zap_low_mappings */
 __init void *early_ioremap(unsigned long addr, unsigned long size)
 {
-	return ioremap(addr, size);
+	unsigned long map = round_down(addr, LARGE_PAGE_SIZE);
+
+	/* actually usually some more */
+	if (size >= LARGE_PAGE_SIZE) {
+		printk("SMBIOS area too long %lu\n", size);
+		return NULL;
+	}
+	set_pmd(temp_mappings[0].pmd,  __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
+	map += LARGE_PAGE_SIZE;
+	set_pmd(temp_mappings[1].pmd,  __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
+	__flush_tlb();
+	return temp_mappings[0].address + (addr & (LARGE_PAGE_SIZE-1));
 }
 
 /* To avoid virtual aliases later */
 __init void early_iounmap(void *addr, unsigned long size)
 {
-	iounmap(addr);
+	if ((void *)round_down((unsigned long)addr, LARGE_PAGE_SIZE) != temp_mappings[0].address)
+		printk("early_iounmap: bad address %p\n", addr);
+	set_pmd(temp_mappings[0].pmd, __pmd(0));
+	set_pmd(temp_mappings[1].pmd, __pmd(0));
+	__flush_tlb();
 }
+#endif
 
 static void __meminit
 phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end)
@@ -648,9 +670,9 @@ void __init extend_init_mapping(unsigned
 	}
 }
 
-static void __init find_early_table_space(unsigned long end)
+static unsigned long __init find_early_table_space(unsigned long end)
 {
-	unsigned long puds, pmds, ptes, tables; 
+	unsigned long puds, pmds, ptes, tables, fixmap_tables;
 
 	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
 	pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
@@ -660,7 +682,16 @@ static void __init find_early_table_spac
 		round_up(pmds * 8, PAGE_SIZE) + 
 		round_up(ptes * 8, PAGE_SIZE); 
 
-	extend_init_mapping(tables);
+	/* Also reserve pages for fixmaps that need to be set up early.
+	 * Their pud is shared with the kernel pud.
+	 */
+	pmds = (PMD_SIZE - 1 - FIXADDR_START) >> PMD_SHIFT;
+	ptes = (PTE_SIZE - 1 - FIXADDR_START) >> PAGE_SHIFT;
+
+	fixmap_tables = round_up(pmds * 8, PAGE_SIZE) +
+		round_up(ptes * 8, PAGE_SIZE);
+
+	extend_init_mapping(tables + fixmap_tables);
 
 	table_start = start_pfn;
 	table_end = table_start + (tables>>PAGE_SHIFT);
@@ -668,6 +699,8 @@ static void __init find_early_table_spac
 	early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
 		end, table_start << PAGE_SHIFT,
 		(table_start << PAGE_SHIFT) + tables);
+
+	return table_end + (fixmap_tables>>PAGE_SHIFT);
 }
 
 /* Setup the direct mapping of the physical memory at PAGE_OFFSET.
@@ -675,7 +708,7 @@ static void __init find_early_table_spac
    physical memory. To access them they are temporarily mapped. */
 void __meminit init_memory_mapping(unsigned long start, unsigned long end)
 { 
-	unsigned long next; 
+	unsigned long next, table_rsrv_end = 0;
 
 	Dprintk("init_memory_mapping\n");
 
@@ -686,7 +719,7 @@ void __meminit init_memory_mapping(unsig
 	 * discovered.
 	 */
 	if (!after_bootmem)
-		find_early_table_space(end);
+		table_rsrv_end = find_early_table_space(end);
 
 	start = (unsigned long)__va(start);
 	end = (unsigned long)__va(end);
@@ -714,6 +747,7 @@ void __meminit init_memory_mapping(unsig
 
 	if (!after_bootmem) {
 		BUG_ON(start_pfn != table_end);
+		table_end = table_rsrv_end;
 
 		/* Re-vector virtual addresses pointing into the initial
 		   mapping to the just-established permanent ones. */
@@ -739,6 +773,24 @@ void __meminit init_memory_mapping(unsig
 		for (; start < end; start += PAGE_SIZE)
 			WARN_ON(HYPERVISOR_update_va_mapping(
 				start, __pte_ma(0), 0));
+
+		/* Switch to the real shared_info page, and clear the
+		 * dummy page. */
+		set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
+		HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
+		memset(empty_zero_page, 0, sizeof(empty_zero_page));
+
+		/* Setup mapping of lower 1st MB */
+		for (next = 0; next < NR_FIX_ISAMAPS; next++)
+			if (is_initial_xendomain())
+				set_fixmap(FIX_ISAMAP_BEGIN - next, next * PAGE_SIZE);
+			else
+				__set_fixmap(FIX_ISAMAP_BEGIN - next,
+					     virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
+					     PAGE_KERNEL_RO);
+
+		BUG_ON(start_pfn > table_end);
+		table_end = start_pfn;
 	}
 
 	__flush_tlb_all();
@@ -817,7 +869,6 @@ size_zones(unsigned long *z, unsigned lo
 void __init paging_init(void)
 {
 	unsigned long zones[MAX_NR_ZONES], holes[MAX_NR_ZONES];
-	int i;
 
 	memory_present(0, 0, end_pfn);
 	sparse_init();
@@ -825,22 +876,7 @@ void __init paging_init(void)
 	free_area_init_node(0, NODE_DATA(0), zones,
 			    __pa(PAGE_OFFSET) >> PAGE_SHIFT, holes);
 
-	/* Switch to the real shared_info page, and clear the
-	 * dummy page. */
-	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
-	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
-	memset(empty_zero_page, 0, sizeof(empty_zero_page));
-
 	init_mm.context.pinned = 1;
-
-	/* Setup mapping of lower 1st MB */
-	for (i = 0; i < NR_FIX_ISAMAPS; i++)
-		if (is_initial_xendomain())
-			set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
-		else
-			__set_fixmap(FIX_ISAMAP_BEGIN - i,
-				     virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
-				     PAGE_KERNEL_RO);
 }
 #endif
 
Index: head-2007-02-08/include/asm-x86_64/mach-xen/asm/io.h
===================================================================
--- head-2007-02-08.orig/include/asm-x86_64/mach-xen/asm/io.h	2007-02-08 17:07:13.000000000 +0100
+++ head-2007-02-08/include/asm-x86_64/mach-xen/asm/io.h	2007-02-08 17:09:47.000000000 +0100
@@ -150,8 +150,10 @@ static inline void __iomem * ioremap (un
 	return __ioremap(offset, size, 0);
 }
 
-extern void *early_ioremap(unsigned long addr, unsigned long size);
-extern void early_iounmap(void *addr, unsigned long size);
+extern void *bt_ioremap(unsigned long addr, unsigned long size);
+extern void bt_iounmap(void *addr, unsigned long size);
+#define early_ioremap bt_ioremap
+#define early_iounmap bt_iounmap
 
 /*
  * This one maps high address device memory and turns off caching for that area.
Index: head-2007-02-08/include/asm-x86_64/mach-xen/asm/fixmap.h
===================================================================
--- head-2007-02-08.orig/include/asm-x86_64/mach-xen/asm/fixmap.h	2007-02-08 17:07:13.000000000 +0100
+++ head-2007-02-08/include/asm-x86_64/mach-xen/asm/fixmap.h	2007-02-08 17:09:47.000000000 +0100
@@ -53,6 +53,11 @@ enum fixed_addresses {
 #define NR_FIX_ISAMAPS	256
 	FIX_ISAMAP_END,
 	FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
+	__end_of_permanent_fixed_addresses,
+	/* temporary boot-time mappings, used before ioremap() is functional */
+#define NR_FIX_BTMAPS	16
+	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
+	FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
 	__end_of_fixed_addresses
 };

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 8/8] 2.6.17: scan DMI early
  2007-02-14 16:00 [PATCH 8/8] 2.6.17: scan DMI early Jan Beulich
@ 2007-03-05 15:51 ` Keir Fraser
  2007-03-05 18:11   ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Keir Fraser @ 2007-03-05 15:51 UTC (permalink / raw)
  To: Jan Beulich, xen-devel

On 14/2/07 16:00, "Jan Beulich" <jbeulich@novell.com> wrote:

> While shuffling quite a few things around, this gets us closer to native,
> which clearly had a reason to do the DMI scan early.
> 
> Signed-off-by: Jan Beulich <jbeulich@novell.com>

Taken, but a few comments:

 - could we get rid of alloc_static_page() and use spp_getpage() everywhere?

 - the double-staged find_early_table_space(), where table_end gets updated
halfway through init_memory_mapping(), is pretty skanky. I suppose we get to
keep the BUG_ON(start_pfn != table_end) this way, but perhaps it would be
nicer just to set table_end once and for all in find_early_table_space().

 - the estimate of number of fixmap pagetables required in
find_early_table_space() is conservative. Is there any risk that
spp_getpage() may end up with start_pfn<table_end for long enough that we
run into concurrency issues? Perhaps we could do a dummy set_fixmap for
every fixmap slot to force population of all fixmap slots in
init_memory_mapping(), and then BUG_ON(start_pfn != table_end)?

 -- Keir

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 8/8] 2.6.17: scan DMI early
  2007-03-05 15:51 ` Keir Fraser
@ 2007-03-05 18:11   ` Keir Fraser
  0 siblings, 0 replies; 3+ messages in thread
From: Keir Fraser @ 2007-03-05 18:11 UTC (permalink / raw)
  To: Jan Beulich, xen-devel




On 5/3/07 15:51, "Keir Fraser" <keir@xensource.com> wrote:

>> While shuffling quite a few things around, this gets us closer to native,
>> which clearly had a reason to do the DMI scan early.
>> 
>> Signed-off-by: Jan Beulich <jbeulich@novell.com>
> 
> Taken, but a few comments:

I had a go at cleaning this up myself and it isn't as straightforward as I
first thought (can't get rid of alloc_static_page() for example!). But I did
simplify the fixmap pagetable allocation and initialisation a bit, at least.

 -- Keir

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-05 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 16:00 [PATCH 8/8] 2.6.17: scan DMI early Jan Beulich
2007-03-05 15:51 ` Keir Fraser
2007-03-05 18:11   ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.