Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1019155imu; Fri, 11 Jan 2019 13:24:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN53ypaZMQhMDeR2XLuSMC3jbF8XyWFavQGvIAyXZRaANf4KJ5T6Ut0AGB5r6Zpi/HiXN2n/ X-Received: by 2002:a17:902:a411:: with SMTP id p17mr15956252plq.292.1547241880876; Fri, 11 Jan 2019 13:24:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547241880; cv=none; d=google.com; s=arc-20160816; b=rzq3JOGZnk/MY5AC+ySqLVWEkG9zKKjS4EKDlLVaVwd5NdswRDhjWviX/GkY9s2RG6 c2ECvCvP5FEoubWnsssq1C043DigJVFJ1hGApeQxMTDtEz4h2rTiT5beN6bKABf/An33 mp1GcJEGVCn0ikJJIaYE3wgevWPWeZ+vcGWMuPNKjlJQVBx0x3OxlDFDtvIxI59nVjNU yZHbGIz94uzN6ubqxjkMmVnt7txVnrjuz1gBvE4ILLk1KZi1gkak6UoJxHiClYR4RawH T9LnsGBBm1+mnOwDkn3KJ3Gxp2bnyZSgaTOhlNDnWFVTPnxLxVfFmTV/GYCl0R82Ky+m SJMQ== 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; bh=xoXiq8v/chn4F8EO44PadU1M41KQZWEav3WQYJ0GAQ0=; b=RY9dGxf4Qc9iMOvvjpT+Kk4GPuihGXSgTl5qb8QDHjwoVLTLzW80PBzpNbRUXHpg5K XwVwqLeh3j6su6P8LiXNpFxCwKgItyY6h6BRvrf19SNQdGYaheEnNd109EphCGuHuOrB X+qKA4gzk99C67O9T9hOmoujrU4vhoOoKSW+dPYUOr4E+BxpB4ftmFT+WFlo+B3a+gOm 8XruVIJInYTNK2mR/qu5Nb6WTKhqjjacGhX7v0FfoyOafH9aLCC31+36kZDaOFNCCNLI jGkbOWqNe4VpNDw2entn6hx/FtDYCXYVsPqfrUrWTntmXBuK2Zomg/AiURT0pH0uM1XH O59Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si21713797pls.170.2019.01.11.13.24.25; Fri, 11 Jan 2019 13:24:40 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725828AbfAKVW0 (ORCPT + 99 others); Fri, 11 Jan 2019 16:22:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44336 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbfAKVWZ (ORCPT ); Fri, 11 Jan 2019 16:22:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA6BA804FA; Fri, 11 Jan 2019 21:22:23 +0000 (UTC) Received: from treble (ovpn-122-231.rdu2.redhat.com [10.10.122.231]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE67881636; Fri, 11 Jan 2019 21:22:12 +0000 (UTC) Date: Fri, 11 Jan 2019 15:22:10 -0600 From: Josh Poimboeuf To: Linus Torvalds Cc: Nadav Amit , Andy Lutomirski , Peter Zijlstra , the arch/x86 maintainers , Linux List Kernel Mailing , Ard Biesheuvel , Steven Rostedt , Ingo Molnar , Thomas Gleixner , 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 0/6] Static calls Message-ID: <20190111212210.veyfn5vvjswcwacm@treble> References: <20190110205226.iburt6mrddsxnjpk@treble> <20190111151525.tf7lhuycyyvjjxez@treble> <20190111200420.qtyffayxceysoarf@treble> <20190111203135.5clurevf34bkiy3o@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 11 Jan 2019 21:22:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 11, 2019 at 12:46:39PM -0800, Linus Torvalds wrote: > On Fri, Jan 11, 2019 at 12:31 PM Josh Poimboeuf wrote: > > > > I was referring to the fact that a single static call key update will > > usually result in patching multiple call sites. But you're right, it's > > only 1-2 trampolines per text_poke_bp() invocation. Though eventually > > we may want to batch all the writes like what Daniel has proposed for > > jump labels, to reduce IPIs. > > Yeah, my suggestion doesn't allow for batching, since it would > basically generate one trampoline for every rewritten instruction. As Andy said, I think batching would still be possible, it's just that we'd have to create multiple trampolines at a time. Or... we could do a hybrid approach: create a single custom trampoline which has the call destination patched in, but put the return address in %rax -- which is always clobbered, even for callee-saved PV ops. Like: trampoline: push %rax call patched-dest That way the batching could be done with a single trampoline (particularly if using rcu-sched to avoid the sti hack). If you don't completely hate that approach then I may try it. > > Regardless, the trampoline management seems more complex to me. But > > it's easier to argue about actual code, so maybe I'll code it up to make > > it easier to compare solutions. > > I do agree hat the stack games are likely "simpler" in one sense. I > just abhor playing those kinds of games with the entry code and entry > stack. > > A small bit of extra complexity in the code that actually does the > rewriting would be much more palatable to me than the complexity in > the entry code. I prefer seeing the onus of complexity being on the > code that introduces the problem, not on a innocent bystander. > > I'd like to say that our entry code actually looks fairly sane these > days. I'd _like_ to say that, but I'd be lying through my teeth if I > did. The macros we use make any normal persons head spin. > > The workaround for the stack corruption was fairly simple, but the > subtlety behind the *reason* for it was what made my hackles rise > about that code. > > The x86 entry code is some of the nastiest in the kernel, I feel, with > all the subtle interactions about odd stack switches, odd CPU bugs > causing odd TLB switches, NMI interactions etc etc. > > So I am fully cognizant that the workaround to shift the stack in the > entry code was just a couple of lines, and not very complicated. > > And I agree that I may be a bit oversensitive about that area, but it > really is one of those places where I go "damn, I think I know some > low-level x86 stuff better than most, but that code scares *me*". > > Which is why I'd accept a rather bigger complexity hit just about > anywhere else in the code... I agree that, to a certain extent, it can make sense to put the "onus of complexity" on the code that introduces the problem. But of course it's not an absolute rule, and should be considered in context with the relative complexities of the competing solutions. But I think where I see things differently is that: a) The entry code is, by far, in the best shape it's ever been [*], thanks to Andy's considerable efforts. I find it to be quite readable, but that might be due to many hours of intense study... [*] overlooking recent unavoidable meltdown/spectre hacks b) Adding a gap to the #DB entry stack is (in my mind) a simple localized change, which is easily understandable by a reader of the entry code -- assuming certain personality characteristics of a person whose life decisions have resulted in them reading entry code in the first place... c) Doing so is an order of magnitude simpler than the custom trampoline thing (or really any of the other many alternatives we've discussed). At least that's my feeling. -- Josh