Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4434136pxb; Sat, 12 Feb 2022 05:09:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3aJqrxo6tlrIefkuBBfORLxQMd0pmyN8TtwyEtob2LDCDAJusXFf/srQ47YPvbnv8CV+s X-Received: by 2002:a65:6294:: with SMTP id f20mr4933558pgv.235.1644671343619; Sat, 12 Feb 2022 05:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644671343; cv=none; d=google.com; s=arc-20160816; b=tsSHho3iPoFoIjIs+xyFtPj2ZKTgrc7b/HBASUV57hSXZBoigo1UP9gkP384o6P0Up eWp40baRkpnCUcd9eTUEpkd2ZPEXC6Tv4NLdD9vnCf7eLSdGIUrFzeBQStfq2IVlsvKg aY9vkYkitYvQrvPwJyvsXwSDd7hCs25sGcVAHuI2aTM6hcsE4WOLB1Oz2SV9E29p9Xpf 2v0khH6V1rgSsiwUJjRJU6k9w6S18WeHE8jOnPrcdDkndWiXWYtbhFyDXXCNadTy4d5x dfXLIEOJBNOerVJbTyY7Iswtd4wbfECQF3nNTUVHFZ6Y3I+behvClbOAKDaLdkHld3Nk B4FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=wySlk2wsAeXjatUNDvS74oKxz+Slx4VfClSvGFdx5lI=; b=P0B1ISplk6XpNb+/Ob9y+cfTTNhXn+/UejFinH39UMYsGb3gQ7BeiaWHJYFlhqlAiF NaxgNFxHY0LMkkqQGkxKzhCQ9qBsanwRGkH2en5Kz6hSr8uOyYw7wkmQ468rWeJsrd2C Pzb5EhWZ4OWElSJ/pXbcmo+mgXlsK0UAJrKx1yBNKRxfR3IJIewkavZKbQ0gv4DUsIOD xBVjMytk2cgnSLcNoVUTZDq+ME3ezc0A7ba47JUxlmQouGRA4Y93bqGoiNGEL0fArLcO pAatX5NjQhO4oKnGRzHcCrGGgIWRdmujx2hJfqBnoVjoKL+6relkhKQoNLr72H5Lfcgn 3eSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="MD/s1Kgb"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z7si799494plg.513.2022.02.12.05.08.29; Sat, 12 Feb 2022 05:09:03 -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=@kernel.org header.s=k20201202 header.b="MD/s1Kgb"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354170AbiBKXdn (ORCPT + 93 others); Fri, 11 Feb 2022 18:33:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243430AbiBKXdm (ORCPT ); Fri, 11 Feb 2022 18:33:42 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8CC0C66; Fri, 11 Feb 2022 15:33:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 06EF061AB8; Fri, 11 Feb 2022 23:33:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6308C340E9; Fri, 11 Feb 2022 23:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644622418; bh=NcXN/ZExFBWEE/4j7wW8A6WXqsCsTCy55XEhj/QVImY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=MD/s1KgbDdFqUM3Vb1BzoByXZiIGv1RlMk7utUYwSOUf2JBAZFlRXxt4ECnUyYqy2 W2P/xae6UgnONaMt/yfHTrkcp/Ewnkisg3q/XL2qGzszRkrYQfhNfDKBUVkaTyjKiI TMeacNN8OOe3NX8ZpbtDEriWYxrQhsGFC7y9uGqj0S7moAb1kWthU5wOueV/EfmDja 96CZMpWUQRSafptUAWevRxcbiJHzmf1Bt5DG3KdDxxX9JAXkqI6HsnPE0GyAOsixEF V+mxb58acULwgB8+JZQHVywpmh7FewNQBkD25shtBrNaMabuc4v6KV0+VFfKIvJZXJ fcZZKVqrIZMqg== Message-ID: <619547ad-de96-1be9-036b-a7b4e99b09a6@kernel.org> Date: Fri, 11 Feb 2022 15:33:35 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 01/12] mm/shmem: Introduce F_SEAL_INACCESSIBLE Content-Language: en-US To: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, qemu-devel@nongnu.org, Linux API Cc: 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 References: <20220118132121.31388-1-chao.p.peng@linux.intel.com> <20220118132121.31388-2-chao.p.peng@linux.intel.com> From: Andy Lutomirski In-Reply-To: <20220118132121.31388-2-chao.p.peng@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,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 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. (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.)