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 94387C32772 for ; Tue, 23 Aug 2022 16:05:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA1D8940008; Tue, 23 Aug 2022 12:05:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5111940007; Tue, 23 Aug 2022 12:05:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCAD3940008; Tue, 23 Aug 2022 12:05:33 -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 B9FE8940007 for ; Tue, 23 Aug 2022 12:05:33 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 898F51C6D5C for ; Tue, 23 Aug 2022 16:05:33 +0000 (UTC) X-FDA: 79831332546.15.6A9C052 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf11.hostedemail.com (Postfix) with ESMTP id 3AB0840002 for ; Tue, 23 Aug 2022 16:05:32 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 73so12650360pgb.9 for ; Tue, 23 Aug 2022 09:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=aVBt+IuocN3gZGMsPNsv72g8OF66w1EEamrVZjnB+J4=; b=aHRlHO4kNIRNDNrpKgB2QM9cSMZjQBb6u4l59Y4E0tZW/BrvBnqckZTcn9cz3SUw3D igHUCLBokcR+QGB8XUc1cJbRn7hVuyKGyfeg1tfWEOZHpP64tT9cUzSSzx1Y0vgX+Uyv RPdN051ayBxF8NbSnhZI7UkDJIxJC2b9PXw94OGmVsv1/XB2K1qoCbLTnhTe5HqVT1w+ uDjWiexbtDjcheCp9qg/+R4RDyAtHxBooBSO8W1phCNDG09PvGpKx4gmxB38OKo5Au+a wQuvSmBbg3eLIxGH8V0BVxy3Pbhs0aKjR4E9VsFcpOdyvMRpUtUfAdi6lWLpFgc21aKV eFRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=aVBt+IuocN3gZGMsPNsv72g8OF66w1EEamrVZjnB+J4=; b=Rh2VXMjFqUG9oY6Uax42z56sc5nf3IbHn0CXEtRnomWdj2v3XqgtL26p+peoU6xCgh d5o19ruYcZC+WnQG8byfXee5STLFMmktIaqxWPNi0WZdfCWPAIEKLlGrjZxK5V6r2WHC 9+be0/WecK6NVEGBVO08uoyJceMapsnCkx2pGg1mzVejrUackUvHtHlOahhFeBmpbkQ0 s2cYxgWyxnF6OAj2AgYICoqo0yd22aUSn0CiJx5rLzYOZ/wiZYlaAuFaRHmoubC7d40n vV2P0oUc6t+0laS0jJ3XqniY1NSjVG2kXQna58N3Dq34NRg388bvevayln6CLanXgrcK OuZA== X-Gm-Message-State: ACgBeo3GCV/an5FXUSOg93EE2HkGU9sNuXhvJGGF3RIQ8QbkvPiubI8F EHcegTA2TnbUkblzGB92rt+CNQ== X-Google-Smtp-Source: AA6agR7U2euXK2YAHsShhKay0KkYkkaAjkpwjugKPMjrIdRBiwJTOXGIGRCd9tb8zWpXTJzh2djP8w== X-Received: by 2002:a63:1c11:0:b0:41d:89d5:8ef0 with SMTP id c17-20020a631c11000000b0041d89d58ef0mr21289304pgc.403.1661270731660; Tue, 23 Aug 2022 09:05:31 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id z27-20020aa7959b000000b00536ede9e344sm2384650pfj.14.2022.08.23.09.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 09:05:31 -0700 (PDT) Date: Tue, 23 Aug 2022 16:05:27 +0000 From: Sean Christopherson To: David Hildenbrand Cc: Hugh Dickins , "Kirill A . Shutemov" , Chao Peng , 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 , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , 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 , "Gupta, Pankaj" Subject: Re: [PATCH v7 00/14] KVM: mm: fd-based approach for supporting KVM guest private memory Message-ID: References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220818132421.6xmjqduempmxnnu2@box> <226ab26d-9aa8-dce2-c7f0-9e3f5b65b63@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661270733; a=rsa-sha256; cv=none; b=fd9WVvFpaj8JaqHPPVgeyFJVmCMSdw9SSIJL809CvL/WttXCpCUZJknV7y944E96/vG59U boSrgypqRVdugpNYCQ1v59gVrILB1qn++aC8eY+gODfsSeZNG8hcyu9zCHS7Gu6N45EHkK jb/+/6MpC01kiu3hmBsUhF+e5igqPbo= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aHRlHO4k; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of seanjc@google.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=seanjc@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661270733; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aVBt+IuocN3gZGMsPNsv72g8OF66w1EEamrVZjnB+J4=; b=JwDO3hqULhPxt7X8102oE8FSW4wIddMLcrdJXCi0HiO5216p29P1Fbw3budHQXYNFw3XAa Qd7jpvuBtRxjal7p/8BJTQsxcseVrVIyiSn5m7ArsjRhxsbEST0q2Qc7i9jinqQc4ojSD3 D6HeYSfEunhTbaa23LVrAsDf0F31UnY= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3AB0840002 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aHRlHO4k; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of seanjc@google.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=seanjc@google.com X-Stat-Signature: 9xmhacb3wetraj6b4oa5pisd83n81u8i X-HE-Tag: 1661270732-377367 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 Tue, Aug 23, 2022, David Hildenbrand wrote: > On 19.08.22 05:38, Hugh Dickins wrote: > > On Fri, 19 Aug 2022, Sean Christopherson wrote: > >> On Thu, Aug 18, 2022, Kirill A . Shutemov wrote: > >>> On Wed, Aug 17, 2022 at 10:40:12PM -0700, Hugh Dickins wrote: > >>>> On Wed, 6 Jul 2022, Chao Peng wrote: > >>>> But since then, TDX in particular has forced an effort into preventing > >>>> (by flags, seals, notifiers) almost everything that makes it shmem/tmpfs. > >>>> > >>>> Are any of the shmem.c mods useful to existing users of shmem.c? No. > >>>> Is MFD_INACCESSIBLE useful or comprehensible to memfd_create() users? No. > >> > >> But QEMU and other VMMs are users of shmem and memfd. The new features certainly > >> aren't useful for _all_ existing users, but I don't think it's fair to say that > >> they're not useful for _any_ existing users. > > > > Okay, I stand corrected: there exist some users of memfd_create() > > who will also have use for "INACCESSIBLE" memory. > > As raised in reply to the relevant patch, I'm not sure if we really have > to/want to expose MFD_INACCESSIBLE to user space. I feel like this is a > requirement of specific memfd_notifer (memfile_notifier) implementations > -- such as TDX that will convert the memory and MCE-kill the machine on > ordinary write access. We might be able to set/enforce this when > registering a notifier internally instead, and fail notifier > registration if a condition isn't met (e.g., existing mmap). > > So I'd be curious, which other users of shmem/memfd would benefit from > (MMU)-"INACCESSIBLE" memory obtained via memfd_create()? I agree that there's no need to expose the inaccessible behavior via uAPI. Making it a kernel-internal thing that's negotiated/resolved when KVM binds to the fd would align INACCESSIBLE with the UNMOVABLE and UNRECLAIMABLE flags (and any other flags that get added in the future). AFAICT, the user-visible flag is a holdover from the early RFCs and doesn't provide any unique functionality. If we go that route, we might want to have shmem/memfd require INACCESSIBLE to be set for the initial implementation. I.e. disallow binding without INACCESSIBLE until there's a use case.