* [PATCH 5/7] setup.c: use __pa_symbol() where needed
2006-10-13 12:38 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #2] Franck Bui-Huu
@ 2006-10-13 12:39 ` Franck Bui-Huu
0 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-13 12:39 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
It should fix the broken code in resource_init() too.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
arch/mips/kernel/setup.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 00d62bd..84faa4b 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -256,7 +256,7 @@ static void __init bootmem_init(void)
* of usable memory.
*/
reserved_end = init_initrd();
- reserved_end = PFN_UP(__pa(max(reserved_end, (unsigned long)&_end)));
+ reserved_end = PFN_UP(max(__pa(reserved_end), __pa_symbol(&_end)));
/*
* Find the highest page frame number we have available.
@@ -428,10 +428,10 @@ static void __init resource_init(void)
if (UNCAC_BASE != IO_BASE)
return;
- code_resource.start = virt_to_phys(&_text);
- code_resource.end = virt_to_phys(&_etext) - 1;
- data_resource.start = virt_to_phys(&_etext);
- data_resource.end = virt_to_phys(&_edata) - 1;
+ code_resource.start = __pa_symbol(&_text);
+ code_resource.end = __pa_symbol(&_etext) - 1;
+ data_resource.start = __pa_symbol(&_etext);
+ data_resource.end = __pa_symbol(&_edata) - 1;
/*
* Request address space for all standard RAM.
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/7] setup.c: use __pa_symbol() where needed
2006-10-16 16:12 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #3] Franck Bui-Huu
@ 2006-10-16 16:12 ` Franck Bui-Huu
0 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-16 16:12 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
It should fix the broken code in resource_init() too.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
arch/mips/kernel/setup.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 00d62bd..84faa4b 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -256,7 +256,7 @@ static void __init bootmem_init(void)
* of usable memory.
*/
reserved_end = init_initrd();
- reserved_end = PFN_UP(__pa(max(reserved_end, (unsigned long)&_end)));
+ reserved_end = PFN_UP(max(__pa(reserved_end), __pa_symbol(&_end)));
/*
* Find the highest page frame number we have available.
@@ -428,10 +428,10 @@ static void __init resource_init(void)
if (UNCAC_BASE != IO_BASE)
return;
- code_resource.start = virt_to_phys(&_text);
- code_resource.end = virt_to_phys(&_etext) - 1;
- data_resource.start = virt_to_phys(&_etext);
- data_resource.end = virt_to_phys(&_edata) - 1;
+ code_resource.start = __pa_symbol(&_text);
+ code_resource.end = __pa_symbol(&_etext) - 1;
+ data_resource.start = __pa_symbol(&_etext);
+ data_resource.end = __pa_symbol(&_edata) - 1;
/*
* Request address space for all standard RAM.
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4]
@ 2006-10-19 11:19 Franck Bui-Huu
2006-10-19 11:19 ` [PATCH 1/7] page.h: remove __pa() usages Franck Bui-Huu
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:19 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips
Changes since take #3
--------------------
* Sign extension hack still needed by rd_start_early() (Atsushi)
* Replace panic() by printk() in init_initrd() (Atsushi)
* Fix CONFIG_64BITS typo (Atsushi)
* Add a new sanity check in init_initrd():
initrd_start < PAGE_OFFSET
Changes since take #2
--------------------
* More initrd code clean up. It should be more readable and
more robust now.
* Add some missing include in page.h (Atsushi)
* Fix a wrong use of __page_offset() in __va() (Atsushi)
* Rename __page_offset() into __pa_page_offset()
changes since take #1
--------------------
* Changed the definition of __pa() for 64-bits kernels to match
the one suggested by Atsushi. It should be safer.
* Make virt_to_page() uses virt_to_phys() instead of __pa().
Thanks to Atsushi for testing this patchset on 64 bit kernels.
Please consider,
Franck
---
arch/mips/kernel/setup.c | 87 +++++++++++++++++++++++++++-----------------
arch/mips/mm/init.c | 42 ++++++++++-----------
include/asm-mips/io.h | 2 +
include/asm-mips/page.h | 16 ++++++--
include/asm-mips/pgtable.h | 2 +
5 files changed, 87 insertions(+), 62 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/7] page.h: remove __pa() usages.
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
@ 2006-10-19 11:19 ` Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 2/7] Make __pa() aware of XKPHYS/CKSEG0 address mix for 64 bit kernels Franck Bui-Huu
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:19 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
__pa() was used by virt_to_page() and virt_addr_valid(). These
latter are used when kernel is initialised so __pa() is not
appropriate, we use virt_to_phys() instead.
Futhermore __pa() is going to take care of CKSEG0/XKPHYS
address mix for 64 bit kernels. This makes __pa() more complex
than virt_to_phys() and this extra work is not needed by
virt_to_page() and virt_addr_valid().
Eventually it consolidates virt_to_phys() prototype by making
its argument 'const'. this avoids some warnings that was due
to some virt_to_page() usages which pass const pointer.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
arch/mips/mm/init.c | 8 ++++----
include/asm-mips/io.h | 2 +-
include/asm-mips/page.h | 6 ++++--
include/asm-mips/pgtable.h | 2 +-
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 2f346d1..4431ea0 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -90,9 +90,9 @@ unsigned long setup_zero_pages(void)
if (!empty_zero_page)
panic("Oh boy, that early out of memory?");
- page = virt_to_page(empty_zero_page);
+ page = virt_to_page((void *)empty_zero_page);
split_page(page, order);
- while (page < virt_to_page(empty_zero_page + (PAGE_SIZE << order))) {
+ while (page < virt_to_page((void *)(empty_zero_page + (PAGE_SIZE << order)))) {
SetPageReserved(page);
page++;
}
@@ -490,8 +490,8 @@ void free_init_pages(char *what, unsigne
unsigned long addr;
for (addr = begin; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
+ ClearPageReserved(virt_to_page((void *)addr));
+ init_page_count(virt_to_page((void *)addr));
memset((void *)addr, 0xcc, PAGE_SIZE);
free_page(addr);
totalram_pages++;
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index d5307dd..9b9f804 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -113,7 +113,7 @@ #endif
* almost all conceivable cases a device driver should not be using
* this function
*/
-static inline unsigned long virt_to_phys(volatile void * address)
+static inline unsigned long virt_to_phys(volatile const void *address)
{
return (unsigned long)address - PAGE_OFFSET;
}
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index 32e5625..fa4e4d9 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -34,7 +34,9 @@ #define PAGE_MASK (~((1 << PAGE_SH
#ifndef __ASSEMBLY__
+#include <linux/pfn.h>
#include <asm/cpu-features.h>
+#include <asm/io.h>
extern void clear_page(void * page);
extern void copy_page(void * to, void * from);
@@ -157,8 +159,8 @@ ({ \
#endif
-#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
-#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
+#define virt_to_page(kaddr) pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
+#define virt_addr_valid(kaddr) pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index 1ca4d1e..f2e1325 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -67,7 +67,7 @@ extern unsigned long empty_zero_page;
extern unsigned long zero_page_mask;
#define ZERO_PAGE(vaddr) \
- (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))
+ (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
#define __HAVE_ARCH_MOVE_PTE
#define move_pte(pte, prot, old_addr, new_addr) \
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/7] Make __pa() aware of XKPHYS/CKSEG0 address mix for 64 bit kernels
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
2006-10-19 11:19 ` [PATCH 1/7] page.h: remove __pa() usages Franck Bui-Huu
@ 2006-10-19 11:20 ` Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 3/7] setup.c: get ride of CPHYSADDR() Franck Bui-Huu
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:20 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
During early boot mem init, some configs couldn't use __pa() to
convert virtual into physical addresses. Specially for 64 bit
kernel cases when CONFIG_BUILD_ELF64=n. This patch make __pa()
work for _all_ configs and thus make CPHYSADDR() useless.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
include/asm-mips/page.h | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index fa4e4d9..119daee 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -133,8 +133,13 @@ #endif /* !__ASSEMBLY__ */
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
+#if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
+#define __pa_page_offset(x) ((unsigned long)(x) < CKSEG0 ? PAGE_OFFSET : CKSEG0)
+#else
+#define __pa_page_offset(x) PAGE_OFFSET
+#endif
+#define __pa(x) ((unsigned long)(x) - __pa_page_offset(x))
+#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/7] setup.c: get ride of CPHYSADDR()
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
2006-10-19 11:19 ` [PATCH 1/7] page.h: remove __pa() usages Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 2/7] Make __pa() aware of XKPHYS/CKSEG0 address mix for 64 bit kernels Franck Bui-Huu
@ 2006-10-19 11:20 ` Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 4/7] Introduce __pa_symbol() Franck Bui-Huu
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:20 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
and use new __pa() implementation instead introduced by the previous
patch. Indeed this macro can be used now even by the 64 bit kernels
with CONFIG_BUILD_ELF64=n config.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
arch/mips/kernel/setup.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8f6e896..715451a 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -204,12 +204,12 @@ static void __init finalize_initrd(void)
printk(KERN_INFO "Initrd not found or empty");
goto disable;
}
- if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) {
+ if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) {
printk("Initrd extends beyond end of memory");
goto disable;
}
- reserve_bootmem(CPHYSADDR(initrd_start), size);
+ reserve_bootmem(__pa(initrd_start), size);
initrd_below_start_ok = 1;
printk(KERN_INFO "Initial ramdisk at: 0x%lx (%lu bytes)\n",
@@ -260,7 +260,7 @@ static void __init bootmem_init(void)
* of usable memory.
*/
reserved_end = init_initrd();
- reserved_end = PFN_UP(CPHYSADDR(max(reserved_end, (unsigned long)&_end)));
+ reserved_end = PFN_UP(__pa(max(reserved_end, (unsigned long)&_end)));
/*
* Find the highest page frame number we have available.
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/7] Introduce __pa_symbol()
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
` (2 preceding siblings ...)
2006-10-19 11:20 ` [PATCH 3/7] setup.c: get ride of CPHYSADDR() Franck Bui-Huu
@ 2006-10-19 11:20 ` Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 5/7] setup.c: use __pa_symbol() where needed Franck Bui-Huu
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:20 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
This patch introduces __pa_symbol() macro which should be used to
calculate the physical address of kernel symbols. It also relies
on RELOC_HIDE() to avoid any compiler's oddities when doing
arithmetics on symbols.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
include/asm-mips/page.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index 119daee..5c4284b 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -139,6 +139,7 @@ #else
#define __pa_page_offset(x) PAGE_OFFSET
#endif
#define __pa(x) ((unsigned long)(x) - __pa_page_offset(x))
+#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))
#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/7] setup.c: use __pa_symbol() where needed
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
` (3 preceding siblings ...)
2006-10-19 11:20 ` [PATCH 4/7] Introduce __pa_symbol() Franck Bui-Huu
@ 2006-10-19 11:20 ` Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 6/7] setup.c: clean up initrd related code Franck Bui-Huu
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:20 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
It should fix the broken code in resource_init() too.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
arch/mips/kernel/setup.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 715451a..b52cc97 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -260,7 +260,7 @@ static void __init bootmem_init(void)
* of usable memory.
*/
reserved_end = init_initrd();
- reserved_end = PFN_UP(__pa(max(reserved_end, (unsigned long)&_end)));
+ reserved_end = PFN_UP(max(__pa(reserved_end), __pa_symbol(&_end)));
/*
* Find the highest page frame number we have available.
@@ -432,10 +432,10 @@ static void __init resource_init(void)
if (UNCAC_BASE != IO_BASE)
return;
- code_resource.start = virt_to_phys(&_text);
- code_resource.end = virt_to_phys(&_etext) - 1;
- data_resource.start = virt_to_phys(&_etext);
- data_resource.end = virt_to_phys(&_edata) - 1;
+ code_resource.start = __pa_symbol(&_text);
+ code_resource.end = __pa_symbol(&_etext) - 1;
+ data_resource.start = __pa_symbol(&_etext);
+ data_resource.end = __pa_symbol(&_edata) - 1;
/*
* Request address space for all standard RAM.
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/7] setup.c: clean up initrd related code
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
` (4 preceding siblings ...)
2006-10-19 11:20 ` [PATCH 5/7] setup.c: use __pa_symbol() where needed Franck Bui-Huu
@ 2006-10-19 11:20 ` Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 7/7] Make free_init_pages() arguments to be physical addresses Franck Bui-Huu
2006-10-20 3:19 ` [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Atsushi Nemoto
7 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:20 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
arch/mips/kernel/setup.c | 75 +++++++++++++++++++++++++++++-----------------
arch/mips/mm/init.c | 5 ---
2 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index b52cc97..89440a0 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -145,13 +145,12 @@ static int __init rd_start_early(char *p
unsigned long start = memparse(p, &p);
#ifdef CONFIG_64BIT
- /* HACK: Guess if the sign extension was forgotten */
- if (start > 0x0000000080000000 && start < 0x00000000ffffffff)
- start |= 0xffffffff00000000UL;
+ /* Guess if the sign extension was forgotten by bootloader */
+ if (start < XKPHYS)
+ start = (int)start;
#endif
initrd_start = start;
initrd_end += start;
-
return 0;
}
early_param("rd_start", rd_start_early);
@@ -159,41 +158,64 @@ early_param("rd_start", rd_start_early);
static int __init rd_size_early(char *p)
{
initrd_end += memparse(p, &p);
-
return 0;
}
early_param("rd_size", rd_size_early);
+/* it returns the next free pfn after initrd */
static unsigned long __init init_initrd(void)
{
- unsigned long tmp, end, size;
+ unsigned long end;
u32 *initrd_header;
- ROOT_DEV = Root_RAM0;
-
/*
* Board specific code or command line parser should have
* already set up initrd_start and initrd_end. In these cases
* perfom sanity checks and use them if all looks good.
*/
- size = initrd_end - initrd_start;
- if (initrd_end == 0 || size == 0) {
- initrd_start = 0;
- initrd_end = 0;
- } else
- return initrd_end;
-
- end = (unsigned long)&_end;
- tmp = PAGE_ALIGN(end) - sizeof(u32) * 2;
- if (tmp < end)
- tmp += PAGE_SIZE;
-
- initrd_header = (u32 *)tmp;
- if (initrd_header[0] == 0x494E5244) {
- initrd_start = (unsigned long)&initrd_header[2];
- initrd_end = initrd_start + initrd_header[1];
+ if (initrd_start && initrd_end > initrd_start)
+ goto sanitize;
+
+ /*
+ * See if initrd has been added to the kernel image by
+ * arch/mips/boot/addinitrd.c. In that case a header is
+ * prepended to initrd and is made up by 8 bytes. The fisrt
+ * word is a magic number and the second one is the size of
+ * initrd. Initrd start must be page aligned in any cases.
+ */
+ initrd_header = __va(PAGE_ALIGN(__pa_symbol(&_end) + 8)) - 8;
+ if (initrd_header[0] != 0x494E5244)
+ goto disable;
+ initrd_start = (unsigned long)(initrd_header + 2);
+ initrd_end = initrd_start + initrd_header[1];
+
+sanitize:
+ if (initrd_start & ~PAGE_MASK) {
+ printk(KERN_ERR "initrd start must be page aligned\n");
+ goto disable;
}
- return initrd_end;
+ if (initrd_start < PAGE_OFFSET) {
+ printk(KERN_ERR "initrd start < PAGE_OFFSET\n");
+ goto disable;
+ }
+
+ /*
+ * Sanitize initrd addresses. For example firmware
+ * can't guess if they need to pass them through
+ * 64-bits values if the kernel has been built in pure
+ * 32-bit. We need also to switch from KSEG0 to XKPHYS
+ * addresses now, so the code can now safely use __pa().
+ */
+ end = __pa(initrd_end);
+ initrd_end = (unsigned long)__va(end);
+ initrd_start = (unsigned long)__va(__pa(initrd_start));
+
+ ROOT_DEV = Root_RAM0;
+ return PFN_UP(end);
+disable:
+ initrd_start = 0;
+ initrd_end = 0;
+ return 0;
}
static void __init finalize_initrd(void)
@@ -259,8 +281,7 @@ static void __init bootmem_init(void)
* not selected. Once that done we can determine the low bound
* of usable memory.
*/
- reserved_end = init_initrd();
- reserved_end = PFN_UP(max(__pa(reserved_end), __pa_symbol(&_end)));
+ reserved_end = max(init_initrd(), PFN_UP(__pa_symbol(&_end)));
/*
* Find the highest page frame number we have available.
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 4431ea0..072b3b0 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -502,11 +502,6 @@ void free_init_pages(char *what, unsigne
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
-#ifdef CONFIG_64BIT
- /* Switch from KSEG0 to XKPHYS addresses */
- start = (unsigned long)phys_to_virt(CPHYSADDR(start));
- end = (unsigned long)phys_to_virt(CPHYSADDR(end));
-#endif
free_init_pages("initrd memory", start, end);
}
#endif
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 7/7] Make free_init_pages() arguments to be physical addresses
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
` (5 preceding siblings ...)
2006-10-19 11:20 ` [PATCH 6/7] setup.c: clean up initrd related code Franck Bui-Huu
@ 2006-10-19 11:20 ` Franck Bui-Huu
2006-10-20 3:19 ` [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Atsushi Nemoto
7 siblings, 0 replies; 11+ messages in thread
From: Franck Bui-Huu @ 2006-10-19 11:20 UTC (permalink / raw)
To: ralf; +Cc: anemo, ths, linux-mips, Franck Bui-Huu
It allows caller of this function to not care about CKSEG0/XKPHYS
address mixes. It's now automatically done by free_init_pages().
We can now safely remove hack needed by 64 bit kernels with
CONFIG_BUILD_ELF64=n in free_initmem().
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
arch/mips/mm/init.c | 33 +++++++++++++++++----------------
1 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 072b3b0..733bdec 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -485,15 +485,18 @@ #endif
}
#endif /* !CONFIG_NEED_MULTIPLE_NODES */
-void free_init_pages(char *what, unsigned long begin, unsigned long end)
+static void free_init_pages(char *what, unsigned long begin, unsigned long end)
{
- unsigned long addr;
+ unsigned long pfn;
- for (addr = begin; addr < end; addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page((void *)addr));
- init_page_count(virt_to_page((void *)addr));
- memset((void *)addr, 0xcc, PAGE_SIZE);
- free_page(addr);
+ for (pfn = PFN_UP(begin); pfn < PFN_DOWN(end); pfn++) {
+ struct page *page = pfn_to_page(pfn);
+ void *addr = phys_to_virt(PFN_PHYS(pfn));
+
+ ClearPageReserved(page);
+ init_page_count(page);
+ memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
+ __free_page(page);
totalram_pages++;
}
printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
@@ -502,7 +505,9 @@ void free_init_pages(char *what, unsigne
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- free_init_pages("initrd memory", start, end);
+ free_init_pages("initrd memory",
+ virt_to_phys((void *)start),
+ virt_to_phys((void *)end));
}
#endif
@@ -510,17 +515,13 @@ extern unsigned long prom_free_prom_memo
void free_initmem(void)
{
- unsigned long start, end, freed;
+ unsigned long freed;
freed = prom_free_prom_memory();
if (freed)
printk(KERN_INFO "Freeing firmware memory: %ldk freed\n",freed);
- start = (unsigned long)(&__init_begin);
- end = (unsigned long)(&__init_end);
-#ifdef CONFIG_64BIT
- start = PAGE_OFFSET | CPHYSADDR(start);
- end = PAGE_OFFSET | CPHYSADDR(end);
-#endif
- free_init_pages("unused kernel memory", start, end);
+ free_init_pages("unused kernel memory",
+ __pa_symbol(&__init_begin),
+ __pa_symbol(&__init_end));
}
--
1.4.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4]
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
` (6 preceding siblings ...)
2006-10-19 11:20 ` [PATCH 7/7] Make free_init_pages() arguments to be physical addresses Franck Bui-Huu
@ 2006-10-20 3:19 ` Atsushi Nemoto
7 siblings, 0 replies; 11+ messages in thread
From: Atsushi Nemoto @ 2006-10-20 3:19 UTC (permalink / raw)
To: vagabon.xyz; +Cc: ralf, ths, linux-mips
On Thu, 19 Oct 2006 13:19:58 +0200, Franck Bui-Huu <vagabon.xyz@gmail.com> wrote:
> Changes since take #3
> --------------------
> * Sign extension hack still needed by rd_start_early() (Atsushi)
> * Replace panic() by printk() in init_initrd() (Atsushi)
> * Fix CONFIG_64BITS typo (Atsushi)
> * Add a new sanity check in init_initrd():
> initrd_start < PAGE_OFFSET
Works fine for me. Thanks.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-10-20 3:19 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-19 11:19 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Franck Bui-Huu
2006-10-19 11:19 ` [PATCH 1/7] page.h: remove __pa() usages Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 2/7] Make __pa() aware of XKPHYS/CKSEG0 address mix for 64 bit kernels Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 3/7] setup.c: get ride of CPHYSADDR() Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 4/7] Introduce __pa_symbol() Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 5/7] setup.c: use __pa_symbol() where needed Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 6/7] setup.c: clean up initrd related code Franck Bui-Huu
2006-10-19 11:20 ` [PATCH 7/7] Make free_init_pages() arguments to be physical addresses Franck Bui-Huu
2006-10-20 3:19 ` [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #4] Atsushi Nemoto
-- strict thread matches above, loose matches on Subject: below --
2006-10-16 16:12 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #3] Franck Bui-Huu
2006-10-16 16:12 ` [PATCH 5/7] setup.c: use __pa_symbol() where needed Franck Bui-Huu
2006-10-13 12:38 [PATCH 0/7] Get ride of CPHYSADDR() in setup.c [take #2] Franck Bui-Huu
2006-10-13 12:39 ` [PATCH 5/7] setup.c: use __pa_symbol() where needed Franck Bui-Huu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox