Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1706426
| From | Pasha Tatashin <pasha.tatashin@oracle.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [v6 11/15] arm64/kasan: explicitly zero kasan shadow memory |
| Date | 2017-08-08 14:00 +0200 |
| Message-ID | <ucbl0-7TS-33@gated-at.bofh.it> (permalink) |
| References | <ubX8m-5vB-5@gated-at.bofh.it> <ubX8n-5vB-47@gated-at.bofh.it> <uc8Gt-5Tu-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Will,
Thank you for looking at this change. What you described was in my
previous iterations of this project.
See for example here: https://lkml.org/lkml/2017/5/5/369
I was asked to remove that flag, and only zero memory in place when
needed. Overall the current approach is better everywhere else in the
kernel, but it adds a little extra code to kasan initialization.
Pasha
On 08/08/2017 05:07 AM, Will Deacon wrote:
> On Mon, Aug 07, 2017 at 04:38:45PM -0400, Pavel Tatashin wrote:
>> To optimize the performance of struct page initialization,
>> vmemmap_populate() will no longer zero memory.
>>
>> We must explicitly zero the memory that is allocated by vmemmap_populate()
>> for kasan, as this memory does not go through struct page initialization
>> path.
>>
>> Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
>> Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
>> Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
>> Reviewed-by: Bob Picco <bob.picco@oracle.com>
>> ---
>> arch/arm64/mm/kasan_init.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 42 insertions(+)
>>
>> diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c
>> index 81f03959a4ab..e78a9ecbb687 100644
>> --- a/arch/arm64/mm/kasan_init.c
>> +++ b/arch/arm64/mm/kasan_init.c
>> @@ -135,6 +135,41 @@ static void __init clear_pgds(unsigned long start,
>> set_pgd(pgd_offset_k(start), __pgd(0));
>> }
>>
>> +/*
>> + * Memory that was allocated by vmemmap_populate is not zeroed, so we must
>> + * zero it here explicitly.
>> + */
>> +static void
>> +zero_vmemmap_populated_memory(void)
>> +{
>> + struct memblock_region *reg;
>> + u64 start, end;
>> +
>> + for_each_memblock(memory, reg) {
>> + start = __phys_to_virt(reg->base);
>> + end = __phys_to_virt(reg->base + reg->size);
>> +
>> + if (start >= end)
>> + break;
>> +
>> + start = (u64)kasan_mem_to_shadow((void *)start);
>> + end = (u64)kasan_mem_to_shadow((void *)end);
>> +
>> + /* Round to the start end of the mapped pages */
>> + start = round_down(start, SWAPPER_BLOCK_SIZE);
>> + end = round_up(end, SWAPPER_BLOCK_SIZE);
>> + memset((void *)start, 0, end - start);
>> + }
>> +
>> + start = (u64)kasan_mem_to_shadow(_text);
>> + end = (u64)kasan_mem_to_shadow(_end);
>> +
>> + /* Round to the start end of the mapped pages */
>> + start = round_down(start, SWAPPER_BLOCK_SIZE);
>> + end = round_up(end, SWAPPER_BLOCK_SIZE);
>> + memset((void *)start, 0, end - start);
>> +}
>
> I can't help but think this would be an awful lot nicer if you made
> vmemmap_alloc_block take extra GFP flags as a parameter. That way, we could
> implement a version of vmemmap_populate that does the zeroing when we need
> it, without having to duplicate a bunch of the code like this. I think it
> would also be less error-prone, because you wouldn't have to do the
> allocation and the zeroing in two separate steps.
>
> Will
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[v6 00/15] complete deferred page initialization Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
[v6 09/15] sparc64: optimized struct page zeroing Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
Re: [v6 09/15] sparc64: optimized struct page zeroing Michal Hocko <mhocko@kernel.org> - 2017-08-11 15:00 +0200
Re: [v6 09/15] sparc64: optimized struct page zeroing Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-11 18:10 +0200
[v6 08/15] mm: zero struct pages during initialization Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
Re: [v6 08/15] mm: zero struct pages during initialization Michal Hocko <mhocko@kernel.org> - 2017-08-11 15:00 +0200
Re: [v6 08/15] mm: zero struct pages during initialization Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-11 18:10 +0200
[v6 07/15] mm: defining memblock_virt_alloc_try_nid_raw Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
Re: [v6 07/15] mm: defining memblock_virt_alloc_try_nid_raw Michal Hocko <mhocko@kernel.org> - 2017-08-11 14:50 +0200
Re: [v6 07/15] mm: defining memblock_virt_alloc_try_nid_raw Michal Hocko <mhocko@kernel.org> - 2017-08-11 18:10 +0200
Re: [v6 07/15] mm: defining memblock_virt_alloc_try_nid_raw Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-11 18:30 +0200
Re: [v6 07/15] mm: defining memblock_virt_alloc_try_nid_raw Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-11 18:10 +0200
[v6 10/15] x86/kasan: explicitly zero kasan shadow memory Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
[v6 05/15] mm: don't accessed uninitialized struct pages Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
Re: [v6 05/15] mm: don't accessed uninitialized struct pages Michal Hocko <mhocko@kernel.org> - 2017-08-11 11:40 +0200
Re: [v6 05/15] mm: don't accessed uninitialized struct pages Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-11 18:00 +0200
[v6 11/15] arm64/kasan: explicitly zero kasan shadow memory Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
Re: [v6 11/15] arm64/kasan: explicitly zero kasan shadow memory Will Deacon <will.deacon@arm.com> - 2017-08-08 11:10 +0200
Re: [v6 11/15] arm64/kasan: explicitly zero kasan shadow memory Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-08 14:00 +0200
Re: [v6 11/15] arm64/kasan: explicitly zero kasan shadow memory Will Deacon <will.deacon@arm.com> - 2017-08-08 14:40 +0200
Re: [v6 11/15] arm64/kasan: explicitly zero kasan shadow memory Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-08 15:00 +0200
RE: [v6 11/15] arm64/kasan: explicitly zero kasan shadow memory David Laight <David.Laight@ACULAB.COM> - 2017-08-08 15:20 +0200
Re: [v6 11/15] arm64/kasan: explicitly zero kasan shadow memory Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-08 15:40 +0200
[v6 13/15] mm: stop zeroing memory during allocation in vmemmap Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-08-07 22:50 +0200
Re: [v6 13/15] mm: stop zeroing memory during allocation in vmemmap Michal Hocko <mhocko@kernel.org> - 2017-08-11 15:10 +0200
Re: [v6 13/15] mm: stop zeroing memory during allocation in vmemmap Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-11 18:20 +0200
Re: [v6 00/15] complete deferred page initialization Michal Hocko <mhocko@kernel.org> - 2017-08-11 10:00 +0200
Re: [v6 00/15] complete deferred page initialization Pasha Tatashin <pasha.tatashin@oracle.com> - 2017-08-11 17:20 +0200
Re: [v6 00/15] complete deferred page initialization Michal Hocko <mhocko@kernel.org> - 2017-08-11 17:30 +0200
csiph-web