Re: [PATCH] x86: Implement __WARN using UD0
From: Peter Zijlstra
Date: Thu Feb 23 2017 - 10:24:16 EST
On Thu, Feb 23, 2017 at 07:09:05AM -0800, hpa@xxxxxxxxx wrote:
> Well, it only matters if the instruction extends past a segment
> boundary or page. However, the CPU instruction decoder will consume a
> modrm for UD1, and so using just the two opcode bytes may cause a #PF
> or #GP when a #UD was intended.
It also matters if you want the decoded instruction stream to make
If for instance I use UD1 without the ModRM byte for WARN, objtool gets
mighty confused because the instruction stream doesn't decode properly.
objtool will also consume the extra byte and then the next instruction
is offset and decodes wrong and it stresses out.
Similarly, if you were to do objdump (and objdump were to actually
correctly decode UD1) then the resulting asm would make no sense.
The kernel will work 'fine', because even without ModRM it will #UD, and
the #UD handler will IP+=2 and all is well, but it becomes impossible to
actually decode the function..