powerpc/mm/radix: Display if mappings are exec or not
authorMichael Ellerman <mpe@ellerman.id.au>
Wed, 17 Oct 2018 12:53:38 +0000 (23:53 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 20 Oct 2018 02:26:47 +0000 (13:26 +1100)
At boot we print the ranges we've mapped for the linear mapping and
what page size we've used. Also track whether the range is mapped
executable or not and display that as well.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/mm/pgtable-radix.c

index 0e87733eed80d63f85faf8a923b6b06c962df1cb..931156069a81b03a91eddcc83ede2103e4f54ac3 100644 (file)
@@ -241,9 +241,8 @@ void radix__mark_initmem_nx(void)
 }
 #endif /* CONFIG_STRICT_KERNEL_RWX */
 
-static inline void __meminit print_mapping(unsigned long start,
-                                          unsigned long end,
-                                          unsigned long size)
+static inline void __meminit
+print_mapping(unsigned long start, unsigned long end, unsigned long size, bool exec)
 {
        char buf[10];
 
@@ -252,7 +251,8 @@ static inline void __meminit print_mapping(unsigned long start,
 
        string_get_size(size, 1, STRING_UNITS_2, buf, sizeof(buf));
 
-       pr_info("Mapped 0x%016lx-0x%016lx with %s pages\n", start, end, buf);
+       pr_info("Mapped 0x%016lx-0x%016lx with %s pages%s\n", start, end, buf,
+               exec ? " (exec)" : "");
 }
 
 static unsigned long next_boundary(unsigned long addr, unsigned long end)
@@ -269,6 +269,7 @@ static int __meminit create_physical_mapping(unsigned long start,
                                             int nid)
 {
        unsigned long vaddr, addr, mapping_size = 0;
+       bool prev_exec, exec = false;
        pgprot_t prot;
        int psize;
 
@@ -279,6 +280,7 @@ static int __meminit create_physical_mapping(unsigned long start,
 
                gap = next_boundary(addr, end) - addr;
                previous_size = mapping_size;
+               prev_exec = exec;
 
                if (IS_ALIGNED(addr, PUD_SIZE) && gap >= PUD_SIZE &&
                    mmu_psize_defs[MMU_PAGE_1G].shift) {
@@ -293,18 +295,21 @@ static int __meminit create_physical_mapping(unsigned long start,
                        psize = mmu_virtual_psize;
                }
 
-               if (mapping_size != previous_size) {
-                       print_mapping(start, addr, previous_size);
-                       start = addr;
-               }
-
                vaddr = (unsigned long)__va(addr);
 
                if (overlaps_kernel_text(vaddr, vaddr + mapping_size) ||
-                   overlaps_interrupt_vector_text(vaddr, vaddr + mapping_size))
+                   overlaps_interrupt_vector_text(vaddr, vaddr + mapping_size)) {
                        prot = PAGE_KERNEL_X;
-               else
+                       exec = true;
+               } else {
                        prot = PAGE_KERNEL;
+                       exec = false;
+               }
+
+               if (mapping_size != previous_size || exec != prev_exec) {
+                       print_mapping(start, addr, previous_size, prev_exec);
+                       start = addr;
+               }
 
                rc = __map_kernel_page(vaddr, addr, prot, mapping_size, nid, start, end);
                if (rc)
@@ -313,7 +318,7 @@ static int __meminit create_physical_mapping(unsigned long start,
                update_page_count(psize, 1);
        }
 
-       print_mapping(start, addr, mapping_size);
+       print_mapping(start, addr, mapping_size, exec);
        return 0;
 }