[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190429081246.GT3584@localhost.localdomain>
Date: Mon, 29 Apr 2019 16:12:46 +0800
From: Baoquan He <bhe@...hat.com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org, tglx@...utronix.de,
mingo@...nel.org, bp@...en8.de, hpa@...or.com,
kirill.shutemov@...ux.intel.com, keescook@...omium.org,
peterz@...radead.org, thgarnie@...gle.com,
herbert@...dor.apana.org.au, mike.travis@....com,
frank.ramsay@....com, yamada.masahiro@...ionext.com
Subject: Re: [PATCH v3 RESEND 2/2] x86/mm/KASLR: Fix the size of vmemmap
section
On 04/28/19 at 09:54pm, Kirill A. Shutemov wrote:
> > @@ -109,6 +110,14 @@ void __init kernel_randomize_memory(void)
> > if (memory_tb < kaslr_regions[0].size_tb)
> > kaslr_regions[0].size_tb = memory_tb;
> >
> > + /**
>
> Nit: that is weird style for inline comment.
Right, will fix.
Thanks a lot for reviewing.
>
> > + * Calculate how many TB vmemmap region needs, and aligned to
> > + * 1TB boundary.
> > + */
> > + vmemmap_size = (kaslr_regions[0].size_tb << (TB_SHIFT - PAGE_SHIFT)) *
> > + sizeof(struct page);
>
> Hm. Don't we need to take into account alignment requirements for struct
> page here? I'm worried about some exotic debug kernel config where
> sizeof(struct page) doesn't satify __alignof__(struct page).
I know sizeof(struct page) has handled its own struct alignment and
padding. About __alignof__(struct page), will it conflict with below
code to convert pfn < -- > page? Not sure if I got your point.
#elif defined(CONFIG_SPARSEMEM_VMEMMAP)
/* memmap is virtually contiguous. */
#define __pfn_to_page(pfn) (vmemmap + (pfn))
#define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
#elif...
>
> > + kaslr_regions[2].size_tb = DIV_ROUND_UP(vmemmap_size, 1UL << TB_SHIFT);
> > +
> > /* Calculate entropy available between regions */
> > remain_entropy = vaddr_end - vaddr_start;
> > for (i = 0; i < ARRAY_SIZE(kaslr_regions); i++)
> --
> Kirill A. Shutemov
Powered by blists - more mailing lists