On Tue, Mar 04, 2014 at 04:03:25PM -0800, tip-bot for Jiri Olsa wrote:

FWIW I also prefer this patch.

> @@ -1252,9 +1249,11 @@ dotraplinkage void __kprobes
>  do_page_fault(struct pt_regs *regs, unsigned long error_code)
>  {
>       enum ctx_state prev_state;
> +     /* Get the faulting address: */
> +     unsigned long address = read_cr2();
>  
>       prev_state = exception_enter();
> -     __do_page_fault(regs, error_code);
> +     __do_page_fault(regs, error_code, address);
>       exception_exit(prev_state);
>  }
>  
> @@ -1271,9 +1270,16 @@ dotraplinkage void __kprobes
>  trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
>  {
>       enum ctx_state prev_state;
> +     /*
> +      * The exception_enter and tracepoint processing could
> +      * trigger another page faults (user space callchain
> +      * reading) and destroy the original cr2 value, so read
> +      * the faulting address now.
> +      */
> +     unsigned long address = read_cr2();
>  
>       prev_state = exception_enter();
>       trace_page_fault_entries(regs, error_code);
> -     __do_page_fault(regs, error_code);
> +     __do_page_fault(regs, error_code, address);
>       exception_exit(prev_state);
>  }

How about also marking these two functions as notrace? That would also
avoid getting __mcount calls from before we read CR2.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to