diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-12-13 18:02:31 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-12-13 18:02:31 -0500 |
| commit | 373da0a2a33018d560afcb2c77f8842985d79594 (patch) | |
| tree | 88f9ffb1357928e463514929a68781a79c1dca97 | |
| parent | 653f42f6b6348652c02737924abd6a5a6426e7ee (diff) | |
| parent | e1ad783b12ec8b69da83479c5d21a0d8180bc519 (diff) | |
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
Revert "x86, efi: Calling __pa() with an ioremap()ed address is invalid"
x86, efi: Make efi_call_phys_{prelog,epilog} CONFIG_RELOCATABLE-aware
| -rw-r--r-- | arch/x86/include/asm/e820.h | 8 | ||||
| -rw-r--r-- | arch/x86/include/asm/efi.h | 5 | ||||
| -rw-r--r-- | arch/x86/kernel/e820.c | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/setup.c | 21 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi.c | 29 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi_32.c | 48 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi_64.c | 17 |
7 files changed, 37 insertions, 94 deletions
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h index c9547033e38e..908b96957d88 100644 --- a/arch/x86/include/asm/e820.h +++ b/arch/x86/include/asm/e820.h | |||
| @@ -53,13 +53,6 @@ | |||
| 53 | */ | 53 | */ |
| 54 | #define E820_RESERVED_KERN 128 | 54 | #define E820_RESERVED_KERN 128 |
| 55 | 55 | ||
| 56 | /* | ||
| 57 | * Address ranges that need to be mapped by the kernel direct | ||
| 58 | * mapping. This is used to make sure regions such as | ||
| 59 | * EFI_RUNTIME_SERVICES_DATA are directly mapped. See setup_arch(). | ||
| 60 | */ | ||
| 61 | #define E820_RESERVED_EFI 129 | ||
| 62 | |||
| 63 | #ifndef __ASSEMBLY__ | 56 | #ifndef __ASSEMBLY__ |
| 64 | #include <linux/types.h> | 57 | #include <linux/types.h> |
| 65 | struct e820entry { | 58 | struct e820entry { |
| @@ -122,7 +115,6 @@ static inline void early_memtest(unsigned long start, unsigned long end) | |||
| 122 | } | 115 | } |
| 123 | #endif | 116 | #endif |
| 124 | 117 | ||
| 125 | extern unsigned long e820_end_pfn(unsigned long limit_pfn, unsigned type); | ||
| 126 | extern unsigned long e820_end_of_ram_pfn(void); | 118 | extern unsigned long e820_end_of_ram_pfn(void); |
| 127 | extern unsigned long e820_end_of_low_ram_pfn(void); | 119 | extern unsigned long e820_end_of_low_ram_pfn(void); |
| 128 | extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); | 120 | extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); |
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index b8d8bfcd44a9..7093e4a6a0bc 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h | |||
| @@ -33,6 +33,8 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...); | |||
| 33 | #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ | 33 | #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ |
| 34 | efi_call_virt(f, a1, a2, a3, a4, a5, a6) | 34 | efi_call_virt(f, a1, a2, a3, a4, a5, a6) |
| 35 | 35 | ||
| 36 | #define efi_ioremap(addr, size, type) ioremap_cache(addr, size) | ||
| 37 | |||
| 36 | #else /* !CONFIG_X86_32 */ | 38 | #else /* !CONFIG_X86_32 */ |
| 37 | 39 | ||
| 38 | extern u64 efi_call0(void *fp); | 40 | extern u64 efi_call0(void *fp); |
| @@ -82,6 +84,9 @@ extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3, | |||
| 82 | efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ | 84 | efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ |
| 83 | (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) | 85 | (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) |
| 84 | 86 | ||
| 87 | extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size, | ||
| 88 | u32 type); | ||
| 89 | |||
| 85 | #endif /* CONFIG_X86_32 */ | 90 | #endif /* CONFIG_X86_32 */ |
| 86 | 91 | ||
| 87 | extern int add_efi_memmap; | 92 | extern int add_efi_memmap; |
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 65ffd110a81b..303a0e48f076 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
| @@ -135,7 +135,6 @@ static void __init e820_print_type(u32 type) | |||
| 135 | printk(KERN_CONT "(usable)"); | 135 | printk(KERN_CONT "(usable)"); |
| 136 | break; | 136 | break; |
| 137 | case E820_RESERVED: | 137 | case E820_RESERVED: |
| 138 | case E820_RESERVED_EFI: | ||
| 139 | printk(KERN_CONT "(reserved)"); | 138 | printk(KERN_CONT "(reserved)"); |
| 140 | break; | 139 | break; |
| 141 | case E820_ACPI: | 140 | case E820_ACPI: |
| @@ -784,7 +783,7 @@ u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) | |||
| 784 | /* | 783 | /* |
| 785 | * Find the highest page frame number we have available | 784 | * Find the highest page frame number we have available |
| 786 | */ | 785 | */ |
| 787 | unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type) | 786 | static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type) |
| 788 | { | 787 | { |
| 789 | int i; | 788 | int i; |
| 790 | unsigned long last_pfn = 0; | 789 | unsigned long last_pfn = 0; |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 9a9e40fb091c..cf0ef986cb6d 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
| @@ -691,8 +691,6 @@ early_param("reservelow", parse_reservelow); | |||
| 691 | 691 | ||
| 692 | void __init setup_arch(char **cmdline_p) | 692 | void __init setup_arch(char **cmdline_p) |
| 693 | { | 693 | { |
| 694 | unsigned long end_pfn; | ||
| 695 | |||
| 696 | #ifdef CONFIG_X86_32 | 694 | #ifdef CONFIG_X86_32 |
| 697 | memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); | 695 | memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); |
| 698 | visws_early_detect(); | 696 | visws_early_detect(); |
| @@ -934,24 +932,7 @@ void __init setup_arch(char **cmdline_p) | |||
| 934 | init_gbpages(); | 932 | init_gbpages(); |
| 935 | 933 | ||
| 936 | /* max_pfn_mapped is updated here */ | 934 | /* max_pfn_mapped is updated here */ |
| 937 | end_pfn = max_low_pfn; | 935 | max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT); |
| 938 | |||
| 939 | #ifdef CONFIG_X86_64 | ||
| 940 | /* | ||
| 941 | * There may be regions after the last E820_RAM region that we | ||
| 942 | * want to include in the kernel direct mapping, such as | ||
| 943 | * EFI_RUNTIME_SERVICES_DATA. | ||
| 944 | */ | ||
| 945 | if (efi_enabled) { | ||
| 946 | unsigned long efi_end; | ||
| 947 | |||
| 948 | efi_end = e820_end_pfn(MAXMEM>>PAGE_SHIFT, E820_RESERVED_EFI); | ||
| 949 | if (efi_end > max_low_pfn) | ||
| 950 | end_pfn = efi_end; | ||
| 951 | } | ||
| 952 | #endif | ||
| 953 | |||
| 954 | max_low_pfn_mapped = init_memory_mapping(0, end_pfn << PAGE_SHIFT); | ||
| 955 | max_pfn_mapped = max_low_pfn_mapped; | 936 | max_pfn_mapped = max_low_pfn_mapped; |
| 956 | 937 | ||
| 957 | #ifdef CONFIG_X86_64 | 938 | #ifdef CONFIG_X86_64 |
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index c9718a16be15..37718f0f053d 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
| @@ -323,13 +323,10 @@ static void __init do_add_efi_memmap(void) | |||
| 323 | case EFI_UNUSABLE_MEMORY: | 323 | case EFI_UNUSABLE_MEMORY: |
| 324 | e820_type = E820_UNUSABLE; | 324 | e820_type = E820_UNUSABLE; |
| 325 | break; | 325 | break; |
| 326 | case EFI_RUNTIME_SERVICES_DATA: | ||
| 327 | e820_type = E820_RESERVED_EFI; | ||
| 328 | break; | ||
| 329 | default: | 326 | default: |
| 330 | /* | 327 | /* |
| 331 | * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE | 328 | * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE |
| 332 | * EFI_MEMORY_MAPPED_IO | 329 | * EFI_RUNTIME_SERVICES_DATA EFI_MEMORY_MAPPED_IO |
| 333 | * EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE | 330 | * EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE |
| 334 | */ | 331 | */ |
| 335 | e820_type = E820_RESERVED; | 332 | e820_type = E820_RESERVED; |
| @@ -674,21 +671,10 @@ void __init efi_enter_virtual_mode(void) | |||
| 674 | end_pfn = PFN_UP(end); | 671 | end_pfn = PFN_UP(end); |
| 675 | if (end_pfn <= max_low_pfn_mapped | 672 | if (end_pfn <= max_low_pfn_mapped |
| 676 | || (end_pfn > (1UL << (32 - PAGE_SHIFT)) | 673 | || (end_pfn > (1UL << (32 - PAGE_SHIFT)) |
| 677 | && end_pfn <= max_pfn_mapped)) { | 674 | && end_pfn <= max_pfn_mapped)) |
| 678 | va = __va(md->phys_addr); | 675 | va = __va(md->phys_addr); |
| 679 | 676 | else | |
| 680 | if (!(md->attribute & EFI_MEMORY_WB)) { | 677 | va = efi_ioremap(md->phys_addr, size, md->type); |
| 681 | addr = (u64) (unsigned long)va; | ||
| 682 | npages = md->num_pages; | ||
| 683 | memrange_efi_to_native(&addr, &npages); | ||
| 684 | set_memory_uc(addr, npages); | ||
| 685 | } | ||
| 686 | } else { | ||
| 687 | if (!(md->attribute & EFI_MEMORY_WB)) | ||
| 688 | va = ioremap_nocache(md->phys_addr, size); | ||
| 689 | else | ||
| 690 | va = ioremap_cache(md->phys_addr, size); | ||
| 691 | } | ||
| 692 | 678 | ||
| 693 | md->virt_addr = (u64) (unsigned long) va; | 679 | md->virt_addr = (u64) (unsigned long) va; |
| 694 | 680 | ||
| @@ -698,6 +684,13 @@ void __init efi_enter_virtual_mode(void) | |||
| 698 | continue; | 684 | continue; |
| 699 | } | 685 | } |
| 700 | 686 | ||
| 687 | if (!(md->attribute & EFI_MEMORY_WB)) { | ||
| 688 | addr = md->virt_addr; | ||
| 689 | npages = md->num_pages; | ||
| 690 | memrange_efi_to_native(&addr, &npages); | ||
| 691 | set_memory_uc(addr, npages); | ||
| 692 | } | ||
| 693 | |||
| 701 | systab = (u64) (unsigned long) efi_phys.systab; | 694 | systab = (u64) (unsigned long) efi_phys.systab; |
| 702 | if (md->phys_addr <= systab && systab < end) { | 695 | if (md->phys_addr <= systab && systab < end) { |
| 703 | systab += md->virt_addr - md->phys_addr; | 696 | systab += md->virt_addr - md->phys_addr; |
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c index e36bf714cb77..40e446941dd7 100644 --- a/arch/x86/platform/efi/efi_32.c +++ b/arch/x86/platform/efi/efi_32.c | |||
| @@ -39,43 +39,14 @@ | |||
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | static unsigned long efi_rt_eflags; | 41 | static unsigned long efi_rt_eflags; |
| 42 | static pgd_t efi_bak_pg_dir_pointer[2]; | ||
| 43 | 42 | ||
| 44 | void efi_call_phys_prelog(void) | 43 | void efi_call_phys_prelog(void) |
| 45 | { | 44 | { |
| 46 | unsigned long cr4; | ||
| 47 | unsigned long temp; | ||
| 48 | struct desc_ptr gdt_descr; | 45 | struct desc_ptr gdt_descr; |
| 49 | 46 | ||
| 50 | local_irq_save(efi_rt_eflags); | 47 | local_irq_save(efi_rt_eflags); |
| 51 | 48 | ||
| 52 | /* | 49 | load_cr3(initial_page_table); |
| 53 | * If I don't have PAE, I should just duplicate two entries in page | ||
| 54 | * directory. If I have PAE, I just need to duplicate one entry in | ||
| 55 | * page directory. | ||
| 56 | */ | ||
| 57 | cr4 = read_cr4_safe(); | ||
| 58 | |||
| 59 | if (cr4 & X86_CR4_PAE) { | ||
| 60 | efi_bak_pg_dir_pointer[0].pgd = | ||
| 61 | swapper_pg_dir[pgd_index(0)].pgd; | ||
| 62 | swapper_pg_dir[0].pgd = | ||
| 63 | swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd; | ||
| 64 | } else { | ||
| 65 | efi_bak_pg_dir_pointer[0].pgd = | ||
| 66 | swapper_pg_dir[pgd_index(0)].pgd; | ||
| 67 | efi_bak_pg_dir_pointer[1].pgd = | ||
| 68 | swapper_pg_dir[pgd_index(0x400000)].pgd; | ||
| 69 | swapper_pg_dir[pgd_index(0)].pgd = | ||
| 70 | swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd; | ||
| 71 | temp = PAGE_OFFSET + 0x400000; | ||
| 72 | swapper_pg_dir[pgd_index(0x400000)].pgd = | ||
| 73 | swapper_pg_dir[pgd_index(temp)].pgd; | ||
| 74 | } | ||
| 75 | |||
| 76 | /* | ||
| 77 | * After the lock is released, the original page table is restored. | ||
| 78 | */ | ||
| 79 | __flush_tlb_all(); | 50 | __flush_tlb_all(); |
| 80 | 51 | ||
| 81 | gdt_descr.address = __pa(get_cpu_gdt_table(0)); | 52 | gdt_descr.address = __pa(get_cpu_gdt_table(0)); |
| @@ -85,28 +56,13 @@ void efi_call_phys_prelog(void) | |||
| 85 | 56 | ||
| 86 | void efi_call_phys_epilog(void) | 57 | void efi_call_phys_epilog(void) |
| 87 | { | 58 | { |
| 88 | unsigned long cr4; | ||
| 89 | struct desc_ptr gdt_descr; | 59 | struct desc_ptr gdt_descr; |
| 90 | 60 | ||
| 91 | gdt_descr.address = (unsigned long)get_cpu_gdt_table(0); | 61 | gdt_descr.address = (unsigned long)get_cpu_gdt_table(0); |
| 92 | gdt_descr.size = GDT_SIZE - 1; | 62 | gdt_descr.size = GDT_SIZE - 1; |
| 93 | load_gdt(&gdt_descr); | 63 | load_gdt(&gdt_descr); |
| 94 | 64 | ||
| 95 | cr4 = read_cr4_safe(); | 65 | load_cr3(swapper_pg_dir); |
| 96 | |||
| 97 | if (cr4 & X86_CR4_PAE) { | ||
| 98 | swapper_pg_dir[pgd_index(0)].pgd = | ||
| 99 | efi_bak_pg_dir_pointer[0].pgd; | ||
| 100 | } else { | ||
| 101 | swapper_pg_dir[pgd_index(0)].pgd = | ||
| 102 | efi_bak_pg_dir_pointer[0].pgd; | ||
| 103 | swapper_pg_dir[pgd_index(0x400000)].pgd = | ||
| 104 | efi_bak_pg_dir_pointer[1].pgd; | ||
| 105 | } | ||
| 106 | |||
| 107 | /* | ||
| 108 | * After the lock is released, the original page table is restored. | ||
| 109 | */ | ||
| 110 | __flush_tlb_all(); | 66 | __flush_tlb_all(); |
| 111 | 67 | ||
| 112 | local_irq_restore(efi_rt_eflags); | 68 | local_irq_restore(efi_rt_eflags); |
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 312250c6b2de..ac3aa54e2654 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c | |||
| @@ -80,3 +80,20 @@ void __init efi_call_phys_epilog(void) | |||
| 80 | local_irq_restore(efi_flags); | 80 | local_irq_restore(efi_flags); |
| 81 | early_code_mapping_set_exec(0); | 81 | early_code_mapping_set_exec(0); |
| 82 | } | 82 | } |
| 83 | |||
| 84 | void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size, | ||
| 85 | u32 type) | ||
| 86 | { | ||
| 87 | unsigned long last_map_pfn; | ||
| 88 | |||
| 89 | if (type == EFI_MEMORY_MAPPED_IO) | ||
| 90 | return ioremap(phys_addr, size); | ||
| 91 | |||
| 92 | last_map_pfn = init_memory_mapping(phys_addr, phys_addr + size); | ||
| 93 | if ((last_map_pfn << PAGE_SHIFT) < phys_addr + size) { | ||
| 94 | unsigned long top = last_map_pfn << PAGE_SHIFT; | ||
| 95 | efi_ioremap(top, size - (top - phys_addr), type); | ||
| 96 | } | ||
| 97 | |||
| 98 | return (void __iomem *)__va(phys_addr); | ||
| 99 | } | ||
