Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp873619ybb; Wed, 25 Mar 2020 11:14:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuxsPrUQxT2gHcIufyiMA3JtSE3KoYZz2BxodmSuoyV7aoKTroNv+lZQ1k6vokkRHj0J6E3 X-Received: by 2002:a9d:3b6:: with SMTP id f51mr3606345otf.255.1585160066112; Wed, 25 Mar 2020 11:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585160066; cv=none; d=google.com; s=arc-20160816; b=paSLUhh6o5Eg8bKO+DJAAjgQ431jAXgqpxSP5VN4P4uqM2QKWtd/qtRLJfalU7xj4t IbBqwi5yRKlVtEOBln+jZFcdFvyyazkYo0v5tLioFggwwi3dkV1NDDTJdrQkN+pyV5vC xBRd7XY6WMoZVzAo3pc7/9nw6wBtEe1x/ic9myDnOE1YxcVdnQSWVMTf7gC9nR/ms3Id /mMLt5mUbXSVW8MDoVwfyTkcq/O4wJiJhpUeL18hZyUZzQPsteecxpno2PQ3onWAWp2C +Q9Qb9FFLmzUAZRqLbwvwWy6N5eCqe1hTh5W1/P3FKyc1SnsFHFp6VWajk/N0Ocu1ZED LxnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2plezOlRw7hkkh6LziCfkccVGAATkcpghrKnzymW3hs=; b=GFEeJ8NwTT5rTouKI626QxC0jTwtSBd9naHGZe3Ek3V/llou07ljSAmPa5lDcidm/X G4Nn02SUjAvKBZrT/ZxFoUHUqA4ZBTHxLDX19vhCiB9XtOUzkeKCD9PFDGjYxPZanhRp Rbia2qoVCBPiQQlfqB4U0v0IzXeIm/pYO1ENf/jcsFVB70UFwmMPUAzICkmACLSwnqjz 9Meo6ePUhgu5BUIk9WNDePJcOHBtQMY+FpEWfr01Kz/zAQXKSVKhJxBjHkqpVzzCzyXy Y5/yxxbik279//+9UCyDyThD5eFSm7Mn8cGma01guq+RsVr+WeQsngVo/WvWf4z4BlhI H6XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=AXRKABpB; 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 d1si3876063otq.225.2020.03.25.11.14.13; Wed, 25 Mar 2020 11:14:26 -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=AXRKABpB; 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 S1727451AbgCYSN6 (ORCPT + 99 others); Wed, 25 Mar 2020 14:13:58 -0400 Received: from merlin.infradead.org ([205.233.59.134]:60972 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727129AbgCYSN5 (ORCPT ); Wed, 25 Mar 2020 14:13:57 -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; bh=2plezOlRw7hkkh6LziCfkccVGAATkcpghrKnzymW3hs=; b=AXRKABpBtNDx/hoGYGMf6QE6g8 I64wQNxK1qd2fOyN33i1Ws85v7xQpI5JKRwdR4eiDlkCahOjxUJPXlBZM+zf2RirH/5vJO36tjzEY IkKIwzcdXQALUKP+hyz86GNLwTLG0oLY0TEwD7R9Xibr569arxZ7HKmfq79OR7rbjis+ZJdJAADaQ IrZpva/sSPcQYPbkmUYkE42gO8XdG+3sivhrKBOkVfHVqlBmYLsuYgN3ONx4JsVD6IM7b7X0fzC68 gd1mR7nJJrO96wTgcHMNyuW6plaCcMBAsu4XhgtLZMAN7ki/b3idKDdKpr1qyr0gnsbcH9t1+xyQU JEcb/WdQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHAX8-0004Xw-PB; Wed, 25 Mar 2020 18:13:43 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 86EE23010CF; Wed, 25 Mar 2020 19:13:39 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 64524201CEE51; Wed, 25 Mar 2020 19:13:39 +0100 (CET) Date: Wed, 25 Mar 2020 19:13:39 +0100 From: Peter Zijlstra To: Linus Torvalds Cc: Andy Lutomirski , the arch/x86 maintainers , Linux Kernel Mailing List , Steven Rostedt , Masami Hiramatsu , Daniel Bristot de Oliveira , Jason Baron , Thomas Gleixner , Ingo Molnar , Nadav Amit , Peter Anvin , Andrew Lutomirski , Ard Biesheuvel , Josh Poimboeuf Subject: Re: [RESEND][PATCH v3 14/17] static_call: Add static_cond_call() Message-ID: <20200325181339.GK20713@hirez.programming.kicks-ass.net> References: <86D80EA7-9087-4042-8119-12DD5FCEAA87@amacapital.net> <20200324170306.GU20696@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200324170306.GU20696@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2020 at 06:03:06PM +0100, Peter Zijlstra wrote: > On Tue, Mar 24, 2020 at 09:33:21AM -0700, Linus Torvalds wrote: > > Of course, one alternative is to just say "instead of using NOP, use > > 'xorl %eax,%eax'", and then we'd have the rule that a NULL conditional > > function returns zero (or NULL). > > > > I _think_ a "xorl %eax,%eax ; retq" is just three bytes and would fit > > in the tailcall slot too. > > Correct. The only problem is that our text patching machinery can't > replace multiple instructions :/ To clarify; the problem is a task getting preempted with its RIP at the RET. Then when we rewrite the text to be a CALL/JMP.d32 it will read garbage (1 byte into the displacement of the instruction) instead of a RET when it resumes. Now, there are ways to fix this, the easiest being calling synchronize_rcu_tasks() just like optprobes does (see also commit 5c02ece81848 ("x86/kprobes: Fix ordering while text-patching")). It would mean patching a call away from NULL will be 'expensive' but it ought to work. I'll try and do the patch, see what it looks like.