Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp335314pxb; Thu, 17 Feb 2022 05:18:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8AoAAp/OB/JNy1qL9dj2jVxRmG97jT+Xf42r6slEYWm1E1UZKrjo606YjxlrNWUVrKnJa X-Received: by 2002:a17:906:1e94:b0:6b9:6fcc:53fd with SMTP id e20-20020a1709061e9400b006b96fcc53fdmr2337109ejj.450.1645103913272; Thu, 17 Feb 2022 05:18:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645103913; cv=none; d=google.com; s=arc-20160816; b=IO5wNZ7Ix79G1jiLs3KKIrAQ4PdC7Yk2INRJhZ/7RckReyDindMc9PtovL7c1SVY64 ikVeB+0aJgYr1Ev+/XDj705pgUDvNcMZbUqGgPOAcA9UsUHxOc/1KZRsJ9aapNA4Ve8X e7tsrfd4dW5Vpx/eKR5TKJacNa9Hp/rwlXUmPLoeCxCcG/5VeccV11NlCZDkVoG+Kz2P rBNoniHlNWlHMlI6j3Be7XaKl6udHYJCdyphDBS/h6+gC0RgQi4Nw1eikdgFu6TkOvP/ U7Dr3f8ivncn6KFm+QRiFluoROSGUNpkkn8b2EmpQwPzW2BR4R43iG00NYl4GYOcEsnp L+wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=NTcvOQ6hp43ULx55AeW/bGUTGeF26fNW0VDXv4v0aPs=; b=o+UoEBbTstiVJyYit+zIA3nVe9t/fHW/re6HZNwQettKN2eKsQuEpXN7AOQeSxxHos saHM6xNM/xZfMBiaN+HOBYLeBjeAIA9Y+JWkHmrkKYX8L6bxei9GJgHpAtOtlI/JBmbC Wp4aqk8x+GgEaAPXN7BsL+syJQDDGYWi43H/QLWyTvokDn8T4aZNB8XTSS1zuBN5OpBe tksQTCFW+lR4YB5vD/h9rvce6CbLXNu3fZPuLCNTZ4CKcsnzwxkamsgUc/kwyQE85FMw 27wg+4e0G1Sf/VbeTuEySQkGyg6/9gQ3/kY7d9T1ctYfICvoNJJr0a0WKYXEDj5ZZhVB hdrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aMNw7pRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h22si4832602ede.436.2022.02.17.05.17.45; Thu, 17 Feb 2022 05:18:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aMNw7pRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240678AbiBQNHR (ORCPT + 99 others); Thu, 17 Feb 2022 08:07:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240647AbiBQNHP (ORCPT ); Thu, 17 Feb 2022 08:07:15 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D50105A9D; Thu, 17 Feb 2022 05:07:00 -0800 (PST) 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="230830598" X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="230830598" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 05:07:00 -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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.)