Re: [PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2019-03-04 Thread Prateek Patel



On 3/4/2019 4:04 PM, Nicolas Boichat wrote:

On Wed, Feb 13, 2019 at 4:56 PM Nicolas Boichat  wrote:

On Tue, Jan 22, 2019 at 4:46 PM Prateek Patel  wrote:


On 11/10/2018 2:58 AM, Rob Herring wrote:

On Fri, Nov 9, 2018 at 1:09 AM Prateek Patel  wrote:

From: Sri Krishna chowdary 

Memory reserved with "nomap" DT property in of_reserved_mem.c
removes the memory block. The removed memory blocks don't have
VA to PA mapping created in kernel page table. Kmemleak scan on
removed memory blocks is causing page faults and leading to
kernel panic. So, Disable kmemleak scan on the removed memory
blocks.

Following is the observed crash log:
[  154.846370] Unable to handle kernel paging request at virtual address 
ffc070a0
<1>[  154.846576] Mem abort info:
<1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
<1>[  154.846737]   SET = 0, FnV = 0
<1>[  154.846796]   EA = 0, S1PTW = 0
<1>[  154.846859] Data abort info:
<1>[  154.846913]   ISV = 0, ISS = 0x0006
<1>[  154.846983]   CM = 0, WnR = 0
<1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = ff8009df7000
<1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
*pud=00087fff5803, *pmd=
<0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
<4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts imx268 imx318 
imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 ov5693 tc358840 pca9570 nvs 
snd_soc_tegra_machine_driver_mobile lp855x_bl spidev input_cfboost pwm_tegra 
tegra_cryptodev tegra_se_nvhost tegra_se_elp tegra_se ghash_ce sha2_ce sha1_ce 
aes_ce_ccm cryptd nvgpu cpufreq_userspace snd_soc_tegra186_alt_dspk 
snd_soc_tegra186_alt_asrc snd_soc_tegra186_alt_arad snd_soc_tegra210_alt_ope 
snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic snd_soc_tegra210_alt_amx 
snd_soc_tegra210_alt_adx snd_soc_tegra210_alt_afc snd_soc_tegra210_alt_mixer 
snd_soc_tegra210_alt_i2s snd_soc_tegra210_alt_sfc snd_soc_tegra210_alt_adsp 
snd_soc_tegra210_alt_admaif snd_soc_tegra210_alt_xbar
<4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
<4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
4.14.53-tegra-05132-g9c33465 #2
<4>[  154.895983] Hardware name: e3360_1099 (DT)
<4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
<4>[  154.906502] PC is at scan_block+0x7c/0x148
<4>[  154.911234] LR is at scan_block+0x78/0x148
<4>[  154.915689] pc : [] lr : [] pstate: 
804000c9
<4>[  154.923290] sp : ff800e2b3b80
<4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
<4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
<4>[  154.938769] x25: 00c0 x24: ff8009d90608
<4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
<4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
<4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
<4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
<4>[  154.967124] x15:  x14: 0f75
<4>[  154.973069] x13: 000f x12: ffbf1e9f4240
<4>[  154.978670] x11: 0040 x10: 0ad0
<4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
<4>[  154.989958] x7 : 00078000 x6 : 0018
<4>[  154.995645] x5 :  x4 : 
<4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
<4>[  155.006846] x1 : ffc7d1ae6900 x0 : 

[snip]

For reference, there is another patch series that fixes the problem,
by Mike Rapoport (https://lore.kernel.org/patchwork/patch/1041790/),
already in linux-next (through mmotm):
42c9c0ac24393c of: fix kmemleak crash caused by imbalance in early
memory reservation
48ec6d51f7d3f2 of: fix parameters order for call to memblock_find_in_range()

If anyone is interested, I backported these patch to our 4.19 tree
here, and they fix the issue:
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1496707
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1496708

Thanks,


Thanks Nicolas for the reference,

My acked-by is already present in the patch 
(https://lore.kernel.org/patchwork/patch/1041790/)




Re: [PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2019-03-04 Thread Nicolas Boichat
On Wed, Feb 13, 2019 at 4:56 PM Nicolas Boichat  wrote:
>
> On Tue, Jan 22, 2019 at 4:46 PM Prateek Patel  wrote:
> >
> >
> > On 11/10/2018 2:58 AM, Rob Herring wrote:
> > > On Fri, Nov 9, 2018 at 1:09 AM Prateek Patel  wrote:
> > >> From: Sri Krishna chowdary 
> > >>
> > >> Memory reserved with "nomap" DT property in of_reserved_mem.c
> > >> removes the memory block. The removed memory blocks don't have
> > >> VA to PA mapping created in kernel page table. Kmemleak scan on
> > >> removed memory blocks is causing page faults and leading to
> > >> kernel panic. So, Disable kmemleak scan on the removed memory
> > >> blocks.
> > >>
> > >> Following is the observed crash log:
> > >> [  154.846370] Unable to handle kernel paging request at virtual address 
> > >> ffc070a0
> > >> <1>[  154.846576] Mem abort info:
> > >> <1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
> > >> <1>[  154.846737]   SET = 0, FnV = 0
> > >> <1>[  154.846796]   EA = 0, S1PTW = 0
> > >> <1>[  154.846859] Data abort info:
> > >> <1>[  154.846913]   ISV = 0, ISS = 0x0006
> > >> <1>[  154.846983]   CM = 0, WnR = 0
> > >> <1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = 
> > >> ff8009df7000
> > >> <1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
> > >> *pud=00087fff5803, *pmd=
> > >> <0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
> > >> <4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
> > >> nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts 
> > >> imx268 imx318 imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 
> > >> ov5693 tc358840 pca9570 nvs snd_soc_tegra_machine_driver_mobile 
> > >> lp855x_bl spidev input_cfboost pwm_tegra tegra_cryptodev tegra_se_nvhost 
> > >> tegra_se_elp tegra_se ghash_ce sha2_ce sha1_ce aes_ce_ccm cryptd nvgpu 
> > >> cpufreq_userspace snd_soc_tegra186_alt_dspk snd_soc_tegra186_alt_asrc 
> > >> snd_soc_tegra186_alt_arad snd_soc_tegra210_alt_ope 
> > >> snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic 
> > >> snd_soc_tegra210_alt_amx snd_soc_tegra210_alt_adx 
> > >> snd_soc_tegra210_alt_afc snd_soc_tegra210_alt_mixer 
> > >> snd_soc_tegra210_alt_i2s snd_soc_tegra210_alt_sfc 
> > >> snd_soc_tegra210_alt_adsp snd_soc_tegra210_alt_admaif 
> > >> snd_soc_tegra210_alt_xbar
> > >> <4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
> > >> <4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
> > >> 4.14.53-tegra-05132-g9c33465 #2
> > >> <4>[  154.895983] Hardware name: e3360_1099 (DT)
> > >> <4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
> > >> <4>[  154.906502] PC is at scan_block+0x7c/0x148
> > >> <4>[  154.911234] LR is at scan_block+0x78/0x148
> > >> <4>[  154.915689] pc : [] lr : [] 
> > >> pstate: 804000c9
> > >> <4>[  154.923290] sp : ff800e2b3b80
> > >> <4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
> > >> <4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
> > >> <4>[  154.938769] x25: 00c0 x24: ff8009d90608
> > >> <4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
> > >> <4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
> > >> <4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
> > >> <4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
> > >> <4>[  154.967124] x15:  x14: 0f75
> > >> <4>[  154.973069] x13: 000f x12: ffbf1e9f4240
> > >> <4>[  154.978670] x11: 0040 x10: 0ad0
> > >> <4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
> > >> <4>[  154.989958] x7 : 00078000 x6 : 0018
> > >> <4>[  154.995645] x5 :  x4 : 
> > >> <4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
> > >> <4>[  155.006846] x1 : ffc7d1ae6900 x0 : 

[snip]

For reference, there is another patch series that fixes the problem,
by Mike Rapoport (https://lore.kernel.org/patchwork/patch/1041790/),
already in linux-next (through mmotm):
42c9c0ac24393c of: fix kmemleak crash caused by imbalance in early
memory reservation
48ec6d51f7d3f2 of: fix parameters order for call to memblock_find_in_range()

If anyone is interested, I backported these patch to our 4.19 tree
here, and they fix the issue:
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1496707
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1496708

Thanks,


Re: [PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2019-02-13 Thread Nicolas Boichat
On Tue, Jan 22, 2019 at 4:46 PM Prateek Patel  wrote:
>
>
> On 11/10/2018 2:58 AM, Rob Herring wrote:
> > On Fri, Nov 9, 2018 at 1:09 AM Prateek Patel  wrote:
> >> From: Sri Krishna chowdary 
> >>
> >> Memory reserved with "nomap" DT property in of_reserved_mem.c
> >> removes the memory block. The removed memory blocks don't have
> >> VA to PA mapping created in kernel page table. Kmemleak scan on
> >> removed memory blocks is causing page faults and leading to
> >> kernel panic. So, Disable kmemleak scan on the removed memory
> >> blocks.
> >>
> >> Following is the observed crash log:
> >> [  154.846370] Unable to handle kernel paging request at virtual address 
> >> ffc070a0
> >> <1>[  154.846576] Mem abort info:
> >> <1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
> >> <1>[  154.846737]   SET = 0, FnV = 0
> >> <1>[  154.846796]   EA = 0, S1PTW = 0
> >> <1>[  154.846859] Data abort info:
> >> <1>[  154.846913]   ISV = 0, ISS = 0x0006
> >> <1>[  154.846983]   CM = 0, WnR = 0
> >> <1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = 
> >> ff8009df7000
> >> <1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
> >> *pud=00087fff5803, *pmd=
> >> <0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
> >> <4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
> >> nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts imx268 
> >> imx318 imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 ov5693 
> >> tc358840 pca9570 nvs snd_soc_tegra_machine_driver_mobile lp855x_bl spidev 
> >> input_cfboost pwm_tegra tegra_cryptodev tegra_se_nvhost tegra_se_elp 
> >> tegra_se ghash_ce sha2_ce sha1_ce aes_ce_ccm cryptd nvgpu 
> >> cpufreq_userspace snd_soc_tegra186_alt_dspk snd_soc_tegra186_alt_asrc 
> >> snd_soc_tegra186_alt_arad snd_soc_tegra210_alt_ope 
> >> snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic 
> >> snd_soc_tegra210_alt_amx snd_soc_tegra210_alt_adx snd_soc_tegra210_alt_afc 
> >> snd_soc_tegra210_alt_mixer snd_soc_tegra210_alt_i2s 
> >> snd_soc_tegra210_alt_sfc snd_soc_tegra210_alt_adsp 
> >> snd_soc_tegra210_alt_admaif snd_soc_tegra210_alt_xbar
> >> <4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
> >> <4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
> >> 4.14.53-tegra-05132-g9c33465 #2
> >> <4>[  154.895983] Hardware name: e3360_1099 (DT)
> >> <4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
> >> <4>[  154.906502] PC is at scan_block+0x7c/0x148
> >> <4>[  154.911234] LR is at scan_block+0x78/0x148
> >> <4>[  154.915689] pc : [] lr : [] 
> >> pstate: 804000c9
> >> <4>[  154.923290] sp : ff800e2b3b80
> >> <4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
> >> <4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
> >> <4>[  154.938769] x25: 00c0 x24: ff8009d90608
> >> <4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
> >> <4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
> >> <4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
> >> <4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
> >> <4>[  154.967124] x15:  x14: 0f75
> >> <4>[  154.973069] x13: 000f x12: ffbf1e9f4240
> >> <4>[  154.978670] x11: 0040 x10: 0ad0
> >> <4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
> >> <4>[  154.989958] x7 : 00078000 x6 : 0018
> >> <4>[  154.995645] x5 :  x4 : 
> >> <4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
> >> <4>[  155.006846] x1 : ffc7d1ae6900 x0 : 
> >>
> >> Signed-off-by: Sri Krishna chowdary 
> >> Signed-off-by: Prateek 
> >> ---
> >>   drivers/of/of_reserved_mem.c | 5 -
> >>   1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> >> index 1977ee0..ac8f377 100644
> >> --- a/drivers/of/of_reserved_mem.c
> >> +++ b/drivers/of/of_reserved_mem.c
> >> @@ -21,6 +21,7 @@
> >>   #include 
> >>   #include 
> >>   #include 
> >> +#include 
> >>
> >>   #define MAX_RESERVED_REGIONS   32
> >>   static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
> >> @@ -50,8 +51,10 @@ int __init __weak 
> >> early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
> >>  }
> >>
> >>  *res_base = base;
> >> -   if (nomap)
> >> +   if (nomap) {
> >> +   kmemleak_no_scan(__va(base));
> >>  return memblock_remove(base, size);
> > I'm curious how I can't find any other similar example in the kernel.
> > Please Cc some kmemleak folks.
> >
> > Perhaps we should be using memblock_mark_nomap() for nomap areas?
> >
> > Rob
>
> Sorry for this late reply.
>
> Yes, memblock_mark_nomap() can be used here but if I understand
> correctly, memblock_mark_nomap() is used to indicate marked parts of
> memory should 

Re: [PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2019-01-22 Thread Prateek Patel



On 11/10/2018 2:58 AM, Rob Herring wrote:

On Fri, Nov 9, 2018 at 1:09 AM Prateek Patel  wrote:

From: Sri Krishna chowdary 

Memory reserved with "nomap" DT property in of_reserved_mem.c
removes the memory block. The removed memory blocks don't have
VA to PA mapping created in kernel page table. Kmemleak scan on
removed memory blocks is causing page faults and leading to
kernel panic. So, Disable kmemleak scan on the removed memory
blocks.

Following is the observed crash log:
[  154.846370] Unable to handle kernel paging request at virtual address 
ffc070a0
<1>[  154.846576] Mem abort info:
<1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
<1>[  154.846737]   SET = 0, FnV = 0
<1>[  154.846796]   EA = 0, S1PTW = 0
<1>[  154.846859] Data abort info:
<1>[  154.846913]   ISV = 0, ISS = 0x0006
<1>[  154.846983]   CM = 0, WnR = 0
<1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = ff8009df7000
<1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
*pud=00087fff5803, *pmd=
<0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
<4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts imx268 imx318 
imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 ov5693 tc358840 pca9570 nvs 
snd_soc_tegra_machine_driver_mobile lp855x_bl spidev input_cfboost pwm_tegra 
tegra_cryptodev tegra_se_nvhost tegra_se_elp tegra_se ghash_ce sha2_ce sha1_ce 
aes_ce_ccm cryptd nvgpu cpufreq_userspace snd_soc_tegra186_alt_dspk 
snd_soc_tegra186_alt_asrc snd_soc_tegra186_alt_arad snd_soc_tegra210_alt_ope 
snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic snd_soc_tegra210_alt_amx 
snd_soc_tegra210_alt_adx snd_soc_tegra210_alt_afc snd_soc_tegra210_alt_mixer 
snd_soc_tegra210_alt_i2s snd_soc_tegra210_alt_sfc snd_soc_tegra210_alt_adsp 
snd_soc_tegra210_alt_admaif snd_soc_tegra210_alt_xbar
<4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
<4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
4.14.53-tegra-05132-g9c33465 #2
<4>[  154.895983] Hardware name: e3360_1099 (DT)
<4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
<4>[  154.906502] PC is at scan_block+0x7c/0x148
<4>[  154.911234] LR is at scan_block+0x78/0x148
<4>[  154.915689] pc : [] lr : [] pstate: 
804000c9
<4>[  154.923290] sp : ff800e2b3b80
<4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
<4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
<4>[  154.938769] x25: 00c0 x24: ff8009d90608
<4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
<4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
<4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
<4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
<4>[  154.967124] x15:  x14: 0f75
<4>[  154.973069] x13: 000f x12: ffbf1e9f4240
<4>[  154.978670] x11: 0040 x10: 0ad0
<4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
<4>[  154.989958] x7 : 00078000 x6 : 0018
<4>[  154.995645] x5 :  x4 : 
<4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
<4>[  155.006846] x1 : ffc7d1ae6900 x0 : 

Signed-off-by: Sri Krishna chowdary 
Signed-off-by: Prateek 
---
  drivers/of/of_reserved_mem.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 1977ee0..ac8f377 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -21,6 +21,7 @@
  #include 
  #include 
  #include 
+#include 

  #define MAX_RESERVED_REGIONS   32
  static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
@@ -50,8 +51,10 @@ int __init __weak 
early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
 }

 *res_base = base;
-   if (nomap)
+   if (nomap) {
+   kmemleak_no_scan(__va(base));
 return memblock_remove(base, size);

I'm curious how I can't find any other similar example in the kernel.
Please Cc some kmemleak folks.

Perhaps we should be using memblock_mark_nomap() for nomap areas?

Rob


Sorry for this late reply.

Yes, memblock_mark_nomap() can be used here but if I understand 
correctly, memblock_mark_nomap() is used to indicate marked parts of 
memory should not be covered by the kernel direct mapping and 
memblock_remove() here is doing that by removing a given memory from the 
"memblock.memory" list to prevent the memory from CPU accessing by the 
linear address. I am not 100% sure what will be the side effects of 
using memblock_mark_nomap(). Adding folks to help me here on 
MEMBLOCK_NOMAP and kmemleak.


I checked and verified with following and I didn't find any errors on my 
local setup:


diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 

Re: [PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2018-11-09 Thread Rob Herring
On Fri, Nov 9, 2018 at 1:09 AM Prateek Patel  wrote:
>
> From: Sri Krishna chowdary 
>
> Memory reserved with "nomap" DT property in of_reserved_mem.c
> removes the memory block. The removed memory blocks don't have
> VA to PA mapping created in kernel page table. Kmemleak scan on
> removed memory blocks is causing page faults and leading to
> kernel panic. So, Disable kmemleak scan on the removed memory
> blocks.
>
> Following is the observed crash log:
> [  154.846370] Unable to handle kernel paging request at virtual address 
> ffc070a0
> <1>[  154.846576] Mem abort info:
> <1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
> <1>[  154.846737]   SET = 0, FnV = 0
> <1>[  154.846796]   EA = 0, S1PTW = 0
> <1>[  154.846859] Data abort info:
> <1>[  154.846913]   ISV = 0, ISS = 0x0006
> <1>[  154.846983]   CM = 0, WnR = 0
> <1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = 
> ff8009df7000
> <1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
> *pud=00087fff5803, *pmd=
> <0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
> <4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
> nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts imx268 
> imx318 imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 ov5693 tc358840 
> pca9570 nvs snd_soc_tegra_machine_driver_mobile lp855x_bl spidev 
> input_cfboost pwm_tegra tegra_cryptodev tegra_se_nvhost tegra_se_elp tegra_se 
> ghash_ce sha2_ce sha1_ce aes_ce_ccm cryptd nvgpu cpufreq_userspace 
> snd_soc_tegra186_alt_dspk snd_soc_tegra186_alt_asrc snd_soc_tegra186_alt_arad 
> snd_soc_tegra210_alt_ope snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic 
> snd_soc_tegra210_alt_amx snd_soc_tegra210_alt_adx snd_soc_tegra210_alt_afc 
> snd_soc_tegra210_alt_mixer snd_soc_tegra210_alt_i2s snd_soc_tegra210_alt_sfc 
> snd_soc_tegra210_alt_adsp snd_soc_tegra210_alt_admaif 
> snd_soc_tegra210_alt_xbar
> <4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
> <4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
> 4.14.53-tegra-05132-g9c33465 #2
> <4>[  154.895983] Hardware name: e3360_1099 (DT)
> <4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
> <4>[  154.906502] PC is at scan_block+0x7c/0x148
> <4>[  154.911234] LR is at scan_block+0x78/0x148
> <4>[  154.915689] pc : [] lr : [] pstate: 
> 804000c9
> <4>[  154.923290] sp : ff800e2b3b80
> <4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
> <4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
> <4>[  154.938769] x25: 00c0 x24: ff8009d90608
> <4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
> <4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
> <4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
> <4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
> <4>[  154.967124] x15:  x14: 0f75
> <4>[  154.973069] x13: 000f x12: ffbf1e9f4240
> <4>[  154.978670] x11: 0040 x10: 0ad0
> <4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
> <4>[  154.989958] x7 : 00078000 x6 : 0018
> <4>[  154.995645] x5 :  x4 : 
> <4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
> <4>[  155.006846] x1 : ffc7d1ae6900 x0 : 
>
> Signed-off-by: Sri Krishna chowdary 
> Signed-off-by: Prateek 
> ---
>  drivers/of/of_reserved_mem.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 1977ee0..ac8f377 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -21,6 +21,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define MAX_RESERVED_REGIONS   32
>  static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
> @@ -50,8 +51,10 @@ int __init __weak 
> early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
> }
>
> *res_base = base;
> -   if (nomap)
> +   if (nomap) {
> +   kmemleak_no_scan(__va(base));
> return memblock_remove(base, size);

I'm curious how I can't find any other similar example in the kernel.
Please Cc some kmemleak folks.

Perhaps we should be using memblock_mark_nomap() for nomap areas?

Rob


Re: [PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2018-11-09 Thread Rob Herring
On Fri, Nov 9, 2018 at 1:09 AM Prateek Patel  wrote:
>
> From: Sri Krishna chowdary 
>
> Memory reserved with "nomap" DT property in of_reserved_mem.c
> removes the memory block. The removed memory blocks don't have
> VA to PA mapping created in kernel page table. Kmemleak scan on
> removed memory blocks is causing page faults and leading to
> kernel panic. So, Disable kmemleak scan on the removed memory
> blocks.
>
> Following is the observed crash log:
> [  154.846370] Unable to handle kernel paging request at virtual address 
> ffc070a0
> <1>[  154.846576] Mem abort info:
> <1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
> <1>[  154.846737]   SET = 0, FnV = 0
> <1>[  154.846796]   EA = 0, S1PTW = 0
> <1>[  154.846859] Data abort info:
> <1>[  154.846913]   ISV = 0, ISS = 0x0006
> <1>[  154.846983]   CM = 0, WnR = 0
> <1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = 
> ff8009df7000
> <1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
> *pud=00087fff5803, *pmd=
> <0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
> <4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
> nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts imx268 
> imx318 imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 ov5693 tc358840 
> pca9570 nvs snd_soc_tegra_machine_driver_mobile lp855x_bl spidev 
> input_cfboost pwm_tegra tegra_cryptodev tegra_se_nvhost tegra_se_elp tegra_se 
> ghash_ce sha2_ce sha1_ce aes_ce_ccm cryptd nvgpu cpufreq_userspace 
> snd_soc_tegra186_alt_dspk snd_soc_tegra186_alt_asrc snd_soc_tegra186_alt_arad 
> snd_soc_tegra210_alt_ope snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic 
> snd_soc_tegra210_alt_amx snd_soc_tegra210_alt_adx snd_soc_tegra210_alt_afc 
> snd_soc_tegra210_alt_mixer snd_soc_tegra210_alt_i2s snd_soc_tegra210_alt_sfc 
> snd_soc_tegra210_alt_adsp snd_soc_tegra210_alt_admaif 
> snd_soc_tegra210_alt_xbar
> <4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
> <4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
> 4.14.53-tegra-05132-g9c33465 #2
> <4>[  154.895983] Hardware name: e3360_1099 (DT)
> <4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
> <4>[  154.906502] PC is at scan_block+0x7c/0x148
> <4>[  154.911234] LR is at scan_block+0x78/0x148
> <4>[  154.915689] pc : [] lr : [] pstate: 
> 804000c9
> <4>[  154.923290] sp : ff800e2b3b80
> <4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
> <4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
> <4>[  154.938769] x25: 00c0 x24: ff8009d90608
> <4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
> <4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
> <4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
> <4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
> <4>[  154.967124] x15:  x14: 0f75
> <4>[  154.973069] x13: 000f x12: ffbf1e9f4240
> <4>[  154.978670] x11: 0040 x10: 0ad0
> <4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
> <4>[  154.989958] x7 : 00078000 x6 : 0018
> <4>[  154.995645] x5 :  x4 : 
> <4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
> <4>[  155.006846] x1 : ffc7d1ae6900 x0 : 
>
> Signed-off-by: Sri Krishna chowdary 
> Signed-off-by: Prateek 
> ---
>  drivers/of/of_reserved_mem.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 1977ee0..ac8f377 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -21,6 +21,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define MAX_RESERVED_REGIONS   32
>  static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
> @@ -50,8 +51,10 @@ int __init __weak 
> early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
> }
>
> *res_base = base;
> -   if (nomap)
> +   if (nomap) {
> +   kmemleak_no_scan(__va(base));
> return memblock_remove(base, size);

I'm curious how I can't find any other similar example in the kernel.
Please Cc some kmemleak folks.

Perhaps we should be using memblock_mark_nomap() for nomap areas?

Rob


[PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2018-11-08 Thread Prateek Patel
From: Sri Krishna chowdary 

Memory reserved with "nomap" DT property in of_reserved_mem.c
removes the memory block. The removed memory blocks don't have
VA to PA mapping created in kernel page table. Kmemleak scan on
removed memory blocks is causing page faults and leading to
kernel panic. So, Disable kmemleak scan on the removed memory
blocks.

Following is the observed crash log:
[  154.846370] Unable to handle kernel paging request at virtual address 
ffc070a0
<1>[  154.846576] Mem abort info:
<1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
<1>[  154.846737]   SET = 0, FnV = 0
<1>[  154.846796]   EA = 0, S1PTW = 0
<1>[  154.846859] Data abort info:
<1>[  154.846913]   ISV = 0, ISS = 0x0006
<1>[  154.846983]   CM = 0, WnR = 0
<1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = ff8009df7000
<1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
*pud=00087fff5803, *pmd=
<0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
<4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts imx268 
imx318 imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 ov5693 tc358840 
pca9570 nvs snd_soc_tegra_machine_driver_mobile lp855x_bl spidev input_cfboost 
pwm_tegra tegra_cryptodev tegra_se_nvhost tegra_se_elp tegra_se ghash_ce 
sha2_ce sha1_ce aes_ce_ccm cryptd nvgpu cpufreq_userspace 
snd_soc_tegra186_alt_dspk snd_soc_tegra186_alt_asrc snd_soc_tegra186_alt_arad 
snd_soc_tegra210_alt_ope snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic 
snd_soc_tegra210_alt_amx snd_soc_tegra210_alt_adx snd_soc_tegra210_alt_afc 
snd_soc_tegra210_alt_mixer snd_soc_tegra210_alt_i2s snd_soc_tegra210_alt_sfc 
snd_soc_tegra210_alt_adsp snd_soc_tegra210_alt_admaif snd_soc_tegra210_alt_xbar
<4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
<4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
4.14.53-tegra-05132-g9c33465 #2
<4>[  154.895983] Hardware name: e3360_1099 (DT)
<4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
<4>[  154.906502] PC is at scan_block+0x7c/0x148
<4>[  154.911234] LR is at scan_block+0x78/0x148
<4>[  154.915689] pc : [] lr : [] pstate: 
804000c9
<4>[  154.923290] sp : ff800e2b3b80
<4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
<4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
<4>[  154.938769] x25: 00c0 x24: ff8009d90608
<4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
<4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
<4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
<4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
<4>[  154.967124] x15:  x14: 0f75
<4>[  154.973069] x13: 000f x12: ffbf1e9f4240
<4>[  154.978670] x11: 0040 x10: 0ad0
<4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
<4>[  154.989958] x7 : 00078000 x6 : 0018
<4>[  154.995645] x5 :  x4 : 
<4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
<4>[  155.006846] x1 : ffc7d1ae6900 x0 : 

Signed-off-by: Sri Krishna chowdary 
Signed-off-by: Prateek 
---
 drivers/of/of_reserved_mem.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 1977ee0..ac8f377 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAX_RESERVED_REGIONS   32
 static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
@@ -50,8 +51,10 @@ int __init __weak 
early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
}
 
*res_base = base;
-   if (nomap)
+   if (nomap) {
+   kmemleak_no_scan(__va(base));
return memblock_remove(base, size);
+   }
return 0;
 }
 
-- 
2.1.4



[PATCH] of: reserved_mem: disable kmemleak scan on removed memory blocks

2018-11-08 Thread Prateek Patel
From: Sri Krishna chowdary 

Memory reserved with "nomap" DT property in of_reserved_mem.c
removes the memory block. The removed memory blocks don't have
VA to PA mapping created in kernel page table. Kmemleak scan on
removed memory blocks is causing page faults and leading to
kernel panic. So, Disable kmemleak scan on the removed memory
blocks.

Following is the observed crash log:
[  154.846370] Unable to handle kernel paging request at virtual address 
ffc070a0
<1>[  154.846576] Mem abort info:
<1>[  154.846635]   Exception class = DABT (current EL), IL = 32 bits
<1>[  154.846737]   SET = 0, FnV = 0
<1>[  154.846796]   EA = 0, S1PTW = 0
<1>[  154.846859] Data abort info:
<1>[  154.846913]   ISV = 0, ISS = 0x0006
<1>[  154.846983]   CM = 0, WnR = 0
<1>[  154.847053] swapper pgtable: 4k pages, 39-bit VAs, pgd = ff8009df7000
<1>[  154.847228] [ffc070a0] *pgd=00087fff5803, 
*pud=00087fff5803, *pmd=
<0>[  154.847408] Internal error: Oops: 9606 [#1] PREEMPT SMP
<4>[  154.847511] Modules linked in: nvs_led_test nvs_bmi160 nvs_cm3218 
nvs_bh1730fvc nvi_bmpX80 nvi_ak89xx nvi_mpu cdc_acm uas lr388k7_ts imx268 
imx318 imx204 imx274 imx185 lc898212 ov23850 ov10823 ov9281 ov5693 tc358840 
pca9570 nvs snd_soc_tegra_machine_driver_mobile lp855x_bl spidev input_cfboost 
pwm_tegra tegra_cryptodev tegra_se_nvhost tegra_se_elp tegra_se ghash_ce 
sha2_ce sha1_ce aes_ce_ccm cryptd nvgpu cpufreq_userspace 
snd_soc_tegra186_alt_dspk snd_soc_tegra186_alt_asrc snd_soc_tegra186_alt_arad 
snd_soc_tegra210_alt_ope snd_soc_tegra210_alt_mvc snd_soc_tegra210_alt_dmic 
snd_soc_tegra210_alt_amx snd_soc_tegra210_alt_adx snd_soc_tegra210_alt_afc 
snd_soc_tegra210_alt_mixer snd_soc_tegra210_alt_i2s snd_soc_tegra210_alt_sfc 
snd_soc_tegra210_alt_adsp snd_soc_tegra210_alt_admaif snd_soc_tegra210_alt_xbar
<4>[  154.882606]  snd_soc_tegra_alt_utils snd_hda_tegra
<4>[  154.888133] CPU: 2 PID: 8079 Comm: sh Not tainted 
4.14.53-tegra-05132-g9c33465 #2
<4>[  154.895983] Hardware name: e3360_1099 (DT)
<4>[  154.900447] task: ffc7d62dda00 task.stack: ff800e2b
<4>[  154.906502] PC is at scan_block+0x7c/0x148
<4>[  154.911234] LR is at scan_block+0x78/0x148
<4>[  154.915689] pc : [] lr : [] pstate: 
804000c9
<4>[  154.923290] sp : ff800e2b3b80
<4>[  154.927228] x29: ff800e2b3b80 x28: ffc7d62dda00
<4>[  154.932999] x27: ff8009aaa000 x26: ffc070c0
<4>[  154.938769] x25: 00c0 x24: ff8009d90608
<4>[  154.944287] x23: ffc7dc6c6000 x22: ff8009d9
<4>[  154.950320] x21: ff8009aeb320 x20: ffc070a00ff9
<4>[  154.955919] x19: ffc070a0 x18: bec4c3f2
<4>[  154.961438] x17: 002224777924 x16: ff80080bb0e0
<4>[  154.967124] x15:  x14: 0f75
<4>[  154.973069] x13: 000f x12: ffbf1e9f4240
<4>[  154.978670] x11: 0040 x10: 0ad0
<4>[  154.984107] x9 : ff800e2b3ab0 x8 : ffc7d62de530
<4>[  154.989958] x7 : 00078000 x6 : 0018
<4>[  154.995645] x5 :  x4 : 
<4>[  155.001245] x3 : ff8009aaa000 x2 : 0047f6712000
<4>[  155.006846] x1 : ffc7d1ae6900 x0 : 

Signed-off-by: Sri Krishna chowdary 
Signed-off-by: Prateek 
---
 drivers/of/of_reserved_mem.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 1977ee0..ac8f377 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAX_RESERVED_REGIONS   32
 static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
@@ -50,8 +51,10 @@ int __init __weak 
early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
}
 
*res_base = base;
-   if (nomap)
+   if (nomap) {
+   kmemleak_no_scan(__va(base));
return memblock_remove(base, size);
+   }
return 0;
 }
 
-- 
2.1.4