Skip to contentSkip to conversation

x86: Remove nx_enabled from fault.c

PATCH Applied Harvey Harrison 2 participants 2 messages Jan 25, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Remove nx_enabled from fault.c

On !PAE 32-bit, _PAGE_NX will be 0, making is_prefetch always return early. The test is sufficient on PAE as __supported_pte_mask is updated in the same places as nx_enabled in init_32.c which also takes disable_nx into account.

---
 arch/x86/mm/fault.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)
arch/x86/mm/fault.c +4 -9
index bdf0282..32755eb 100644
@@ -92,18 +92,13 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
 	unsigned char *max_instr;
 
 #ifdef CONFIG_X86_32
-# ifdef CONFIG_X86_PAE
-	/* If it was a exec fault on NX page, ignore */
-	if (nx_enabled && (error_code & PF_INSTR))
+	if (!(__supported_pte_mask & _PAGE_NX))
 		return 0;
-# else
-	return 0;
-# endif
-#else /* CONFIG_X86_64 */
+#endif
+
 	/* If it was a exec fault on NX page, ignore */
 	if (error_code & PF_INSTR)
 		return 0;
-#endif
 
 	instr = (unsigned char *)convert_ip_to_linear(current, regs);
 	max_instr = instr + 15;
@@ -468,7 +463,7 @@ static int vmalloc_fault(unsigned long address)
 	pmd_t *pmd, *pmd_ref;
 	pte_t *pte, *pte_ref;
 
-	if (address >= VMALLOC_START && address < VMALLOC_END)
+	if (!(address >= VMALLOC_START && address < VMALLOC_END))
 		return -1;
 
 	/* Copy kernel mappings over when needed. This can also
Signature · 1 line
1.5.4.rc4.1142.gf5a97
Applied
#1 lore raw
Quoted 10 lines · Harvey Harrison

On !PAE 32-bit, _PAGE_NX will be 0, making is_prefetch always return early. The test is sufficient on PAE as __supported_pte_mask is updated in the same places as nx_enabled in init_32.c which also takes disable_nx into account.

arch/x86/mm/fault.c +0 -1
@@ -92,18 +92,13 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
 	unsigned char *max_instr;
 
 #ifdef CONFIG_X86_32
-# ifdef CONFIG_X86_PAE

arch/x86/mm/fault.c static int is_prefetch(struct pt_regs *regs, unsigned long addr, · line 98

Quoted 10 lines
arch/x86/mm/fault.c +3 -6
-	/* If it was a exec fault on NX page, ignore */
-	if (nx_enabled && (error_code & PF_INSTR))
+	if (!(__supported_pte_mask & _PAGE_NX))
 		return 0;
-# else
-	return 0;
-# endif
-#else /* CONFIG_X86_64 */
+#endif
+

thanks, applied this portion of the patch.

arch/x86/mm/fault.c static int vmalloc_fault(unsigned long address) · line 467

Quoted 7 lines
arch/x86/mm/fault.c +1 -1
@@ -468,7 +463,7 @@ static int vmalloc_fault(unsigned long address)
 	pmd_t *pmd, *pmd_ref;
 	pte_t *pte, *pte_ref;
 
-	if (address >= VMALLOC_START && address < VMALLOC_END)
+	if (!(address >= VMALLOC_START && address < VMALLOC_END))
 		return -1;

hm, what's this?

Ingo