From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755487AbbJUSxb (ORCPT ); Wed, 21 Oct 2015 14:53:31 -0400 Received: from mail-ob0-f169.google.com ([209.85.214.169]:36622 "EHLO mail-ob0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752975AbbJUSx3 (ORCPT ); Wed, 21 Oct 2015 14:53:29 -0400 MIME-Version: 1.0 In-Reply-To: References: <1445373372-6567-1-git-send-email-cmetcalf@ezchip.com> <1445373372-6567-7-git-send-email-cmetcalf@ezchip.com> <20151020205610.51b3d742@grimm.local.home> <5626EABC.9060202@ezchip.com> From: Andy Lutomirski Date: Wed, 21 Oct 2015 11:53:09 -0700 Message-ID: Subject: Re: [PATCH v8 06/14] task_isolation: provide strict mode configurable signal To: Gilad Ben Yossef Cc: Chris Metcalf , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , Rik van Riel , Tejun Heo , Frederic Weisbecker , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , Catalin Marinas , Will Deacon , "linux-doc@vger.kernel.org" , Linux API , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 20, 2015 at 11:41 PM, Gilad Ben Yossef wrote: > > >> From: Andy Lutomirski [mailto:luto@amacapital.net] >> Sent: Wednesday, October 21, 2015 4:43 AM >> To: Chris Metcalf >> Subject: Re: [PATCH v8 06/14] task_isolation: provide strict mode >> configurable signal >> >> On Tue, Oct 20, 2015 at 6:30 PM, Chris Metcalf >> wrote: >> > On 10/20/2015 8:56 PM, Steven Rostedt wrote: >> >> >> >> On Tue, 20 Oct 2015 16:36:04 -0400 >> >> Chris Metcalf wrote: >> >> >> >>> Allow userspace to override the default SIGKILL delivered >> >>> when a task_isolation process in STRICT mode does a syscall >> >>> or otherwise synchronously enters the kernel. >> >>> > >> > >> > It doesn't map SIGKILL to some other signal unconditionally. It just allows >> > the "hey, you broke the STRICT contract and entered the kernel" signal >> > to be something besides the default SIGKILL. >> > >> > > >> >> I still dislike this thing. It seems like a debugging feature being >> implemented using signals instead of existing APIs. I *still* don't >> see why perf can't be used to accomplish your goal. >> > > It is not (just) a debugging feature. There are workloads were not performing an action is much preferred to being late. > > Consider the following artificial but representative scenario: a task running in strict isolation is controlling a radiotherapy alpha emitter. > The code runs in a tight event loop, reading an MMIO register with location data, making some calculation and in response writing an > MMIO register that triggers the alpha emitter. As a safety measure, each trigger is for a specific very short time frame - the alpha emitter > auto stops. > > The code has a strict assumption that no more than X cycles pass between reading the value and the response and the system is built in > such a way that as long as the code has mastery of the CPU the assumption holds true. If something breaks this assumption (unplanned > context switch to kernel), what you want to do is just stop place > rather than fire the alpha emitter X nanoseconds too late. > > This feature lets you say: if the "contract" of isolation is broken, notify/kill me at once. That's a fair point. It's risky, though, for quite a few reasons. 1. If someone builds an alpha emitter like this, they did it wrong. The kernel should write a trigger *and* a timestamp to the hardware and the hardware should trigger at the specified time if the time is in the future and throw an error if it's in the past. If you need to check that you made the deadline, check the actual desired condition (did you meat the deadline?) not a proxy (did the signal fire?). 2. This strict mode thing isn't exhaustive. It's missing, at least, coverage for NMI, MCE, and SMI. Sure, you can think that you've disabled all NMI sources, you can try to remember to set the appropriate boot flag that panics on MCE (and hope that you don't get screwed by broadcast MCE on Intel systems before it got fixed (Skylake? Is the fix even available in a released chip?), and, for SMI, good luck... 3. You haven't dealt with IPIs. The TLB flush code in particular seems like it will break all your assumptions. Maybe it would make sense to whack more of the moles before adding a big assertion that there aren't any moles any more. --Andy