From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 22 Jan 2019 05:09:55 -0000 Received: from userp2120.oracle.com ([156.151.31.85]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gloJt-0004iX-R8 for speck@linutronix.de; Tue, 22 Jan 2019 06:09:54 +0100 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0M59Exb075399 for ; Tue, 22 Jan 2019 05:09:47 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2q3vhrh9m1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 22 Jan 2019 05:09:47 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0M59feY016351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 22 Jan 2019 05:09:41 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0M59fpd010506 for ; Tue, 22 Jan 2019 05:09:41 GMT Date: Tue, 22 Jan 2019 00:09:40 -0500 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [PATCH v5 19/27] MDSv5 12 Message-ID: <20190122050940.GO12859@char.us.oracle.com> References: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Fri, Jan 18, 2019 at 04:50:34PM -0800, speck for Andi Kleen wrote: > From: Andi Kleen > Subject: mds: Clear CPU on irq poll, unless opted-out > > By default we assume that irq poll handlers running in the irq poll > softirq might touch user data and we schedule a cpu clear on next > kernel exit. > > Add interfaces for audited handlers to declare that they are safe. Reviewed-by: Konrad Rzeszutek Wilk Thank you! > > Signed-off-by: Andi Kleen > --- > include/linux/irq_poll.h | 2 ++ > lib/irq_poll.c | 18 ++++++++++++++++-- > 2 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/include/linux/irq_poll.h b/include/linux/irq_poll.h > index 16aaeccb65cb..5f13582f1b8e 100644 > --- a/include/linux/irq_poll.h > +++ b/include/linux/irq_poll.h > @@ -15,6 +15,8 @@ struct irq_poll { > enum { > IRQ_POLL_F_SCHED = 0, > IRQ_POLL_F_DISABLE = 1, > + > + IRQ_POLL_F_NO_USER = 1<<4, > }; > > extern void irq_poll_sched(struct irq_poll *); > diff --git a/lib/irq_poll.c b/lib/irq_poll.c > index 86a709954f5a..cb19431f53ec 100644 > --- a/lib/irq_poll.c > +++ b/lib/irq_poll.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > > static unsigned int irq_poll_budget __read_mostly = 256; > > @@ -111,6 +112,9 @@ static void __latent_entropy irq_poll_softirq(struct softirq_action *h) > > budget -= work; > > + if (!(iop->state & IRQ_POLL_F_NO_USER)) > + lazy_clear_cpu(); > + > local_irq_disable(); > > /* > @@ -168,21 +172,31 @@ void irq_poll_enable(struct irq_poll *iop) > EXPORT_SYMBOL(irq_poll_enable); > > /** > - * irq_poll_init - Initialize this @iop > + * irq_poll_init_flags - Initialize this @iop > * @iop: The parent iopoll structure > * @weight: The default weight (or command completion budget) > * @poll_fn: The handler to invoke > + * @flags: IRQ_POLL_F_NO_USER if callback does not touch user data. > * > * Description: > * Initialize and enable this irq_poll structure. > **/ > -void irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *poll_fn) > +void irq_poll_init_flags(struct irq_poll *iop, int weight, irq_poll_fn *poll_fn, > + int flags) > { > memset(iop, 0, sizeof(*iop)); > INIT_LIST_HEAD(&iop->list); > iop->weight = weight; > iop->poll = poll_fn; > + iop->state = flags; > } > +EXPORT_SYMBOL(irq_poll_init_flags); > + > +void irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *poll_fn) > +{ > + return irq_poll_init_flags(iop, weight, poll_fn, 0); > +} > + > EXPORT_SYMBOL(irq_poll_init); > > static int irq_poll_cpu_dead(unsigned int cpu) > -- > 2.17.2