Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic jump patching without stop_machine

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mathieu Desnoyers
Date: Monday, January 18, 2010 - 9:52 am

* H. Peter Anvin (hpa@zytor.com) wrote:

The additional characteristic of the int3 instruction (compared to the
general case of a single-byte instruction) is that, when executed, it
will trigger a trap, run a trap handler and return to the original code,
typically with iret. This therefore implies that a serializing
instruction is executed before returning to the instructions following
the modification site when the breakpoint is hit.

So I hand out to Intel's expertise the question of whether single-byte
instruction modification is safe or not in the general case. I'm just
pointing out that I can very well imagine an aggressive superscalar
architecture for which pipeline structure would support single-byte int3
patching without any problem due to the implied serialization, but would
not support the general-case single-byte modification due to its lack of
serialization.

As we might have to port this algorithm to Itanium in a near future, I
prefer to stay on the safe side. Intel's "by the book" recommendation is
more or less that a serializing instruction must be executed on all CPUs
before new code is executed, without mention of single-vs-multi byte
instructions. The int3-based bypass follows this requirement, but the
single-byte code patching does not.

Unless there is a visible performance gain to special-case the
single-byte instruction, I would recommend to stick to the safest
solution, which follows Intel "official" guide-lines too.

Thanks,

Mathieu


-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH 0/8] jump label v4 , Jason Baron, (Tue Jan 12, 9:26 am)
[RFC PATCH 5/8] jump label v4 - base patch, Jason Baron, (Tue Jan 12, 9:26 am)
[RFC PATCH 6/8] jump label v4 - x86 support, Jason Baron, (Tue Jan 12, 9:26 am)
[RFC PATCH 7/8] jump label v4 - tracepoint support, Jason Baron, (Tue Jan 12, 9:26 am)
[RFC PATCH 8/8] jump label v4 - add module support, Jason Baron, (Tue Jan 12, 9:26 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Tue Jan 12, 7:06 pm)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Masami Hiramatsu, (Tue Jan 12, 10:38 pm)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Wed Jan 13, 7:30 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Masami Hiramatsu, (Wed Jan 13, 11:57 pm)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Thu Jan 14, 8:39 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Masami Hiramatsu, (Thu Jan 14, 11:45 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Sun Jan 17, 11:55 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Arjan van de Ven, (Sun Jan 17, 12:16 pm)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Mon Jan 18, 9:52 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Mon Jan 18, 9:54 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Masami Hiramatsu, (Mon Jan 18, 11:21 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Mon Jan 18, 11:33 am)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Mon Jan 18, 2:32 pm)
Re: [RFC PATCH 2/8] jump label v4 - x86: Introduce generic ..., Mathieu Desnoyers, (Tue Apr 13, 10:16 am)