From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751460AbdBWPXv (ORCPT ); Thu, 23 Feb 2017 10:23:51 -0500 Received: from merlin.infradead.org ([205.233.59.134]:46866 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbdBWPXt (ORCPT ); Thu, 23 Feb 2017 10:23:49 -0500 Date: Thu, 23 Feb 2017 16:23:09 +0100 From: Peter Zijlstra To: hpa@zytor.com Cc: Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, arjan@linux.intel.com, bp@alien8.de, jpoimboe@redhat.com, richard.weinberger@gmail.com Subject: Re: [PATCH] x86: Implement __WARN using UD0 Message-ID: <20170223152309.GF6515@twins.programming.kicks-ass.net> References: <20170223132813.GB6515@twins.programming.kicks-ass.net> <20170223140929.GU6536@twins.programming.kicks-ass.net> <69617B03-BF08-4C25-9A82-6F01ABAB48DE@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <69617B03-BF08-4C25-9A82-6F01ABAB48DE@zytor.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 23, 2017 at 07:09:05AM -0800, hpa@zytor.com 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 sense. 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..