Return-path: Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fEWta-00084i-6J for speck@linutronix.de; Fri, 04 May 2018 11:20:54 +0200 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 1fEWtY-0007ox-Eq for speck@linutronix.de; Fri, 04 May 2018 09:20:52 +0000 Date: Fri, 4 May 2018 11:20:50 +0200 From: Peter Zijlstra Subject: [MODERATED] Re: [PATCH 1/5] SSB extra 2 Message-ID: <20180504092050.GK12217@hirez.programming.kicks-ass.net> References: =?utf-8?q?=3Ce69f3b?= =?utf-8?q?41d5b7fa52cf43682663d1f6f3c5de7d03=2E1525383411=2Egit=2Edave=2E?= =?utf-8?q?hansen=40intel=2Ecom=3E?= MIME-Version: 1.0 In-Reply-To: =?utf-8?q?=3Ce69f3b41d5b7fa52cf43682663d1f6f3c5de7d03=2E15253?= =?utf-8?q?83411=2Egit=2Edave=2Ehansen=40intel=2Ecom=3E?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Thu, May 03, 2018 at 03:29:44PM -0700, speck for Dave Hansen wrote: > BPF code is often supplied from outside the kernel. While it can > be programmatically verified, it is very difficult to verify > potential effects from speculative execution. > > This patch adds some marker functions as BFP code is entered or > exited. These serve only a stubs for now. > > There are many possibilities for optimization. The BFP programs > that run on devices, for instance, are less likely to need any > CPU-based mitigations. These patches are an entirely unoptimized > first pass. > @@ -357,7 +357,9 @@ int bpf_prog_array_copy(struct bpf_prog_array __rcu *old_array, > goto _out; \ > _prog = _array->progs; \ > while ((__prog = READ_ONCE(*_prog))) { \ > + bpf_enter_prog(__prog); \ > _ret &= func(__prog, ctx); \ > + bpf_leave_prog(__prog); \ > _prog++; \ > } \ > _out: \ So I actually had a look at this yesterday, and why did you choose to put these hooks at the prog callsites instead of inside the prog itself? It seems to me that placing them inside the program (either the interpreter or the jit) is much less invasive.