Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754971Ab3GJWjN (ORCPT ); Wed, 10 Jul 2013 18:39:13 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49429 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754695Ab3GJWjM (ORCPT ); Wed, 10 Jul 2013 18:39:12 -0400 Date: Thu, 11 Jul 2013 00:39:07 +0200 (CEST) From: Jiri Kosina To: "H. Peter Anvin" Cc: Masami Hiramatsu , Steven Rostedt , Jason Baron , Borislav Petkov , linux-kernel@vger.kernel.org Subject: Re: [RFC] [PATCH 1/2 v2] x86: introduce int3-based instruction patching In-Reply-To: <51DDD3E9.6090601@linux.intel.com> Message-ID: References: <51DDD3E9.6090601@linux.intel.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1562 Lines: 35 On Wed, 10 Jul 2013, H. Peter Anvin wrote: > > If any CPU instruction execution would collide with the patching, > > it'd be trapped by the int3 breakpoint and redirected to the provided > > "handler" (which would typically mean just skipping over the patched > > region, acting as "nop" has been there, in case we are doing nop -> jump > > and jump -> nop transitions). > > > > I'm wondering if it would be easier/more general to just return to the > instruction. The "more general" bit would allow this to be used for > other things, like alternatives, and perhaps eventually dynamic call > patching. Interesting idea ... This should be very easily done by just setting the "handler" to the exact address that is being patched, and it'll work exactly the way you are proposing, no? > Returning to the instruction will, in effect, be a busy-wait for the > faulted CPU until the patch is complete; more or less what stop_machine > would do, but only for a CPU which actually strays into the affected region. Exactly ... so the special case I am introducing for jump labels in 2/2 (i.e. implicitly behaving like there was a nop) is an optimized one, but can be easily turned into busy loop by just redirecting the "handler" one instruction back in cases where it'd be desirable. -- Jiri Kosina SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/