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 CE3F0C00140 for ; Wed, 10 Aug 2022 09:55:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E4C18E0002; Wed, 10 Aug 2022 05:55:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 594AB8E0001; Wed, 10 Aug 2022 05:55:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 435498E0002; Wed, 10 Aug 2022 05:55:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 30A798E0001 for ; Wed, 10 Aug 2022 05:55:26 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0DF2BA1261 for ; Wed, 10 Aug 2022 09:55:26 +0000 (UTC) X-FDA: 79783225452.13.8382387 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 82EEC4016B for ; Wed, 10 Aug 2022 09:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660125325; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m5UKomJJr5XDUN8t2Kmb7khiadiUQsrzaj90s+j66gQ=; b=XauGWYwm2YHllDCVya8h3dh2VCxcMp2eXLrGwCCuukmjOLrdAx5dk/CMcpX/u+Lxbe24xF 6/yzLXImuFsBVkN5tVXkNKcIczY4r9o46GIbAr0lLA4DDNQc4p7aNcS4wjx+f70N3f13Je hmRhx8eqHVUmTxMEGhGKI3mOSI+l6LM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-8N4roJlbNk6JA5GMz79uAw-1; Wed, 10 Aug 2022 05:55:23 -0400 X-MC-Unique: 8N4roJlbNk6JA5GMz79uAw-1 Received: by mail-wm1-f71.google.com with SMTP id c189-20020a1c35c6000000b003a4bfb16d86so7193822wma.3 for ; Wed, 10 Aug 2022 02:55:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=m5UKomJJr5XDUN8t2Kmb7khiadiUQsrzaj90s+j66gQ=; b=dd1WkzZtmZb4T2mxRnIUhMKl4jJd25RKelpvZz2+d0bnFtGeD+BWEGr7uSiRKfI0mY zzTdjc9UK5sDAUnLUHKKY9ck4xHjBU6VjT/F1j+r07xLic4I/3kDv2fpi0nl7W1QGtwd J6+zx6lc4Vg4LZsIXnDXnLPhFHlgKN3Ry2Fg1cVFcBPs90j9D3mWq7OvNRdADZMdk59S PVihIxID8aeGWF09F/twvAG2GBjygD+XlgNf3NqWR1Xbuv+BBQ8qncW1QXHOFL4wRbSc 6UnfhbVR6rAqUaFXpTI6GRzFDdTs40+1YA3VQ4fJURlL7L/l313LHpy/1iz210feYWNy 4vtA== X-Gm-Message-State: ACgBeo0Kp/J4BLHCiOhiPL5k9vl7udUoiXfkmMEqOgti+Fw9+4Oxifb0 WrAZyuRaf0+aPx0xzjMVLvEixHoyomuGsvAisJJrLypWMle75guH0oAC2O/V9w5ygWoV7E3HxJp UbYJjh6NpRAk= X-Received: by 2002:a5d:64e4:0:b0:222:d4da:c2e1 with SMTP id g4-20020a5d64e4000000b00222d4dac2e1mr7468942wri.15.1660125322329; Wed, 10 Aug 2022 02:55:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR57ng+8LAmFqiWIYkxzU0qIaLTw96OSbpCj25JDzNCtyJxE1FXqxz6BaUC8mUFwvCSeHhucCg== X-Received: by 2002:a5d:64e4:0:b0:222:d4da:c2e1 with SMTP id g4-20020a5d64e4000000b00222d4dac2e1mr7468880wri.15.1660125322007; Wed, 10 Aug 2022 02:55:22 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:1600:a3ce:b459:ef57:7b93? (p200300cbc7071600a3ceb459ef577b93.dip0.t-ipconnect.de. [2003:cb:c707:1600:a3ce:b459:ef57:7b93]) by smtp.gmail.com with ESMTPSA id l3-20020a05600c4f0300b003a4bb3f9bc6sm1837127wmq.41.2022.08.10.02.55.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Aug 2022 02:55:21 -0700 (PDT) Message-ID: <64ab9678-c72d-b6d9-8532-346cc9c06814@redhat.com> Date: Wed, 10 Aug 2022 11:55:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v7 05/14] mm/memfd: Introduce MFD_INACCESSIBLE flag To: Chao Peng Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, linux-kselftest@vger.kernel.org, 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 , 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, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220706082016.2603916-6-chao.p.peng@linux.intel.com> <203c752f-9439-b5ae-056c-27b2631dcb81@redhat.com> <20220810093741.GE862421@chaop.bj.intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220810093741.GE862421@chaop.bj.intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660125325; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=m5UKomJJr5XDUN8t2Kmb7khiadiUQsrzaj90s+j66gQ=; b=8HeUkgkvbIDm0guL1ohpOwtqn5XlxwJ2iJEd6Tvy8i9EgcZRUnTWEI9kxOyZBvh1ZQ1Z4C sgiARu8X1fv5cfy4wXHTRpV0tRK4lF9AxlgOo5ZgO/dzIRsp94+NwlmEn2IxrP3EYILpQM TvWGLS38FXQ9aXPRh8BsOGbs3aD6XKE= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XauGWYwm; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660125325; a=rsa-sha256; cv=none; b=xNtRjt+IHm53EsobxLEP5b29cykNkXgTsKUpUMeJESVaXQ284OUXqMPROc64kY9Cu0HgtD SINbx/xMFW0yhjUHWc7edK1gtoaadFGgGYdrntzb4BzbPvo05U4Au/Cyd/rAG17QqEpiBE OMLV2FvtJmhSQkWBN5J6DGlmwcYud7o= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XauGWYwm; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam02 X-Stat-Signature: 7tmiyk8s43ibb3fsm1irdwsb4x719gxi X-Rspamd-Queue-Id: 82EEC4016B X-Rspam-User: X-HE-Tag: 1660125325-434101 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 10.08.22 11:37, Chao Peng wrote: > On Fri, Aug 05, 2022 at 03:28:50PM +0200, David Hildenbrand wrote: >> On 06.07.22 10:20, Chao Peng wrote: >>> Introduce a new memfd_create() flag indicating the content of the >>> created memfd 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 flag 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. >>> >>> The flag can not coexist with MFD_ALLOW_SEALING, future sealing is >>> also impossible for a memfd created with this flag. >> >> It's kind of weird to have it that way. Why should the user have to >> care? It's the notifier requirement to have that, no? >> >> Why can't we handle that when register a notifier? If anything is >> already mapped, fail registering the notifier if the notifier has these >> demands. If registering succeeds, block it internally. >> >> Or what am I missing? We might not need the memfile set flag semantics >> eventually and would not have to expose such a flag to user space. > > This makes sense if doable. The major concern was: is there a reliable > way to detect this (already mapped) at the time of memslot registering. If too complicated, we could simplify to "was this ever mapped" and fail for now. Hooking into shmem_mmap() might be sufficient for that to get notified about the first mmap. As an alternative, mapping_mapped() or similar *might* do what we want. -- Thanks, David / dhildenb