Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1309375imm; Wed, 26 Sep 2018 15:38:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV60w4BPFR8rmNgCj2cYdtiflBJ975LpcFfg/HDKjb9DskbqmW9xZ/FmVrKIzIXxtbwRaDWcy X-Received: by 2002:a17:902:2e83:: with SMTP id r3-v6mr969154plb.80.1538001519643; Wed, 26 Sep 2018 15:38:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538001519; cv=none; d=google.com; s=arc-20160816; b=p2tWFGytpyhoVe+gHmV4chHqW+AgVaoxg9wXzqG7raJfZlmtim3R3YiNNFeGA1n3N1 B8luICWRy2CCYqFo3zLEmPmPYD/kvWiDb4oNN5pv1HQT+4aS8nW3M6goyHv0TMZMSk5i Dw5C3qfFiY3UUicYxZLTPamcBUZsewNY0XQawFGrSLDCWR1uTuJzYTJtaStm3fCHmLWE 2AtAVbrMhoJNkIKwFsx8IKBWBanpIK1+Xa1L7xmDBNAJDtUl/nPveDaxjjEQwDmG02PH 6LLbYIaVt3Pzysa0sAZBCSzyIVM2b5D2o/ORgFfZmpr0Ms+VTfgTtE9J7IbehCBvEqp+ bR9w== 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=tjCid2raywD9TiP/EG3nqgGcPqMQjzebtE2YnSs0iIk=; b=KPnHl6i2p45BBO+O7BQqvMQygFdki3cAptGEabRre8k3DW4bPZ/tYtT0Ithw5PUXZR A3s+sbBWbYgvSIzxQLV9txUuTBDWxnKynD1Ri6iw5wswtVctrz497LVS0KGCtL9KmxaV Yw4OuMRB1F0cnBj8FHBGyUSsYruW8x5kzFDSfXAobcPzVhF0eysZNEjoF1YMt3zRcGDS LwSFd2h9jLNKDtR5E2itKVevphwmNx/uqmluMcjy0BXsdRcU+1TCAt4UYaoxHAy/PrIt PNJ6fauTvxVGZ7NgUyNhjfjfEjQa1IwC1WryUBBDXEbLVgyqBNpfI/1+YSDGdVAViTU5 7CmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=MY9tHArU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g70-v6si235264pfe.4.2018.09.26.15.38.24; Wed, 26 Sep 2018 15:38:39 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=MY9tHArU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbeI0ExI (ORCPT + 99 others); Thu, 27 Sep 2018 00:53:08 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41283 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbeI0ExI (ORCPT ); Thu, 27 Sep 2018 00:53:08 -0400 Received: by mail-wr1-f66.google.com with SMTP id j15-v6so502429wrt.8 for ; Wed, 26 Sep 2018 15:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tjCid2raywD9TiP/EG3nqgGcPqMQjzebtE2YnSs0iIk=; b=MY9tHArUFddizrowgA6vJAy3w3tm5x2TojafHcyCfxTRxYObxe4Qnnwfb9rLI5t+0B ly/JSX+avKDjEVPoP8bFX/6fMWvxIntu5CE+o7mXV0Hdt5lOa2RNO71xvdCh8EcCoaeD JKPlSZwnmMhWXtFWid5dNRVWx5po1ymQcOS3ZWzgoFok+D2Ow9xh2K6arumybw4aYDGj q2C3KlL40kjL2CY9vKTrWuVkmuBNEAboQZ35A29qtpR3AlR4APJiUTz4lowX88Lt6gZx e5ObnkbkKawEhxozfAQVx4PDUqasIAs5NpTDIJ86YRAdNIAya3E/S+k+o33WStzSA9yl VMJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tjCid2raywD9TiP/EG3nqgGcPqMQjzebtE2YnSs0iIk=; b=HdcZs6p+zlcrrUfjgfzR0PKwl6hKxhGNZ+KHTGwQgYiBc7zTrq/Xp7I0lJhwFtKeND DCryMKW+akkIlnK+/MfJJt4lUM/HtgVaQnMlq3PoI2s9GDbubh9DCaWpZcXPoSCK7fak muwEXbgqEZ55YT62SrBP0Ftp2sTaz2S+ZMpGfZLolxjsycEIgHEpgVLojcDzliN6Fjwy HR/Y2D87OY9Esh+Dbqe42gCgDeYAmka+cLhKKEme2CeAqFQuFQsvjUbiDWQ33EwX9Hoo 6vabyF0ZZG9CMygWxb+hUT3csF069OhuscAJ9VbFEEgBsWJcwyjOZJvgBH/DT50FQ7SY y5bQ== X-Gm-Message-State: ABuFfoiaqWpsMBixEh9rpBhQsQcj90quHCF8dA5Vzd+HbLodMu4BLjEM 6NSDdK5QifvTiWDoyiMs4HS6fLzk48H1ZSnj0jUAqw== X-Received: by 2002:adf:dcc1:: with SMTP id x1-v6mr6644969wrm.21.1538001476929; Wed, 26 Sep 2018 15:37:56 -0700 (PDT) MIME-Version: 1.0 References: <20180925130845.9962-1-jarkko.sakkinen@linux.intel.com> <20180925130845.9962-10-jarkko.sakkinen@linux.intel.com> <20180926173516.GA10920@linux.intel.com> <2D60780F-ADB4-48A4-AB74-15683493D369@amacapital.net> <9835e288-ba98-2f9e-ac73-504db9512bb9@intel.com> <20180926204400.GA11446@linux.intel.com> <992b1d6d-cc0f-776f-d938-2a1f7cad52c8@intel.com> In-Reply-To: <992b1d6d-cc0f-776f-d938-2a1f7cad52c8@intel.com> From: Andy Lutomirski Date: Wed, 26 Sep 2018 15:37:45 -0700 Message-ID: Subject: Re: [PATCH v14 09/19] x86/mm: x86/sgx: Signal SEGV_SGXERR for #PFs w/ PF_SGX To: Dave Hansen Cc: "Christopherson, Sean J" , Andrew Lutomirski , Jarkko Sakkinen , X86 ML , Platform Driver , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, Andy Shevchenko , Dave Hansen , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , LKML 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 Wed, Sep 26, 2018 at 2:45 PM Dave Hansen wrote: > > On 09/26/2018 02:15 PM, Andy Lutomirski wrote: > > Could we perhaps have a little vDSO entry (or syscall, I suppose) that > > runs an enclave an returns an error code, and rig up the #PF handler > > to check if the error happened in the vDSO entry and fix it up rather > > than sending a signal? > > Yeah, signals suck. > > So, instead of doing the enclave entry instruction (EENTER is it?), the > app would do the vDSO call. It would have some calling convention, like > "set %rax to 0 before entering". Then, we just teach the page fault > handler about the %RIP in the vDSO that can fault and how to move one > instruction later, munge %RIP to a value that tells about the error, > then return from the fault. It would basically be like the kernel > exception tables, but for userspace. Right? Yeah. Maybe like this: xorl %eax,%eax eenter_insn: ENCLU[whatever] eenter_landing_pad: ret And the kernel would use the existing vdso2c vdso-symbol-finding mechanism to do the fixup. > > How would a syscall work, though? I assume we can't just enter the > enclave from ring0. My understanding of how AEX works is a bit vague, but maybe a syscall could reuse the mechanism? The vDSO approach seems considerably simpler. We do need to make sure that a fault that happens on or after return from an AEX event does the right thing. But I'm still vague on how that works, sigh. --Andy