mirror of https://github.com/OpenIPC/firmware.git
124 lines
4.4 KiB
Diff
124 lines
4.4 KiB
Diff
diff -drupN a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
|
|
--- a/arch/arm64/mm/mmu.c 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/arch/arm64/mm/mmu.c 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -30,6 +30,7 @@
|
|
#include <linux/io.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/stop_machine.h>
|
|
+#include <linux/mm.h>
|
|
|
|
#include <asm/barrier.h>
|
|
#include <asm/cputype.h>
|
|
@@ -319,8 +320,8 @@ static void create_mapping_late(phys_add
|
|
|
|
static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end)
|
|
{
|
|
- unsigned long kernel_start = __pa(_text);
|
|
- unsigned long kernel_end = __pa(__init_begin);
|
|
+ unsigned long kernel_start = __pa_symbol(_text);
|
|
+ unsigned long kernel_end = __pa_symbol(__init_begin);
|
|
|
|
/*
|
|
* Take care not to create a writable alias for the
|
|
@@ -387,21 +388,21 @@ void mark_rodata_ro(void)
|
|
unsigned long section_size;
|
|
|
|
section_size = (unsigned long)_etext - (unsigned long)_text;
|
|
- create_mapping_late(__pa(_text), (unsigned long)_text,
|
|
+ create_mapping_late(__pa_symbol(_text), (unsigned long)_text,
|
|
section_size, PAGE_KERNEL_ROX);
|
|
/*
|
|
* mark .rodata as read only. Use __init_begin rather than __end_rodata
|
|
* to cover NOTES and EXCEPTION_TABLE.
|
|
*/
|
|
section_size = (unsigned long)__init_begin - (unsigned long)__start_rodata;
|
|
- create_mapping_late(__pa(__start_rodata), (unsigned long)__start_rodata,
|
|
+ create_mapping_late(__pa_symbol(__start_rodata), (unsigned long)__start_rodata,
|
|
section_size, PAGE_KERNEL_RO);
|
|
}
|
|
|
|
static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end,
|
|
pgprot_t prot, struct vm_struct *vma)
|
|
{
|
|
- phys_addr_t pa_start = __pa(va_start);
|
|
+ phys_addr_t pa_start = __pa_symbol(va_start);
|
|
unsigned long size = va_end - va_start;
|
|
|
|
BUG_ON(!PAGE_ALIGNED(pa_start));
|
|
@@ -424,7 +425,7 @@ static int __init map_entry_trampoline(v
|
|
{
|
|
extern char __entry_tramp_text_start[];
|
|
|
|
- pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
|
|
+ pgprot_t prot = PAGE_KERNEL_EXEC;
|
|
phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start);
|
|
|
|
/* The trampoline is always mapped and can therefore be global */
|
|
@@ -480,7 +481,7 @@ static void __init map_kernel(pgd_t *pgd
|
|
*/
|
|
BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES));
|
|
set_pud(pud_set_fixmap_offset(pgd, FIXADDR_START),
|
|
- __pud(__pa(bm_pmd) | PUD_TYPE_TABLE));
|
|
+ __pud(__pa_symbol(bm_pmd) | PUD_TYPE_TABLE));
|
|
pud_clear_fixmap();
|
|
} else {
|
|
BUG();
|
|
@@ -511,7 +512,7 @@ void __init paging_init(void)
|
|
*/
|
|
cpu_replace_ttbr1(__va(pgd_phys));
|
|
memcpy(swapper_pg_dir, pgd, PGD_SIZE);
|
|
- cpu_replace_ttbr1(swapper_pg_dir);
|
|
+ cpu_replace_ttbr1(lm_alias(swapper_pg_dir));
|
|
|
|
pgd_clear_fixmap();
|
|
memblock_free(pgd_phys, PAGE_SIZE);
|
|
@@ -520,7 +521,7 @@ void __init paging_init(void)
|
|
* We only reuse the PGD from the swapper_pg_dir, not the pud + pmd
|
|
* allocated with it.
|
|
*/
|
|
- memblock_free(__pa(swapper_pg_dir) + PAGE_SIZE,
|
|
+ memblock_free(__pa_symbol(swapper_pg_dir) + PAGE_SIZE,
|
|
SWAPPER_DIR_SIZE - PAGE_SIZE);
|
|
}
|
|
|
|
@@ -631,6 +632,12 @@ static inline pte_t * fixmap_pte(unsigne
|
|
return &bm_pte[pte_index(addr)];
|
|
}
|
|
|
|
+/*
|
|
+ * The p*d_populate functions call virt_to_phys implicitly so they can't be used
|
|
+ * directly on kernel symbols (bm_p*d). This function is called too early to use
|
|
+ * lm_alias so __p*d_populate functions must be used to populate with the
|
|
+ * physical address from __pa_symbol.
|
|
+ */
|
|
void __init early_fixmap_init(void)
|
|
{
|
|
pgd_t *pgd;
|
|
@@ -640,7 +647,7 @@ void __init early_fixmap_init(void)
|
|
|
|
pgd = pgd_offset_k(addr);
|
|
if (CONFIG_PGTABLE_LEVELS > 3 &&
|
|
- !(pgd_none(*pgd) || pgd_page_paddr(*pgd) == __pa(bm_pud))) {
|
|
+ !(pgd_none(*pgd) || pgd_page_paddr(*pgd) == __pa_symbol(bm_pud))) {
|
|
/*
|
|
* We only end up here if the kernel mapping and the fixmap
|
|
* share the top level pgd entry, which should only happen on
|
|
@@ -649,12 +656,14 @@ void __init early_fixmap_init(void)
|
|
BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES));
|
|
pud = pud_offset_kimg(pgd, addr);
|
|
} else {
|
|
- pgd_populate(&init_mm, pgd, bm_pud);
|
|
+ if (pgd_none(*pgd))
|
|
+ __pgd_populate(pgd, __pa_symbol(bm_pud), PUD_TYPE_TABLE);
|
|
pud = fixmap_pud(addr);
|
|
}
|
|
- pud_populate(&init_mm, pud, bm_pmd);
|
|
+ if (pud_none(*pud))
|
|
+ __pud_populate(pud, __pa_symbol(bm_pmd), PMD_TYPE_TABLE);
|
|
pmd = fixmap_pmd(addr);
|
|
- pmd_populate_kernel(&init_mm, pmd, bm_pte);
|
|
+ __pmd_populate(pmd, __pa_symbol(bm_pte), PMD_TYPE_TABLE);
|
|
|
|
/*
|
|
* The boot-ioremap range spans multiple pmds, for which
|