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 1fEcyk-0006vH-Ny for speck@linutronix.de; Fri, 04 May 2018 17:50:39 +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 1fEcyj-0001MG-G4 for speck@linutronix.de; Fri, 04 May 2018 15:50:37 +0000 Date: Fri, 4 May 2018 17:50:34 +0200 From: Peter Zijlstra Subject: [MODERATED] Re: [PATCH 1/5] SSB extra 2 Message-ID: <20180504155034.GO12217@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?= <20180504092050.GK12217@hirez.programming.kicks-ass.net> <90f19909-5f25-ece9-e2b0-3c8cedc60caf@linux.intel.com> MIME-Version: 1.0 In-Reply-To: <90f19909-5f25-ece9-e2b0-3c8cedc60caf@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Fri, May 04, 2018 at 07:04:53AM -0700, speck for Dave Hansen wrote: > On 05/04/2018 02:20 AM, speck for Peter Zijlstra wrote: > >> @@ -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. > > It's not a bad idea. This didn't seem *too* invasive other than I had > to hit all the variants of calling func(). > Were you thinking we add some eBPF instruction which calls out to the > kernel machinery and then the kernel BPF code inserts it as the first > instruction of the program? Teaching the interpreter to do this is trivial, for the JIT we would emit a "CALL $asm_pre_thunk" as first instruction and "CALL $asm_post_thunk" before every RET. And when it doesn't need to mitigate, don't issue the instructions at all.