Re: [PATCH v2 2/3] x86/mm/KASLR: Calculate the actual size of vmemmap region
From: Baoquan He
Date: Tue Sep 11 2018 - 03:31:04 EST
On 09/10/18 at 08:11am, Ingo Molnar wrote:
> * Baoquan He <bhe@xxxxxxxxxx> wrote:
> > @@ -108,6 +109,14 @@ void __init kernel_randomize_memory(void)
> > if (memory_tb < kaslr_regions.size_tb)
> > kaslr_regions.size_tb = memory_tb;
> > + /*
> > + * Calculate how many TB vmemmap region needs, and align to
> > + * 1TB boundary.
> > + * */
> Yeah, so that's not the standard comment style ...
Sorry for this, Will change. Thanks.
About clean up you suggested, I have made two patches and paste them at
below. Please help check if it's OK. Thanks a lot.
> So I get the part where the 'base' pointer is essentially pointers to various global variables
> used by the MM to get the virtual base address of the kernel, vmalloc and vmemmap areas from,
> which base addresses can thus be modified by the very early KASLR code to dynamically shape the
> virtual memory layout of these kernel memory areas on a per bootup basis.
> (BTW., that would be a great piece of information to add for the uninitiated. It's not like
> it's obvious!)
> But what does 'size_tb' do? Nothing explains it and your patch doesn't make it clearer either.
> Also, get_padding() looks like an unnecessary layer of obfuscation:
Yes, I agree. Have made an patch according to your suggestion, paste