--- zzzz-none-000/linux-3.10.107/arch/arm/include/asm/proc-fns.h 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/arch/arm/include/asm/proc-fns.h 2021-02-04 17:41:59.000000000 +0000 @@ -60,7 +60,7 @@ /* * Set the page table */ - void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm); + void (*switch_mm)(phys_addr_t pgd_phys, struct mm_struct *mm); /* * Set a possibly extended PTE. Non-extended PTEs should * ignore 'ext'. @@ -82,7 +82,7 @@ extern void cpu_proc_fin(void); extern int cpu_do_idle(void); extern void cpu_dcache_clean_area(void *, int); -extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm); +extern void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm); #ifdef CONFIG_ARM_LPAE extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte); #else @@ -116,17 +116,44 @@ #define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm) #ifdef CONFIG_ARM_LPAE + +#define cpu_get_ttbr(nr) \ + ({ \ + u64 ttbr; \ + __asm__("mrrc p15, " #nr ", %Q0, %R0, c2" \ + : "=r" (ttbr)); \ + ttbr; \ + }) + #define cpu_get_pgd() \ ({ \ - unsigned long pg, pg2; \ - __asm__("mrrc p15, 0, %0, %1, c2" \ - : "=r" (pg), "=r" (pg2) \ - : \ - : "cc"); \ + u64 pg = cpu_get_ttbr(0); \ pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \ (pgd_t *)phys_to_virt(pg); \ }) +#define cpu_set_ttbr0(val) \ + do { \ + u64 ttbr = val; \ + __asm__("mcrr p15, 0, %0, %1, c2" \ + : : "r" (ttbr), "r" (ttbr >> 32)); \ + } while (0) + #else +#define cpu_get_ttbr(nr) \ + ({ \ + unsigned long ttbr; \ + __asm__("mrc p15, 0, %0, c2, c0, 0" \ + : "=r" (ttbr)); \ + ttbr; \ + }) + +#define cpu_set_ttbr0(val) \ + do { \ + u64 ttbr = val; \ + __asm__("mcr p15, 0, %0, c2, c0, 0" \ + : : "r" (ttbr)); \ + } while (0) + #define cpu_get_pgd() \ ({ \ unsigned long pg; \ @@ -137,6 +164,10 @@ }) #endif +#else /*!CONFIG_MMU */ + +#define cpu_switch_mm(pgd,mm) { } + #endif #endif /* __ASSEMBLY__ */