Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp500995imm; Fri, 5 Oct 2018 07:16:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV63W/FWqXHBSjprGFSUgg80O3NdHdBvEgNa8AfIoNoayrz5KlMgPJ5p7acT0ycq2/z4eVLeO X-Received: by 2002:a63:9f0a:: with SMTP id g10-v6mr10029887pge.232.1538749019937; Fri, 05 Oct 2018 07:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538749019; cv=none; d=google.com; s=arc-20160816; b=mPCURrrm/7XXOpni159oZuHNom4fBmDIdQE1blTQ0VtZwB/8bjDFks8dbgz7JRiOY9 2rTaaHhCYeUtEvH26hxO7UUWdfN7q3+ZK6E6KdHROSCcb5VwbiQZTNyzvxX9O9hjNc1J Dae8XW752OxDVN04VANFC0CB5LpqfHOJb951QL9BXgdChI0awbyqEACFaNuxjEYhUmGi kEKjzyNnuk4Vl3KpteHsbnhEXlNjO1493x/R7O1Xr14bz5uWT9fxNJ4uTmCQKLAc9IRk r3QOKk2vofWZdp4+m0i84zuZG7aC8u0Uana0xt/UQauoSHH31/lS2hZJQjdQ+yh9Gdlh TsKA== 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:dkim-signature; bh=+2Hg3x+DThcI5Dql16qLdvIGmJ3ZNOO2ZjgVB3KbByQ=; b=FvSgRieb71YXRFIuRYe63L1oHo7s/lZFm4WZiQOBUw0izIAEPp+Dh6NWqLTWQ4eeAs al/Drt7wRAIauA1FgWAs6SHAL2jMDJNRsWIHje938gpMCFaCUVA/czLaSPb8qKMJlDeP XWHLaVbAyh8Z0Y1xxLAY5AXDx71sLSs+b8C2RO8fE0HaxXzE7lNmj/dEMldbetQtd12L gzn+Okr+SI9EK1UMHIalsqt4HH6PzjZd7RFMUOI6Haflw1OKEetltpjGhVrv6JUitXiE 6BTIzn/W4FyBCR1GEN3Nfw61pVzIwffM7KctMecrELJsJxhPz8KQghEgc+YcEVsfcn1u AZ+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=VhxDDfRa; 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 z27-v6si7427948pgk.297.2018.10.05.07.16.43; Fri, 05 Oct 2018 07:16:59 -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=VhxDDfRa; 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 S1728715AbeJEVON (ORCPT + 99 others); Fri, 5 Oct 2018 17:14:13 -0400 Received: from merlin.infradead.org ([205.233.59.134]:50008 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727968AbeJEVOM (ORCPT ); Fri, 5 Oct 2018 17:14:12 -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: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=+2Hg3x+DThcI5Dql16qLdvIGmJ3ZNOO2ZjgVB3KbByQ=; b=VhxDDfRakhA7KvlOrldiJzTiu WlsJ6C3CDGpqOjkNRtwN0eVpdrQ4FM2n3tDHa7+xV6XQ5m7ZfyMOrN6TaLYvLFRPsSbp2QT/U1bED /DgO3nz1C4X7i2ObbiGm45DXABKMSqBFV7EJx4Gj/KqHajM/7t4MNk/8MYg5wRqXipXZCfOvVeiUd no3a5nc17AbXivzjepRlm5TlR0cAw8kcP+LxMdW8W72PpazRpn7X2AxXeStpvpKN1s5TebIxgYd4e Tvi7l0JzRJbgQS+g/JIm8Txm1XTw/iDVAGxD6rfgjJhA/wNy+U9YlLPb+iQeZX5qqzGSPyUDR88f1 h87AtGejg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g8QsF-0004ER-AB; Fri, 05 Oct 2018 14:14:35 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C1675202631DA; Fri, 5 Oct 2018 16:14:33 +0200 (CEST) Date: Fri, 5 Oct 2018 16:14:33 +0200 From: Peter Zijlstra To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, "Jason A . Donenfeld" , Eric Biggers , Samuel Neves , Andy Lutomirski , Arnd Bergmann , Herbert Xu , "David S. Miller" , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Kees Cook , "Martin K. Petersen" , Greg Kroah-Hartman , Andrew Morton , Richard Weinberger , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [RFC PATCH 1/9] kernel: add support for patchable function pointers Message-ID: <20181005141433.GS19272@hirez.programming.kicks-ass.net> References: <20181005081333.15018-1-ard.biesheuvel@linaro.org> <20181005081333.15018-2-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181005081333.15018-2-ard.biesheuvel@linaro.org> 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 Fri, Oct 05, 2018 at 10:13:25AM +0200, Ard Biesheuvel wrote: > diff --git a/include/linux/ffp.h b/include/linux/ffp.h > new file mode 100644 > index 000000000000..8fc3b4c9b38f > --- /dev/null > +++ b/include/linux/ffp.h > @@ -0,0 +1,43 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#ifndef __LINUX_FFP_H > +#define __LINUX_FFP_H > + > +#include > +#include > + > +#ifdef CONFIG_HAVE_ARCH_FFP > +#include > +#else > + > +struct ffp { > + void (**fn)(void); > + void (*default_fn)(void); > +}; > + > +#define DECLARE_FFP(_fn, _def) \ > + extern typeof(_def) *_fn; \ > + extern struct ffp const __ffp_ ## _fn > + > +#define DEFINE_FFP(_fn, _def) \ > + typeof(_def) *_fn = &_def; \ > + struct ffp const __ffp_ ## _fn \ > + = { (void(**)(void))&_fn, (void(*)(void))&_def }; \ > + EXPORT_SYMBOL(__ffp_ ## _fn) > + > +static inline void ffp_set_target(const struct ffp *m, void *new_fn) > +{ > + WRITE_ONCE(*m->fn, new_fn); > +} > + > +static inline void ffp_reset_target(const struct ffp *m) > +{ > + WRITE_ONCE(*m->fn, m->default_fn); > +} > + > +#endif > + > +#define SET_FFP(_fn, _new) ffp_set_target(&__ffp_ ## _fn, _new) > +#define RESET_FFP(_fn) ffp_reset_target(&__ffp_ ## _fn) > + > +#endif I don't understand this interface. There is no wrapper for the call site, so how are we going to patch all call-sites when you update the target?