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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D9D1C433F5 for ; Thu, 17 Feb 2022 13:07:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 017696B0074; Thu, 17 Feb 2022 08:07:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE24A6B0075; Thu, 17 Feb 2022 08:07:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5CCB6B0078; Thu, 17 Feb 2022 08:07:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id C000C6B0074 for ; Thu, 17 Feb 2022 08:07:02 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 743BA180CA82B for ; Thu, 17 Feb 2022 13:07:02 +0000 (UTC) X-FDA: 79152297084.27.B393104 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf07.hostedemail.com (Postfix) with ESMTP id 44D8F40006 for ; Thu, 17 Feb 2022 13:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645103221; x=1676639221; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=xA8H4mCuPL0+Y5H2RRjONOFAaibouE9qYQsummWmUDo=; b=aMNw7pRa+alHrCvUlPZSDNgXHuOgdVAYpRvtWtRYfQg8WRw8AXq72jmh VRbPq0FdNtsyadDd/CuUxZ9cM/bdvP6d7/HKJ0DzM1RtKNNQky/1N0kD+ DxNK6T172poY8G9eRhOLRqpYvavLamNNSg7P12UxRRmqj+LETEYz7zDSQ 7u5OrHpqUn/VFu9N8OKfipFYEOKkl18iPI9rjporPOBrow12eeHol2sll eBP1h231szuwPPwTRe44InuTf7f+EUpMxoxs4Eq4pRXRKLRv9i92roUPM GhKGZTjWUTlJLPeE4IATQAjT2JC9xj2DMmu5+M17tSDeOkoUjaiVsQq5B w==; X-IronPort-AV: E=McAfee;i="6200,9189,10260"; a="231491573" X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="231491573" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 05:06:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="704790168" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.101]) by orsmga005.jf.intel.com with ESMTP; 17 Feb 2022 05:06:52 -0800 Date: Thu, 17 Feb 2022 21:06:31 +0800 From: Chao Peng To: Andy Lutomirski Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, qemu-devel@nongnu.org, Linux API , Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Yu Zhang , "Kirill A . Shutemov" , jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com Subject: Re: [PATCH v4 01/12] mm/shmem: Introduce F_SEAL_INACCESSIBLE Message-ID: <20220217130631.GB32679@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220118132121.31388-1-chao.p.peng@linux.intel.com> <20220118132121.31388-2-chao.p.peng@linux.intel.com> <619547ad-de96-1be9-036b-a7b4e99b09a6@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <619547ad-de96-1be9-036b-a7b4e99b09a6@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 44D8F40006 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=aMNw7pRa; spf=none (imf07.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=chao.p.peng@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: e4z8khdcarw8d513u89u6w7nc9zfubiq X-HE-Tag: 1645103221-353305 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Feb 11, 2022 at 03:33:35PM -0800, Andy Lutomirski wrote: > On 1/18/22 05:21, Chao Peng wrote: > > From: "Kirill A. Shutemov" > > > > Introduce a new seal F_SEAL_INACCESSIBLE indicating the content of > > the file is inaccessible from userspace through ordinary MMU access > > (e.g., read/write/mmap). However, the file content can be accessed > > via a different mechanism (e.g. KVM MMU) indirectly. > > > > It provides semantics required for KVM guest private memory support > > that a file descriptor with this seal set is going to be used as the > > source of guest memory in confidential computing environments such > > as Intel TDX/AMD SEV but may not be accessible from host userspace. > > > > At this time only shmem implements this seal. > > > > I don't dislike this *that* much, but I do dislike this. F_SEAL_INACCESSIBLE > essentially transmutes a memfd into a different type of object. While this > can apparently be done successfully and without races (as in this code), > it's at least awkward. I think that either creating a special inaccessible > memfd should be a single operation that create the correct type of object or > there should be a clear justification for why it's a two-step process. Now one justification maybe from Stever's comment to patch-00: for ARM usage it can be used with creating a normal memfd, (partially)populate it with initial guest memory content (e.g. firmware), and then F_SEAL_INACCESSIBLE it just before the first time lunch of the guest in KVM (definitely the current code needs to be changed to support that). Thanks, Chao > > (Imagine if the way to create an eventfd would be to call timerfd_create() > and then do a special fcntl to turn it into an eventfd but only if it's not > currently armed. This would be weird.)