Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2724777imu; Thu, 29 Nov 2018 09:15:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/VM7hv5L1XD69Lkl3kYYmFHpw/7U+ASZFkLII/KqnUZHUDPyoNgxSCm8f/9L4i8SXMZ5sXt X-Received: by 2002:a17:902:20c8:: with SMTP id v8mr2299787plg.319.1543511708510; Thu, 29 Nov 2018 09:15:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543511708; cv=none; d=google.com; s=arc-20160816; b=wdE/ffCTyssC7cgVUZjeN8wkKLh6RpdRHU4bksVvBr2szUauYTnLbYrPXeUMDjACab QCMSjWSyO0vDzBcQn2NnuWdqc5Q0qwxmLePYkRYIjTLhZ/cospK+9I5UfI/za2GXWP/h INk8cr6Kj6OO43HXUNvt7B3INOoox66WhTmZlKEH1ij5eUOihLF6sAMCcgweeEmOW4Y+ VCt7ciF7ghI4VVnjgDDQX+fg8zkWdXR5OvhrDT/V6ydyLEzPl/QqZDd+i7F65+4b2Yta Lvi9jSEtbev3wuoM4Xs7+jUDqkNbiahecQylgrTKJ4xqWw+IzYfa4T5FU+yjGXf0lsHK gNbA== 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=OmlDJf4PdwX+5unCh3t99U6B/moraVXqmUbSh1LcBsg=; b=rLd9YPFBUFby6dg/0DZwxDm6VNxTrxr3UodrzLsaVUCfIeGmAsvr8J95KaVrSqM855 OMojOqn0MriWekIu+A8JjRzrOpUuskKx0GUlLTD2lIARmZe1faOl8kDvglq7D9UnLPWU 2vHwhrDefr4rayKe7qd0X+h0MAl0n/vCsWw3NBBRrzqlhaU7xx+icENxOWoFgUSoVXfb e4v6E7uBdctucEl54jqkLsA50QZNsBk8+BG/+bcpGK36iCeIDwNbegc+wnZt2jQgqeaF lOp/AQvXhqT8PgRBjR+mzWtULmeQDv+b3g5BBzUR3vM58waKBVm3QPNqijYxsOy9j8zr EFXw== 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 w23si2674683plq.198.2018.11.29.09.14.16; Thu, 29 Nov 2018 09:15:08 -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 S1730698AbeK3ETQ (ORCPT + 99 others); Thu, 29 Nov 2018 23:19:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:33480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728551AbeK3ETP (ORCPT ); Thu, 29 Nov 2018 23:19:15 -0500 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (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 2B7E7213A2; Thu, 29 Nov 2018 17:13:09 +0000 (UTC) Date: Thu, 29 Nov 2018 12:13:07 -0500 From: Steven Rostedt To: Andy Lutomirski Cc: Linus Torvalds , Josh Poimboeuf , Peter Zijlstra , Andrew Lutomirski , the arch/x86 maintainers , Linux List Kernel Mailing , Ard Biesheuvel , Ingo Molnar , Thomas Gleixner , mhiramat@kernel.org, jbaron@akamai.com, Jiri Kosina , David.Laight@aculab.com, bp@alien8.de, julia@ni.com, jeyu@kernel.org, Peter Anvin Subject: Re: [PATCH v2 4/4] x86/static_call: Add inline static call implementation for x86-64 Message-ID: <20181129121307.12393c57@gandalf.local.home> In-Reply-To: <0A629D30-ADCF-4159-9443-E5727146F65F@amacapital.net> References: <20181126160217.GR2113@hirez.programming.kicks-ass.net> <20181126171036.chcbmb35ygpxziub@treble> <20181126175624.bruqfbkngbucpvxr@treble> <20181126200801.GW2113@hirez.programming.kicks-ass.net> <20181126212628.4apztfazichxnt7r@treble> <20181127084330.GX2113@hirez.programming.kicks-ass.net> <20181129094210.GC2131@hirez.programming.kicks-ass.net> <20181129143853.GO2131@hirez.programming.kicks-ass.net> <20181129163342.tp5wlfcyiazwwyoh@treble> <0A629D30-ADCF-4159-9443-E5727146F65F@amacapital.net> 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 Thu, 29 Nov 2018 09:02:23 -0800 Andy Lutomirski wrote: > > Instead, I'd suggest: > > > > - just restart the instruction (with the suggested "ptregs->rip --") > > > > - to avoid any "oh, we're not making progress" issues, just fix the > > instruction yourself to be the right call, by looking it up in the > > "what needs to be fixed" tables. > > > > No? > > I thought that too. I think it deadlocks. CPU A does > text_poke_bp(). CPU B is waiting for a spinlock with IRQs off. CPU > C holds the spinlock and hits the int3. The int3 never goes away > because CPU A is waiting for CPU B to handle the sync_core IPI. I agree that this can happen. > > Or do you think we can avoid the IPI while the int3 is there? No, we really do need to sync after we change the second part of the command with the int3 on it. Unless there's another way to guarantee that the full instruction gets seen when we replace the int3 with the finished command. To refresh everyone's memory for why we have an IPI (as IPIs have an implicit memory barrier for the CPU). We start with: e8 01 02 03 04 and we want to convert it to: e8 ab cd ef 01 And let's say the instruction crosses a cache line that breaks it into e8 01 and 02 03 04. We add the breakpoint: cc 01 02 03 04 We do a sync (so now everyone should see the break point), because we don't want to update the second part and another CPU happens to update the second part of the cache, and might see: e8 01 cd ef 01 Which would not be good. And we need another sync after we change the code so all CPUs see cc ab cd ef 01 Because when we remove the break point, we don't want other CPUs to see e8 ab 02 03 04 Which would also be bad. -- Steve