* [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
@ 2008-10-04 6:23 Yinghai Lu
2008-10-04 8:46 ` Ingo Molnar
2008-10-04 9:35 ` huang ying
0 siblings, 2 replies; 10+ messages in thread
From: Yinghai Lu @ 2008-10-04 6:23 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
Huang Ying
Cc: linux-kernel, Yinghai Lu
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
---
arch/x86/kernel/efi.c | 5 +----
arch/x86/kernel/efi_64.c | 27 ++-------------------------
include/asm-x86/efi.h | 8 ++------
include/asm-x86/fixmap_64.h | 3 ---
4 files changed, 5 insertions(+), 38 deletions(-)
Index: linux-2.6/arch/x86/kernel/efi.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/efi.c
+++ linux-2.6/arch/x86/kernel/efi.c
@@ -475,10 +475,7 @@ void __init efi_enter_virtual_mode(void)
size = md->num_pages << EFI_PAGE_SHIFT;
end = md->phys_addr + size;
- if (PFN_UP(end) <= max_low_pfn_mapped)
- va = __va(md->phys_addr);
- else
- va = efi_ioremap(md->phys_addr, size);
+ va = efi_ioremap(md->phys_addr, size);
md->virt_addr = (u64) (unsigned long) va;
Index: linux-2.6/arch/x86/kernel/efi_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/efi_64.c
+++ linux-2.6/arch/x86/kernel/efi_64.c
@@ -46,8 +46,8 @@ static void __init early_mapping_set_exe
{
unsigned long num_pages;
- start &= PMD_MASK;
- end = (end + PMD_SIZE - 1) & PMD_MASK;
+ start &= PAGE_MASK;
+ end = (end + PAGE_SIZE - 1) & PAGE_MASK;
num_pages = (end - start) >> PAGE_SHIFT;
if (executable)
set_memory_x((unsigned long)__va(start), num_pages);
@@ -97,26 +97,3 @@ void __init efi_call_phys_epilog(void)
early_runtime_code_mapping_set_exec(0);
}
-void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size)
-{
- static unsigned pages_mapped __initdata;
- unsigned i, pages;
- unsigned long offset;
-
- pages = PFN_UP(phys_addr + size) - PFN_DOWN(phys_addr);
- offset = phys_addr & ~PAGE_MASK;
- phys_addr &= PAGE_MASK;
-
- if (pages_mapped + pages > MAX_EFI_IO_PAGES)
- return NULL;
-
- for (i = 0; i < pages; i++) {
- __set_fixmap(FIX_EFI_IO_MAP_FIRST_PAGE - pages_mapped,
- phys_addr, PAGE_KERNEL);
- phys_addr += PAGE_SIZE;
- pages_mapped++;
- }
-
- return (void __iomem *)__fix_to_virt(FIX_EFI_IO_MAP_FIRST_PAGE - \
- (pages_mapped - pages)) + offset;
-}
Index: linux-2.6/include/asm-x86/efi.h
===================================================================
--- linux-2.6.orig/include/asm-x86/efi.h
+++ linux-2.6/include/asm-x86/efi.h
@@ -33,12 +33,8 @@ extern unsigned long asmlinkage efi_call
#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
efi_call_virt(f, a1, a2, a3, a4, a5, a6)
-#define efi_ioremap(addr, size) ioremap_cache(addr, size)
-
#else /* !CONFIG_X86_32 */
-#define MAX_EFI_IO_PAGES 100
-
extern u64 efi_call0(void *fp);
extern u64 efi_call1(void *fp, u64 arg1);
extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
@@ -86,10 +82,10 @@ extern u64 efi_call6(void *fp, u64 arg1,
efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
(u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
-extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size);
-
#endif /* CONFIG_X86_32 */
+#define efi_ioremap(addr, size) ioremap_cache(addr, size)
+
extern void efi_reserve_early(void);
extern void efi_call_phys_prelog(void);
extern void efi_call_phys_epilog(void);
Index: linux-2.6/include/asm-x86/fixmap_64.h
===================================================================
--- linux-2.6.orig/include/asm-x86/fixmap_64.h
+++ linux-2.6/include/asm-x86/fixmap_64.h
@@ -43,9 +43,6 @@ enum fixed_addresses {
FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
FIX_IO_APIC_BASE_0,
FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1,
- FIX_EFI_IO_MAP_LAST_PAGE,
- FIX_EFI_IO_MAP_FIRST_PAGE = FIX_EFI_IO_MAP_LAST_PAGE
- + MAX_EFI_IO_PAGES - 1,
#ifdef CONFIG_PARAVIRT
FIX_PARAVIRT_BOOTMAP,
#endif
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-04 6:23 [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap Yinghai Lu
@ 2008-10-04 8:46 ` Ingo Molnar
2008-10-04 9:35 ` huang ying
1 sibling, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2008-10-04 8:46 UTC (permalink / raw)
To: Yinghai Lu
Cc: Thomas Gleixner, H. Peter Anvin, Andrew Morton, Huang Ying,
linux-kernel, Arjan van de Ven
* Yinghai Lu <yhlu.kernel@gmail.com> wrote:
> Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
>
> ---
> arch/x86/kernel/efi.c | 5 +----
> arch/x86/kernel/efi_64.c | 27 ++-------------------------
> include/asm-x86/efi.h | 8 ++------
> include/asm-x86/fixmap_64.h | 3 ---
> 4 files changed, 5 insertions(+), 38 deletions(-)
ok, that looks like a very nice cleanup and should make the EFI mapping
code more generic and more robust as well.
Huang, any chance you could test this against latest tip/master on a
real EFI system?
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-04 6:23 [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap Yinghai Lu
2008-10-04 8:46 ` Ingo Molnar
@ 2008-10-04 9:35 ` huang ying
2008-10-04 17:44 ` Yinghai Lu
1 sibling, 1 reply; 10+ messages in thread
From: huang ying @ 2008-10-04 9:35 UTC (permalink / raw)
To: Yinghai Lu
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
Huang Ying, linux-kernel
Hi, Yinghai,
On Sat, Oct 4, 2008 at 2:23 PM, Yinghai Lu <yhlu.kernel@gmail.com> wrote:
[...]
> --- linux-2.6.orig/arch/x86/kernel/efi.c
> +++ linux-2.6/arch/x86/kernel/efi.c
> @@ -475,10 +475,7 @@ void __init efi_enter_virtual_mode(void)
> size = md->num_pages << EFI_PAGE_SHIFT;
> end = md->phys_addr + size;
>
> - if (PFN_UP(end) <= max_low_pfn_mapped)
> - va = __va(md->phys_addr);
> - else
> - va = efi_ioremap(md->phys_addr, size);
> + va = efi_ioremap(md->phys_addr, size);
Using __va and efi_ioremap() here is to make EFI support compatible
with kexec. Because EFI provide only efi_enter_virtual_mode(), no
efi_leave_virtual_mode(), we should make EFI runtime memory area
mapped to same virtual memory area in original kernel and kexeced
kernel, so that the EFI runtime services can be used in kexeced
kernel.
[...]
> --- linux-2.6.orig/arch/x86/kernel/efi_64.c
> +++ linux-2.6/arch/x86/kernel/efi_64.c
> @@ -46,8 +46,8 @@ static void __init early_mapping_set_exe
> {
> unsigned long num_pages;
>
> - start &= PMD_MASK;
> - end = (end + PMD_SIZE - 1) & PMD_MASK;
> + start &= PAGE_MASK;
> + end = (end + PAGE_SIZE - 1) & PAGE_MASK;
> num_pages = (end - start) >> PAGE_SHIFT;
> if (executable)
> set_memory_x((unsigned long)__va(start), num_pages);
early_mapping_set_exe() may be called before page allocator is
available. Using PAGE_MASK may make set_memory_x() allocate new page,
while using PMD_MASK will not.
Best Regards,
Huang Ying
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-04 9:35 ` huang ying
@ 2008-10-04 17:44 ` Yinghai Lu
2008-10-05 8:56 ` huang ying
0 siblings, 1 reply; 10+ messages in thread
From: Yinghai Lu @ 2008-10-04 17:44 UTC (permalink / raw)
To: huang ying
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
Huang Ying, linux-kernel
On Sat, Oct 4, 2008 at 2:35 AM, huang ying <huang.ying.caritas@gmail.com> wrote:
> Hi, Yinghai,
>
> On Sat, Oct 4, 2008 at 2:23 PM, Yinghai Lu <yhlu.kernel@gmail.com> wrote:
> [...]
>> --- linux-2.6.orig/arch/x86/kernel/efi.c
>> +++ linux-2.6/arch/x86/kernel/efi.c
>> @@ -475,10 +475,7 @@ void __init efi_enter_virtual_mode(void)
>> size = md->num_pages << EFI_PAGE_SHIFT;
>> end = md->phys_addr + size;
>>
>> - if (PFN_UP(end) <= max_low_pfn_mapped)
>> - va = __va(md->phys_addr);
>> - else
>> - va = efi_ioremap(md->phys_addr, size);
>> + va = efi_ioremap(md->phys_addr, size);
>
> Using __va and efi_ioremap() here is to make EFI support compatible
> with kexec. Because EFI provide only efi_enter_virtual_mode(), no
> efi_leave_virtual_mode(), we should make EFI runtime memory area
> mapped to same virtual memory area in original kernel and kexeced
> kernel, so that the EFI runtime services can be used in kexeced
> kernel.
so need to make efi range all under direct-mapping like E820-RAM?
if so we need to update
e820_end_of_low_ram_pfn to return correct max_low_pfn, and then
max_low_pfn_mapped...
YH
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-04 17:44 ` Yinghai Lu
@ 2008-10-05 8:56 ` huang ying
2008-10-05 10:04 ` Ingo Molnar
2008-10-05 18:04 ` Yinghai Lu
0 siblings, 2 replies; 10+ messages in thread
From: huang ying @ 2008-10-05 8:56 UTC (permalink / raw)
To: Yinghai Lu
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
Huang Ying, linux-kernel
On Sun, Oct 5, 2008 at 1:44 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Sat, Oct 4, 2008 at 2:35 AM, huang ying <huang.ying.caritas@gmail.com> wrote:
[...]
>> Using __va and efi_ioremap() here is to make EFI support compatible
>> with kexec. Because EFI provide only efi_enter_virtual_mode(), no
>> efi_leave_virtual_mode(), we should make EFI runtime memory area
>> mapped to same virtual memory area in original kernel and kexeced
>> kernel, so that the EFI runtime services can be used in kexeced
>> kernel.
>
> so need to make efi range all under direct-mapping like E820-RAM?
Some EFI runtime range is just some RAM area used by EFI runtime
services, they can be direct-mapped. Some EFI runtime range may be IO
MEM range used by EFI runtime services, it is possible that these IO
MEM range can not be direct-mapped. So I implement efi_ioremap() to
deal with them.
Best Regards,
Huang Ying
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-05 8:56 ` huang ying
@ 2008-10-05 10:04 ` Ingo Molnar
2008-10-06 1:47 ` Huang Ying
2008-10-05 18:04 ` Yinghai Lu
1 sibling, 1 reply; 10+ messages in thread
From: Ingo Molnar @ 2008-10-05 10:04 UTC (permalink / raw)
To: huang ying
Cc: Yinghai Lu, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
Huang Ying, linux-kernel
* huang ying <huang.ying.caritas@gmail.com> wrote:
> On Sun, Oct 5, 2008 at 1:44 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> > On Sat, Oct 4, 2008 at 2:35 AM, huang ying <huang.ying.caritas@gmail.com> wrote:
> [...]
> >> Using __va and efi_ioremap() here is to make EFI support compatible
> >> with kexec. Because EFI provide only efi_enter_virtual_mode(), no
> >> efi_leave_virtual_mode(), we should make EFI runtime memory area
> >> mapped to same virtual memory area in original kernel and kexeced
> >> kernel, so that the EFI runtime services can be used in kexeced
> >> kernel.
> >
> > so need to make efi range all under direct-mapping like E820-RAM?
>
> Some EFI runtime range is just some RAM area used by EFI runtime
> services, they can be direct-mapped. Some EFI runtime range may be IO
> MEM range used by EFI runtime services, it is possible that these IO
> MEM range can not be direct-mapped. So I implement efi_ioremap() to
> deal with them.
hm, but in the "some RAM area" case, that area should not be listed in
the e820 map (or any EFI memory map), and hence it should never be
mapped directly. I.e. you should be able to just standardize on
ioremap() and have no parallel facility for this.
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-05 8:56 ` huang ying
2008-10-05 10:04 ` Ingo Molnar
@ 2008-10-05 18:04 ` Yinghai Lu
2008-10-06 1:50 ` Huang Ying
1 sibling, 1 reply; 10+ messages in thread
From: Yinghai Lu @ 2008-10-05 18:04 UTC (permalink / raw)
To: huang ying
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
Huang Ying, linux-kernel
On Sun, Oct 5, 2008 at 1:56 AM, huang ying <huang.ying.caritas@gmail.com> wrote:
> On Sun, Oct 5, 2008 at 1:44 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>> On Sat, Oct 4, 2008 at 2:35 AM, huang ying <huang.ying.caritas@gmail.com> wrote:
> [...]
>>> Using __va and efi_ioremap() here is to make EFI support compatible
>>> with kexec. Because EFI provide only efi_enter_virtual_mode(), no
>>> efi_leave_virtual_mode(), we should make EFI runtime memory area
>>> mapped to same virtual memory area in original kernel and kexeced
>>> kernel, so that the EFI runtime services can be used in kexeced
>>> kernel.
>>
>> so need to make efi range all under direct-mapping like E820-RAM?
>
> Some EFI runtime range is just some RAM area used by EFI runtime
> services, they can be direct-mapped. Some EFI runtime range may be IO
> MEM range used by EFI runtime services, it is possible that these IO
> MEM range can not be direct-mapped. So I implement efi_ioremap() to
> deal with them.
>
i'm confused.
so
--- linux-2.6.orig/arch/x86/kernel/efi.c
+++ linux-2.6/arch/x86/kernel/efi.c
@@ -475,10 +475,7 @@ void __init efi_enter_virtual_mode(void)
size = md->num_pages << EFI_PAGE_SHIFT;
end = md->phys_addr + size;
- if (PFN_UP(end) <= max_low_pfn_mapped)
- va = __va(md->phys_addr);
- else
- va = efi_ioremap(md->phys_addr, size);
+ va = efi_ioremap(md->phys_addr, size);
md->virt_addr = (u64) (unsigned long) va;
should be ok.
then how about use ioremap directly to replace fixed mapping in 64bit
with efi_ioremap?
YH
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-05 10:04 ` Ingo Molnar
@ 2008-10-06 1:47 ` Huang Ying
0 siblings, 0 replies; 10+ messages in thread
From: Huang Ying @ 2008-10-06 1:47 UTC (permalink / raw)
To: Ingo Molnar
Cc: huang ying, Yinghai Lu, Thomas Gleixner, H. Peter Anvin,
Andrew Morton, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]
On Sun, 2008-10-05 at 12:04 +0200, Ingo Molnar wrote:
> * huang ying <huang.ying.caritas@gmail.com> wrote:
[...]
> > Some EFI runtime range is just some RAM area used by EFI runtime
> > services, they can be direct-mapped. Some EFI runtime range may be IO
> > MEM range used by EFI runtime services, it is possible that these IO
> > MEM range can not be direct-mapped. So I implement efi_ioremap() to
> > deal with them.
>
> hm, but in the "some RAM area" case, that area should not be listed in
> the e820 map (or any EFI memory map), and hence it should never be
> mapped directly. I.e. you should be able to just standardize on
> ioremap() and have no parallel facility for this.
EFI runtime memory area will be E820_RESERVED in e820 map and
EFI_RUNTIME_SERVICES_CODE/DATA in EFI memory map. In general they will
be mapped directly.
ioremap() should not used here, because for kexec to work, EFI runtime
memory area should be mapped to same virtual address across reboot.
Best Regards,
Huang Ying
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
2008-10-05 18:04 ` Yinghai Lu
@ 2008-10-06 1:50 ` Huang Ying
0 siblings, 0 replies; 10+ messages in thread
From: Huang Ying @ 2008-10-06 1:50 UTC (permalink / raw)
To: Yinghai Lu
Cc: huang ying, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
Andrew Morton, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2009 bytes --]
On Sun, 2008-10-05 at 11:04 -0700, Yinghai Lu wrote:
> On Sun, Oct 5, 2008 at 1:56 AM, huang ying <huang.ying.caritas@gmail.com> wrote:
> > On Sun, Oct 5, 2008 at 1:44 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> >> On Sat, Oct 4, 2008 at 2:35 AM, huang ying <huang.ying.caritas@gmail.com> wrote:
> > [...]
> >>> Using __va and efi_ioremap() here is to make EFI support compatible
> >>> with kexec. Because EFI provide only efi_enter_virtual_mode(), no
> >>> efi_leave_virtual_mode(), we should make EFI runtime memory area
> >>> mapped to same virtual memory area in original kernel and kexeced
> >>> kernel, so that the EFI runtime services can be used in kexeced
> >>> kernel.
> >>
> >> so need to make efi range all under direct-mapping like E820-RAM?
> >
> > Some EFI runtime range is just some RAM area used by EFI runtime
> > services, they can be direct-mapped. Some EFI runtime range may be IO
> > MEM range used by EFI runtime services, it is possible that these IO
> > MEM range can not be direct-mapped. So I implement efi_ioremap() to
> > deal with them.
> >
>
> i'm confused.
>
> so
> --- linux-2.6.orig/arch/x86/kernel/efi.c
> +++ linux-2.6/arch/x86/kernel/efi.c
> @@ -475,10 +475,7 @@ void __init efi_enter_virtual_mode(void)
> size = md->num_pages << EFI_PAGE_SHIFT;
> end = md->phys_addr + size;
>
> - if (PFN_UP(end) <= max_low_pfn_mapped)
> - va = __va(md->phys_addr);
> - else
> - va = efi_ioremap(md->phys_addr, size);
> + va = efi_ioremap(md->phys_addr, size);
>
> md->virt_addr = (u64) (unsigned long) va;
> should be ok.
I think __va() and efi_ioremap() should be used.
> then how about use ioremap directly to replace fixed mapping in 64bit
> with efi_ioremap?
Because for kexec to work, EFI runtime memory area should be mapped to
same virtual address across reboot.
Best Regards,
Huang Ying
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap
@ 2008-12-11 20:41 Jonathan Barkelew
0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Barkelew @ 2008-12-11 20:41 UTC (permalink / raw)
To: linux-kernel
>> then how about use ioremap directly to replace fixed mapping in 64bit
>> with efi_ioremap?
>
> Because for kexec to work, EFI runtime memory area should be mapped to
> same virtual address across reboot.
Why would this require a separate function for 64-bit systems?
Wouldn't the 32-bit function have to take this into consideration as well?
Also, why is the fixed address space so limited? What about EFI runtime services
that are larger than 1MB?
Thanks,
Jonathan Barkelew
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-12-11 20:41 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-04 6:23 [RFC PATCH] x86: make 64bit efi to use ioremap_cache for efi_ioremap Yinghai Lu
2008-10-04 8:46 ` Ingo Molnar
2008-10-04 9:35 ` huang ying
2008-10-04 17:44 ` Yinghai Lu
2008-10-05 8:56 ` huang ying
2008-10-05 10:04 ` Ingo Molnar
2008-10-06 1:47 ` Huang Ying
2008-10-05 18:04 ` Yinghai Lu
2008-10-06 1:50 ` Huang Ying
-- strict thread matches above, loose matches on Subject: below --
2008-12-11 20:41 Jonathan Barkelew
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox