Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3440877imu; Mon, 17 Dec 2018 21:03:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/VI8OuE+tAZ7Gwpw0jKZK2f8YtvjZ6/Z4iOl0z0Y6tMtP1mxdeAZ9cJD/6Nw97xizAxehgu X-Received: by 2002:a63:2d82:: with SMTP id t124mr14512588pgt.260.1545109423331; Mon, 17 Dec 2018 21:03:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109423; cv=none; d=google.com; s=arc-20160816; b=NhBJAY44UPK41VywUphFIHNkfYUi1R+uPvc079u3+V3NqGfQq/Dxq3HFF05vobItE8 5CVwR1Wf2r5gQcCZUxMJHy3dFRbOiVrJ3r3TvGOfRNVRCByE6HXUw1z/A/AkZoCyGJpP smRHIAu2sq5BqgmtDkaHCSjPwL4fnck5lpXtVoPDRbtN1hLWvTxRDsET+PtOfLnDkYgb KEi3L9ECN1CEebrAfTkFPmWdxPnBVwT5Fzy2PmYkskP7iPnRvf7vTtryZzLCQTz5eiuI oGJEDeDwPxkktkX6BmVuQ7cXQRFk519sb2iFXFMbbEEXkYsxZUCz5Ku4BYnGG7oavq0G +3YA== 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=U2A4t8ZOQZ7h48yQhjUMP0CF5vn1XimxpBMZ7d1dNn8=; b=zwjKbWjALyOZCJMfJg4kltw40jTqKuN6jr3jQ0nBNjEt0wJZQ5h0K0jM5Fct2HowtA dFOMivIf+LkORPldbWW+hNNG/By5lyrylaacR3Avq8v/X03UL+QuVJTVUaxua+Cy4wxb sZqms6uHIQHIN0a17QqwUBmZfIoF9TjHVeT/Ma6SfSgEZC5upaPUS7XGHO43O4H2qHVD jnSjXiiie5FD7xMpJRyO/UQnPD82PcBf3vXtxrGBorXoaoHFYRtu3Z7JoOVDfm7iZPX/ VxEMb1J6BYnfkDFeqbzpdmLta8zHtSBvB4BrR4gV/uG/8skeEGovzmA3ZDxrxglJc59A FSew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ju0hVs9L; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si12451256pgk.103.2018.12.17.21.03.27; Mon, 17 Dec 2018 21:03:43 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ju0hVs9L; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726669AbeLRFCT (ORCPT + 99 others); Tue, 18 Dec 2018 00:02:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:43212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbeLRFCS (ORCPT ); Tue, 18 Dec 2018 00:02:18 -0500 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D284F21848 for ; Tue, 18 Dec 2018 05:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545109338; bh=TKC+IXVMQgdMwlbJGDewPI6zoy8Su+7mMv0Fg9t32oE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ju0hVs9L/hBvtbV+7kUZHLf3o7h2zpp3BQ8C/hTguOAWDSTfSRFrQef/EmofOjcCe TZQyhvfMAX5HrM91hGBNYzhKwHFOVHhgv/bWdeSC8MScqD1gU1pj3CtL70BXCvIidB SeCGr000+jYyzPUkkz3IKDJyDALgtJla6Fmv1yGU= Received: by mail-wr1-f41.google.com with SMTP id v13so14482175wrw.5 for ; Mon, 17 Dec 2018 21:02:17 -0800 (PST) X-Gm-Message-State: AA+aEWa7hpoMil/PT/anmDK8RDYItS0LBB6jKHLNXyRyg3TzPTuYYY21 xvXkBzheRGx664HsYv7s6WyUZvlXJgygXwDlbRruEw== X-Received: by 2002:a5d:550f:: with SMTP id b15mr13723383wrv.330.1545109334432; Mon, 17 Dec 2018 21:02:14 -0800 (PST) MIME-Version: 1.0 References: <20181116010412.23967-1-jarkko.sakkinen@linux.intel.com> <20181116010412.23967-19-jarkko.sakkinen@linux.intel.com> <7d5cde02-4649-546b-0f03-2d6414bb80b5@intel.com> <20181217180102.GA12560@linux.intel.com> <20181217183613.GD12491@linux.intel.com> <20181217184333.GA26920@linux.intel.com> <20181217222047.GG12491@linux.intel.com> <20181218013918.GC333@linux.intel.com> <20181218032702.GA2903@linux.intel.com> In-Reply-To: <20181218032702.GA2903@linux.intel.com> From: Andy Lutomirski Date: Mon, 17 Dec 2018 21:02:03 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver To: Jarkko Sakkinen Cc: Sean Christopherson , Andy Lutomirski , Dave Hansen , X86 ML , Platform Driver , linux-sgx@vger.kernel.org, nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, Haitao Huang , Andy Shevchenko , Thomas Gleixner , "Svahn, Kai" , mark.shanahan@intel.com, Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Darren Hart , Andy Shevchenko , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" 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 Mon, Dec 17, 2018 at 7:27 PM Jarkko Sakkinen wrote: > > On Tue, Dec 18, 2018 at 03:39:18AM +0200, Jarkko Sakkinen wrote: > > On Mon, Dec 17, 2018 at 02:20:48PM -0800, Sean Christopherson wrote: > > > The only potential hiccup I can see is the build flow. Currently, > > > EADD+EEXTEND is done via a work queue to avoid major performance issues > > > (10x regression) when userspace is building multiple enclaves in parallel > > > using goroutines to wrap Cgo (the issue might apply to any M:N scheduler, > > > but I've only confirmed the Golang case). The issue is that allocating > > > an EPC page acts like a blocking syscall when the EPC is under pressure, > > > i.e. an EPC page isn't immediately available. This causes Go's scheduler > > > to thrash and tank performance[1]. > > > > I don't see any major issues having that kthread. All the code that > > maps the enclave would be removed. > > > > I would only allow to map enclave to process address space after the > > enclave has been initialized i.e. SGX_IOC_ENCLAVE_ATTACH. > > Some refined thoughts. > > PTE insertion can done in the #PF handler. In fact, we can PoC this > already with the current architecture (and I will right after sending > v18). > > The backing space is a bit more nasty issue in the add pager thread. > The previous shmem swapping would have been a better fit. Maybe that > should be reconsidered? > > If shmem was used, all the commits up to "SGX Enclave Driver" could > be reworked to the new model. > > When we think about the swapping code, there uprises some difficulties. > Namely, when a page is swapped, the enclave must unmap the PTE from all > processes that have it mapped. That's what unmap_mapping_range(), etc do for you, no? IOW make a struct address_space that represents the logical enclave address space, i.e. address 0 is the start and the pages count up from there. You can unmap pages whenever you want, and the core mm code will take care of zapping the pages from all vmas referencing that address_space.