Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1463907imd; Thu, 1 Nov 2018 16:23:45 -0700 (PDT) X-Google-Smtp-Source: AJdET5flR/xyZp2ECB9pE7C9v/k53ACa/xSHIMAd5LD5dOjDvjUExf/79PUB4nH5q1fZtQkkoHcs X-Received: by 2002:a63:cb4a:: with SMTP id m10mr8570622pgi.105.1541114625552; Thu, 01 Nov 2018 16:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541114625; cv=none; d=google.com; s=arc-20160816; b=tI3oOPob46wo1bM04e8dbK3xvgm//+vQeeZAjPHpe6oioQxun7MkxVj6CG84pueBXP OLyONc9JjfLdCzib+vHzT7bZpjPCM/d9byLabb7dv0jwkx77G7TRyJZKcazJiIW5giFr dYT0u2gFSlOd1IFCgjqe06Li2MsuA4VtFKuD7usbeS96CBzH1r56N0VsCyuqbSxk2j7M uqMcQXRnhyNmZ9w6aMXB6p24NiVabIBVxVab/EPRVGJTkF0bTWlsLkUn1zhm5lTpEJRH 0NUnn8oxh2Bl5+mmuvFSfyPaA4rvvuQbtne4EvliXf2PkvaSm2cWu6ZJ1DnxaJEjM1FV mEBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=R4Id/Ym5O5JL0lMdzStLSiwfkTSDbnXGSisam+YoaWA=; b=Twhu48c8yTU6YThoafjDhkUelCzt1tJruI/i5ymxELmE2J8gz7m//mUBRHUa2fgVFg DZetIIpQFKgn5cTMXaIK6GEZ4Gzh3yYx61Q2o6pxxJUknEonbsIktIwr5+UKESuFzu7i 2jYrNKttq/2G68A0fVC5a0N8tnCuv8o6AZ7MObzyGNFeIdKt1oQq4azDrgbW6j2jX2Vm B8klp93kYdrYVSto5QZNGLISqU45Ndc37CN9rQcJjIOml99bkDiG+rCIK4asS1/tZXrY 9tT0FcB/+6i4AnRHbH/Uw8AYc1oDKktAjv9O6bgFRZsKpHAULJB9mZb0pZfRkJ2rCO6U k33w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="JVKXYLV/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i66-v6si32781884pfc.173.2018.11.01.16.23.30; Thu, 01 Nov 2018 16:23:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="JVKXYLV/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728203AbeKBI2M (ORCPT + 99 others); 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-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.