aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2015-09-15 08:50:22 -0400
committerard <ard.biesheuvel@linaro.org>2015-12-13 13:18:28 -0500
commit1bdb2d4ee05f2fdad4d8a82d7e0ce8d6d91ec4ac (patch)
treeaf0656e07c2a2501c8f0b8935dc008a09b7454ba
parent2937367b8a4b0d46ce3312cb997e4a240b02cf15 (diff)
ARM: split off core mapping logic from create_mapping
In order to be able to reuse the core mapping logic of create_mapping for mapping the UEFI Runtime Services into a private set of page tables, split it off from create_mapping() into a separate function __create_mapping which we will wire up in a subsequent patch. Tested-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
-rw-r--r--arch/arm/mm/mmu.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index de19f90221e2..3100de92148b 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -818,7 +818,8 @@ static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr,
818} 818}
819 819
820#ifndef CONFIG_ARM_LPAE 820#ifndef CONFIG_ARM_LPAE
821static void __init create_36bit_mapping(struct map_desc *md, 821static void __init create_36bit_mapping(struct mm_struct *mm,
822 struct map_desc *md,
822 const struct mem_type *type) 823 const struct mem_type *type)
823{ 824{
824 unsigned long addr, length, end; 825 unsigned long addr, length, end;
@@ -859,7 +860,7 @@ static void __init create_36bit_mapping(struct map_desc *md,
859 */ 860 */
860 phys |= (((md->pfn >> (32 - PAGE_SHIFT)) & 0xF) << 20); 861 phys |= (((md->pfn >> (32 - PAGE_SHIFT)) & 0xF) << 20);
861 862
862 pgd = pgd_offset_k(addr); 863 pgd = pgd_offset(mm, addr);
863 end = addr + length; 864 end = addr + length;
864 do { 865 do {
865 pud_t *pud = pud_offset(pgd, addr); 866 pud_t *pud = pud_offset(pgd, addr);
@@ -876,33 +877,13 @@ static void __init create_36bit_mapping(struct map_desc *md,
876} 877}
877#endif /* !CONFIG_ARM_LPAE */ 878#endif /* !CONFIG_ARM_LPAE */
878 879
879/* 880static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md)
880 * Create the page directory entries and any necessary
881 * page tables for the mapping specified by `md'. We
882 * are able to cope here with varying sizes and address
883 * offsets, and we take full advantage of sections and
884 * supersections.
885 */
886static void __init create_mapping(struct map_desc *md)
887{ 881{
888 unsigned long addr, length, end; 882 unsigned long addr, length, end;
889 phys_addr_t phys; 883 phys_addr_t phys;
890 const struct mem_type *type; 884 const struct mem_type *type;
891 pgd_t *pgd; 885 pgd_t *pgd;
892 886
893 if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) {
894 pr_warn("BUG: not creating mapping for 0x%08llx at 0x%08lx in user region\n",
895 (long long)__pfn_to_phys((u64)md->pfn), md->virtual);
896 return;
897 }
898
899 if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
900 md->virtual >= PAGE_OFFSET && md->virtual < FIXADDR_START &&
901 (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
902 pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",
903 (long long)__pfn_to_phys((u64)md->pfn), md->virtual);
904 }
905
906 type = &mem_types[md->type]; 887 type = &mem_types[md->type];
907 888
908#ifndef CONFIG_ARM_LPAE 889#ifndef CONFIG_ARM_LPAE
@@ -910,7 +891,7 @@ static void __init create_mapping(struct map_desc *md)
910 * Catch 36-bit addresses 891 * Catch 36-bit addresses
911 */ 892 */
912 if (md->pfn >= 0x100000) { 893 if (md->pfn >= 0x100000) {
913 create_36bit_mapping(md, type); 894 create_36bit_mapping(mm, md, type);
914 return; 895 return;
915 } 896 }
916#endif 897#endif
@@ -925,7 +906,7 @@ static void __init create_mapping(struct map_desc *md)
925 return; 906 return;
926 } 907 }
927 908
928 pgd = pgd_offset_k(addr); 909 pgd = pgd_offset(mm, addr);
929 end = addr + length; 910 end = addr + length;
930 do { 911 do {
931 unsigned long next = pgd_addr_end(addr, end); 912 unsigned long next = pgd_addr_end(addr, end);
@@ -938,6 +919,31 @@ static void __init create_mapping(struct map_desc *md)
938} 919}
939 920
940/* 921/*
922 * Create the page directory entries and any necessary
923 * page tables for the mapping specified by `md'. We
924 * are able to cope here with varying sizes and address
925 * offsets, and we take full advantage of sections and
926 * supersections.
927 */
928static void __init create_mapping(struct map_desc *md)
929{
930 if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) {
931 pr_warn("BUG: not creating mapping for 0x%08llx at 0x%08lx in user region\n",
932 (long long)__pfn_to_phys((u64)md->pfn), md->virtual);
933 return;
934 }
935
936 if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
937 md->virtual >= PAGE_OFFSET && md->virtual < FIXADDR_START &&
938 (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
939 pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",
940 (long long)__pfn_to_phys((u64)md->pfn), md->virtual);
941 }
942
943 __create_mapping(&init_mm, md);
944}
945
946/*
941 * Create the architecture specific mappings 947 * Create the architecture specific mappings
942 */ 948 */
943void __init iotable_init(struct map_desc *io_desc, int nr) 949void __init iotable_init(struct map_desc *io_desc, int nr)