From: Daniel Axtens <dja@axtens.net>
To: aneesh.kumar@linux.ibm.com, christophe.leroy@c-s.fr,
bsingharora@gmail.com
Cc: linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com,
Daniel Axtens <dja@axtens.net>
Subject: [RFC PATCH 5/7] kasan: allow arches to provide their own early shadow setup
Date: Thu, 23 May 2019 15:21:18 +1000 [thread overview]
Message-ID: <20190523052120.18459-6-dja@axtens.net> (raw)
In-Reply-To: <20190523052120.18459-1-dja@axtens.net>
powerpc supports several different MMUs. In particular, book3s
machines support both a hash-table based MMU and a radix MMU.
These MMUs support different numbers of entries per directory
level: PTES_PER_* reference variables. This leads to complier
errors as global variables must have constant sizes.
Allow architectures to manage their own early shadow variables
so we can work around this on powerpc.
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
include/linux/kasan.h | 2 ++
mm/kasan/init.c | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index a630d53f1a36..dfee2b42d799 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -18,11 +18,13 @@ struct task_struct;
static inline bool kasan_arch_is_ready(void) { return true; }
#endif
+#ifndef ARCH_HAS_KASAN_EARLY_SHADOW
extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE];
extern pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD];
extern pud_t kasan_early_shadow_pud[PTRS_PER_PUD];
extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D];
+#endif
int kasan_populate_early_shadow(const void *shadow_start,
const void *shadow_end);
diff --git a/mm/kasan/init.c b/mm/kasan/init.c
index ce45c491ebcd..2522382bf374 100644
--- a/mm/kasan/init.c
+++ b/mm/kasan/init.c
@@ -31,10 +31,14 @@
* - Latter it reused it as zero shadow to cover large ranges of memory
* that allowed to access, but not handled by kasan (vmalloc/vmemmap ...).
*/
+#ifndef ARCH_HAS_KASAN_EARLY_SHADOW
unsigned char kasan_early_shadow_page[PAGE_SIZE] __page_aligned_bss;
+#endif
#if CONFIG_PGTABLE_LEVELS > 4
+#ifndef ARCH_HAS_KASAN_EARLY_SHADOW
p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D] __page_aligned_bss;
+#endif
static inline bool kasan_p4d_table(pgd_t pgd)
{
return pgd_page(pgd) == virt_to_page(lm_alias(kasan_early_shadow_p4d));
@@ -46,7 +50,9 @@ static inline bool kasan_p4d_table(pgd_t pgd)
}
#endif
#if CONFIG_PGTABLE_LEVELS > 3
+#ifndef ARCH_HAS_KASAN_EARLY_SHADOW
pud_t kasan_early_shadow_pud[PTRS_PER_PUD] __page_aligned_bss;
+#endif
static inline bool kasan_pud_table(p4d_t p4d)
{
return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud));
@@ -58,7 +64,9 @@ static inline bool kasan_pud_table(p4d_t p4d)
}
#endif
#if CONFIG_PGTABLE_LEVELS > 2
+#ifndef ARCH_HAS_KASAN_EARLY_SHADOW
pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD] __page_aligned_bss;
+#endif
static inline bool kasan_pmd_table(pud_t pud)
{
return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd));
@@ -69,7 +77,9 @@ static inline bool kasan_pmd_table(pud_t pud)
return false;
}
#endif
+#ifndef ARCH_HAS_KASAN_EARLY_SHADOW
pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss;
+#endif
static inline bool kasan_pte_table(pmd_t pmd)
{
--
2.19.1
next prev parent reply other threads:[~2019-05-23 5:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 5:21 [RFC PATCH 0/7] powerpc: KASAN for 64-bit 3s radix Daniel Axtens
2019-05-23 5:21 ` [RFC PATCH 1/7] kasan: do not open-code addr_has_shadow Daniel Axtens
2019-05-23 5:21 ` [RFC PATCH 2/7] kasan: allow architectures to manage the memory-to-shadow mapping Daniel Axtens
2019-05-23 5:21 ` [RFC PATCH 3/7] kasan: allow architectures to provide an outline readiness check Daniel Axtens
2019-05-23 6:14 ` Christophe Leroy
2019-05-23 5:21 ` [RFC PATCH 4/7] powerpc: KASAN for 64bit Book3E Daniel Axtens
2019-05-23 6:15 ` Christophe Leroy
2019-05-23 5:21 ` Daniel Axtens [this message]
2019-05-23 5:21 ` [RFC PATCH 6/7] kasan: allow arches to hook into global registration Daniel Axtens
2019-05-23 6:31 ` Christophe Leroy
2019-05-23 6:59 ` Daniel Axtens
2019-05-23 5:21 ` [RFC PATCH 7/7] powerpc: Book3S 64-bit "heavyweight" KASAN support Daniel Axtens
2019-05-23 6:10 ` [RFC PATCH 0/7] powerpc: KASAN for 64-bit 3s radix Christophe Leroy
2019-05-23 6:18 ` Daniel Axtens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190523052120.18459-6-dja@axtens.net \
--to=dja@axtens.net \
--cc=aneesh.kumar@linux.ibm.com \
--cc=bsingharora@gmail.com \
--cc=christophe.leroy@c-s.fr \
--cc=kasan-dev@googlegroups.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox