Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3320549imu; Wed, 7 Nov 2018 08:31:12 -0800 (PST) X-Google-Smtp-Source: AJdET5ceZJl0cmcJ79YbPXQHmTcytPEBlkP/OgjfFjovDJzd0Has6mon+/oudL+/aLpr+9wpDRZ6 X-Received: by 2002:a63:6848:: with SMTP id d69-v6mr757051pgc.113.1541608272232; Wed, 07 Nov 2018 08:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541608272; cv=none; d=google.com; s=arc-20160816; b=mI458q8zhJcXwfmPV+fa4VkTCjhkBOibqT8iNKFuciXnH6U/XhneqYrJRzirZeS2vs VRzpOOSI8ig1y21Z41pslgLUYoPhwF6zUQ0lXMfNaLOJVErqMKZXbau+dmUCFQb+/ill QbD+zuzKs6uKcY5651Xma6+VwDplrhd+uDes/ifEKLuxmZ2W0Sl9g2quES1olh7cO04P +DJz69Fem/5SCQL7b+gGrGxZTjDTRANW9FO+z7NX/20OQuJVSVlsWh4La1Sujf5Ee7IX xYKUiruv9TEpV1+xSnZdqhZtoY2E2DiU5JM1JeHQm91QX1+Exh94Un0fOtc7TniY+yFf Wo5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JB33kkJMf+jrZHh0tP0eQHCkVGnOMm0knWmoXJpL+7Q=; b=DwRo0ci1IAyVeDgutkcB83Vk4QxpZpM+I8W9aetQCLi3gIaLjEkFg3Fso5/fBNPqvI wCZBl4QMpSoXAQDUPWEtiByarb6XNV0JMhDFDKvzKUVJCBHhItfOBZ6FjEz2ir92J4dg uOqhmlMHpuZoeEiAEQ4Q5rJj9rqeih2AqVUpKE1DysYn3FN1n+Yv6fCJwtEeOZGbNElf X0Fk3HL4P7SHdVXXgUzW3CafGImIjtgg9teY22vD6IEWBKC9d15FY5nZ3UpR5NBkX/bf ssZDzNfBrOVp6tCX7iY9wNQDZFbvJUPBOufJc6bsLQeg7ckBlbJ35nk3+fT24LX9m/5n NMGA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si1082274pla.207.2018.11.07.08.30.56; Wed, 07 Nov 2018 08:31:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731274AbeKHCBg (ORCPT + 99 others); Wed, 7 Nov 2018 21:01:36 -0500 Received: from mga14.intel.com ([192.55.52.115]:51994 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727312AbeKHCBf (ORCPT ); Wed, 7 Nov 2018 21:01:35 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2018 08:30:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,476,1534834800"; d="scan'208";a="84702378" Received: from kaczmarx-mobl.ger.corp.intel.com (HELO localhost) ([10.249.254.132]) by fmsmga008.fm.intel.com with ESMTP; 07 Nov 2018 08:30:22 -0800 Date: Wed, 7 Nov 2018 18:30:19 +0200 From: Jarkko Sakkinen To: Dave Hansen Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-sgx@vger.kernel.org, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, haitao.huang@intel.com, mark.shanahan@intel.com, andriy.shevchenko@linux.intel.com, Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "open list:DOCUMENTATION" , open list Subject: Re: [PATCH v15 23/23] x86/sgx: Driver documentation Message-ID: <20181107163019.GA11509@linux.intel.com> References: <20181102231320.29164-1-jarkko.sakkinen@linux.intel.com> <20181102231320.29164-24-jarkko.sakkinen@linux.intel.com> <154ded23-fd1d-f324-4e0a-9de8eddcda6d@intel.com> <20181106054911.GA15575@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 06, 2018 at 08:45:37AM -0800, Dave Hansen wrote: > On 11/5/18 9:49 PM, Jarkko Sakkinen wrote: > > On Mon, Nov 05, 2018 at 12:27:11PM -0800, Dave Hansen wrote: > >> The ABI seems entirely undocumented and rather lightly designed, which > >> seems like something we should fix before this is merged. > > > > ABI is documented in arch/x86/include/uapi/asm/sgx.h that from which the > > documentation is included to intel_sgx.rst. I'm not saying that there is > > no space refine it but it is neither undocumented. > > I specifically mean the instruction flow around asynchronous exits or > explicit enclave exit calls via EEXIT. Signals are part of the ABI but > go unmentioned in the documentation. Ok, thanks for clarification. We will document it. > > It's also worth noting that EENTER *can* act (from the kernel's > perspective) like an instruction that both jumps and sets a bunch of > registers (including %rsp). It's certainly abnormal in that regard. Agreed. > In fact, in the docs: > > > +Enclave can only execute code inside the ELRANGE. Instructions that may cause > > +VMEXIT, IO instructions and instructions that require a privilege change are > > +prohibited inside the enclave. Interrupts and exceptions always cause enclave > > +to exit and jump to an address outside the enclave given when the enclave is > > +entered by using the leaf instruction ENCLS(EENTER). > > it's probably a really good idea to explain that the address outside of > the enclave is enclave-provided, and is not, for instance, just the next > instruction after EENTER. > > >> Also, for a feature as massive and complicated as this one, it seems > >> irresponsible to not have a selftest. Is that not feasible for some reason? > > > > I do have the in-kernel launch enclave stuff backed up here: > > > > https://github.com/jsakkine-intel/sgx-le-host > > https://github.com/jsakkine-intel/sgx-le > > > > This is about as simple as it gets without any type of run-time. > > Does this code run when I type "make kselftest"? If not, I think we > should rectify that. No, it doesn't. It is just my backup for the non-SDK user space code that I've made that I will use to fork my user space SGX projects in the future. I can work-out a selftest (and provide a new patch in the series) but I'm still wondering what the enclave should do. I would suggest that we start with an enclave that does just EEXIT and nothing else. /Jarkko