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 323F0C00140 for ; Wed, 10 Aug 2022 09:57:18 +0000 (UTC) Received: from localhost ([::1]:55196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLiSj-0002Vq-16 for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 05:57:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLiQz-0001kA-74 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 05:55:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLiQw-0007lY-Mr for qemu-devel@nongnu.org; Wed, 10 Aug 2022 05:55:27 -0400 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.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-307-IZbexXH-NHe26_R-GNrU1Q-1; Wed, 10 Aug 2022 05:55:23 -0400 X-MC-Unique: IZbexXH-NHe26_R-GNrU1Q-1 Received: by mail-wm1-f71.google.com with SMTP id c66-20020a1c3545000000b003a37b7e0764so854483wma.5 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=ESTwTeqWbixlIvrVbrxe7yyIYy5JNyYqE3Q+ZYNxjN7DUj7b4pITVVcZTP4r76RGAA Gb5IX6t3LiACjmjkCgSMwcTuLZwxfzbUutMglCmaZ0iQVz0FJRfsVGG6louH1ijA51RQ cHBTocmYhFt7oyp91XFKNwLn1EaZNB2jdfgMsVe/BR/hJkcFcILstVaHtmgwfAasTgWG S4rw36PGy4JopcakK32Rsk+CEhXpHfFV7v1yDdsvqS8m9GJNgG5XSiyDynza03yvQcgb GxGkZJsBSJVBVBXMGbV2G0JLbBVpVOntll8U+eaBJd4ZWABGWKP4UZ1RkCuyPmNwG3qo EMeQ== X-Gm-Message-State: ACgBeo2xFt8mjz3Ngu51dt0Kbp1tfI0PJgmInRF8OMDEh8XIg7IIkH60 4EQ7PXal/VGunyzTSP7ueSA2MK6nZ30m0zdnk6v692NtjSFFn33Kny9+5PHuB1qAhFVZ+uYWBAo 7LHf6h8BtQbFV8XY= X-Received: by 2002:a5d:64e4:0:b0:222:d4da:c2e1 with SMTP id g4-20020a5d64e4000000b00222d4dac2e1mr7468929wri.15.1660125322319; 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 Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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