From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751291AbdBXJnV convert rfc822-to-8bit (ORCPT ); Fri, 24 Feb 2017 04:43:21 -0500 Received: from terminus.zytor.com ([65.50.211.136]:51972 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbdBXJnM (ORCPT ); Fri, 24 Feb 2017 04:43:12 -0500 Date: Fri, 24 Feb 2017 01:06:54 -0800 User-Agent: K-9 Mail for Android In-Reply-To: <20170224083115.GK6515@twins.programming.kicks-ass.net> References: <20170223132813.GB6515@twins.programming.kicks-ass.net> <20170223145751.GE6515@twins.programming.kicks-ass.net> <20170224074325.GA4095@gmail.com> <20170224083115.GK6515@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH] x86: Implement __WARN using UD0 To: Peter Zijlstra , Ingo Molnar CC: Arjan van de Ven , Thomas Gleixner , linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, bp@alien8.de, jpoimboe@redhat.com, richard.weinberger@gmail.com, Andrew Morton From: hpa@zytor.com Message-ID: <09556880-A22B-4767-89B3-D2B2FCEBC9F5@zytor.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On February 24, 2017 12:31:15 AM PST, Peter Zijlstra wrote: >On Fri, Feb 24, 2017 at 08:43:25AM +0100, Ingo Molnar wrote: >> The only high level question is whether we trust the trap machinery >to generate >> WARN_ON()s. I believe we do. >> >> BTW.: why not use INT3 instead of all these weird #UD opcodes? It's a >single byte >> opcode and we can do a quick exception table search in do_debug(). >This way we'll >> also have irqs disabled which might help getting the message out >before any irq >> handler comes in and muddies the waters. >> >> In a sense WARN_ON()s and BUG_ON()s can be considered permanently >installed >> in-line kprobes, with a special, built-in handler. > >I've actually been looking into that. There's a bunch of 'fun' details >that I've been checking, but I think I can make that happen. > >My initial patch extended the existing UD2 BUG trap to include the >WARN, >this is what many other architectures already do. Arjan then complained >that some emulators terminate on UD2 and could I please not use that >for >WARN, at which point Borislav called my attention to UD0/UD1. > >So I made the UD0 change and posted (fwiw, there's a lost refresh in >the >patch I posted and it will not actually work). > >I think I'll post an update of said patch and then attempt to do the >INT3 thing in a later patch -- that will require at least one new knob >in the generic BUG code ... > >> BTW. #2: side note, GCC generated crap code here. Why didn't it do: > >I've seen GCC do 'wonderful' things the past few weeks. Absolutely mind >boggling stuff. Terminating on UD2 is really obnoxious, btw. JMPE, ICEBP/INT1, some I/O port or MSR would be appropriate choices for that, but UD2 is rude in the extreme. -- Sent from my Android device with K-9 Mail. Please excuse my brevity.