Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp624610yba; Wed, 3 Apr 2019 16:04:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwloWPUMC88uP5MILRjHaakjrRXVZDqz3C7B6U56mAkfGn1RTBQbGmSM06SCKNU36c39+UF X-Received: by 2002:a63:5a20:: with SMTP id o32mr2257070pgb.225.1554332651174; Wed, 03 Apr 2019 16:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554332651; cv=none; d=google.com; s=arc-20160816; b=CscmcHYu0TJ7Ny5q9bmz/74jFeAWno8B33pW9GWwTVhRN2zokjW4t1mQIlInUw8GVf KtPryJ8xJWSLMi8y/+y4w+xmpO/dIux+mcRl8uh2dvEp8+BH0gkAcXadoDxifU9eJVhw BckaYfX3xRjhobTvfKGPek+MIK43RyHx8nY3WrvBvZHKl7u7Mrk2AWIVpPI7hQBq9vix Te6HyE8B4RWwKr8S9597gYRMHHtDzLEF7nHwnTow2a3xwWG3/geEpWEkpt6ZSA2YBf3f H9TQ74PKRaI8lwxZhG5u0rSULeYn/5kmqomsLPrLrTMNeK/Y2RN91yWyQKjzrZSAy1sS jqSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=s5fHxK0Ro1KVx4d6bBgL6Qpaxo94y1AVMC6QP0OlcWg=; b=rLVIMdtPdneppN/J/cAbP7Jb9DKj5IkeyLK3a5OI/IYrJtELeoAYGOdxAkYpkgnQ46 LCoc7qZgOGEXXDkSiKZoD37YO+YLsJ0EP8tgnu9WU6wFB4ygaho2qtJUVIxPtGYVT3Fq 6VjHwOB8xsuvlMdt5OTWlXq9wPjZTnp4di0d/cj8T88Iyk72Vt1kPWwSTe032djmW1Si 3VhLYdr+dvxYBVQtEaB0e1HlfMWmHdiebA44GTf93cVXnhO5IAd5cz0ovry1I+uaShY+ zRAHQrbC8q93xlHmoBRnxacAo6JGhDolWfOQoD1nG4rwwY8s7sBAEdqQ14sI6XfESAlT Ah9Q== 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 a33si7322357pld.348.2019.04.03.16.03.54; Wed, 03 Apr 2019 16:04:11 -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; 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 S1726372AbfDCXDT (ORCPT + 99 others); Wed, 3 Apr 2019 19:03:19 -0400 Received: from mga18.intel.com ([134.134.136.126]:50167 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbfDCXDT (ORCPT ); Wed, 3 Apr 2019 19:03:19 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 16:03:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="137394331" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by fmsmga008.fm.intel.com with ESMTP; 03 Apr 2019 16:03:17 -0700 Date: Wed, 3 Apr 2019 16:03:17 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: "Xing, Cedric" , Jarkko Sakkinen , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "linux-sgx@vger.kernel.org" , "akpm@linux-foundation.org" , "Hansen, Dave" , "nhorman@redhat.com" , "npmccallum@redhat.com" , "Ayoun, Serge" , "Katz-zamir, Shay" , "Huang, Haitao" , "andriy.shevchenko@linux.intel.com" , "tglx@linutronix.de" , "Svahn, Kai" , "bp@alien8.de" , "josh@joshtriplett.org" , "Huang, Kai" , "rientjes@google.com" , Dave Hansen , Haitao Huang , Jethro Beekman , "Dr . Greg Wettstein" Subject: Re: [PATCH v19,RESEND 24/27] x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave transitions Message-ID: <20190403230317.GD4682@linux.intel.com> References: <20190322215903.GE12666@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F4E85E481@ORSMSX116.amr.corp.intel.com> <960B34DE67B9E140824F1DCDEC400C0F4E85E989@ORSMSX116.amr.corp.intel.com> <20190325180349.GF31069@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F4E85FABF@ORSMSX116.amr.corp.intel.com> <960B34DE67B9E140824F1DCDEC400C0F4E860C69@ORSMSX116.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 28, 2019 at 12:18:40PM -0700, Andy Lutomirski wrote: > Finally, why does the vDSO code bother checking whether the leaf is valid? To sanity check the input to ensure the caller is attempting to enter an enclave, i.e. the function is named __vdso_sgx_enter_enclave(), not __vsgx_enclu(). And if the caller does pass the wrong leaf, EINVAL will be easier to debug than EFAULT, especially on SGX1 hardware where the #GP could be misconstrued as a loss of EPC. I'm not dead set on the checks by any means, but it does seem appropriate. And the cost is all of 3 uops and a few bytes of a code.