aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2012-11-16 16:57:13 -0500
committerH. Peter Anvin <hpa@linux.intel.com>2012-11-16 19:42:09 -0500
commitfc8d782677f163dee76427fdd8a92bebd2b50b23 (patch)
treec3e228bd6a3c194cb28276bb834582a34a4ff371
parent05a476b6e3795f205806662bf09ab95774266292 (diff)
x86: Use __pa_symbol instead of __pa on C visible symbols
When I made an attempt at separating __pa_symbol and __pa I found that there were a number of cases where __pa was used on an obvious symbol. I also caught one non-obvious case as _brk_start and _brk_end are based on the address of __brk_base which is a C visible symbol. In mark_rodata_ro I was able to reduce the overhead of kernel symbol to virtual memory translation by using a combination of __va(__pa_symbol()) instead of page_address(virt_to_page()). Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Link: http://lkml.kernel.org/r/20121116215640.8521.80483.stgit@ahduyck-cp1.jf.intel.com Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/kernel/cpu/intel.c2
-rw-r--r--arch/x86/kernel/setup.c16
-rw-r--r--arch/x86/mm/init_64.c18
-rw-r--r--arch/x86/mm/pageattr.c8
-rw-r--r--arch/x86/platform/efi/efi.c4
-rw-r--r--arch/x86/realmode/init.c8
6 files changed, 27 insertions, 29 deletions
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 198e019a531a..2249e7e44521 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -168,7 +168,7 @@ int __cpuinit ppro_with_ram_bug(void)
168#ifdef CONFIG_X86_F00F_BUG 168#ifdef CONFIG_X86_F00F_BUG
169static void __cpuinit trap_init_f00f_bug(void) 169static void __cpuinit trap_init_f00f_bug(void)
170{ 170{
171 __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO); 171 __set_fixmap(FIX_F00F_IDT, __pa_symbol(idt_table), PAGE_KERNEL_RO);
172 172
173 /* 173 /*
174 * Update the IDT descriptor and reload the IDT so that 174 * Update the IDT descriptor and reload the IDT so that
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index ca45696f30fb..2702c5d4acd2 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -300,8 +300,8 @@ static void __init cleanup_highmap(void)
300static void __init reserve_brk(void) 300static void __init reserve_brk(void)
301{ 301{
302 if (_brk_end > _brk_start) 302 if (_brk_end > _brk_start)
303 memblock_reserve(__pa(_brk_start), 303 memblock_reserve(__pa_symbol(_brk_start),
304 __pa(_brk_end) - __pa(_brk_start)); 304 _brk_end - _brk_start);
305 305
306 /* Mark brk area as locked down and no longer taking any 306 /* Mark brk area as locked down and no longer taking any
307 new allocations */ 307 new allocations */
@@ -761,12 +761,12 @@ void __init setup_arch(char **cmdline_p)
761 init_mm.end_data = (unsigned long) _edata; 761 init_mm.end_data = (unsigned long) _edata;
762 init_mm.brk = _brk_end; 762 init_mm.brk = _brk_end;
763 763
764 code_resource.start = virt_to_phys(_text); 764 code_resource.start = __pa_symbol(_text);
765 code_resource.end = virt_to_phys(_etext)-1; 765 code_resource.end = __pa_symbol(_etext)-1;
766 data_resource.start = virt_to_phys(_etext); 766 data_resource.start = __pa_symbol(_etext);
767 data_resource.end = virt_to_phys(_edata)-1; 767 data_resource.end = __pa_symbol(_edata)-1;
768 bss_resource.start = virt_to_phys(&__bss_start); 768 bss_resource.start = __pa_symbol(__bss_start);
769 bss_resource.end = virt_to_phys(&__bss_stop)-1; 769 bss_resource.end = __pa_symbol(__bss_stop)-1;
770 770
771#ifdef CONFIG_CMDLINE_BOOL 771#ifdef CONFIG_CMDLINE_BOOL
772#ifdef CONFIG_CMDLINE_OVERRIDE 772#ifdef CONFIG_CMDLINE_OVERRIDE
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 3baff255adac..0374a10f4fb7 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -770,12 +770,10 @@ void set_kernel_text_ro(void)
770void mark_rodata_ro(void) 770void mark_rodata_ro(void)
771{ 771{
772 unsigned long start = PFN_ALIGN(_text); 772 unsigned long start = PFN_ALIGN(_text);
773 unsigned long rodata_start = 773 unsigned long rodata_start = PFN_ALIGN(__start_rodata);
774 ((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
775 unsigned long end = (unsigned long) &__end_rodata_hpage_align; 774 unsigned long end = (unsigned long) &__end_rodata_hpage_align;
776 unsigned long text_end = PAGE_ALIGN((unsigned long) &__stop___ex_table); 775 unsigned long text_end = PFN_ALIGN(&__stop___ex_table);
777 unsigned long rodata_end = PAGE_ALIGN((unsigned long) &__end_rodata); 776 unsigned long rodata_end = PFN_ALIGN(&__end_rodata);
778 unsigned long data_start = (unsigned long) &_sdata;
779 777
780 printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", 778 printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
781 (end - start) >> 10); 779 (end - start) >> 10);
@@ -800,12 +798,12 @@ void mark_rodata_ro(void)
800#endif 798#endif
801 799
802 free_init_pages("unused kernel memory", 800 free_init_pages("unused kernel memory",
803 (unsigned long) page_address(virt_to_page(text_end)), 801 (unsigned long) __va(__pa_symbol(text_end)),
804 (unsigned long) 802 (unsigned long) __va(__pa_symbol(rodata_start)));
805 page_address(virt_to_page(rodata_start))); 803
806 free_init_pages("unused kernel memory", 804 free_init_pages("unused kernel memory",
807 (unsigned long) page_address(virt_to_page(rodata_end)), 805 (unsigned long) __va(__pa_symbol(rodata_end)),
808 (unsigned long) page_address(virt_to_page(data_start))); 806 (unsigned long) __va(__pa_symbol(_sdata)));
809} 807}
810 808
811#endif 809#endif
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index a718e0d23503..40f92f3aea54 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -94,12 +94,12 @@ static inline void split_page_count(int level) { }
94 94
95static inline unsigned long highmap_start_pfn(void) 95static inline unsigned long highmap_start_pfn(void)
96{ 96{
97 return __pa(_text) >> PAGE_SHIFT; 97 return __pa_symbol(_text) >> PAGE_SHIFT;
98} 98}
99 99
100static inline unsigned long highmap_end_pfn(void) 100static inline unsigned long highmap_end_pfn(void)
101{ 101{
102 return __pa(roundup(_brk_end, PMD_SIZE)) >> PAGE_SHIFT; 102 return __pa_symbol(roundup(_brk_end, PMD_SIZE)) >> PAGE_SHIFT;
103} 103}
104 104
105#endif 105#endif
@@ -276,8 +276,8 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
276 * The .rodata section needs to be read-only. Using the pfn 276 * The .rodata section needs to be read-only. Using the pfn
277 * catches all aliases. 277 * catches all aliases.
278 */ 278 */
279 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT, 279 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
280 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT)) 280 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
281 pgprot_val(forbidden) |= _PAGE_RW; 281 pgprot_val(forbidden) |= _PAGE_RW;
282 282
283#if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA) 283#if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index ad4439145f85..1b600266265e 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -410,8 +410,8 @@ void __init efi_reserve_boot_services(void)
410 * - Not within any part of the kernel 410 * - Not within any part of the kernel
411 * - Not the bios reserved area 411 * - Not the bios reserved area
412 */ 412 */
413 if ((start+size >= virt_to_phys(_text) 413 if ((start+size >= __pa_symbol(_text)
414 && start <= virt_to_phys(_end)) || 414 && start <= __pa_symbol(_end)) ||
415 !e820_all_mapped(start, start+size, E820_RAM) || 415 !e820_all_mapped(start, start+size, E820_RAM) ||
416 memblock_is_region_reserved(start, size)) { 416 memblock_is_region_reserved(start, size)) {
417 /* Could not reserve, skip it */ 417 /* Could not reserve, skip it */
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
index cbca565af5bd..80450261215c 100644
--- a/arch/x86/realmode/init.c
+++ b/arch/x86/realmode/init.c
@@ -62,9 +62,9 @@ void __init setup_real_mode(void)
62 __va(real_mode_header->trampoline_header); 62 __va(real_mode_header->trampoline_header);
63 63
64#ifdef CONFIG_X86_32 64#ifdef CONFIG_X86_32
65 trampoline_header->start = __pa(startup_32_smp); 65 trampoline_header->start = __pa_symbol(startup_32_smp);
66 trampoline_header->gdt_limit = __BOOT_DS + 7; 66 trampoline_header->gdt_limit = __BOOT_DS + 7;
67 trampoline_header->gdt_base = __pa(boot_gdt); 67 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
68#else 68#else
69 /* 69 /*
70 * Some AMD processors will #GP(0) if EFER.LMA is set in WRMSR 70 * Some AMD processors will #GP(0) if EFER.LMA is set in WRMSR
@@ -78,8 +78,8 @@ void __init setup_real_mode(void)
78 *trampoline_cr4_features = read_cr4(); 78 *trampoline_cr4_features = read_cr4();
79 79
80 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd); 80 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
81 trampoline_pgd[0] = __pa(level3_ident_pgt) + _KERNPG_TABLE; 81 trampoline_pgd[0] = __pa_symbol(level3_ident_pgt) + _KERNPG_TABLE;
82 trampoline_pgd[511] = __pa(level3_kernel_pgt) + _KERNPG_TABLE; 82 trampoline_pgd[511] = __pa_symbol(level3_kernel_pgt) + _KERNPG_TABLE;
83#endif 83#endif
84} 84}
85 85