Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1902615pxb; Wed, 30 Mar 2022 12:14:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywiBikJzngAIb2u8LgVDJcGNlQgC8nZNY7A061G9WCMgsCfqpkakTP/4IzPQeLl2eyHJ/y X-Received: by 2002:a17:907:3d8c:b0:6df:4bdc:a282 with SMTP id he12-20020a1709073d8c00b006df4bdca282mr1179188ejc.464.1648667699236; Wed, 30 Mar 2022 12:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648667699; cv=none; d=google.com; s=arc-20160816; b=rCoCdccBuvxXTbPGigDzuvfDXJKPAAIE+jc730n/JoSRjiTe8WKkboL6e7LetA6D+s 9AfCR7WZLm4oCOpVJIRsMoccgRbjQgZB+m4tuS/wUpnJRoCVuMXydfJCPDW2BF4hJcJo 9qPk8iyKM8vyRCyfC5jIYVsDsoarKggQAwoHabV4AUYIkU4BgqoFpJY+9waOUr/MrepS +Ph+VKcqRVtlxLTFmmbAvthiYQqoEVvsH69dwObI+3Lhycj5FPnTGF/Vi5S2rZLgvSgD YkSW3zOEJ35zKLsAa5cNl6p0UZ5hb0TLCz1zZ9vqkDfyXqhqkPPU32Yv14vIHaZf/ftz qdoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XBBQ7QhXKVIc98QEVPjEPonx9y0lnq2KuoURxYe6b2A=; b=UmWKgKr4T0eG7pl60dEV2feLwm4yV7+REr1AM4EUf6/9p+ebq2JH+c6j2HPYKsdonj xRRQCBS+jodrldMbChdylzVnFr1aPGPoDFcTXmSdGDE2ah6pOyemLQGxWOkYcaRKPBdy qQZqbaZmFTHJdFEBPeIOCVaCBP9OYP1z+bS9FQeUK1M2dSLVJUDMa9wO20pYjkXSqDGd BIBCn+uvVeUH2makNmSbtKheqGlV2prpBa42TzFWrkHH8mqwIXA6EtiyLSfZiuT39dN1 PnbcMjYasEjS9CcA7oZxokP3GRDkr+t8/Imn1nYSd3gWOjdmrwmZxfJNiGoJDbDK0pLK ceaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMCSXeY3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a50e44c000000b00418c2b5bf79si25975842edm.603.2022.03.30.12.14.32; Wed, 30 Mar 2022 12:14:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMCSXeY3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1347760AbiC3PFR (ORCPT + 99 others); Wed, 30 Mar 2022 11:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344203AbiC3PFQ (ORCPT ); Wed, 30 Mar 2022 11:05:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95556BE26; Wed, 30 Mar 2022 08:03:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4F9ADB81D54; Wed, 30 Mar 2022 15:03:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E7BDC340EC; Wed, 30 Mar 2022 15:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648652607; bh=++ynPGFrylC0ID3MoiYnwhVsfuMIg5Z81rn450BMlno=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XMCSXeY3SHU/Io9ZdX7NZ51F/fL2WoLShF22cAAgDsJPZs0/QDsh/HK5BS+jdGLIp E72mgjIVFMqwuOZpTBHFi7gTgByDrBrOgctt7IVJTtfuU08UpRiLPbb6S1LeLby2tJ Liwl4FY5W20uxCdWuevSPp795QAZV1eNWoSNbKBda/tUU5SglMMO67RP9VTB6JjjvQ BvBdyFwgFbvuzY7ZWRsz3XvH+TTmFiyBj8XuN115zbZocp6Sf58tnJsxynmj6saWNW Wcxsc+xBcewCgk+LKNqviZMlNZMEYAq8qDfJBCBUhfB9VQN4y+UsAeBvZwCo9vvkoH qPhbwZC9boNkA== Date: Wed, 30 Mar 2022 18:02:27 +0300 From: Jarkko Sakkinen To: Reinette Chatre Cc: Haitao Huang , "Dhanraj, Vijay" , "dave.hansen@linux.intel.com" , "tglx@linutronix.de" , "bp@alien8.de" , "Lutomirski, Andy" , "mingo@redhat.com" , "linux-sgx@vger.kernel.org" , "x86@kernel.org" , "Christopherson,, Sean" , "Huang, Kai" , "Zhang, Cathy" , "Xing, Cedric" , "Huang, Haitao" , "Shanahan, Mark" , "hpa@zytor.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V2 16/32] x86/sgx: Support restricting of enclave page permissions Message-ID: References: <7ff5e217-4042-764b-3d32-49314f00ff54@intel.com> <690d3d8e-6214-dcdd-daaa-48a380114ad7@intel.com> <061e2afb-289a-c687-7631-61e24ecc71fe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 30, 2022 at 06:00:30PM +0300, Jarkko Sakkinen wrote: > On Mon, Mar 28, 2022 at 04:22:35PM -0700, Reinette Chatre wrote: > > Hi Jarkko, > > > > On 3/19/2022 5:24 PM, Jarkko Sakkinen wrote: > > > On Thu, Mar 17, 2022 at 05:11:40PM -0700, Reinette Chatre wrote: > > >> Hi Jarkko, > > >> > > >> On 3/17/2022 3:51 PM, Jarkko Sakkinen wrote: > > >>> On Thu, Mar 17, 2022 at 03:08:04PM -0700, Reinette Chatre wrote: > > >>>> Hi Jarkko, > > >>>> > > >>>> On 3/16/2022 9:30 PM, Jarkko Sakkinen wrote: > > >>>>> On Mon, Mar 14, 2022 at 08:32:28AM -0700, Reinette Chatre wrote: > > >>>>>> Hi Jarkko, > > >>>>>> > > >>>>>> On 3/13/2022 8:42 PM, Jarkko Sakkinen wrote: > > >>>>>>> On Fri, Mar 11, 2022 at 11:28:27AM -0800, Reinette Chatre wrote: > > >>>>>>>> Supporting permission restriction in an ioctl() enables the runtime to manage > > >>>>>>>> the enclave memory without needing to map it. > > >>>>>>> > > >>>>>>> Which is opposite what you do in EAUG. You can also augment pages without > > >>>>>>> needing the map them. Sure you get that capability, but it is quite useless > > >>>>>>> in practice. > > >>>>>>> > > >>>>>>>> I have considered the idea of supporting the permission restriction with > > >>>>>>>> mprotect() but as you can see in this response I did not find it to be > > >>>>>>>> practical. > > >>>>>>> > > >>>>>>> Where is it practical? What is your application? How is it practical to > > >>>>>>> delegate the concurrency management of a split mprotect() to user space? > > >>>>>>> How do we get rid off a useless up-call to the host? > > >>>>>>> > > >>>>>> > > >>>>>> The email you responded to contained many obstacles against using mprotect() > > >>>>>> but you chose to ignore them and snipped them all from your response. Could > > >>>>>> you please address the issues instead of dismissing them? > > >>>>> > > >>>>> I did read the whole email but did not see anything that would make a case > > >>>>> for fully exposed EMODPR, or having asymmetrical towards how EAUG works. > > >>>> > > >>>> I believe that on its own each obstacle I shared with you is significant enough > > >>>> to not follow that approach. You simply respond that I am just not making a > > >>>> case without acknowledging any obstacle or providing a reason why the obstacles > > >>>> are not valid. > > >>>> > > >>>> To help me understand your view, could you please respond to each of the > > >>>> obstacles I list below and how it is not an issue? > > >>>> > > >>>> > > >>>> 1) ABI change: > > >>>> mprotect() is currently supported to modify VMA permissions > > >>>> irrespective of EPCM permissions. Supporting EPCM permission > > >>>> changes with mprotect() would change this behavior. > > >>>> For example, currently it is possible to have RW enclave > > >>>> memory and support multiple tasks accessing the memory. Two > > >>>> tasks can map the memory RW and later one can run mprotect() > > >>>> to reduce the VMA permissions to read-only without impacting > > >>>> the access of the other task. > > >>>> By moving EPCM permission changes to mprotect() this usage > > >>>> will no longer be supported and current behavior will change. > > >>> > > >>> Your concurrency scenario is somewhat artificial. Obviously you need to > > >>> synchronize somehow, and breaking something that could be done with one > > >>> system call into two separates is not going to help with that. On the > > >>> contrary, it will add a yet one more difficulty layer. > > >> > > >> This is about supporting multiple threads in a single enclave, they can > > >> all have their own memory mappings based on the needs. This is currently > > >> supported in mainline as part of SGX1. > > > > > > Could you please comment on the above? > > > I've probably spent probably over two weeks of my life addressing concerns > to the point that I feel as I was implementing this feature (that could be > faster way to get it done). > > So I'll just wait the next version and see how it is like and give my > feedback based on that. It's not really my problem to address every > possible concern. Once v3 is out, I'll check what I think is right, and what is wrong and might send some fixups and see where that leads to. I think it is more costructive way to move forward. Repeating same arguments leads to nowhere. BR, Jarkko