Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1082907ybi; Fri, 14 Jun 2019 08:20:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqg4OlbG/WF9vZkneUi1P/w4x4ZVzT5xNDgeUb7zcY3nJqaSslHKh51lmfl5OG+PtGj8mZ X-Received: by 2002:a17:90a:b883:: with SMTP id o3mr3711609pjr.50.1560525620614; Fri, 14 Jun 2019 08:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560525620; cv=none; d=google.com; s=arc-20160816; b=qKDSQ4jgeUDNAdRszZJZ2UxQYyMp+JM+Towfl4u9DsrJPLD/OAoNTAFslrUULCtFx1 klSvnMNf6QSNoMvgiE03KUO0bOKMuE48tD6UDg9ayAAyzrRJWvd/ARL7nylh/d1tlhn4 SHt76VjovYUA6HPOIlZBDMCDLlGfKfTe/+nIGLjnxhvCJkzlFRuN1PEkEpq3g3IBSXg9 a4sVPwGPk+W1qMRm3M2Xedyi2MrZ+gNCLNgyUAAFhla8MnUvwk8on/x4TX+bUG0F3IXj g+lo8HuotHfE7eJzVTqp8dQLV0Il0wDqBfDBxvtAExGJuZ122MUbe9tiwFWGKc/d8spe W/wg== 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=kAQwb/hbCXbEmz6nUL3A+Szs28B5Bn7atFhJ/RaGsuY=; b=Cp0lnO0/HFfYPHThgwLwvy3trUfLP7eoWVThvx9Yuz7s36O/vbChUnRs/OELLRcmLi YzqZzK0AhjpO5hTn3rRgzu3KnXuAxV8XLQV6Qn6qVM8yyaINrTEh0Va6yblByegkJMdq Yjo49gfsM0/kxarT0l8X+jgMYzV189ZvU9LMNAN81wt9YdJxAZ8zGbRScM699TKGluPZ C/Ros8y2eQeaITI0r7/vwfOshLCweavT4zHhoImqbiZKKIUS4lsnfimE0lsEMa76wB2c 3tz4R6r6BFYdZB/Ntlruo0+ym0mjEV1PQHfQIaY9oueZYvkBAXii1juvrFkfpFsEol/5 cr+g== 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 h194si2799605pfe.214.2019.06.14.08.20.03; Fri, 14 Jun 2019 08:20:20 -0700 (PDT) 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 S1726115AbfFNPSk (ORCPT + 99 others); Fri, 14 Jun 2019 11:18:40 -0400 Received: from mga18.intel.com ([134.134.136.126]:63789 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725851AbfFNPSk (ORCPT ); Fri, 14 Jun 2019 11:18:40 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jun 2019 08:18:39 -0700 X-ExtLoop1: 1 Received: from mdumitrx-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.32.245]) by orsmga005.jf.intel.com with ESMTP; 14 Jun 2019 08:18:29 -0700 Date: Fri, 14 Jun 2019 18:18:28 +0300 From: Jarkko Sakkinen To: Sean Christopherson Cc: "Xing, Cedric" , Andy Lutomirski , Andy Lutomirski , Stephen Smalley , James Morris , "Serge E . Hallyn" , LSM List , Paul Moore , Eric Paris , "selinux@vger.kernel.org" , Jethro Beekman , "Hansen, Dave" , Thomas Gleixner , Linus Torvalds , LKML , X86 ML , "linux-sgx@vger.kernel.org" , Andrew Morton , "nhorman@redhat.com" , "npmccallum@redhat.com" , "Ayoun, Serge" , "Katz-zamir, Shay" , "Huang, Haitao" , Andy Shevchenko , "Svahn, Kai" , Borislav Petkov , Josh Triplett , "Huang, Kai" , David Rientjes , "Roberts, William C" , "Tricca, Philip B" Subject: Re: [RFC PATCH 2/9] x86/sgx: Do not naturally align MAP_FIXED address Message-ID: <20190614151805.GB11241@linux.intel.com> References: <20190531233159.30992-3-sean.j.christopherson@intel.com> <20190604114951.GC30594@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F654EDBDE@ORSMSX116.amr.corp.intel.com> <20190605151653.GK11331@linux.intel.com> <5A85C1D7-A159-437E-B42A-3F4254E07305@amacapital.net> <20190606153710.GB25112@linux.intel.com> <20190613134800.GA12791@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F65503A93@ORSMSX116.amr.corp.intel.com> <20190613171451.GD5850@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190613171451.GD5850@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 Thu, Jun 13, 2019 at 10:14:51AM -0700, Sean Christopherson wrote: > > I don't get this. The swapper takes a read lock on mm->mmap_sem, which locks > > the vma, which in turn reference counts vma->vm_file. Why is the internal > > refcount still needed? > > mmap_sem is only held when reclaim is touching PTEs, e.g. to test/clear > its accessed bit and to zap the PTE. The liveliness of the enclave needs > to be guaranteed for the entire duration of reclaim, e.g. we can't have > the enclave disappearing when we go to do EWB. It's also worth nothing > that a single reclaim may operate on more than one mmap_sem, as enclaves > can be shared across processes (mm_structs). Anyway, the takeaway I got from this is that encl->refcount does not need to be updated for VMAs (sent a patch to linux-sgx that I plan merge). /Jarkko