Message ID | 3fe9bf0867b2ffc7cd43fe7040ee18d245641ec1.1643791473.git.christophe.leroy@csgroup.eu (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/4] mm/kasan: Add CONFIG_KASAN_SOFTWARE | expand |
Hi Christophe, I love your patch! Yet something to improve: [auto build test ERROR on tip/sched/core] [also build test ERROR on linus/master v5.17-rc2] [cannot apply to hnaz-mm/master next-20220202] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/mm-kasan-Add-CONFIG_KASAN_SOFTWARE/20220202-164612 base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git ec2444530612a886b406e2830d7f314d1a07d4bb config: riscv-randconfig-r042-20220130 (https://download.01.org/0day-ci/archive/20220202/202202022041.mkJKLdPP-lkp@intel.com/config) compiler: riscv64-linux-gcc (GCC) 11.2.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/23eabd57613c3b304c1c54f1133ef5376cf5731d git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Christophe-Leroy/mm-kasan-Add-CONFIG_KASAN_SOFTWARE/20220202-164612 git checkout 23eabd57613c3b304c1c54f1133ef5376cf5731d # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=riscv SHELL=/bin/bash kernel/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): In file included from include/linux/slab.h:136, from kernel/fork.c:16: >> include/linux/kasan.h:102:36: error: unknown type name 'p4d_t'; did you mean 'pgd_t'? 102 | static inline bool kasan_pud_table(p4d_t p4d) | ^~~~~ | pgd_t >> include/linux/kasan.h:113:36: error: unknown type name 'pud_t'; did you mean 'pgd_t'? 113 | static inline bool kasan_pmd_table(pud_t pud) | ^~~~~ | pgd_t >> include/linux/kasan.h:130:36: error: unknown type name 'pmd_t'; did you mean 'pgd_t'? 130 | static inline bool kasan_pte_table(pmd_t pmd) | ^~~~~ | pgd_t kernel/fork.c:162:13: warning: no previous prototype for 'arch_release_task_struct' [-Wmissing-prototypes] 162 | void __weak arch_release_task_struct(struct task_struct *tsk) | ^~~~~~~~~~~~~~~~~~~~~~~~ kernel/fork.c:764:20: warning: no previous prototype for 'arch_task_cache_init' [-Wmissing-prototypes] 764 | void __init __weak arch_task_cache_init(void) { } | ^~~~~~~~~~~~~~~~~~~~ -- In file included from include/linux/slab.h:136, from kernel/resource.c:17: >> include/linux/kasan.h:102:36: error: unknown type name 'p4d_t'; did you mean 'pgd_t'? 102 | static inline bool kasan_pud_table(p4d_t p4d) | ^~~~~ | pgd_t >> include/linux/kasan.h:113:36: error: unknown type name 'pud_t'; did you mean 'pgd_t'? 113 | static inline bool kasan_pmd_table(pud_t pud) | ^~~~~ | pgd_t >> include/linux/kasan.h:130:36: error: unknown type name 'pmd_t'; did you mean 'pgd_t'? 130 | static inline bool kasan_pte_table(pmd_t pmd) | ^~~~~ | pgd_t -- In file included from include/linux/slab.h:136, from include/linux/resource_ext.h:11, from include/linux/acpi.h:14, from kernel/irq/irqdomain.c:5: >> include/linux/kasan.h:102:36: error: unknown type name 'p4d_t'; did you mean 'pgd_t'? 102 | static inline bool kasan_pud_table(p4d_t p4d) | ^~~~~ | pgd_t >> include/linux/kasan.h:113:36: error: unknown type name 'pud_t'; did you mean 'pgd_t'? 113 | static inline bool kasan_pmd_table(pud_t pud) | ^~~~~ | pgd_t >> include/linux/kasan.h:130:36: error: unknown type name 'pmd_t'; did you mean 'pgd_t'? 130 | static inline bool kasan_pte_table(pmd_t pmd) | ^~~~~ | pgd_t kernel/irq/irqdomain.c:1918:13: warning: no previous prototype for 'irq_domain_debugfs_init' [-Wmissing-prototypes] 1918 | void __init irq_domain_debugfs_init(struct dentry *root) | ^~~~~~~~~~~~~~~~~~~~~~~ vim +102 include/linux/kasan.h 84 85 #if defined(CONFIG_KASAN_SOFTWARE) && CONFIG_PGTABLE_LEVELS > 4 86 static inline bool kasan_p4d_table(pgd_t pgd) 87 { 88 return pgd_page(pgd) == virt_to_page(lm_alias(kasan_early_shadow_p4d)); 89 } 90 #else 91 static inline bool kasan_p4d_table(pgd_t pgd) 92 { 93 return false; 94 } 95 #endif 96 #if defined(CONFIG_KASAN_SOFTWARE) && CONFIG_PGTABLE_LEVELS > 3 97 static inline bool kasan_pud_table(p4d_t p4d) 98 { 99 return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud)); 100 } 101 #else > 102 static inline bool kasan_pud_table(p4d_t p4d) 103 { 104 return false; 105 } 106 #endif 107 #if defined(CONFIG_KASAN_SOFTWARE) && CONFIG_PGTABLE_LEVELS > 2 108 static inline bool kasan_pmd_table(pud_t pud) 109 { 110 return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd)); 111 } 112 #else > 113 static inline bool kasan_pmd_table(pud_t pud) 114 { 115 return false; 116 } 117 #endif 118 119 #ifdef CONFIG_KASAN_SOFTWARE 120 static inline bool kasan_pte_table(pmd_t pmd) 121 { 122 return pmd_page(pmd) == virt_to_page(lm_alias(kasan_early_shadow_pte)); 123 } 124 125 static inline bool kasan_early_shadow_page_entry(pte_t pte) 126 { 127 return pte_page(pte) == virt_to_page(lm_alias(kasan_early_shadow_page)); 128 } 129 #else > 130 static inline bool kasan_pte_table(pmd_t pmd) 131 { 132 return false; 133 } 134 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Christophe,
I love your patch! Perhaps something to improve:
[auto build test WARNING on tip/sched/core]
[also build test WARNING on linus/master v5.17-rc2]
[cannot apply to hnaz-mm/master next-20220202]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/mm-kasan-Add-CONFIG_KASAN_SOFTWARE/20220202-164612
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git ec2444530612a886b406e2830d7f314d1a07d4bb
config: mips-cu1000-neo_defconfig (https://download.01.org/0day-ci/archive/20220202/202202022037.dX0aClQq-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6b1e844b69f15bb7dffaf9365cd2b355d2eb7579)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://github.com/0day-ci/linux/commit/23eabd57613c3b304c1c54f1133ef5376cf5731d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-Leroy/mm-kasan-Add-CONFIG_KASAN_SOFTWARE/20220202-164612
git checkout 23eabd57613c3b304c1c54f1133ef5376cf5731d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/irqchip/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from drivers/irqchip/irq-ingenic.c:10:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/mips/include/asm/hardirq.h:16:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:21:
In file included from include/linux/slab.h:136:
include/linux/kasan.h:102:36: error: unknown type name 'p4d_t'
static inline bool kasan_pud_table(p4d_t p4d)
^
include/linux/kasan.h:113:36: error: unknown type name 'pud_t'
static inline bool kasan_pmd_table(pud_t pud)
^
include/linux/kasan.h:130:36: error: unknown type name 'pmd_t'
static inline bool kasan_pte_table(pmd_t pmd)
^
>> drivers/irqchip/irq-ingenic.c:111:22: warning: shift count >= width of type [-Wshift-count-overflow]
gc->wake_enabled = IRQ_MSK(32);
^~~~~~~~~~~
include/linux/irq.h:1175:41: note: expanded from macro 'IRQ_MSK'
#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
^ ~~~
drivers/irqchip/irq-ingenic.c:124:22: warning: shift count >= width of type [-Wshift-count-overflow]
irq_reg_writel(gc, IRQ_MSK(32), JZ_REG_INTC_SET_MASK);
^~~~~~~~~~~
include/linux/irq.h:1175:41: note: expanded from macro 'IRQ_MSK'
#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
^ ~~~
2 warnings and 3 errors generated.
vim +111 drivers/irqchip/irq-ingenic.c
42b64f388c171a arch/mips/jz4740/irq.c Thomas Gleixner 2011-03-23 59
943d69c6c21746 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 60 static int __init ingenic_intc_of_init(struct device_node *node,
943d69c6c21746 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 61 unsigned num_chips)
9869848d12601c arch/mips/jz4740/irq.c Lars-Peter Clausen 2010-07-17 62 {
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 63 struct ingenic_intc_data *intc;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 64 struct irq_chip_generic *gc;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 65 struct irq_chip_type *ct;
638c885185dc2e arch/mips/jz4740/irq.c Paul Burton 2015-05-24 66 struct irq_domain *domain;
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 67 int parent_irq, err = 0;
943d69c6c21746 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 68 unsigned i;
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 69
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 70 intc = kzalloc(sizeof(*intc), GFP_KERNEL);
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 71 if (!intc) {
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 72 err = -ENOMEM;
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 73 goto out_err;
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 74 }
69ce4b2288d22a arch/mips/jz4740/irq.c Paul Burton 2015-05-24 75
69ce4b2288d22a arch/mips/jz4740/irq.c Paul Burton 2015-05-24 76 parent_irq = irq_of_parse_and_map(node, 0);
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 77 if (!parent_irq) {
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 78 err = -EINVAL;
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 79 goto out_free;
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 80 }
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 81
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 82 err = irq_set_handler_data(parent_irq, intc);
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 83 if (err)
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 84 goto out_unmap_irq;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 85
943d69c6c21746 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 86 intc->num_chips = num_chips;
3aa94590e7bf82 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 87 intc->base = of_iomap(node, 0);
3aa94590e7bf82 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 88 if (!intc->base) {
3aa94590e7bf82 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 89 err = -ENODEV;
3aa94590e7bf82 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 90 goto out_unmap_irq;
3aa94590e7bf82 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 91 }
9869848d12601c arch/mips/jz4740/irq.c Lars-Peter Clausen 2010-07-17 92
1fd224e35c1493 drivers/irqchip/irq-ingenic.c Paul Cercueil 2020-01-13 93 domain = irq_domain_add_linear(node, num_chips * 32,
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 94 &irq_generic_chip_ops, NULL);
52ecc87642f273 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 95 if (!domain) {
52ecc87642f273 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 96 err = -ENOMEM;
52ecc87642f273 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 97 goto out_unmap_base;
52ecc87642f273 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 98 }
52ecc87642f273 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 99
208caadce5d4d3 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 100 intc->domain = domain;
208caadce5d4d3 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 101
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 102 err = irq_alloc_domain_generic_chips(domain, 32, 1, "INTC",
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 103 handle_level_irq, 0,
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 104 IRQ_NOPROBE | IRQ_LEVEL, 0);
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 105 if (err)
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 106 goto out_domain_remove;
42b64f388c171a arch/mips/jz4740/irq.c Thomas Gleixner 2011-03-23 107
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 108 for (i = 0; i < num_chips; i++) {
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 109 gc = irq_get_domain_generic_chip(domain, i * 32);
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 110
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 @111 gc->wake_enabled = IRQ_MSK(32);
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 112 gc->reg_base = intc->base + (i * CHIP_SIZE);
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 113
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 114 ct = gc->chip_types;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 115 ct->regs.enable = JZ_REG_INTC_CLEAR_MASK;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 116 ct->regs.disable = JZ_REG_INTC_SET_MASK;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 117 ct->chip.irq_unmask = irq_gc_unmask_enable_reg;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 118 ct->chip.irq_mask = irq_gc_mask_disable_reg;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 119 ct->chip.irq_mask_ack = irq_gc_mask_disable_reg;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 120 ct->chip.irq_set_wake = irq_gc_set_wake;
20b44b4de61f28 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 121 ct->chip.flags = IRQCHIP_MASK_ON_SUSPEND;
83bc769200802c arch/mips/jz4740/irq.c Lars-Peter Clausen 2011-09-24 122
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 123 /* Mask all irqs */
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 124 irq_reg_writel(gc, IRQ_MSK(32), JZ_REG_INTC_SET_MASK);
943d69c6c21746 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 125 }
9869848d12601c arch/mips/jz4740/irq.c Lars-Peter Clausen 2010-07-17 126
821fc9e261f3af drivers/irqchip/irq-ingenic.c Paul Cercueil 2020-08-19 127 if (request_irq(parent_irq, intc_cascade, IRQF_NO_SUSPEND,
2ef1cb763d92f3 drivers/irqchip/irq-ingenic.c afzal mohammed 2020-03-04 128 "SoC intc cascade interrupt", NULL))
2ef1cb763d92f3 drivers/irqchip/irq-ingenic.c afzal mohammed 2020-03-04 129 pr_err("Failed to register SoC intc cascade interrupt\n");
adbdce77ccc345 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 130 return 0;
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 131
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 132 out_domain_remove:
8bc7464b514021 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 133 irq_domain_remove(domain);
52ecc87642f273 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 134 out_unmap_base:
52ecc87642f273 drivers/irqchip/irq-ingenic.c Paul Cercueil 2019-10-02 135 iounmap(intc->base);
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 136 out_unmap_irq:
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 137 irq_dispose_mapping(parent_irq);
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 138 out_free:
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 139 kfree(intc);
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 140 out_err:
fe778ece8e2522 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 141 return err;
9869848d12601c arch/mips/jz4740/irq.c Lars-Peter Clausen 2010-07-17 142 }
943d69c6c21746 arch/mips/jz4740/irq.c Paul Burton 2015-05-24 143
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/include/linux/kasan.h b/include/linux/kasan.h index c29778b25d8a..1629797198ec 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -28,6 +28,7 @@ struct kunit_kasan_expectation { #ifdef CONFIG_KASAN_SOFTWARE #include <linux/pgtable.h> +#include <linux/mm.h> /* Software KASAN implementations use shadow memory. */ @@ -81,6 +82,62 @@ static inline void kasan_disable_current(void) {} #endif /* CONFIG_KASAN_SOFTWARE */ +#if defined(CONFIG_KASAN_SOFTWARE) && CONFIG_PGTABLE_LEVELS > 4 +static inline bool kasan_p4d_table(pgd_t pgd) +{ + return pgd_page(pgd) == virt_to_page(lm_alias(kasan_early_shadow_p4d)); +} +#else +static inline bool kasan_p4d_table(pgd_t pgd) +{ + return false; +} +#endif +#if defined(CONFIG_KASAN_SOFTWARE) && CONFIG_PGTABLE_LEVELS > 3 +static inline bool kasan_pud_table(p4d_t p4d) +{ + return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud)); +} +#else +static inline bool kasan_pud_table(p4d_t p4d) +{ + return false; +} +#endif +#if defined(CONFIG_KASAN_SOFTWARE) && CONFIG_PGTABLE_LEVELS > 2 +static inline bool kasan_pmd_table(pud_t pud) +{ + return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd)); +} +#else +static inline bool kasan_pmd_table(pud_t pud) +{ + return false; +} +#endif + +#ifdef CONFIG_KASAN_SOFTWARE +static inline bool kasan_pte_table(pmd_t pmd) +{ + return pmd_page(pmd) == virt_to_page(lm_alias(kasan_early_shadow_pte)); +} + +static inline bool kasan_early_shadow_page_entry(pte_t pte) +{ + return pte_page(pte) == virt_to_page(lm_alias(kasan_early_shadow_page)); +} +#else +static inline bool kasan_pte_table(pmd_t pmd) +{ + return false; +} + +static inline bool kasan_early_shadow_page_entry(pte_t pte) +{ + return false; +} +#endif + #ifdef CONFIG_KASAN_HW_TAGS DECLARE_STATIC_KEY_FALSE(kasan_flag_enabled); diff --git a/include/linux/mm.h b/include/linux/mm.h index e1a84b1e6787..b06ee84b3717 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -31,7 +31,6 @@ #include <linux/sizes.h> #include <linux/sched.h> #include <linux/pgtable.h> -#include <linux/kasan.h> struct mempolicy; struct anon_vma; @@ -121,6 +120,8 @@ extern int mmap_rnd_compat_bits __read_mostly; #define lm_alias(x) __va(__pa_symbol(x)) #endif +#include <linux/kasan.h> + /* * To prevent common memory management code establishing * a zero page mapping on a read fault. diff --git a/mm/kasan/init.c b/mm/kasan/init.c index cc64ed6858c6..e863071a49ef 100644 --- a/mm/kasan/init.c +++ b/mm/kasan/init.c @@ -30,53 +30,16 @@ unsigned char kasan_early_shadow_page[PAGE_SIZE] __page_aligned_bss; #if CONFIG_PGTABLE_LEVELS > 4 p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D] __page_aligned_bss; -static inline bool kasan_p4d_table(pgd_t pgd) -{ - return pgd_page(pgd) == virt_to_page(lm_alias(kasan_early_shadow_p4d)); -} -#else -static inline bool kasan_p4d_table(pgd_t pgd) -{ - return false; -} #endif #if CONFIG_PGTABLE_LEVELS > 3 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)); -} -#else -static inline bool kasan_pud_table(p4d_t p4d) -{ - return false; -} #endif #if CONFIG_PGTABLE_LEVELS > 2 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)); -} -#else -static inline bool kasan_pmd_table(pud_t pud) -{ - return false; -} #endif pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE + PTE_HWTABLE_PTRS] __page_aligned_bss; -static inline bool kasan_pte_table(pmd_t pmd) -{ - return pmd_page(pmd) == virt_to_page(lm_alias(kasan_early_shadow_pte)); -} - -static inline bool kasan_early_shadow_page_entry(pte_t pte) -{ - return pte_page(pte) == virt_to_page(lm_alias(kasan_early_shadow_page)); -} - static __init void *early_alloc(size_t size, int node) { void *ptr = memblock_alloc_try_nid(size, size, __pa(MAX_DMA_ADDRESS),
In order to reuse them outside of mm/kasan/init.c, move the following helpers outside of init.c: kasan_p4d_table() kasan_pud_table() kasan_pmd_table() kasan_pte_table() kasan_early_shadow_page_entry() And make them available when KASAN is not selected. Inclusion of kasan.h in mm.h needs to be moved down a bit in order to get lm_alias() definition. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> --- include/linux/kasan.h | 57 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 3 ++- mm/kasan/init.c | 37 ---------------------------- 3 files changed, 59 insertions(+), 38 deletions(-)