Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4501558ybl; Mon, 9 Dec 2019 11:52:19 -0800 (PST) X-Google-Smtp-Source: APXvYqynRWKnH/eoMUO2LjNvO/L7bSfOjA1x8Q/kB37QeQS8SgxSw2XbK8uSC4RMHI0BpW76g9xD X-Received: by 2002:aca:df07:: with SMTP id w7mr721895oig.145.1575921139084; Mon, 09 Dec 2019 11:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575921139; cv=none; d=google.com; s=arc-20160816; b=xj6MhockHZlPVuO4re9TFBJ2qHU3EN9GdxC5vPJCcGdo6FEFnIcrmzPHgBXK+Wjo4L hEO4nLUbw7kYl2WfH/wzLz5PblCJMxgDDwNDfWv1Ob5QqtCzGIFCoWyvjcverfPqO0wQ gv/x+JSOdx0qBdLubuqQk+s6YOMECdoRjqR73j4njFzuiDIE43Vc7TSRoQ1G5eF4SLjo G0yyp7qabGgPQ2ceSsXbclduhY5yvHA+wLCkU1gNee1BrsIi0uYI7dHqFqkdXPqb0icj m5gN8fDQl9t5t8HWk3rRmtmxDNkUFjL1o2Q6Gkz2OvzYNEWuIR3UAjnYqvVCrz9C0GlI OlBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=jpOxMr2p8L3IAlkgqQwdAoUVhwntWQt6WR7CHz8Emnw=; b=eEZHOHk2tVM/wVUlvWVPGMoxXJX9rWomXBJfY6EI8Mljoje5G9o3/CnO1pYk01EHcF JsnhKMC8xiEo3Kvmj2WLryK2U2VkqRmAKuNMoM4oQiERc/yJux82dgns30XdcKCj4Ckl nVJeXkKjXDql8O5rM3S9KiMCPBdXHVfewHsdwUB0vP0DtWm0WeVbbSOxdCrhTfbf5IFA lumO48lzpBALDrjMcgu550vfMM73ErI1Au9KQ/+UvE9d2+WcxKSdwnniSPtf3bPUoKHa SpkI8Ujwm/plMXrtvIzQ4z4bEiL04m6hBKCBzBCF3MWCItyRpwdlXqq2DDpVDR5Z1w2I ERMQ== 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 e15si537990otp.161.2019.12.09.11.52.06; Mon, 09 Dec 2019 11:52:19 -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; 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 S1726678AbfLITuO (ORCPT + 99 others); Mon, 9 Dec 2019 14:50:14 -0500 Received: from mga12.intel.com ([192.55.52.136]:18590 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbfLITuO (ORCPT ); Mon, 9 Dec 2019 14:50:14 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2019 11:38:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,296,1571727600"; d="scan'208";a="244573678" Received: from nshalmon-mobl.ger.corp.intel.com (HELO localhost) ([10.252.8.146]) by fmsmga002.fm.intel.com with ESMTP; 09 Dec 2019 11:38:24 -0800 Date: Mon, 9 Dec 2019 21:38:22 +0200 From: Jarkko Sakkinen To: Sean Christopherson Cc: Haitao Huang , linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, bp@alien8.de, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, cedric.xing@intel.com, puiterwijk@redhat.com, linux-security-module@vger.kernel.org, Suresh Siddha Subject: Re: [PATCH v24 12/24] x86/sgx: Linux Enclave Driver Message-ID: <20191209193822.GB19243@linux.intel.com> References: <20191129231326.18076-1-jarkko.sakkinen@linux.intel.com> <20191129231326.18076-13-jarkko.sakkinen@linux.intel.com> <20191202182102.GF4063@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191202182102.GF4063@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 02, 2019 at 10:21:03AM -0800, Sean Christopherson wrote: > On Mon, Dec 02, 2019 at 09:48:43AM -0600, Haitao Huang wrote: > > On Fri, 29 Nov 2019 17:13:14 -0600, Jarkko Sakkinen > > wrote: > > > > > > >+ > > >+ for (c = 0 ; c < addp.length; c += PAGE_SIZE) { > > >+ if (signal_pending(current)) { > > >+ ret = -ERESTARTSYS; > > >+ break; > > >+ } > > > > This IOC is not idempotent as pages EADDed at this point can not be > > re-EADDed again. So we can't return ERESTARTSYS > > Ah, and now I remember why I opted for modifying the parameters directly > instead of including a "number processed" field. Andy pointed out the > ERESTARTSYS thing in the original multi-page add RFC[*], so presumably > updating the params and returning ERESTARTSYS is legal/acceptable. > > [*] https://lkml.kernel.org/r/CALCETrUb4X9_L9RXKhmyNpfSCsbNodP=BfbfO8Fz_efq24jp8w@mail.gmail.com There are exactly two primary options to pick from given the non-idempotent nature: A. Return zero (since we support partial operation with the changes I did in v24). B. Return -EINTR. If we wanted to follow common syscall semantics in IO operations, then the semantics would be a mix of these: 1. Return -EINTR if signals are pending before any pages got added. 2. Return 0 if at least one page got added. This is how write() works for example according to the documentation [1]. As far as the user code goes [2] I think for that it is best idea to rely on semantics that developers are used to instead of being clever here. [1] http://man7.org/linux/man-pages/man2/write.2.html [2] https://lkml.kernel.org/r/CALCETrUb4X9_L9RXKhmyNpfSCsbNodP=BfbfO8Fz_efq24jp8w@mail.gmail.com /Jarkko