diff options
Diffstat (limited to 'arch/x86/mm/ioremap.c')
-rw-r--r-- | arch/x86/mm/ioremap.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 433f7bd4648a..0dfa09d69e80 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
@@ -22,13 +22,17 @@ | |||
22 | #include <asm/pgalloc.h> | 22 | #include <asm/pgalloc.h> |
23 | #include <asm/pat.h> | 23 | #include <asm/pat.h> |
24 | 24 | ||
25 | #ifdef CONFIG_X86_64 | 25 | static inline int phys_addr_valid(resource_size_t addr) |
26 | |||
27 | static inline int phys_addr_valid(unsigned long addr) | ||
28 | { | 26 | { |
29 | return addr < (1UL << boot_cpu_data.x86_phys_bits); | 27 | #ifdef CONFIG_PHYS_ADDR_T_64BIT |
28 | return !(addr >> boot_cpu_data.x86_phys_bits); | ||
29 | #else | ||
30 | return 1; | ||
31 | #endif | ||
30 | } | 32 | } |
31 | 33 | ||
34 | #ifdef CONFIG_X86_64 | ||
35 | |||
32 | unsigned long __phys_addr(unsigned long x) | 36 | unsigned long __phys_addr(unsigned long x) |
33 | { | 37 | { |
34 | if (x >= __START_KERNEL_map) { | 38 | if (x >= __START_KERNEL_map) { |
@@ -38,8 +42,7 @@ unsigned long __phys_addr(unsigned long x) | |||
38 | } else { | 42 | } else { |
39 | VIRTUAL_BUG_ON(x < PAGE_OFFSET); | 43 | VIRTUAL_BUG_ON(x < PAGE_OFFSET); |
40 | x -= PAGE_OFFSET; | 44 | x -= PAGE_OFFSET; |
41 | VIRTUAL_BUG_ON(system_state == SYSTEM_BOOTING ? x > MAXMEM : | 45 | VIRTUAL_BUG_ON(!phys_addr_valid(x)); |
42 | !phys_addr_valid(x)); | ||
43 | } | 46 | } |
44 | return x; | 47 | return x; |
45 | } | 48 | } |
@@ -56,10 +59,8 @@ bool __virt_addr_valid(unsigned long x) | |||
56 | if (x < PAGE_OFFSET) | 59 | if (x < PAGE_OFFSET) |
57 | return false; | 60 | return false; |
58 | x -= PAGE_OFFSET; | 61 | x -= PAGE_OFFSET; |
59 | if (system_state == SYSTEM_BOOTING ? | 62 | if (!phys_addr_valid(x)) |
60 | x > MAXMEM : !phys_addr_valid(x)) { | ||
61 | return false; | 63 | return false; |
62 | } | ||
63 | } | 64 | } |
64 | 65 | ||
65 | return pfn_valid(x >> PAGE_SHIFT); | 66 | return pfn_valid(x >> PAGE_SHIFT); |
@@ -68,18 +69,12 @@ EXPORT_SYMBOL(__virt_addr_valid); | |||
68 | 69 | ||
69 | #else | 70 | #else |
70 | 71 | ||
71 | static inline int phys_addr_valid(unsigned long addr) | ||
72 | { | ||
73 | return 1; | ||
74 | } | ||
75 | |||
76 | #ifdef CONFIG_DEBUG_VIRTUAL | 72 | #ifdef CONFIG_DEBUG_VIRTUAL |
77 | unsigned long __phys_addr(unsigned long x) | 73 | unsigned long __phys_addr(unsigned long x) |
78 | { | 74 | { |
79 | /* VMALLOC_* aren't constants; not available at the boot time */ | 75 | /* VMALLOC_* aren't constants */ |
80 | VIRTUAL_BUG_ON(x < PAGE_OFFSET); | 76 | VIRTUAL_BUG_ON(x < PAGE_OFFSET); |
81 | VIRTUAL_BUG_ON(system_state != SYSTEM_BOOTING && | 77 | VIRTUAL_BUG_ON(__vmalloc_start_set && is_vmalloc_addr((void *) x)); |
82 | is_vmalloc_addr((void *) x)); | ||
83 | return x - PAGE_OFFSET; | 78 | return x - PAGE_OFFSET; |
84 | } | 79 | } |
85 | EXPORT_SYMBOL(__phys_addr); | 80 | EXPORT_SYMBOL(__phys_addr); |
@@ -89,7 +84,9 @@ bool __virt_addr_valid(unsigned long x) | |||
89 | { | 84 | { |
90 | if (x < PAGE_OFFSET) | 85 | if (x < PAGE_OFFSET) |
91 | return false; | 86 | return false; |
92 | if (system_state != SYSTEM_BOOTING && is_vmalloc_addr((void *) x)) | 87 | if (__vmalloc_start_set && is_vmalloc_addr((void *) x)) |
88 | return false; | ||
89 | if (x >= FIXADDR_START) | ||
93 | return false; | 90 | return false; |
94 | return pfn_valid((x - PAGE_OFFSET) >> PAGE_SHIFT); | 91 | return pfn_valid((x - PAGE_OFFSET) >> PAGE_SHIFT); |
95 | } | 92 | } |
@@ -508,13 +505,19 @@ static inline pte_t * __init early_ioremap_pte(unsigned long addr) | |||
508 | return &bm_pte[pte_index(addr)]; | 505 | return &bm_pte[pte_index(addr)]; |
509 | } | 506 | } |
510 | 507 | ||
508 | static unsigned long slot_virt[FIX_BTMAPS_SLOTS] __initdata; | ||
509 | |||
511 | void __init early_ioremap_init(void) | 510 | void __init early_ioremap_init(void) |
512 | { | 511 | { |
513 | pmd_t *pmd; | 512 | pmd_t *pmd; |
513 | int i; | ||
514 | 514 | ||
515 | if (early_ioremap_debug) | 515 | if (early_ioremap_debug) |
516 | printk(KERN_INFO "early_ioremap_init()\n"); | 516 | printk(KERN_INFO "early_ioremap_init()\n"); |
517 | 517 | ||
518 | for (i = 0; i < FIX_BTMAPS_SLOTS; i++) | ||
519 | slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i); | ||
520 | |||
518 | pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN)); | 521 | pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN)); |
519 | memset(bm_pte, 0, sizeof(bm_pte)); | 522 | memset(bm_pte, 0, sizeof(bm_pte)); |
520 | pmd_populate_kernel(&init_mm, pmd, bm_pte); | 523 | pmd_populate_kernel(&init_mm, pmd, bm_pte); |
@@ -581,6 +584,7 @@ static inline void __init early_clear_fixmap(enum fixed_addresses idx) | |||
581 | 584 | ||
582 | static void __iomem *prev_map[FIX_BTMAPS_SLOTS] __initdata; | 585 | static void __iomem *prev_map[FIX_BTMAPS_SLOTS] __initdata; |
583 | static unsigned long prev_size[FIX_BTMAPS_SLOTS] __initdata; | 586 | static unsigned long prev_size[FIX_BTMAPS_SLOTS] __initdata; |
587 | |||
584 | static int __init check_early_ioremap_leak(void) | 588 | static int __init check_early_ioremap_leak(void) |
585 | { | 589 | { |
586 | int count = 0; | 590 | int count = 0; |
@@ -602,7 +606,8 @@ static int __init check_early_ioremap_leak(void) | |||
602 | } | 606 | } |
603 | late_initcall(check_early_ioremap_leak); | 607 | late_initcall(check_early_ioremap_leak); |
604 | 608 | ||
605 | static void __init __iomem *__early_ioremap(unsigned long phys_addr, unsigned long size, pgprot_t prot) | 609 | static void __init __iomem * |
610 | __early_ioremap(unsigned long phys_addr, unsigned long size, pgprot_t prot) | ||
606 | { | 611 | { |
607 | unsigned long offset, last_addr; | 612 | unsigned long offset, last_addr; |
608 | unsigned int nrpages; | 613 | unsigned int nrpages; |
@@ -668,9 +673,9 @@ static void __init __iomem *__early_ioremap(unsigned long phys_addr, unsigned lo | |||
668 | --nrpages; | 673 | --nrpages; |
669 | } | 674 | } |
670 | if (early_ioremap_debug) | 675 | if (early_ioremap_debug) |
671 | printk(KERN_CONT "%08lx + %08lx\n", offset, fix_to_virt(idx0)); | 676 | printk(KERN_CONT "%08lx + %08lx\n", offset, slot_virt[slot]); |
672 | 677 | ||
673 | prev_map[slot] = (void __iomem *)(offset + fix_to_virt(idx0)); | 678 | prev_map[slot] = (void __iomem *)(offset + slot_virt[slot]); |
674 | return prev_map[slot]; | 679 | return prev_map[slot]; |
675 | } | 680 | } |
676 | 681 | ||
@@ -738,8 +743,3 @@ void __init early_iounmap(void __iomem *addr, unsigned long size) | |||
738 | } | 743 | } |
739 | prev_map[slot] = NULL; | 744 | prev_map[slot] = NULL; |
740 | } | 745 | } |
741 | |||
742 | void __this_fixmap_does_not_exist(void) | ||
743 | { | ||
744 | WARN_ON(1); | ||
745 | } | ||