From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD3C1C61DA3 for ; Fri, 24 Feb 2023 05:51:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVQzE-0008Ud-Vq; Fri, 24 Feb 2023 00:51:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVQz5-0008SN-9O for qemu-devel@nongnu.org; Fri, 24 Feb 2023 00:51:08 -0500 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVQyz-0001AR-FS for qemu-devel@nongnu.org; Fri, 24 Feb 2023 00:51:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677217861; x=1708753861; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=V5pIfvtAVZdi4oFKptzL072SqpQseaciK4VwcTkzV+I=; b=XzD/MuEbCDnwR4XV0NKCyZfM5UcqXQPp4WUdafI9Dqc9gqj2HQRyHEmq 4hDxUrkhfM0UAW4JjOLzxXUpth1WIEYjJhCTCHO5uQNc7UHXhQy2Sruj+ OFOLErwJKjbQx4PPZaSvgh7WrqjOMXxvTZYhGJ7Cfbh1VuDAjSnWe05hQ jfL9/q2o7FMn/vFkLZeUZ39wrJuGam6jJnycgRctsOQdX1gSRJnrUAbvf VOTHyXI8VOA3okeLw/XHQH6xjAze2Zq3nVAln5jXmsKAB90djA0ffDM6/ JqkfQM01BTh/+V6+acltoe6StzKPtKtr2wccGIPUiVR35BeebrdkK0nqt g==; X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="419636448" X-IronPort-AV: E=Sophos;i="5.97,322,1669104000"; d="scan'208";a="419636448" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2023 21:50:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="741550783" X-IronPort-AV: E=Sophos;i="5.97,322,1669104000"; d="scan'208";a="741550783" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.105]) by fmsmga004.fm.intel.com with ESMTP; 23 Feb 2023 21:50:36 -0800 Date: Fri, 24 Feb 2023 13:42:56 +0800 From: Chao Peng To: Alexey Kardashevskiy Cc: Sean Christopherson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Arnd Bergmann , Naoya Horiguchi , Miaohe Lin , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , tabba@google.com, Michael Roth , mhocko@suse.com, wei.w.wang@intel.com Subject: Re: [PATCH v10 1/9] mm: Introduce memfd_restricted system call to create restricted user memory Message-ID: <20230224054256.GA1701111@chaop.bj.intel.com> References: <20221202061347.1070246-1-chao.p.peng@linux.intel.com> <20221202061347.1070246-2-chao.p.peng@linux.intel.com> <7555a235-76be-abf5-075a-80dbe6f1ea8e@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7555a235-76be-abf5-075a-80dbe6f1ea8e@amd.com> Received-SPF: none client-ip=192.55.52.43; envelope-from=chao.p.peng@linux.intel.com; helo=mga05.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Chao Peng Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org > > int restrictedmem_bind(struct file *file, pgoff_t start, pgoff_t end, > > struct restrictedmem_notifier *notifier, bool exclusive) > > { > > struct restrictedmem *rm = file->f_mapping->private_data; > > int ret = -EINVAL; > > > > down_write(&rm->lock); > > > > /* Non-exclusive mappings are not yet implemented. */ > > if (!exclusive) > > goto out_unlock; > > > > if (!xa_empty(&rm->bindings)) { > > if (exclusive != rm->exclusive) > > goto out_unlock; > > > > if (exclusive && xa_find(&rm->bindings, &start, end, XA_PRESENT)) > > goto out_unlock; > > } > > > > xa_store_range(&rm->bindings, start, end, notifier, GFP_KERNEL); > > > || ld: mm/restrictedmem.o: in function `restrictedmem_bind': > mm/restrictedmem.c|295| undefined reference to `xa_store_range' Right, xa_store_range() is only available for XARRAY_MULTI. > > > This is missing: > === > diff --git a/mm/Kconfig b/mm/Kconfig > index f952d0172080..03aca542c0da 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -1087,6 +1087,7 @@ config SECRETMEM > config RESTRICTEDMEM > bool > depends on TMPFS > + select XARRAY_MULTI > === > > Thanks, > > > > > rm->exclusive = exclusive; > > ret = 0; > > out_unlock: > > up_write(&rm->lock); > > return ret; > > } > > EXPORT_SYMBOL_GPL(restrictedmem_bind); > > > > void restrictedmem_unbind(struct file *file, pgoff_t start, pgoff_t end, > > struct restrictedmem_notifier *notifier) > > { > > struct restrictedmem *rm = file->f_mapping->private_data; > > > > down_write(&rm->lock); > > xa_store_range(&rm->bindings, start, end, NULL, GFP_KERNEL); > > synchronize_rcu(); > > up_write(&rm->lock); > > } > > EXPORT_SYMBOL_GPL(restrictedmem_unbind); > > -- > Alexey