Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4374184ybi; Tue, 11 Jun 2019 05:44:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaMUauUgs8XJZLN6cx6xTOgUOIhuwP2um4wVveYIJJSJe9o6ANy4nx9tXgIBs0/MYmbQBW X-Received: by 2002:a62:e417:: with SMTP id r23mr47694860pfh.160.1560257063041; Tue, 11 Jun 2019 05:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560257063; cv=none; d=google.com; s=arc-20160816; b=ZFog1zJ66UlhpQYLtbh45DK6DGZSAOpZ29i4M7cx22K85XNM3dZ1mvcN/1Zb78IWdj mKwH8d2sZqzG7Um34DoE3arjSBia/31SZQZWY3ZM/RFfO2QDSq6lWJL5wf6AFzJmBfxp OQmT1hbwaoNGWo4iuTBAyNoigE+4OI7h3OW1bCtm85P1E/OZPeLxJisnSAQWT3bO8yG0 O64TujeLRqcbwOMMBgtSwWo6tnnJ8CGIz+7UA3qH4C5qsvnaHhiTj6PyowYNT/FylqnY HrPKqr8+/m2MViw0ib1FjsD2ZxVIR4OUDalYinbnrRK/5xwK9LvtYta2l8QSEUUUqiFV aWag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Kp1pRRfoumgY4Up20rnCQcSt99FXk8xSho/xLyWE55U=; b=d0tiYfSg1G7b1TJ2xZaTlnrufuDe3bfbE/ECOgsYmm9/oDsRpQ37feSIJMuwnTaPs9 5n66jgernhUY3Ny5YD+Bm8Z6x+cdjgnXq8og1rWf0GlHFbq8cJbHUWPppEKIC1L2znoO ChZNYND/dK5LbQKAnHDZdRSVKp0M5fuKqJjANcXrQa+WFDTWXepmgYGLMnOP2ENsqHOH YtsWkEKyeImwXGuXVYz9gBjQE6ncwQuNNmZv+tzq+qvIbGvG1ELOkHP09+wabUxvm/qr uPLSslRx/Aejng6WbfuiiTy1aVzppcMSR5CxtbqrrbXMaQ6ZSoIERkHAm3qXPBaA1Wun UJAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=AdTA9RyM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si12162019pfb.45.2019.06.11.05.44.06; Tue, 11 Jun 2019 05:44:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=AdTA9RyM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387814AbfFKMnZ (ORCPT + 99 others); Tue, 11 Jun 2019 08:43:25 -0400 Received: from merlin.infradead.org ([205.233.59.134]:54306 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727733AbfFKMnY (ORCPT ); Tue, 11 Jun 2019 08:43:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Kp1pRRfoumgY4Up20rnCQcSt99FXk8xSho/xLyWE55U=; b=AdTA9RyM7eWaOsI2SHx4yq+J+ rQ+xaOkv9SClS4rtoCSqSWfHswNqwGONVngTCv9JhZEyxcyCvBv3RiW8Ggz+0TIrRJGh81Z4CdGrP 4m9yvmNHj02qf3WnCwGGeulWfD4jKlGvWfNDldXMWDEhfDCB4/gSClS+vzYXEh/1e4PbALkTEn5QY E2zxChDB3zdImVaeHQAKnU3obf+8oDkiH/73osCNlhtle8w98vrjjrPQQ+q/MNLXAG2thJgRLgBBQ mO6N+yofbrgzwo3/K+Le0kNTDdsQkm2zRWgYCsTEKDEeTr8/IicojwrRGlH5qgqnRGqfpmI7VRZeF bNmUdPpUA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hag6s-0004Y7-ES; Tue, 11 Jun 2019 12:42:42 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E97F720224753; Tue, 11 Jun 2019 14:42:40 +0200 (CEST) Date: Tue, 11 Jun 2019 14:42:40 +0200 From: Peter Zijlstra To: Andy Lutomirski Cc: Masami Hiramatsu , x86@kernel.org, linux-kernel@vger.kernel.org, Ard Biesheuvel , Andy Lutomirski , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , "H. Peter Anvin" , Nadav Amit , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira Subject: Re: [PATCH 08/15] x86/alternatives: Teach text_poke_bp() to emulate instructions Message-ID: <20190611124240.GI3463@hirez.programming.kicks-ass.net> References: <20190605130753.327195108@infradead.org> <20190605131945.005681046@infradead.org> <20190608004708.7646b287151cf613838ce05f@kernel.org> <20190607173427.GK3436@hirez.programming.kicks-ass.net> <3DA961AB-950B-4886-9656-C0D268D521F1@amacapital.net> <20190611080307.GN3436@hirez.programming.kicks-ass.net> <20190611120834.GG3463@hirez.programming.kicks-ass.net> <20190611123402.GH3463@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611123402.GH3463@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 02:34:02PM +0200, Peter Zijlstra wrote: > Bugger, this isn't right. It'll jump to the beginning of the trampoline, > even if it is multiple instructions in, which would lead to executing > instructions twice, which would be BAD. > > _maybe_, depending on what the slot looks like, we could do something > like: > > offset = regs->ip - (unsigned long)bp_int3_addr; > regs->ip = bp_int3_handler + offset; > > That is; jump into the slot at the same offset we hit the INT3, but this > is quickly getting yuck. Yeah, that won't work either... it needs something far more complex :/