Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3448850imm; Fri, 24 Aug 2018 18:01:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbnYBLqN3D/IjGT7l6HHHTakGi6oy5NHgOEkvj0M1VUoCEZzVGBHN220vwVt5hTx3oLjnve X-Received: by 2002:a62:7590:: with SMTP id q138-v6mr4223859pfc.148.1535158878913; Fri, 24 Aug 2018 18:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535158878; cv=none; d=google.com; s=arc-20160816; b=qqmCHEP0PffqPMINhDuSvwZweq6z6c9K16GrFnz1YZwQo4BTmOmWU5Z4nkDGVFINFz BhiBB5qu8OJgx56vba06Mv/FADm15bGcWnZVBCxpqa7wIrk2bLABxZYtfCAY5isAkXjf yLaeqOxUuQVgUZMWOWAr7qrkRxugCGBMlZ3o9/It/EFJE6+D/zQSY1IdDHpU3uzF3zPT uooMgW31YLDrWlCMq2oBbXj/4neUg7oKjRI0ZvtSr8AQXZi+u0fjTGPxcQi1fr7qNS71 VtspKKNqi5UacEc3Hz2VKKyRjBIrV2DKMo7M2IxQaO4ABRyPm2K45WxgM9Y4S0l8C2St fd6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=ofr3q4SGcvRolQoxJotYyoGCM+4YOEbAafHjmgn/j8w=; b=j81RLkzsOoVw9kewEkLGckgnUxTg1e7YrQrons7myaejt2EgyxcN0osqx7dbZ65UJ+ xkSWx0FlVhP6D3N2/zsuX5Wmne0mYYJSgAelQw5p4Qwo2ptbhEF3Bg/sjyw66Xroai/8 ak0LmVhFhMwqQbZ5vdNzBagBr5H5YiYBAywJ+QUbSB55oY0AsN4S4d/Q9X9pSX9O9de5 i892kihqrjNYzG25qJdLGjQJ7PmrRtdWEKa/dEwdIZ8fBShbX6Sy3HSSulnPzspZvZoY pWpXURsjzlh15Q5aF00/npBBHsGq+7VCsoJRvFa4qoHhlV5K0Q8qHAjBgkCdwZwMfwUe GXzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hbJHRP4i; 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 b20-v6si7889868pls.78.2018.08.24.18.00.49; Fri, 24 Aug 2018 18:01:18 -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=pass header.i=@linux-foundation.org header.s=google header.b=hbJHRP4i; 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 S1726179AbeHYEfz (ORCPT + 99 others); Sat, 25 Aug 2018 00:35:55 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:52067 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbeHYEfz (ORCPT ); Sat, 25 Aug 2018 00:35:55 -0400 Received: by mail-it0-f53.google.com with SMTP id e14-v6so4455454itf.1 for ; Fri, 24 Aug 2018 17:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ofr3q4SGcvRolQoxJotYyoGCM+4YOEbAafHjmgn/j8w=; b=hbJHRP4iPFSTCwiE5ebvSvKKvaEG6t3r5466DhoVJn8Z1uoXuY4+Pkr69r+Uwx4F8w w13tczkdSngQk6Cy+XevMwvAQKTrJF/jpkI5xBwAEtUQKdxsv99+tehAkD2VrNuLQfNC 4UtZbEHDyzJipN0++Ig3NwfcXIuBRqtFPd6ys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ofr3q4SGcvRolQoxJotYyoGCM+4YOEbAafHjmgn/j8w=; b=r4RSyFkin22DRV0LWONFgNVR28XRvHq2q4Z/rAxOSlv1YYxFRKVzlTkorIJ9TNlXrj iiI+EUJHogGvnajRspAKRLD0C2j5p9Z7W9hFXe1kH/nVN7XZlxx79AB2u5CgR7UjrzXq zSk3nsqVkDoiCBFP/1a4cu2971GNxs+vIRtcnvtax2TltQwkcaIITauiq6W2u5dlSE17 JgmP4Hqu+rhUzSi8N3322LQ/8VMeFT9E7EC/9XlUBVSuhV507hxuoFZx73/sl/TGiYxe hTLIYmyDYuXm9gdNM7OWKmnGEq1ihWZEDK0LTvWftIBiLkezrXGQS7LCCkfRDJ7mfaGi UZGA== X-Gm-Message-State: APzg51DFXhV5XGByUEaosl7uUSnOcnAP/SsZ0fX+hqPltq2vQoAJzNI5 TrXczhWOeTcl5U0SXxFJLJg1wLxmudGdrl9ZYIk= X-Received: by 2002:a24:8309:: with SMTP id d9-v6mr60318ite.123.1535158734765; Fri, 24 Aug 2018 17:58:54 -0700 (PDT) MIME-Version: 1.0 References: <20180822153012.173508681@infradead.org> <20180822154046.823850812@infradead.org> <20180822155527.GF24124@hirez.programming.kicks-ass.net> <20180823134525.5f12b0d3@roar.ozlabs.ibm.com> <776104d4c8e4fc680004d69e3a4c2594b638b6d1.camel@au1.ibm.com> <20180823133958.GA1496@brain-police> <20180824084717.GK24124@hirez.programming.kicks-ass.net> <20180824180438.GS24124@hirez.programming.kicks-ass.net> <56A9902F-44BE-4520-A17C-26650FCC3A11@gmail.com> <9A38D3F4-2F75-401D-8B4D-83A844C9061B@gmail.com> In-Reply-To: <9A38D3F4-2F75-401D-8B4D-83A844C9061B@gmail.com> From: Linus Torvalds Date: Fri, 24 Aug 2018 17:58:43 -0700 Message-ID: Subject: Re: TLB flushes on fixmap changes To: Nadav Amit , Paolo Bonzini , Jiri Kosina , Masami Hiramatsu Cc: Peter Zijlstra , Will Deacon , Benjamin Herrenschmidt , Nick Piggin , Andrew Lutomirski , "the arch/x86 maintainers" , Borislav Petkov , Rik van Riel , Jann Horn , Adin Scannell , Dave Hansen , Linux Kernel Mailing List , linux-mm , David Miller , Martin Schwidefsky , Michael Ellerman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding a few people to the cc. On Fri, Aug 24, 2018 at 1:24 PM Nadav Amit wrote: > > > > Can you actually find something that changes the fixmaps after boot > > (again, ignoring kmap)? > > At least the alternatives mechanism appears to do so. > > IIUC the following path is possible when adding a module: > > jump_label_add_module() > ->__jump_label_update() > ->arch_jump_label_transform() > ->__jump_label_transform() > ->text_poke_bp() > ->text_poke() > ->set_fixmap() Yeah, that looks a bit iffy. But making the tlb flush global wouldn't help. This is running on a local core, and if there are other CPU's that can do this at the same time, then they'd just fight about the same mapping. Honestly, I think it's ok just because I *hope* this is all serialized anyway (jump_label_lock? But what about other users of text_poke?). But I'd be a lot happier about it if it either used an explicit lock to make sure, or used per-cpu fixmap entries. And the tlb flush is done *after* the address is used, which is bogus anyway. > And a similar path can happen when static_key_enable/disable() is called. Same comments. How about replacing that local_irq_save(flags); ... do critical things here ... local_irq_restore(flags); in text_poke() with static DEFINE_SPINLOCK(poke_lock); spin_lock_irqsave(&poke_lock, flags); ... do critical things here ... spin_unlock_irqrestore(&poke_lock, flags); and moving the local_flush_tlb() to after the set_fixmaps, but before the access through the virtual address. But changing things to do a global tlb flush would just be wrong. Linus