Re: [PATCH] x86: Implement __WARN using UD0

From: Josh Poimboeuf
Date: Thu Feb 23 2017 - 09:12:52 EST

On Thu, Feb 23, 2017 at 02:28:13PM +0100, Peter Zijlstra wrote:
> +/*
> + * Only UD2 is defined in the Intel SDM and AMD64 docs,
> + * but the interweb provided UD0 and UD1:
> + *
> + *!topic/alt.os.assembly/_rS4L0fnqGE

FYI, the latest Intel SDM does have UD0 and UD1.

I guess AMD64 and hypervisors don't need to know about it, since if they
don't, it will still trigger the same invalid opcode exception anyway?

Any idea what the functional difference is between UD0 and UD2?

> + * Since some emulators terminate on UD2, we cannot use it for WARN.

That's too bad, which emulators are those?

> + * Since various instruction decoders disagree on the length of UD1,
> + * we cannot use it either. So use UD0 for WARN.

It shows up as "(bad)" in objtool and gdb, though it still gets the
length right:

8b9: 0f ff (bad)

It would be nice if the tools knew about it...