Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1537346

[PATCHv5 09/11] mm/kasan: Switch to using __pa_symbol and lm_alias

From Laura Abbott <labbott@redhat.com>
Newsgroups linux.kernel
Subject [PATCHv5 09/11] mm/kasan: Switch to using __pa_symbol and lm_alias
Date 2016-12-07 01:00 +0100
Message-ID <sLxOp-j2-23@gated-at.bofh.it> (permalink)
References <sLxOp-j2-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


__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>
---
v5: Add missing lm_alias call
---
 mm/kasan/kasan_init.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/mm/kasan/kasan_init.c b/mm/kasan/kasan_init.c
index 3f9a41c..922f459 100644
--- a/mm/kasan/kasan_init.c
+++ b/mm/kasan/kasan_init.c
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/memblock.h>
 #include <linux/pfn.h>
+#include <linux/mm.h>
 
 #include <asm/page.h>
 #include <asm/pgalloc.h>
@@ -49,7 +50,7 @@ static void __init zero_pte_populate(pmd_t *pmd, unsigned long addr,
 	pte_t *pte = pte_offset_kernel(pmd, addr);
 	pte_t zero_pte;
 
-	zero_pte = pfn_pte(PFN_DOWN(__pa(kasan_zero_page)), PAGE_KERNEL);
+	zero_pte = pfn_pte(PFN_DOWN(__pa_symbol(kasan_zero_page)), PAGE_KERNEL);
 	zero_pte = pte_wrprotect(zero_pte);
 
 	while (addr + PAGE_SIZE <= end) {
@@ -69,7 +70,7 @@ static void __init zero_pmd_populate(pud_t *pud, unsigned long addr,
 		next = pmd_addr_end(addr, end);
 
 		if (IS_ALIGNED(addr, PMD_SIZE) && end - addr >= PMD_SIZE) {
-			pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte);
+			pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte));
 			continue;
 		}
 
@@ -92,9 +93,9 @@ static void __init zero_pud_populate(pgd_t *pgd, unsigned long addr,
 		if (IS_ALIGNED(addr, PUD_SIZE) && end - addr >= PUD_SIZE) {
 			pmd_t *pmd;
 
-			pud_populate(&init_mm, pud, kasan_zero_pmd);
+			pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd));
 			pmd = pmd_offset(pud, addr);
-			pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte);
+			pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte));
 			continue;
 		}
 
@@ -135,11 +136,11 @@ void __init kasan_populate_zero_shadow(const void *shadow_start,
 			 * puds,pmds, so pgd_populate(), pud_populate()
 			 * is noops.
 			 */
-			pgd_populate(&init_mm, pgd, kasan_zero_pud);
+			pgd_populate(&init_mm, pgd, lm_alias(kasan_zero_pud));
 			pud = pud_offset(pgd, addr);
-			pud_populate(&init_mm, pud, kasan_zero_pmd);
+			pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd));
 			pmd = pmd_offset(pud, addr);
-			pmd_populate_kernel(&init_mm, pmd, kasan_zero_pte);
+			pmd_populate_kernel(&init_mm, pmd, lm_alias(kasan_zero_pte));
 			continue;
 		}
 
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv5 00/11] CONFIG_DEBUG_VIRTUAL for arm64 Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCHv5 07/11] drivers: firmware: psci: Use __pa_symbol for kernel symbol Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCHv5 11/11] arm64: Add support for CONFIG_DEBUG_VIRTUAL Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCHv5 01/11] lib/Kconfig.debug: Add ARCH_HAS_DEBUG_VIRTUAL Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCHv5 05/11] mm: Introduce lm_alias Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCHv5 04/11] arm64: Add cast for virt_to_pfn Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCHv5 06/11] arm64: Use __pa_symbol for kernel symbols Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCHv5 09/11] mm/kasan: Switch to using __pa_symbol and lm_alias Laura Abbott <labbott@redhat.com> - 2016-12-07 01:00 +0100
  [PATCH v2 3/4] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-08 20:10 +0100
  [PATCH v2 0/4] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-08 20:10 +0100
    [PATCH v2 1/4] mtd: lart: Rename partition defines to be prefixed with PART_ Florian Fainelli <f.fainelli@gmail.com> - 2016-12-08 20:10 +0100
    [PATCH v2 2/4] ARM: Define KERNEL_START and KERNEL_END Florian Fainelli <f.fainelli@gmail.com> - 2016-12-08 20:10 +0100
    [PATCH v3 2/4] ARM: Define KERNEL_START and KERNEL_END Florian Fainelli <f.fainelli@gmail.com> - 2016-12-10 00:40 +0100
    [PATCH v3 1/4] mtd: lart: Rename partition defines to be prefixed with PART_ Florian Fainelli <f.fainelli@gmail.com> - 2016-12-10 00:40 +0100
    [PATCH v3 3/4] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-10 00:40 +0100
    [PATCH v3 0/4] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-10 00:40 +0100

csiph-web