Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761026AbZDGPVm (ORCPT ); Tue, 7 Apr 2009 11:21:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758073AbZDGPKK (ORCPT ); Tue, 7 Apr 2009 11:10:10 -0400 Received: from one.firstfloor.org ([213.235.205.2]:41298 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759309AbZDGPKJ (ORCPT ); Tue, 7 Apr 2009 11:10:09 -0400 From: Andi Kleen References: <20090407509.382219156@firstfloor.org> In-Reply-To: <20090407509.382219156@firstfloor.org> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH] [7/16] POISON: Add basic support for poisoned pages in fault handler Message-Id: <20090407151004.2F5D21D0470@basil.firstfloor.org> Date: Tue, 7 Apr 2009 17:10:04 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2733 Lines: 79 - Add a new VM_FAULT_POISON error code to handle_mm_fault. Right now architectures have to explicitely enable poison page support, so this is forward compatible to all architectures. They only need to add it when they enable poison page support. - Add poison page handling in swap in fault code Signed-off-by: Andi Kleen --- include/linux/mm.h | 3 ++- mm/memory.c | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) Index: linux/mm/memory.c =================================================================== --- linux.orig/mm/memory.c 2009-04-07 16:39:24.000000000 +0200 +++ linux/mm/memory.c 2009-04-07 16:43:06.000000000 +0200 @@ -1315,7 +1315,8 @@ if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_OOM) return i ? i : -ENOMEM; - else if (ret & VM_FAULT_SIGBUS) + if (ret & + (VM_FAULT_POISON|VM_FAULT_SIGBUS)) return i ? i : -EFAULT; BUG(); } @@ -2426,8 +2427,15 @@ goto out; entry = pte_to_swp_entry(orig_pte); - if (is_migration_entry(entry)) { - migration_entry_wait(mm, pmd, address); + if (unlikely(non_swap_entry(entry))) { + if (is_migration_entry(entry)) { + migration_entry_wait(mm, pmd, address); + } else if (is_poison_entry(entry)) { + ret = VM_FAULT_POISON; + } else { + print_bad_pte(vma, address, pte, NULL); + ret = VM_FAULT_OOM; + } goto out; } delayacct_set_flag(DELAYACCT_PF_SWAPIN); @@ -2451,6 +2459,9 @@ /* Had to read the page from swap area: Major fault */ ret = VM_FAULT_MAJOR; count_vm_event(PGMAJFAULT); + } else if (PagePoison(page)) { + ret = VM_FAULT_POISON; + goto out; } lock_page(page); Index: linux/include/linux/mm.h =================================================================== --- linux.orig/include/linux/mm.h 2009-04-07 16:39:24.000000000 +0200 +++ linux/include/linux/mm.h 2009-04-07 16:43:05.000000000 +0200 @@ -702,11 +702,12 @@ #define VM_FAULT_SIGBUS 0x0002 #define VM_FAULT_MAJOR 0x0004 #define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ +#define VM_FAULT_POISON 0x0010 /* Hit poisoned page */ #define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ #define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS) +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_POISON) /* * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/