--- zzzz-none-000/linux-4.4.60/arch/arm/mm/init.c 2017-04-08 07:53:53.000000000 +0000 +++ scorpion-7490-727/linux-4.4.60/arch/arm/mm/init.c 2021-02-04 17:41:59.000000000 +0000 @@ -23,7 +23,6 @@ #include #include #include - #include #include #include @@ -152,7 +151,8 @@ */ zone_size[0] = max_low - min; #ifdef CONFIG_HIGHMEM - zone_size[ZONE_HIGHMEM] = max_high - max_low; + if (max_high >= max_low) + zone_size[ZONE_HIGHMEM] = max_high - max_low; #endif /* @@ -473,6 +473,7 @@ */ void __init mem_init(void) { + #ifdef CONFIG_HAVE_TCM /* These pointers are filled in on TCM detection */ extern u32 dtcm_end; @@ -567,6 +568,7 @@ */ sysctl_overcommit_memory = OVERCOMMIT_ALWAYS; } + } #ifdef CONFIG_ARM_KERNMEM_PERMS @@ -748,11 +750,18 @@ #endif } +#if defined(CONFIG_AVM_ENHANCED) +void __init avm_mtd_cleanup(void); +#endif void free_initmem(void) { fix_kernmem_perms(); free_tcmmem(); +#if defined(CONFIG_AVM_ENHANCED) + avm_mtd_cleanup(); +#endif + poison_init_mem(__init_begin, __init_end - __init_begin); if (!machine_is_integrator() && !machine_is_cintegrator()) free_initmem_default(-1); @@ -783,3 +792,44 @@ __setup("keepinitrd", keepinitrd_setup); #endif + +#ifdef CONFIG_QCA_MINIDUMP + +/* Get base address of PGD.*/ +void get_pgd_info(uint64_t *pt_start, uint64_t *pt_len) +{ + *pt_start = (uintptr_t)swapper_pg_dir; + *pt_len = SZ_16K; +} + +/* Get base address of PT and PMD. pmd_offset() gives +* Page Middle Directory offset. The value at this address +* corresponds to the base address of the Page Table. +* pud_offset() gives Page Upper Directory offset. The value +* at this address corresponds to the base address of +* Page Middle Directory. +*/ + +int get_mmu_info(const void *vmalloc_addr, + unsigned long *pt_address, unsigned long *pmd_address) +{ + unsigned long addr = (unsigned long) vmalloc_addr; + struct page *page = NULL; + pgd_t *pgd = pgd_offset_k(addr); + + if (!pgd_none(*pgd)) { + pud_t *pud = pud_offset(pgd, addr); + if (!pud_none(*pud)) { + pmd_t *pmd = pmd_offset(pud, addr); + if (!pmd_none(*pmd)) { + page = pmd_page(*(pmd)); + *pmd_address = (unsigned long) pud_val(*pud) & (~(1024 - 1)); + *pt_address = (unsigned long) pmd_val(*pmd) & (~(1024 - 1)); + return 0; + } + } + } + return -1; +} +#endif +