Hi Thomas,

On Sun, Sep 16, 2018 at 04:43:55PM +0200, Thomas Gleixner wrote:
> On Sun, 16 Sep 2018, Feng Tang wrote:
> > diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
> > index e848a4811785..a927f5f39bee 100644
> > --- a/arch/x86/mm/pgtable.c
> > +++ b/arch/x86/mm/pgtable.c
> > @@ -637,6 +637,16 @@ void __native_set_fixmap(enum fixed_addresses idx, 
> > pte_t pte)
> >  {
> >     unsigned long address = __fix_to_virt(idx);
> >  
> > +#ifdef CONFIG_X86_64
> > +       /*
> > +        * In arch/x86/kernel/head_64.S, the static page table has
> > +   * been setup for fixmap. Add a sanity compiling check
> > +   * whether fixmap space has exceeded the capacity.
> > +        */
> > +       BUILD_BUG_ON((__end_of_permanent_fixed_addresses + 511)/512
> > +                       > FIXMAP_PMD_NUM);
> 
> There exist macros for rounding up and doing this in the header file is
> perfectly fine.

I'll find the sample for the round up.

And for the header file check, I initially put this check directly in
the fixmap.h like:

#if ((__end_of_permanent_fixed_addresses + 511)/512 > FIXMAP_PMD_NUM)
#erro "some warning...."
#endif

But failed to compile, I got the warning
 warning: "__end_of_permanent_fixed_addresses" is not defined

 I guess the header file preprocessing can't handle it.

> 
> > +#endif
> > +
> >     if (idx >= __end_of_fixed_addresses) {
> >             BUG();
> >             return;
> > diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
> > index 45b700ac5fe7..b0aa2364a3c6 100644
> > --- a/arch/x86/xen/mmu_pv.c
> > +++ b/arch/x86/xen/mmu_pv.c
> > @@ -1953,7 +1953,10 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, 
> > unsigned long max_pfn)
> >     set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
> >     set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
> >     set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
> > -   set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
> > +
> > +   for (i = 0; i < FIXMAP_PMD_NUM; i++)
> > +           set_page_prot(level1_fixmap_pgt + i * 512,
> > +                           PAGE_KERNEL_RO);
> 
> The line break is there because?
Will fix it. I used a MACRO before changing to 512  and forgot to remove
the line break :) 

Thanks,
Feng

Reply via email to