Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8210660ybn; Tue, 1 Oct 2019 05:03:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyghtbNsjYaNmYel/mWaAjhDkRYdg0Ds0akBNKyFDy7f1ogVaFPnmlB+/v9CZ+jg87ae1OG X-Received: by 2002:a50:d903:: with SMTP id t3mr24393917edj.117.1569931385131; Tue, 01 Oct 2019 05:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569931385; cv=none; d=google.com; s=arc-20160816; b=HCL+za3ewtYsdaPGCKfhh52iSKmEcOky0lhsbSCN5ACZm0ymWxK7sQ9AFkUxOqYSZS 4vbuWmM6NWI4qbx3clj4mqi9YQQQ2Im5/VU5MdN9XqZZymW0aE81ra7W2kJkXp9pJTz/ AoLfb7oacZa3DioIYP4CeSscjRe9YRMd7BTsM+4sfuqzTkK7h4ouIh7yFkCIoz0R4nwE 1SUtN4fwkqsDBlYkmO18fEvJMqkRD90xgnefsKRpmr5y7v/gzkO3mD5PTc+8uD85qQuP F/HLaO37bQRWol4vj5RG9ApAPd8Cl4ewVYnAa8/t+ZuSLbFGa7JtkuAvmesFvVHsVgGi FUsg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LKr1dzgOhzScC3c310Ljy2SZqBkMLUgSVZmu3N0da8g=; b=0McKWL052CwrrnaC4tiDuq/2TiONfVUateoM4ZmE19lgc1aVVeZL9+BD1M1mUji64X nEanpsrcfKM6hJNsOPXpO83udYbS43YYef8acPYp1A/zr6Ov3I+NnPT6Mkw9x7VMcdKs 68cuSvtC00eqCAId6GMJnMgKrl3xYGGY/mD69Snf+kG1jFhF4siY7xygYA8fMW344g9b Ri2OOzR3u5eZ1XZ+pRyR78kh2YMuzQzcgqMyQUhFctWw9yW5PX1D+BjNXxf5rvBFbaDp 9KhyZ3GwtqgLbarDB3kMGPU5OHpaoevVyc31Zasc9ndv3EKWz8tY+ejSgnpfN9lZudEL mmAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=IvKL0V3M; 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 b15si8728161eda.152.2019.10.01.05.02.39; Tue, 01 Oct 2019 05:03:05 -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=IvKL0V3M; 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 S1732057AbfJAMBT (ORCPT + 99 others); Tue, 1 Oct 2019 08:01:19 -0400 Received: from merlin.infradead.org ([205.233.59.134]:60590 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbfJAMBT (ORCPT ); Tue, 1 Oct 2019 08:01:19 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LKr1dzgOhzScC3c310Ljy2SZqBkMLUgSVZmu3N0da8g=; b=IvKL0V3MvVcllb7C/EJZnXh0E0 9tkkl0R8F+nCHkI/+Gv4GE/IDRgB5UH7bGvA/lUTmtZ29BhxDGndMxcnvSHuEusEIaVBnt7W6jwKs pE79SCg/WkMK8NlnBBdE65s7/dcW6Nc9+VGdiFu9kRTZb0e7fPJ8O83UVIefcQ1CnDmQ0i7iZyt02 fGI5A8SWsPUKVUu+pSNyyy81/9BcKY3s7ioNyUlbCXBFL17We9QlrO/jER9y8Aogx1+vg6KEK+bAm aUeXMZNFRyY/5YtJh7D5yQW/aX68lK1FUm5RCv4H8R7wFilOprU7HfJkHJUO4cFjahab+U+cdKpw2 weOLj7sg==; 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.2 #3 (Red Hat Linux)) id 1iFGpP-00061z-9X; Tue, 01 Oct 2019 12:00:28 +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 6300C30477A; Tue, 1 Oct 2019 13:59:35 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B3DE8202CF69B; Tue, 1 Oct 2019 14:00:23 +0200 (CEST) Date: Tue, 1 Oct 2019 14:00:23 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: Nadav Amit , the arch/x86 maintainers , LKML , Ard Biesheuvel , Andy Lutomirski , Steven Rostedt , 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 11/15] static_call: Add inline static call infrastructure Message-ID: <20191001120023.GQ4519@hirez.programming.kicks-ass.net> References: <20190605130753.327195108@infradead.org> <20190605131945.193241464@infradead.org> <37CFAEC1-6D36-4A6D-8C44-F85FCFA053AA@vmware.com> <20190607083756.GW3419@hirez.programming.kicks-ass.net> <20190610171929.3xemvsykvkswcvya@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190610171929.3xemvsykvkswcvya@treble> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2019 at 12:19:29PM -0500, Josh Poimboeuf wrote: > On Fri, Jun 07, 2019 at 10:37:56AM +0200, Peter Zijlstra wrote: > > > > +} > > > > + > > > > +static int static_call_module_notify(struct notifier_block *nb, > > > > + unsigned long val, void *data) > > > > +{ > > > > + struct module *mod = data; > > > > + int ret = 0; > > > > + > > > > + cpus_read_lock(); > > > > + static_call_lock(); > > > > + > > > > + switch (val) { > > > > + case MODULE_STATE_COMING: > > > > + module_disable_ro(mod); > > > > + ret = static_call_add_module(mod); > > > > + module_enable_ro(mod, false); > > > > > > Doesn’t it cause some pages to be W+X ? > > How so? This is after complete_formation() which does RO,X. If we then disable RO we end up with W+X pages, which is bad. That said, alternatives, ftrace, dynamic_debug all run before complete_formation() specifically such that they can directly poke text. Possibly we should add a notifier callback for MODULE_STATE_UNFORMED, but that is for another day. > >> Can it be avoided? > > > > I don't know why it does this, jump_labels doesn't seem to need this, > > and I'm not seeing what static_call needs differently. > > I forgot why I did this, but it's probably for the case where there's a > static call site in module init code. It deserves a comment. > > Theoretically, jump labels need this to. > > BTW, there's a change coming that will require the text_mutex before > calling module_{disable,enable}_ro(). I can't find why it would need this (and I'm going to remove it). Specifically complete_formation() does enable_ro(.after_init=false), which leaves .ro_after_init writable so {jump_label,static_call}_sort_entries() will work. But both jump_label and static_call then use the full text_poke(), not text_poke_early(), for modules.