From 0f38bd9206820fd0b4a3969561fae6a5c674408a Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 30 Jan 2008 13:34:04 +0100 Subject: [PATCH] --- yaml --- r: 80499 b: refs/heads/master c: 687c4825b6ccab69b85f266ae925500b27aab6c2 h: refs/heads/master i: 80497: e966604032a1a60e700f97cd392d69614c4a00f2 80495: 3ff01ccadad051b5056072bd74ed594fc1ac38e9 v: v3 --- [refs] | 2 +- trunk/arch/x86/mm/pageattr.c | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index b62114d0f27c..2d5175290d3c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 30551bb3ce9257a2352b3cb4e45010d415cc0ad5 +refs/heads/master: 687c4825b6ccab69b85f266ae925500b27aab6c2 diff --git a/trunk/arch/x86/mm/pageattr.c b/trunk/arch/x86/mm/pageattr.c index 4589a1382fa1..effcd78d5f40 100644 --- a/trunk/arch/x86/mm/pageattr.c +++ b/trunk/arch/x86/mm/pageattr.c @@ -22,6 +22,27 @@ void clflush_cache_range(void *addr, int size) #include #include +/* + * We allow the BIOS range to be executable: + */ +#define BIOS_BEGIN 0x000a0000 +#define BIOS_END 0x00100000 + +static inline pgprot_t check_exec(pgprot_t prot, unsigned long address) +{ + if (__pa(address) >= BIOS_BEGIN && __pa(address) < BIOS_END) + pgprot_val(prot) &= ~_PAGE_NX; + /* + * Better fail early if someone sets the kernel text to NX. + * Does not cover __inittext + */ + BUG_ON(address >= (unsigned long)&_text && + address < (unsigned long)&_etext && + (pgprot_val(prot) & _PAGE_NX)); + + return prot; +} + pte_t *lookup_address(unsigned long address, int *level) { pgd_t *pgd = pgd_offset_k(address); @@ -140,13 +161,7 @@ __change_page_attr(unsigned long address, struct page *page, pgprot_t prot) BUG_ON(PageLRU(kpte_page)); BUG_ON(PageCompound(kpte_page)); - /* - * Better fail early if someone sets the kernel text to NX. - * Does not cover __inittext - */ - BUG_ON(address >= (unsigned long)&_text && - address < (unsigned long)&_etext && - (pgprot_val(prot) & _PAGE_NX)); + prot = check_exec(prot, address); if (level == PG_LEVEL_4K) { set_pte_atomic(kpte, mk_pte(page, canon_pgprot(prot)));