| .. | .. |
|---|
| 8 | 8 | * Copyright (C) 2017 Cadence Design Systems Inc. |
|---|
| 9 | 9 | */ |
|---|
| 10 | 10 | |
|---|
| 11 | | -#include <linux/bootmem.h> |
|---|
| 11 | +#include <linux/memblock.h> |
|---|
| 12 | 12 | #include <linux/init_task.h> |
|---|
| 13 | 13 | #include <linux/kasan.h> |
|---|
| 14 | 14 | #include <linux/kernel.h> |
|---|
| 15 | | -#include <linux/memblock.h> |
|---|
| 16 | 15 | #include <asm/initialize_mmu.h> |
|---|
| 17 | 16 | #include <asm/tlbflush.h> |
|---|
| 18 | 17 | #include <asm/traps.h> |
|---|
| .. | .. |
|---|
| 20 | 19 | void __init kasan_early_init(void) |
|---|
| 21 | 20 | { |
|---|
| 22 | 21 | unsigned long vaddr = KASAN_SHADOW_START; |
|---|
| 23 | | - pgd_t *pgd = pgd_offset_k(vaddr); |
|---|
| 24 | | - pmd_t *pmd = pmd_offset(pgd, vaddr); |
|---|
| 22 | + pmd_t *pmd = pmd_off_k(vaddr); |
|---|
| 25 | 23 | int i; |
|---|
| 26 | 24 | |
|---|
| 27 | 25 | for (i = 0; i < PTRS_PER_PTE; ++i) |
|---|
| .. | .. |
|---|
| 42 | 40 | unsigned long n_pmds = n_pages / PTRS_PER_PTE; |
|---|
| 43 | 41 | unsigned long i, j; |
|---|
| 44 | 42 | unsigned long vaddr = (unsigned long)start; |
|---|
| 45 | | - pgd_t *pgd = pgd_offset_k(vaddr); |
|---|
| 46 | | - pmd_t *pmd = pmd_offset(pgd, vaddr); |
|---|
| 47 | | - pte_t *pte = memblock_virt_alloc(n_pages * sizeof(pte_t), PAGE_SIZE); |
|---|
| 43 | + pmd_t *pmd = pmd_off_k(vaddr); |
|---|
| 44 | + pte_t *pte = memblock_alloc(n_pages * sizeof(pte_t), PAGE_SIZE); |
|---|
| 45 | + |
|---|
| 46 | + if (!pte) |
|---|
| 47 | + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", |
|---|
| 48 | + __func__, n_pages * sizeof(pte_t), PAGE_SIZE); |
|---|
| 48 | 49 | |
|---|
| 49 | 50 | pr_debug("%s: %p - %p\n", __func__, start, end); |
|---|
| 50 | 51 | |
|---|
| .. | .. |
|---|
| 53 | 54 | |
|---|
| 54 | 55 | for (k = 0; k < PTRS_PER_PTE; ++k, ++j) { |
|---|
| 55 | 56 | phys_addr_t phys = |
|---|
| 56 | | - memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, |
|---|
| 57 | | - MEMBLOCK_ALLOC_ANYWHERE); |
|---|
| 57 | + memblock_phys_alloc_range(PAGE_SIZE, PAGE_SIZE, |
|---|
| 58 | + 0, |
|---|
| 59 | + MEMBLOCK_ALLOC_ANYWHERE); |
|---|
| 60 | + |
|---|
| 61 | + if (!phys) |
|---|
| 62 | + panic("Failed to allocate page table page\n"); |
|---|
| 58 | 63 | |
|---|
| 59 | 64 | set_pte(pte + j, pfn_pte(PHYS_PFN(phys), PAGE_KERNEL)); |
|---|
| 60 | 65 | } |
|---|