Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756571Ab2EYJaI (ORCPT ); Fri, 25 May 2012 05:30:08 -0400 Received: from mailxx.hitachi.co.jp ([133.145.228.50]:56045 "EHLO mailxx.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752586Ab2EYJaF (ORCPT ); Fri, 25 May 2012 05:30:05 -0400 X-AuditID: b753bd60-9b106ba000007aa1-a8-4fbf4c8c610c X-AuditID: b753bd60-9b106ba000007aa1-a8-4fbf4c8c610c From: YOSHIDA Masanori Subject: [RFC PATCH 1/4 V2] livedump: Add notifier-call-chain into do_page_fault To: "Thomas Gleixner" , "Ingo Molnar" , "H. Peter Anvin" , x86@kernel.org, "Vivek Goyal" , linux-kernel@vger.kernel.org Cc: "Andy Lutomirski" , "H. Peter Anvin" , "Ingo Molnar" , "Ingo Molnar" , "KOSAKI Motohiro" , "Kees Cook" , "Kevin Hilman" , "Peter Zijlstra" , "Prarit Bhargava" , "Rafael J. Wysocki" , "Tejun Heo" , "Thomas Gleixner" , linux-kernel@vger.kernel.org, x86@kernel.org, yrl.pp-manager.tt@hitachi.com Date: Fri, 25 May 2012 18:12:07 +0900 Message-ID: <20120525091207.10256.15550.stgit@t3500.sdl.hitachi.co.jp> In-Reply-To: <20120525091207.10256.18614.stgit@t3500.sdl.hitachi.co.jp> References: <20120525091207.10256.18614.stgit@t3500.sdl.hitachi.co.jp> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2227 Lines: 63 This patch adds notifier-call-chain that is called in do_page_fault. Livedump uses this to check if page fault is caused by livedump, and if so, the fault is handled by livedump's handler function. Otherwise, it is handled by the original page fault handler. Signed-off-by: YOSHIDA Masanori Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Andy Lutomirski Cc: Kees Cook Cc: KOSAKI Motohiro Cc: Prarit Bhargava Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/traps.h | 2 ++ arch/x86/mm/fault.c | 7 +++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index 88eae2a..dcd5318 100644 --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -114,4 +114,6 @@ enum { X86_TRAP_IRET = 32, /* 32, IRET Exception */ }; +extern struct atomic_notifier_head page_fault_notifier_list; + #endif /* _ASM_X86_TRAPS_H */ diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 3ecfd1a..f7460e2 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -995,6 +995,8 @@ static int fault_in_kernel_space(unsigned long address) return address >= TASK_SIZE_MAX; } +ATOMIC_NOTIFIER_HEAD(page_fault_notifier_list); + /* * This routine handles page faults. It determines the address, * and the problem, and then passes it off to one of the appropriate @@ -1018,6 +1020,11 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code) /* Get the faulting address: */ address = read_cr2(); + if (atomic_notifier_call_chain( + &page_fault_notifier_list, error_code, regs) + == NOTIFY_STOP) + return; + /* * Detect and handle instructions that would cause a page fault for * both a tracked kernel page and a userspace page. -- 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/