From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0501C6786F for ; Thu, 1 Nov 2018 23:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6290B20843 for ; Thu, 1 Nov 2018 23:23:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="JVKXYLV/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6290B20843 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728215AbeKBI2M (ORCPT ); Fri, 2 Nov 2018 04:28:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:56020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728030AbeKBI2M (ORCPT ); Fri, 2 Nov 2018 04:28:12 -0400 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 79E1F21019 for ; Thu, 1 Nov 2018 23:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541114588; bh=415MFWHDIZtY1qe6caCyVVn8I98XBm9BvsFAfLS0CTU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JVKXYLV/sYI1NWV6HXUo6hcHdtWht5lJelqnZ359Fahb6uzf7V/ZYFoyB2O0xMa7r 0AQvyLchCLsOvB4QhR3jjXJw8muiqLi1+Qiu0qCbOvTxkOq/UhadOOsolehV8Txk15 vga7mxRRpQqNpP2KaXo90bVL9CE1Ni0KWVT6dLDA= Received: by mail-wr1-f51.google.com with SMTP id j26-v6so170623wre.1 for ; Thu, 01 Nov 2018 16:23:08 -0700 (PDT) X-Gm-Message-State: AGRZ1gIqDfvUFTSv2/qRGa3Ona4x5eOxnr0aQ/5Ou+5cufaNdVI0+EeH SLdzvo6aN+qNkSKqKJ0a0rgGkIVuWZuH2+P23QHeRA== X-Google-Smtp-Source: AJdET5dhuzroPAEW5lPVQoXX0VyqDMbXzwT6rfzx0IjgqP5lijbGEa9KnlxloP0J7tTYHatP7JIn6BVCRwejrzQzveg= X-Received: by 2002:adf:97d3:: with SMTP id t19-v6mr8620050wrb.283.1541114586807; Thu, 01 Nov 2018 16:23:06 -0700 (PDT) MIME-Version: 1.0 References: <20181101185225.GC5150@brightrain.aerifal.cx> <20181101193107.GE5150@brightrain.aerifal.cx> In-Reply-To: From: Andy Lutomirski Date: Thu, 1 Nov 2018 16:22:55 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: RFC: userspace exception fixups To: Linus Torvalds Cc: Rich Felker , Jann Horn , Andrew Lutomirski , Dave Hansen , "Christopherson, Sean J" , Jethro Beekman , Jarkko Sakkinen , Florian Weimer , Linux API , X86 ML , linux-arch , LKML , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, Andy Shevchenko , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "Carlos O'Donell" , adhemerval.zanella@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 1, 2018 at 2:24 PM Linus Torvalds wrote: > > On Thu, Nov 1, 2018 at 12:31 PM Rich Felker wrote: > > > > See my other emails in this thread. You would register the *address* > > (in TLS) of a function pointer object pointing to the handler, rather > > than the function address of the handler. Then switching handler is > > just a single store in userspace, no syscalls involved. > > Yes. > > And for just EENTER, maybe that's the right model. > > If we want to generalize it to other thread-synchronous faults, it > needs way more information and a list of handlers, but if we limit the > thing to _only_ EENTER getting an SGX fault, then a single "this is > the fault handler" address is probably the right thing to do. It sounds like you're saying that the kernel should know, *before* running any user fixup code, whether the fault in question is one that wants a fixup. Sounds reasonable. I think it would be nice, but not absolutely necessary, if user code didn't need to poke some value into TLS each time it ran a function that had a fixup. With the poke-into-TLS approach, it looks a lot like rseq, and rseq doesn't nest very nicely. I think we really want this mechanism to Just Work. So we could maybe have a syscall that associates a list of fixups with a given range of text addresses. We might want the kernel to automatically zap the fixups when the text in question is unmapped.