Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp945725imu; Tue, 11 Dec 2018 10:00:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/VMsGzBhK5NCob3OoDXQ5/BJgS/mk1sWNMzLt2v9GGDa0rjEbYVwXHTFTsZ4VhkEoZof4BI X-Received: by 2002:a63:1c09:: with SMTP id c9mr15244035pgc.200.1544551207538; Tue, 11 Dec 2018 10:00:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544551207; cv=none; d=google.com; s=arc-20160816; b=bb8ChJIZjHUJl5bKWws/9D9pcH56RKuwC8oX295P2cKKCLYQ7jLwuMO0xGgKLGOBCc 8tyT1lCKT8FF4tWKrXG9YA7tNbKovMfq/dW8prI9X6hA+D1iPR5eNGil9PMNrFjGsBYH mT3dFFjrB+mqImhpl7dMR5FrFU/YbyRkFah4HIMIteFlb0EJlWLc7EIGQlEDrLsJ2vHh C2C1sdVJ1qDXIYKd/Jp758KatNDAfkM8usGoKmWRVvFNBea8w8SYwZl/iteHtlJzBA4W hBduGJ0Fv7d3ihLMTixau1ik6k9DgiXCbONZugSwEae+3iEtB466Hrt+xzHmJi5YTvQI m/Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YYbO67/NzJoPRDj0IKIj9WAIpgku1Zhlk8ekwOBUjpg=; b=yME+MoQcO/VqfB/LmqZqsbAau8BNkCJASFe6zqJ/DJkkrUhj6e6YkyoJU5LwvpOhD3 +7uyGfmQxgM2uTi+x2JJuC5EZLp4AmVlWyRiPqnHJIEOQ23jYRbzCFjO8PnKv/OF+1fk FW0yLrMAjCe+JsSfEpeSW1GoXePmzYKemnyDOWa9FK/Eav4+sm3uJYEQhrYdhNC4EYF7 Md8EKoELEJ5KmxRpbGa76+tejKkLj1EBLnMZrefwrGXWMuKKPkOGdxTMZOHgkaiIhdEO xPRTFMGQqSrcLpaNuD/fRwgeV1zR3bdK7epGEBa5HyvEje5a8EySI2iAfji9v6S5mjQY b6fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KzPMVCIa; 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 y73si11935725pgd.478.2018.12.11.09.59.52; Tue, 11 Dec 2018 10:00:07 -0800 (PST) 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=KzPMVCIa; 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 S1726771AbeLKR6e (ORCPT + 99 others); Tue, 11 Dec 2018 12:58:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:46976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbeLKR6e (ORCPT ); Tue, 11 Dec 2018 12:58:34 -0500 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 0321F208E7 for ; Tue, 11 Dec 2018 17:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544551113; bh=IT+/Sn539b1Hv8g6PSWkXhUMKvsM5oSYYLuIqhpavcs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KzPMVCIasypCyr/lG9ew7dulA9cm+XNoq7h1/vatjcUMLSWnwovRqtB0FCoa9oEG+ 3sNT2Kd29o/3Mlbbll7HAaSHlJc+55hE+ERi8s9Rl20c2d3cpdVv3DC5oROgbT6dq+ Yo241SoQrwAjqZQZULXXHnxfRs+NI30mhvrlsKD8= Received: by mail-wm1-f46.google.com with SMTP id m22so3263765wml.3 for ; Tue, 11 Dec 2018 09:58:32 -0800 (PST) X-Gm-Message-State: AA+aEWZjJH3r50xQPDMtDVUZAzBiLVp7umzahiQXq17lfRh6xSuLKnKz tV5OTVt7uUYnlf8W8akSurzYqvvfcWddiYPBSbQ4jA== X-Received: by 2002:a1c:aa0f:: with SMTP id t15mr3219252wme.108.1544551111470; Tue, 11 Dec 2018 09:58:31 -0800 (PST) MIME-Version: 1.0 References: <20181210232141.5425-1-sean.j.christopherson@intel.com> <20181210232449.GA11843@localhost> <20181211165253.GB14731@linux.intel.com> In-Reply-To: <20181211165253.GB14731@linux.intel.com> From: Andy Lutomirski Date: Tue, 11 Dec 2018 09:58:19 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v3 0/4] x86: Add exception fixup for SGX ENCLU To: "Christopherson, Sean J" Cc: Josh Triplett , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , Jarkko Sakkinen , Dave Hansen , Andrew Lutomirski , Peter Zijlstra , "H. Peter Anvin" , LKML , linux-sgx@vger.kernel.org, Haitao Huang , Jethro Beekman , "Dr. Greg Wettstein" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Dec 11, 2018, at 8:52 AM, Sean Christopherson wrote: > >> On Tue, Dec 11, 2018 at 07:41:27AM -0800, Andy Lutomirski wrote: >> >> >>>> On Dec 10, 2018, at 3:24 PM, Josh Triplett wro= te: >>>> >>>> On Mon, Dec 10, 2018 at 03:21:37PM -0800, Sean Christopherson wrote: >>>> At that point I realized it's a hell of a lot easier to simply provide >>>> an IOCTL via /dev/sgx that allows userspace to register a per-process >>>> ENCLU exception handler. At a high level, the basic idea is the same >>>> as the vDSO approach: provide a hardcoded fixup handler for ENCLU and >>>> attempt to fixup select unhandled exceptions that occurred in user cod= e. >>> >>> So, on the one hand, this is *absolutely* much cleaner than the VDSO >>> approach. On the other hand, this is global process state and has some >>> of the same problems as a signal handler as a result. >> >> I liked the old version better for this reason > > This isn't fundamentally different than forcing all EENTER calls through > the vDSO, which is also per-process. Technically this is more flexible > in that regard since userspace gets to choose where their one ENCLU gets > to reside. Userspace can have per-enclave entry flows so long as the > actual ENLU[EENTER] is common, same as vDSO. Right. The problem is that user libraries have a remarkably hard time agreeing on where their one copy of anything lives. > >> and for another reason: >> while this new one looks very very simple, it still has the hidden >> complexity that the magic values written to registers in the event of an >> exception are very much Linux specific. > > Definitely more magical, but not necessarily more difficult to document. > It'd essentially be an extension of hardware's AEE/AEP behavior. > >> OTOH, the old approach clobbered more regs than needed, but that=E2=80= =99s a easy fix.