Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3132593yba; Mon, 22 Apr 2019 20:54:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4nojVsyFEAjsk9EQJ/mO2RzCoxqeRHU7YjQiZnMgyB7xWUqvQESwT7I4l617Al3B1oTSx X-Received: by 2002:a62:5206:: with SMTP id g6mr23864359pfb.227.1555991648227; Mon, 22 Apr 2019 20:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555991648; cv=none; d=google.com; s=arc-20160816; b=061ImHeal558UK6kWBfhQ83glnfhy5hji0c85ftiEXBPjm42S42tWNIGsiAmHFi+m6 2pT8eMpDswNAlSmLNPsmpW3HmX975J9yDlxV09B8ZmSzpOOBDpcNJIpCw6ShChjwdlCk bObcZdNYLptUm2eIxdNlrIXVtF4Yf27pmcadvwEeQYXLYNAf7/0QJTBLZ6817eGN6QXS yIvGQpfNBg6gxWHjSP3BXLzm7WBjuLAxbWDHXxD4o9kwfPoxr9Su9WEcV1WyqL3SAvTf +E5izt9HfQ4m4FPP9BtQPBJfJtxws/cQ9tQCeevYfQRHDkN3d2PKZ5CwoCyInQhWCXcq 2bbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=4/GJN2txJrMz3pj3mpMuTnuGm6ZLR3XMHrDvUyTZyPI=; b=lDJMk8+rztl1z/Nt6qdQsVc2mwFZvHQhPZlKjbBxQoYd8hKT8Yg3Ytak/+0vGA2JIY n1eCIBUeHsvDV8QZscviUJ4o2J/JH1rlPBpHMnWu400YBOXPlgGMa6KdKxbt7kmyTTXf /PEOG5NJXBU1bVBOjgH2yAQhKIgSGM6SMbP5OopLQF+R6YAZ0QDLLPD/Rn4NzG9vAUdm ftvJLtPGpEztPBkjUr08kc/dAb4J+3sd47JIGFsYK27EIJSJNSeq4uSnu2PsuFDIieij DuzS2TeIVCDu+NN8hvTwmvdA0yI7ZirSucre9ygfqWGzDDg0CE0rL0SuR6AxGClf9koX udZA== 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 z22si13238984pgv.196.2019.04.22.20.53.53; Mon, 22 Apr 2019 20:54:08 -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 S1731019AbfDWAh0 (ORCPT + 99 others); Mon, 22 Apr 2019 20:37:26 -0400 Received: from mga11.intel.com ([192.55.52.93]:13158 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729106AbfDWAh0 (ORCPT ); Mon, 22 Apr 2019 20:37:26 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Apr 2019 17:37:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,383,1549958400"; d="scan'208";a="225774513" Received: from bxing-ubuntu.jf.intel.com ([10.23.30.27]) by orsmga001.jf.intel.com with ESMTP; 22 Apr 2019 17:37:25 -0700 From: Cedric Xing To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org Cc: akpm@linux-foundation.org, Hansen@vger.kernel.org, Dave , Christopherson@vger.kernel.org, Sean J , nhorman@redhat.com, npmccallum@redhat.com, Ayoun@vger.kernel.org, Serge , Katz-zamir@vger.kernel.org, Shay , Huang@vger.kernel.org, Haitao , andriy.shevchenko@linux.intel.com, tglx@linutronix.de, Svahn@vger.kernel.org, Kai , bp@alien8.de, josh@joshtriplett.org, luto@kernel.org, Kai , rientjes@google.com, Jarkko Sakkinen , Cedric Xing Subject: [RFC PATCH v1 0/3] An alternative __vdso_sgx_enter_enclave() to allow enclave/host parameter passing using untrusted stack Date: Mon, 22 Apr 2019 17:37:22 -0700 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190417103938.7762-1-jarkko.sakkinen@linux.intel.com> References: <20190417103938.7762-1-jarkko.sakkinen@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current proposed __vdso_sgx_enter_enclave() requires enclaves to preserve %rsp, which prohibits enclaves from allocating space on the untrusted stack. However, there are existing enclaves (e.g. those built with current Intel SGX SDK libraries) relying on the untrusted stack for passing parameters to untrusted functions (aka. o-calls), which requires allocating space on the untrusted stack by enclaves. And given its simplicity and convenience, it could be desired by future SGX applications as well. This patchset introduces a new ABI for __vdso_sgx_enter_enclave() to anchor its stack frame on %rbp (instead of %rsp), so as to allow enclaves to "push" onto the untrusted stack by decrementing the untrusted %rsp. Additionally, this new __vdso_sgx_enter_enclave() will take one more parameter - a callback function, to be invoked upon all enclave exits (both AEX and normal exits). The callback function will be given the value of %rsp left off by the enclave, so that data "pushed" by the enclave (if any) could be addressed/accessed. Please note that the callback function is optional, and if not supplied (i.e. null), __vdso_sgx_enter_enclave() will just return (i.e. behave the same as the current implementation) after the enclave exits (or AEX due to exceptions). The SGX selftest is augmented to test out the new callback interface, and to serve as a simple example to showcase how to use the callback interface in practice. Reference: * This patchset is based upon SGX1 patch v20 (https://lkml.org/lkml/2019/4/17/344) by Jarkko Sakkinen Cedric Xing (3): selftests/x86: Fixed Makefile for SGX selftest x86/vdso: Modify __vdso_sgx_enter_enclave() to allow parameter passing on untrusted stack selftests/x86: Augment SGX selftest to test new __vdso_sgx_enter_enclave() and its callback interface arch/x86/entry/vdso/vsgx_enter_enclave.S | 156 ++++++++++++--------- arch/x86/include/uapi/asm/sgx.h | 14 +- tools/testing/selftests/x86/Makefile | 12 +- tools/testing/selftests/x86/sgx/Makefile | 45 +++--- tools/testing/selftests/x86/sgx/main.c | 123 +++++++++++++--- tools/testing/selftests/x86/sgx/sgx_call.S | 40 +++++- 6 files changed, 264 insertions(+), 126 deletions(-) -- 2.17.1