Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1153776pxk; Fri, 18 Sep 2020 05:22:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBWX8vJSLGwc4v7Et/GbDrbAV8UW5/rOaSE6CCFco17vFfvRX6MCVNF1lQg/Ty8zXTpizs X-Received: by 2002:a05:6402:164d:: with SMTP id s13mr37747617edx.222.1600431726467; Fri, 18 Sep 2020 05:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600431726; cv=none; d=google.com; s=arc-20160816; b=MBeg/exdZz1qJKUEVpUz8qilyuadoJmT3nJL9ldWSrXf6lDxCNpToYLqKuIXGd565z 2944I+FqIZwIhX/9OxsY3xvfiejuWBSFUTp4RjR/P9bCHO6OvZhcPuOpyyihFEkRu9/G uneMJaStnWc1iRKRPBKB3eQMzJDJDSe4SaJhDGu/I6oyC9SX5g4Fz4R8tyJsAF5PZqV8 Q09TMmu2/SisTt9GFg9zdg1xEXqG8Oeovxc+BN9LpPYYhwe5x3HOoOgJHKjF/2udraaI SFlQ0UaIri7PaPhjJwGIgtCSe0DvIOyx9whe+Nm1Z3lyDSYR7OvqwVn3Csv0/F7d/H7m mXYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=Uxkk2BHEMLhYMw1Cbz+ENhTWJ9IOTMA9aa/RULfFV/A=; b=KS7Goh9rxR6aQXkMc906de7T7QS98EZj9vYfrVVGL7cYQuLvO4+m7QKGp74Jky3hjs MVu5inhB3fYK1RH9vE7Z+8zASAUAS2PD3hziiYvYUur7goYjNXGlMtQGjcpPbhASIijd nfZ975KKm7OVaom6JAYIeNgCAR2DMMTaAB3BGVZb+zgSiYgTNfdDDxiZLTIT7aGJlDyu Cv1syF2xqMT7c04TSUT/DF3IEOAC3TEHhlwLzSvNWahpMl9Ec1uZzD3pGVZsIFIrxQ5Z gsYLTev0GX2ajFtH2h0PiujzwAJHIXtV9WwYF7YmNbwN/BmxjxCuVP1lrFJIl/aYB9LX XYKQ== 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 f3si2029357ejt.743.2020.09.18.05.21.43; Fri, 18 Sep 2020 05:22:06 -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 S1726306AbgIRMUj (ORCPT + 99 others); Fri, 18 Sep 2020 08:20:39 -0400 Received: from mga04.intel.com ([192.55.52.120]:32713 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbgIRMUj (ORCPT ); Fri, 18 Sep 2020 08:20:39 -0400 IronPort-SDR: nHFyFrVsCQjWUdLTDEZrGRiuGHcOYHThmV2kyWH1X6PgV5eqORvd62HYALoyu7+8NxEDtzI7QB 8+fICJU2D6VQ== X-IronPort-AV: E=McAfee;i="6000,8403,9747"; a="157308566" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="157308566" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 05:20:38 -0700 IronPort-SDR: 26rsxlzkUjoyWfUmXaZhnh2gPThhOxPT3/XeacRReQtDQdLNBYTz63w2ET9nCxMHSQdAgMNpPF yUmCSzt3mRiA== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484182929" Received: from dlos-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.48.212]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 05:20:31 -0700 Date: Fri, 18 Sep 2020 15:20:29 +0300 From: Jarkko Sakkinen To: Sean Christopherson Cc: Haitao Huang , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Jethro Beekman , Chunyang Hui , Jordan Hand , Nathaniel McCallum , Seth Moore , Darren Kenny , Suresh Siddha , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, bp@alien8.de, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v38 13/24] x86/sgx: Add SGX_IOC_ENCLAVE_ADD_PAGES Message-ID: <20200918122029.GA27028@linux.intel.com> References: <20200915110522.893152-1-jarkko.sakkinen@linux.intel.com> <20200915110522.893152-14-jarkko.sakkinen@linux.intel.com> <20200917160206.GF8530@linux.intel.com> <20200918020940.GA14678@sjchrist-ice> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918020940.GA14678@sjchrist-ice> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 07:09:40PM -0700, Sean Christopherson wrote: > On Thu, Sep 17, 2020 at 01:35:10PM -0500, Haitao Huang wrote: > > On Thu, 17 Sep 2020 11:02:06 -0500, Jarkko Sakkinen > > wrote: > > > > > > Right, I do get the OOM case but wouldn't in that case the reasonable > > > thing to do destroy the enclave that is not even running? I mean that > > > means that we are globally out of EPC. > > > > > > > I would say it could be a policy, but not the only one. If it does not make > > much difference to kernel, IMHO we should not set it in stone now. > > Debugging is also huge benefit to me. > > Agreed, an EPC cgroup is the proper way to define/enforce what happens when > there is EPC pressure. E.g. if process A is consuming 99% of the EPC, then > it doesn't make sense to unconditionally kill enclaves from process B. If > the admin wants to give process A priority, so be it, but such a decision > shouldn't be baked into the kernel. > > This series obviously doesn't provide an EPC cgroup, but that doesn't mean > we can't make decisions that will play nice with a cgroup in the future. Here's the core issue why the API "as is used to be" does not work: if (ret == -EIO) { mutex_lock(&encl->lock); sgx_encl_destroy(encl); mutex_unlock(&encl->lock); } It would be better to instead whitelist *when* the enclave is preserved. if (ret != -ENOMEM) { mutex_lock(&encl->lock); sgx_encl_destroy(encl); mutex_unlock(&encl->lock); } That is the information we *deterministically* want to know. Otherwise, we will live in ultimate chaos. Only this way can caller know when there are means to continue, and when to quit. I.e. the code is whitelisting wrong way around currently. /Jarkko