Re: [PATCH v2] x86, mm: set NX across entire PMD at boot

From: Thomas Gleixner
Date: Sun Nov 16 2014 - 16:26:52 EST


On Sat, 15 Nov 2014, Yinghai Lu wrote:
> +static pmd_t *last_pmd;
> /*
> * The head.S code sets up the kernel high mapping:
> *
> @@ -408,9 +409,26 @@ void __init cleanup_highmap(void)
> continue;
> if (vaddr < (unsigned long) _text || vaddr > end)
> set_pmd(pmd, __pmd(0));
> + else
> + last_pmd = pmd;

Why do you need to store this? You can compute this.

> +static void __init cleanup_highmap_tail(unsigned long addr)

Brilliant stuff. mark_rodata_ro() is called AFTER free_initmem() which
will free exactly that code.

> +{
> + int i;
> + pte_t *pte;
> +
> + if (!last_pmd || pmd_none(*last_pmd))
> + return;

Aside of the above: This is complete and utter crap. Just another
useless function which can be avoided by switching on brain before
coding.

> Index: linux-2.6/arch/x86/mm/pageattr.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/mm/pageattr.c
> +++ linux-2.6/arch/x86/mm/pageattr.c
> @@ -100,7 +100,7 @@ static inline unsigned long highmap_star
>
> static inline unsigned long highmap_end_pfn(void)
> {
> - return __pa_symbol(roundup(_brk_end, PMD_SIZE)) >> PAGE_SHIFT;
> + return __pa_symbol(PFN_ALIGN(_brk_end)) >> PAGE_SHIFT;
> }

Wrong as well for CONFIG_DEBUG_RODATA=n for obvious reasons.

I know why I have your patches on blacklist ....

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/