Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 660a293e authored by Shaohua Li's avatar Shaohua Li Committed by H. Peter Anvin
Browse files

x86, mm: Make spurious_fault check explicitly check the PRESENT bit



pte_present() returns true even present bit isn't set but _PAGE_PROTNONE
(global bit) bit is set. While with CONFIG_DEBUG_PAGEALLOC, free pages have
global bit set but present bit clear. This patch makes we could catch
free pages access with CONFIG_DEBUG_PAGEALLOC enabled.

[ hpa: added a comment in the code as a warning to janitors ]

Signed-off-by: default avatarShaohua Li <shaohua.li@intel.com>
LKML-Reference: <1280217988.32400.75.camel@sli10-desk.sh.intel.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 9b861528
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -872,8 +872,14 @@ spurious_fault(unsigned long error_code, unsigned long address)
	if (pmd_large(*pmd))
	if (pmd_large(*pmd))
		return spurious_fault_check(error_code, (pte_t *) pmd);
		return spurious_fault_check(error_code, (pte_t *) pmd);


	/*
	 * Note: don't use pte_present() here, since it returns true
	 * if the _PAGE_PROTNONE bit is set.  However, this aliases the
	 * _PAGE_GLOBAL bit, which for kernel pages give false positives
	 * when CONFIG_DEBUG_PAGEALLOC is used.
	 */
	pte = pte_offset_kernel(pmd, address);
	pte = pte_offset_kernel(pmd, address);
	if (!pte_present(*pte))
	if (!(pte_flags(*pte) & _PAGE_PRESENT))
		return 0;
		return 0;


	ret = spurious_fault_check(error_code, pte);
	ret = spurious_fault_check(error_code, pte);