Message ID | 20191210044714.27265-3-dja@axtens.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KASAN for powerpc64 radix, plus generic mm change | expand |
Le 10/12/2019 à 05:47, Daniel Axtens a écrit : > This helps with powerpc support, and should have no effect on > anything else. As explained in previous patch, this patch is based on MAX_PTRS_PER_Pxx existing for every arch using KASAN, allthought all arches but powerpc will define it as PTRS_PER_Pxx. I think instead of forcing all arches to define that value, just define a fallback in kasan.h (or somewhere else) would help keeping the changes to the minimum, see below. > > Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr> > Signed-off-by: Daniel Axtens <dja@axtens.net> > --- > include/linux/kasan.h | 6 +++--- > mm/kasan/init.c | 6 +++--- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/include/linux/kasan.h b/include/linux/kasan.h > index e18fe54969e9..d2f2a4ffcb12 100644 > --- a/include/linux/kasan.h > +++ b/include/linux/kasan.h > @@ -15,9 +15,9 @@ struct task_struct; > #include <asm/pgtable.h> Add #ifndef MAX_PTRS_PER_PTE #define MAX_PTRS_PER_PTE PTRS_PER_PTE #endif #ifndef MAX_PTRS_PER_PMD #define MAX_PTRS_PER_PMD PTRS_PER_PMD #endif #ifndef MAX_PTRS_PER_PUD #define MAX_PTRS_PER_PUD PTRS_PER_PUD #endif #ifndef MAX_PTRS_PER_P4D #define MAX_PTRS_PER_P4D PTRS_PER_P4D #endif With that you don't need patch 1. > > 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 pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE]; > +extern pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD]; > +extern pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD]; > extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D]; > > int kasan_populate_early_shadow(const void *shadow_start, > diff --git a/mm/kasan/init.c b/mm/kasan/init.c > index ce45c491ebcd..8b54a96d3b3e 100644 > --- a/mm/kasan/init.c > +++ b/mm/kasan/init.c > @@ -46,7 +46,7 @@ static inline bool kasan_p4d_table(pgd_t pgd) > } > #endif > #if CONFIG_PGTABLE_LEVELS > 3 > -pud_t kasan_early_shadow_pud[PTRS_PER_PUD] __page_aligned_bss; > +pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD] __page_aligned_bss; > static inline bool kasan_pud_table(p4d_t p4d) > { > return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud)); > @@ -58,7 +58,7 @@ static inline bool kasan_pud_table(p4d_t p4d) > } > #endif > #if CONFIG_PGTABLE_LEVELS > 2 > -pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD] __page_aligned_bss; > +pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD] __page_aligned_bss; > static inline bool kasan_pmd_table(pud_t pud) > { > return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd)); > @@ -69,7 +69,7 @@ static inline bool kasan_pmd_table(pud_t pud) > return false; > } > #endif > -pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss; > +pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE] __page_aligned_bss; > > static inline bool kasan_pte_table(pmd_t pmd) > { > Christophe
On 10/12/19 3:47 pm, Daniel Axtens wrote: > This helps with powerpc support, and should have no effect on > anything else. > > Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr> > Signed-off-by: Daniel Axtens <dja@axtens.net> If you follow the recommendations by Christophe and I, you don't need this patch Balbir Singh. > --- > include/linux/kasan.h | 6 +++--- > mm/kasan/init.c | 6 +++--- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/include/linux/kasan.h b/include/linux/kasan.h > index e18fe54969e9..d2f2a4ffcb12 100644 > --- a/include/linux/kasan.h > +++ b/include/linux/kasan.h > @@ -15,9 +15,9 @@ struct task_struct; > #include <asm/pgtable.h> > > 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 pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE]; > +extern pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD]; > +extern pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD]; > extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D]; > > int kasan_populate_early_shadow(const void *shadow_start, > diff --git a/mm/kasan/init.c b/mm/kasan/init.c > index ce45c491ebcd..8b54a96d3b3e 100644 > --- a/mm/kasan/init.c > +++ b/mm/kasan/init.c > @@ -46,7 +46,7 @@ static inline bool kasan_p4d_table(pgd_t pgd) > } > #endif > #if CONFIG_PGTABLE_LEVELS > 3 > -pud_t kasan_early_shadow_pud[PTRS_PER_PUD] __page_aligned_bss; > +pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD] __page_aligned_bss; > static inline bool kasan_pud_table(p4d_t p4d) > { > return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud)); > @@ -58,7 +58,7 @@ static inline bool kasan_pud_table(p4d_t p4d) > } > #endif > #if CONFIG_PGTABLE_LEVELS > 2 > -pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD] __page_aligned_bss; > +pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD] __page_aligned_bss; > static inline bool kasan_pmd_table(pud_t pud) > { > return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd)); > @@ -69,7 +69,7 @@ static inline bool kasan_pmd_table(pud_t pud) > return false; > } > #endif > -pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss; > +pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE] __page_aligned_bss; > > static inline bool kasan_pte_table(pmd_t pmd) > { >
Le 10/12/2019 à 10:36, Balbir Singh a écrit : > > > On 10/12/19 3:47 pm, Daniel Axtens wrote: >> This helps with powerpc support, and should have no effect on >> anything else. >> >> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr> >> Signed-off-by: Daniel Axtens <dja@axtens.net> > > If you follow the recommendations by Christophe and I, you don't need this patch I guess you mean Patch 1 (the one adding the const to all arches) is not needed. Of course this one (Patch 2) is needed as it is the one that changes kasan.h to use const table size instead of impossible variable table size. And that would also fix the problem reported by the kbuild test robot. Christophe
diff --git a/include/linux/kasan.h b/include/linux/kasan.h index e18fe54969e9..d2f2a4ffcb12 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -15,9 +15,9 @@ struct task_struct; #include <asm/pgtable.h> 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 pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE]; +extern pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD]; +extern pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD]; extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D]; int kasan_populate_early_shadow(const void *shadow_start, diff --git a/mm/kasan/init.c b/mm/kasan/init.c index ce45c491ebcd..8b54a96d3b3e 100644 --- a/mm/kasan/init.c +++ b/mm/kasan/init.c @@ -46,7 +46,7 @@ static inline bool kasan_p4d_table(pgd_t pgd) } #endif #if CONFIG_PGTABLE_LEVELS > 3 -pud_t kasan_early_shadow_pud[PTRS_PER_PUD] __page_aligned_bss; +pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD] __page_aligned_bss; static inline bool kasan_pud_table(p4d_t p4d) { return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud)); @@ -58,7 +58,7 @@ static inline bool kasan_pud_table(p4d_t p4d) } #endif #if CONFIG_PGTABLE_LEVELS > 2 -pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD] __page_aligned_bss; +pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD] __page_aligned_bss; static inline bool kasan_pmd_table(pud_t pud) { return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd)); @@ -69,7 +69,7 @@ static inline bool kasan_pmd_table(pud_t pud) return false; } #endif -pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss; +pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE] __page_aligned_bss; static inline bool kasan_pte_table(pmd_t pmd) {
This helps with powerpc support, and should have no effect on anything else. Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Daniel Axtens <dja@axtens.net> --- include/linux/kasan.h | 6 +++--- mm/kasan/init.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)