Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4970235imu; Tue, 15 Jan 2019 08:59:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN7d8Zf9Iw67hFwDp8i6uI+5ffMsoazuyKjsIQF0HHI8YyGZd1/9dR8U/khgeHqwn5rDvozV X-Received: by 2002:a62:938f:: with SMTP id r15mr4958315pfk.27.1547571555692; Tue, 15 Jan 2019 08:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547571555; cv=none; d=google.com; s=arc-20160816; b=ukh4jFcRwBqkZG3j/FC1Ss7v53VAe8c8kn7FBZxzp5LJpsjJuxCC4KRPzPMMTMadWm rG1s4cq+9A/bTQpjz5XNr+SxBP17Xdm/4TaPK5HzWizPf8v9QoEHQ9lCqIlA2SdrEhA5 75mdNy3D5cfS3OPDY8wZz9O3j5/OtaZEpOFvuM0yQ5BCxs4fUhGwpwadkNmh3l0Ddu1/ NlvfIY4Ijr4eTGDSDPXat0+DnpXrdRpZIEpErrVQoPQQdB8M/5wKQuIeR6xpncSU10r0 O6Lmqv6/XOPCOKjCZD+Ffs5wG8gJG4wsbI6BO5tN4bUm3Lyd0OvkASGIgiLekGk4ffGW Gqkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=0d4rmnreDWN6wHVpI/l4pVHwVEOTGjFFrdSl9O3sUCw=; b=RAxwQkI8PpW29i4QuKD5Eh0jWgttC/gJSK8Upn9JvPMvn6MdzjnTem24y6zXUbgXUj NMoW/+a5mxn8M0UpCbIORqE8ab7idXxOX5EZqobLb3FLavXE9htvI9/HrhRjQKw3nl66 eNFPuSMqA/5G2hKGrXVVu7WSD20tKd7TxabpBRWdmqLX+bs1EZHYavT4BasCKjKnAD90 cXQ4BiNWSl6Hm4PM99T37No9bTNkAhfEb5B7qOjM70WoOHwSqgB/bcNM/9g/qgbIsXIw tDmqFXS0A0XT9HKzQr5GpCjHy6fvGGwupSMHpNdHYOfZgjwT7NeT3Vwl6UKh7Wgp79gn GLBw== ARC-Authentication-Results: i=1; mx.google.com; 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 37si3784423pgw.590.2019.01.15.08.59.00; Tue, 15 Jan 2019 08:59:15 -0800 (PST) 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; 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 S1729363AbfAOQT0 (ORCPT + 99 others); Tue, 15 Jan 2019 11:19:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:44002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727626AbfAOQT0 (ORCPT ); Tue, 15 Jan 2019 11:19:26 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B936620657; Tue, 15 Jan 2019 16:19:23 +0000 (UTC) Date: Tue, 15 Jan 2019 11:19:22 -0500 From: Steven Rostedt To: Alexandre Chartre Cc: Josh Poimboeuf , Sean Christopherson , Nadav Amit , X86 ML , LKML , Ard Biesheuvel , Andy Lutomirski , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , "H. Peter Anvin" , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira Subject: Re: [PATCH v3 5/6] x86/alternative: Use a single access in text_poke() where possible Message-ID: <20190115111922.153240f0@gandalf.local.home> In-Reply-To: <49f9bb3d-7b65-06e8-b0b3-42cf7f0a82b5@oracle.com> References: <279b8003f7f0a6831d090ab822d37bc958f974de.1547073843.git.jpoimboe@redhat.com> <8138A1EE-359D-4CD2-8E96-5BF00313AB3B@vmware.com> <20190110172004.wuh45xoafynfm2df@treble> <20190110123243.3b9e0856@gandalf.local.home> <20190110174257.GE16556@linux.intel.com> <20190110125757.1c8d2870@gandalf.local.home> <20190110180428.GG16556@linux.intel.com> <20190111152809.ejutcmqrx4ud3fli@treble> <20190111165752.z6e2dfktj2caqi4n@treble> <49f9bb3d-7b65-06e8-b0b3-42cf7f0a82b5@oracle.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Jan 2019 12:10:19 +0100 Alexandre Chartre wrote: > Thinking more about it (and I've probably missed something or I am just being > totally stupid because this seems way too simple), can't we just replace the > "call" with "push+jmp" and patch the jmp instruction? > > Instead of having: > > call target > > Have: > > push $done > static_call: > jmp target > done: But how do you implement it? Inline assembly()? Then you need to be able to do that for any type of function parameters (there will be users that have 13 parameters!) I believe people have mentioned having a gcc plugin that would do it for us, which was one of the suggested solutions. -- Steve > > Then we can safely patch the "jmp" instruction to jump to a new target > with text_poke_bp(), using the new target as the text_poke_bp() handler: > > new_jmp_code = opcode of "jmp new_target" > > text_poke_bp(static_call, new_jmp_code, new_jmp_code_size, new_target); > > Problems come with patching a call instruction, but there's no issue with patching > a jmp, no? (that's what jump labels do). > > No change to the int3 handler, no thunk, this seems really too simple... :-)