diff options
| author | Laura Abbott <labbott@redhat.com> | 2017-01-10 16:35:44 -0500 |
|---|---|---|
| committer | Will Deacon <will.deacon@arm.com> | 2017-01-11 08:56:50 -0500 |
| commit | 5c6a84a3f4558a6115fef1b59343c7ae56b3abc3 (patch) | |
| tree | deadee2a46cb0675e319ec47db6753f5a73686e2 | |
| parent | b6e92aa81038ce57d298a87b4c44285a1d456c3e (diff) | |
mm/kasan: Switch to using __pa_symbol and lm_alias
__pa_symbol is the correct API to find the physical address of symbols.
Switch to it to allow for debugging APIs to work correctly. Other
functions such as p*d_populate may call __pa internally. Ensure that the
address passed is in the linear region by calling lm_alias.
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
| -rw-r--r-- | mm/kasan/kasan_init.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/mm/kasan/kasan_init.c b/mm/kasan/kasan_init.c index 3f9a41cf0ac6..31238dad85fb 100644 --- a/mm/kasan/kasan_init.c +++ b/mm/kasan/kasan_init.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/kasan.h> | 15 | #include <linux/kasan.h> |
| 16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/memblock.h> | 17 | #include <linux/memblock.h> |
| 18 | #include <linux/mm.h> | ||
| 18 | #include <linux/pfn.h> | 19 | #include <linux/pfn.h> |
| 19 | 20 | ||
| 20 | #include <asm/page.h> | 21 | #include <asm/page.h> |
| @@ -49,7 +50,7 @@ static void __init zero_pte_populate(pmd_t *pmd, unsigned long addr, | |||
| 49 | pte_t *pte = pte_offset_kernel(pmd, addr); | 50 | pte_t *pte = pte_offset_kernel(pmd, addr); |
| 50 | pte_t zero_pte; | 51 | pte_t zero_pte; |
| 51 | 52 | ||
| 52 | zero_pte = pfn_pte(PFN_DOWN(__pa(kasan_zero_page)), PAGE_KERNEL); | 53 | zero_pte = pfn_pte(PFN_DOWN(__pa_symbol(kasan_zero_page)), PAGE_KERNEL); |
| 53 | zero_pte = pte_wrprotect(zero_pte); | 54 | zero_pte = pte_wrprotect(zero_pte); |
| 54 | 55 | ||
| 55 | while (addr + PAGE_SIZE <= end) { | 56 | while (addr + PAGE_SIZE <= end) { |
| @@ -69,7 +70,7 @@ static void __init zero_pmd_populate(pud_t *pud, unsigned long addr, | |||
| 69 | next = pmd_addr_end(addr, end); | 70 | next = pmd_addr_end(addr, end); |
| 70 | 71 | ||
| 71 | if (IS_ALIGNED(addr, PMD_SIZE) && end - addr >= PMD_SIZE) { | 72 | if (IS_ALIGNED(addr, PMD_SIZE) && end - addr >= PMD_SIZE) { |
| 72 | pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte); | 73 | pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte)); |
| 73 | continue; | 74 | continue; |
| 74 | } | 75 | } |
| 75 | 76 | ||
| @@ -92,9 +93,9 @@ static void __init zero_pud_populate(pgd_t *pgd, unsigned long addr, | |||
| 92 | if (IS_ALIGNED(addr, PUD_SIZE) && end - addr >= PUD_SIZE) { | 93 | if (IS_ALIGNED(addr, PUD_SIZE) && end - addr >= PUD_SIZE) { |
| 93 | pmd_t *pmd; | 94 | pmd_t *pmd; |
| 94 | 95 | ||
| 95 | pud_populate(&init_mm, pud, kasan_zero_pmd); | 96 | pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd)); |
| 96 | pmd = pmd_offset(pud, addr); | 97 | pmd = pmd_offset(pud, addr); |
| 97 | pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte); | 98 | pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte)); |
| 98 | continue; | 99 | continue; |
| 99 | } | 100 | } |
| 100 | 101 | ||
| @@ -135,11 +136,11 @@ void __init kasan_populate_zero_shadow(const void *shadow_start, | |||
| 135 | * puds,pmds, so pgd_populate(), pud_populate() | 136 | * puds,pmds, so pgd_populate(), pud_populate() |
| 136 | * is noops. | 137 | * is noops. |
| 137 | */ | 138 | */ |
| 138 | pgd_populate(&init_mm, pgd, kasan_zero_pud); | 139 | pgd_populate(&init_mm, pgd, lm_alias(kasan_zero_pud)); |
| 139 | pud = pud_offset(pgd, addr); | 140 | pud = pud_offset(pgd, addr); |
| 140 | pud_populate(&init_mm, pud, kasan_zero_pmd); | 141 | pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd)); |
| 141 | pmd = pmd_offset(pud, addr); | 142 | pmd = pmd_offset(pud, addr); |
| 142 | pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte); | 143 | pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte)); |
| 143 | continue; | 144 | continue; |
| 144 | } | 145 | } |
| 145 | 146 | ||
