Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp610112ybt; Wed, 8 Jul 2020 07:35:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwolbGPuSx0D0kmuAMmqUqsuYx/24j5pBxMYiZyrr2ijYAbt2lzNubABePsT2U3x147iuoh X-Received: by 2002:aa7:c353:: with SMTP id j19mr19629570edr.219.1594218933819; Wed, 08 Jul 2020 07:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594218933; cv=none; d=google.com; s=arc-20160816; b=hNUmMmuLanNxktSfJMZsgYEDiknuePGcE/Lf+6mwY+6rG3Tiek7W9qckermLftcBxv NKMUwziKAfCN+3Ax+xrSUvNFPNKKRTrJmGdDUcyUMjpGnmQ+nsx3FMRZsbY1nr8DnfRc w0misVl7/5S3Mx9/+raf2FTTij8qx5OjBr+IjeHeg1pBILe7DhIdg75tCs906yEzVT7Z eNVP/Dp0Py15QIrmz+GasJ6LUYnnuRfBE53CNWfAVy2EgiXW1oZMbNjlzOWYZESO+qq2 J8UAVLwB8/mgmzxLN0r4zA8gVSKX68a68skQOLiFCCddu96JEk7OXWrZRG29/4fWOMP+ XR2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=Oo2lVptur8R7my9oHbqnW6btCubvfidMQQpESby0f5A=; b=GadWHUNk1ZSZ67UyZHvRHwm2mghmvF1S4rNPl4pwrDkmo0GnGwv0le8yWsRnv3twlg ujbDch4qTQCTLbkEHESZ+HKZ2GRe/yXgewyagQTpn7TVBx3KIOQCSwpbR78jdxrk0+yK AZmG25fMxhBWIY4uk72YgyfCN6IyNMzwwglc41c933Lyuf0HJmu/z5RuxJRhvePzF/iI WiAdaNNvHJ1TXT7asbbS19Rq8tQVGdxl5afEna0X7zcNGP59+kkOtVoH/B9M1GCBnI9K SL8y15+qAixmX+uUe1y2EEOeoMbp57GCllWSe8Hqb8oWcmD0FNvkTSUNzvSbxDqsQYap g+CQ== 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 g9si23539ejj.380.2020.07.08.07.35.07; Wed, 08 Jul 2020 07:35:33 -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 S1729717AbgGHOdf (ORCPT + 99 others); Wed, 8 Jul 2020 10:33:35 -0400 Received: from mga09.intel.com ([134.134.136.24]:34195 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729486AbgGHOde (ORCPT ); Wed, 8 Jul 2020 10:33:34 -0400 IronPort-SDR: CSvo5k/57tfwZe6we2UhzCLFRg7Hc5v+GM8VmwjjficWCifnJ+W7pMkzx+AqFRg1q7s8g56Qob 1znwNszI+LqA== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="149313247" X-IronPort-AV: E=Sophos;i="5.75,327,1589266800"; d="scan'208";a="149313247" 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; 08 Jul 2020 07:33:33 -0700 IronPort-SDR: 2gn2BVPH5VBBaMKCqKSK+xkp94CECkdlpw6fL9C23g9y0C1iv9HumZs4ZwJf0+mMVXSu7cHAUx RmQOBjRkuezw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,327,1589266800"; d="scan'208";a="457523928" Received: from jschirra-mobl.ger.corp.intel.com (HELO localhost) ([10.249.47.201]) by orsmga005.jf.intel.com with ESMTP; 08 Jul 2020 07:33:22 -0700 Date: Wed, 8 Jul 2020 17:33:20 +0300 From: Jarkko Sakkinen To: Matthew Wilcox Cc: Sean Christopherson , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Jethro Beekman , 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, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v34 10/24] mm: Add vm_ops->mprotect() Message-ID: <20200708143320.GD538949@linux.intel.com> References: <20200707030204.126021-1-jarkko.sakkinen@linux.intel.com> <20200707030204.126021-11-jarkko.sakkinen@linux.intel.com> <20200707031424.GD25523@casper.infradead.org> <20200707032254.GB5208@linux.intel.com> <20200707032408.GE25523@casper.infradead.org> <20200707040151.GA143804@linux.intel.com> <20200707041046.GI25523@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707041046.GI25523@casper.infradead.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 05:10:46AM +0100, Matthew Wilcox wrote: > On Tue, Jul 07, 2020 at 07:01:51AM +0300, Jarkko Sakkinen wrote: > > On Tue, Jul 07, 2020 at 04:24:08AM +0100, Matthew Wilcox wrote: > > > On Mon, Jul 06, 2020 at 08:22:54PM -0700, Sean Christopherson wrote: > > > > On Tue, Jul 07, 2020 at 04:14:24AM +0100, Matthew Wilcox wrote: > > > > > > + if (vma->vm_ops && vma->vm_ops->mprotect) { > > > > > > + error = vma->vm_ops->mprotect(vma, nstart, tmp, prot); > > > > > > + if (error) > > > > > > + goto out; > > > > > > + } > > > > > > > > Based on "... and then the vma owner can do whatever it needs to before > > > > calling mprotect_fixup(), which is already not static", my interpretation > > > > is that Matthew's intent was to do: > > > > > > > > if (vma->vm_ops && vma->vm_ops->mprotect) > > > > error = = vma->vm_ops->mprotect(vma, nstart, tmp, prot); > > > > else > > > > error = mprotect_fixup(vma, &prev, nstart, tmp, newflags); > > > > if (error) > > > > goto out; > > > > > > > > i.e. make .mprotect() a full replacement as opposed to a prereq hook. > > > > > > Yes, it was. I was just looking at the next patch to be sure this was > > > how I'd been misunderstood. > > > > I'm don't get this part. If mprotect_fixup is called in the tail of the > > callback, why it has to be called inside the callback and not be called > > after the callback? > > Because that's how every other VM operation works. Look at your > implementation of get_unmapped_area() for example. I get the point but I don't think that your proposal could work given that mprotect-callback takes neither 'prev' nor 'newflags' as its parameters. The current callback has no means to call mprotect_fixup() properly. It would have to be extended int (*mprotect)(struct vm_area_struct *vma, struct vm_area_struct **pprev, unsigned long start, unsigned long end, unsigned long prot, unsigned long newflags); Is this what you want? /Jarkko