Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3132838pxa; Tue, 18 Aug 2020 07:27:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvQ//x8Z/HxBkjCwwslvtjud8d1iScBL8bUWWetqvhneUjZJzN6V1jsYQ2k9Mx2dzUit5u X-Received: by 2002:a17:906:b2d7:: with SMTP id cf23mr20384959ejb.113.1597760874231; Tue, 18 Aug 2020 07:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597760874; cv=none; d=google.com; s=arc-20160816; b=VPkWiEUl+JrCEqUBbEqePLKFF9fRrqIyRMIEdAVS2dqbCR2N6+Dec5+JfM5GF/PrI0 fjt/kXd24O3vUH+Ht0qC1/5mEpYA7lfUrHh8gI+hxXS/7gpdmBAR+AZvsvz4fq0BysOK k6MjdpYKB983BwJYuceh5fg1GcsdrQuiDcxTBB1DqveGEqcv486AAhHAZsBBsI5w2+YS YKWmFt2zgMrTG4dSeESNAcFQndUCdh+dRL96jm3X1T/SeJ+s92a8v5y+wTajWRdMrGFx 0FIJ9ct3V39myIJTinAJfS564hK4tkMkpYrKzuKAGw3DfHflDHYxmil8Bfq35nMGIa6W K4bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=eEBZ1990prx/pdJcaNZ32U1RQFcL9YpXyYv6yVXN3T0=; b=HqV40R4jlRbRqT+/F8mjLpSYUi7aLpuWHpSAPZT9NJjpaoNhbrTg7VQTuvrPw2X2nf e1r8lcIn/OXF7M0e7Kq/NXu6sQay1MTvh1Of8pGp9L5lerMog4LASmszDBdew0x7jOX/ 6ktxtaP/EHn3Qx2zSK9N9yKj7HeS51MqiQ8A4W1y87gcMvMn3MF46QDkmepHpWgKI8vj cHngUZx+YAv/nFlw4xbZSWNQS+u3YcCWCSKUgYXPlH8ZkQDtkLmXTMi6+97/0/6l3Ss1 SxMrNdKeVGo8ef5nRs6J/5YOnhsxTGaO3LH64l5mLg9z+HmJ/CZUrldFmww6jJBS7aQ9 KzsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y26si13152306edr.390.2020.08.18.07.27.30; Tue, 18 Aug 2020 07:27:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726569AbgHRO0e (ORCPT + 99 others); Tue, 18 Aug 2020 10:26:34 -0400 Received: from mga17.intel.com ([192.55.52.151]:49348 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbgHRO0d (ORCPT ); Tue, 18 Aug 2020 10:26:33 -0400 IronPort-SDR: LOf5ZthRJlyv6JmDDA9awHUuWGHWJfUnUybI/0bw/ZiwPziWcYyPG/2eRJYGHXs+/4UF9QFIx3 2e2AlTESHlkw== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="134968974" X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="134968974" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 07:26:32 -0700 IronPort-SDR: 6k2SbS6PyYJK8VDtr8rqyNjsVTFPQAc2p72UKWyp5AmkJ4gsKFaDYDiptWZFwNIwDgboNTydOs EjFziqeP3Idg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="334385459" Received: from ribnhajh-mobl.ger.corp.intel.com (HELO localhost) ([10.249.47.113]) by FMSMGA003.fm.intel.com with ESMTP; 18 Aug 2020 07:26:26 -0700 Date: Tue, 18 Aug 2020 17:26:25 +0300 From: Jarkko Sakkinen To: Nathaniel McCallum Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Andy Lutomirski , Jethro Beekman , Cedric Xing , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, bp@alien8.de, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, "Huang, Haitao" , Josh Triplett , kai.huang@intel.com, "Svahn, Kai" , kmoy@google.com, ludloff@google.com, luto@kernel.org, Neil Horman , Patrick Uiterwijk , David Rientjes , Thomas Gleixner , yaozhangx@google.com Subject: Re: [PATCH v36 21/24] x86/vdso: Implement a vDSO for Intel SGX enclave call Message-ID: <20200818142625.GB132200@linux.intel.com> References: <20200716135303.276442-1-jarkko.sakkinen@linux.intel.com> <20200716135303.276442-22-jarkko.sakkinen@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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 06, 2020 at 10:55:43AM -0400, Nathaniel McCallum wrote: > In a past revision of this patch, I had requested a void *misc > parameter that could be passed through vdso_sgx_enter_enclave_t into > sgx_enclave_exit_handler_t. This request encountered some push back > and I dropped the issue. However, I'd like to revisit it or something > similar. > > One way to create a generic interface to SGX is to pass a structure > that captures the relevant CPU state from the handler so that it can > be evaluated in C code before reentry. Precedent for this approach can > be found in struct kvm_run[0]. Currently, however, there is no way to > pass a pointer to such a structure directly into the handler. > > This can be done implicitly by wrapping the struct > sgx_enclave_exception in another structure and then using techniques > like container_of() to find another field. However, this is made more > difficult by the fact that the sgx_enclave_exit_handler_t is not > really using the x86_64 sysv calling convention. Therefore, the > sgx_enclave_exit_handler_t MUST be written in assembly. This also > implies that we can't use techniques like container_of() and must > calculate all the offsets manually, which is tedious, error prone and > fragile. If instead of having a callback, kernel would run an optional bpf program, then a state structure could passed by the kernel to the execution context of the bpf program. That would also sort out difficulty of writing exit handlers. /Jarkko