commit 272793dcb989fc1ff2caaa9519f8f1ea5434b578 Author: Juergen Gross Date: Wed May 11 07:53:54 2016 +0200 xen: register early page fault handler In early boot of dom0 accesses to the sparse m2p list of the hypervisor can result in unhandled page faults as the #PF handler handling this case via exception table isn't yet registered. Install a primitive early page fault handler for this case. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 858b555..a20ea98 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -911,6 +911,7 @@ idtentry stack_segment do_stack_segment has_error_code=1 idtentry xen_debug do_debug has_error_code=0 idtentry xen_int3 do_int3 has_error_code=0 idtentry xen_stack_segment do_stack_segment has_error_code=1 +idtentry xen_page_fault xen_do_page_fault has_error_code=1 #endif idtentry general_protection do_general_protection has_error_code=1 diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index c3496619..f91cb3f 100644 --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -16,6 +16,7 @@ asmlinkage void int3(void); asmlinkage void xen_debug(void); asmlinkage void xen_int3(void); asmlinkage void xen_stack_segment(void); +asmlinkage void xen_page_fault(void); asmlinkage void overflow(void); asmlinkage void bounds(void); asmlinkage void invalid_op(void); @@ -54,6 +55,7 @@ asmlinkage void trace_page_fault(void); #define trace_alignment_check alignment_check #define trace_simd_coprocessor_error simd_coprocessor_error #define trace_async_page_fault async_page_fault +#define trace_xen_page_fault xen_page_fault #endif dotraplinkage void do_divide_error(struct pt_regs *, long); @@ -74,6 +76,7 @@ asmlinkage struct pt_regs *sync_regs(struct pt_regs *); #endif dotraplinkage void do_general_protection(struct pt_regs *, long); dotraplinkage void do_page_fault(struct pt_regs *, unsigned long); +dotraplinkage void xen_do_page_fault(struct pt_regs *, unsigned long); #ifdef CONFIG_TRACING dotraplinkage void trace_do_page_fault(struct pt_regs *, unsigned long); #else diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 7ab2951..eaee9d3 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -17,7 +17,10 @@ #include #include #include +#include #include +#include +#include #include #include @@ -1067,4 +1070,19 @@ void __init xen_arch_setup(void) #ifdef CONFIG_NUMA numa_off = 1; #endif + + sort_main_extable(); + set_intr_gate(X86_TRAP_PF, xen_page_fault); +} + +/* + * Early page fault handler being capable to handle page faults resulting + * from accesses via xen_safe_read_ulong(). + * This page fault handler will be active in early boot only. It is being + * replaced by the default page fault handler later. + */ +dotraplinkage void notrace +xen_do_page_fault(struct pt_regs *regs, unsigned long error_code) +{ + fixup_exception(regs, X86_TRAP_PF); }