Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3412160pxk; Mon, 21 Sep 2020 13:01:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye7WWS6SHdEUv14u45r31jkNmef2M3fcSLgWZ/0uIltcxHEOd+ZozZnx09EbAPnXHlkRwN X-Received: by 2002:a17:906:4a81:: with SMTP id x1mr1171650eju.541.1600718510057; Mon, 21 Sep 2020 13:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600718510; cv=none; d=google.com; s=arc-20160816; b=gb6q9ot/NeYS8tqKHg49LrvBYoyMqwIW9t2zwDCDmUlPak5CQsuxVl4NPqlTSpvP0V xSNCoMul6jNqZbTj3y6Y0DdolGTWZEaHwFf8AmDcEzAO1L1WIL2F5CgpVu9nZC8TiM8/ QJP1bfIVpcYekDP68ZG/AKEG9ALj75zK3o/8wmI4ahHntN3jWFd+ZNGX6b61AwcuFFwk EkfLJSuBYOfWqSfkuR1j31DhxCQUU7FK4eTuE3LgZCVC2zeXvy/QaCRVcUyKdstwZL03 ccCjTDi/nDtQsl1BPfIsV2wYbC0u7f64LGk3Nt2v/c5rJ2S4fL8EtOITLWtF1X+BQFPq 4agg== 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=9YbUH7UPD9gL4EV/BHxiVSjVbgbrw6yaV7VAo0F5zSQ=; b=CZ0QZBpV38BoXO5Vfe6QDCJXbkmYiJNLEHU12cunX3Kem7JeVN6KTJgwtNLdxg0e1W 7cXK5xxLifUpdAVL9ORUaL2VgQWhAAP5hgqKZdRMqlaIoxdsculgWpmvwk1Y/+wZ6wwr 6ZK9ey7aPjdZMISGWNbRBFPYgBz8am9FUrJrIc90ie7Obg75t03mKAp9jp35ZxWWnw0W kd8Q81h8vuCQH1VhKJAi7zq+wZYQIyeA6drteBzBNstgGuLtJXZFyk2KxJFJorHlUf3I gxTmzb3BKM3bYhVT8+5ZBGUWdcigzuXbV6H7RY3z8+FCvrAwmd0MuFouCF+PKOX63XV1 Oy5Q== 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 p11si9029932edj.203.2020.09.21.13.01.26; Mon, 21 Sep 2020 13:01:50 -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 S1728476AbgIUT6e (ORCPT + 99 others); Mon, 21 Sep 2020 15:58:34 -0400 Received: from mga09.intel.com ([134.134.136.24]:6567 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727197AbgIUT6b (ORCPT ); Mon, 21 Sep 2020 15:58:31 -0400 IronPort-SDR: lSsMAJfz9GNJcYE0NFmcHXpJwQGAAu12gG1N/XBhMyr++zV6clBjPL6fA90SzXqCF4+rsXo6um 9rG8nYk7jWGQ== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="161391879" X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="161391879" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:58:30 -0700 IronPort-SDR: rAEqZ+YlzVG9mAhqVrqnE3X93fmpOiEzu0W+Q11CidGTPAHHF3PI4Yf1ELoMf4L5q51aAEUrYS uku4r5JKn0VA== X-IronPort-AV: E=Sophos;i="5.77,287,1596524400"; d="scan'208";a="485647966" Received: from kofels-mobl.ger.corp.intel.com (HELO localhost) ([10.249.45.179]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 12:58:23 -0700 Date: Mon, 21 Sep 2020 22:58:22 +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: <20200921195822.GA58176@linux.intel.com> References: <20200917160206.GF8530@linux.intel.com> <20200918020940.GA14678@sjchrist-ice> <20200918122029.GA27028@linux.intel.com> <20200918123932.GB27028@linux.intel.com> <20200919000918.GB21189@sjchrist-ice> <20200921114104.GB6038@linux.intel.com> <20200921164647.GC23989@linux.intel.com> <20200921184948.GA49586@linux.intel.com> <20200921194419.GA56547@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200921194419.GA56547@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 21, 2020 at 10:44:19PM +0300, Jarkko Sakkinen wrote: > On Mon, Sep 21, 2020 at 09:49:48PM +0300, Jarkko Sakkinen wrote: > > To have understandable semantics you have to map error codes to > > conditions rather than opcodes. -EIO means loss of enclave in the event > > of EPC gone invalid. Enclave is already lost, that is the reason why we > > deinitialize the kernel data structures. > > > > EADD must have a different error code because nothing is actually lost > > but the failure conditions are triggered outside. -EFAULT would be > > probably the most reasonable choice for that. > > Now that I did all the changes discussed and then I remember why EADD > and EEXTEND had a common error code, and common behaviour. Obviously EADD > can also fail because of EPC reset because it depends on a valid SECS > page. > > If we cannot distinct from EADD caused by EPC loss and EADD caused by > problems with the source, it should have the same error code, and also > the enclave should be deinitialized, whenver this happens. > > So I would just revert to v38 behaviour, keeping of course the whole > check more visible in sgx_ioc_enclave_add_pages(), and just refine > the documentation better describe the whole situation. So now the behaviour is reverted back to same as it was before [*] and I refined the documenation as: " * The function deinitializes kernel data structures for enclave and returns * -EIO in any of the following conditions: * * - Enclave Page Cache (EPC), the physical memory holding enclaves, has * been invalidated. This will cause EADD and EEXTEND to fail. * - If the source address is corrupted somehow when executing EADD. " [*] https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-sgx.git/tree/arch/x86/kernel/cpu/sgx/ioctl.c /Jarkko