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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ABA7C43217 for ; Sun, 24 Apr 2022 08:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238640AbiDXIKz (ORCPT ); Sun, 24 Apr 2022 04:10:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236428AbiDXIKx (ORCPT ); Sun, 24 Apr 2022 04:10:53 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB101816C6; Sun, 24 Apr 2022 01:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650787674; x=1682323674; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=Jg69NAeROVkmxoEWc411QwNioJnF4WnIiJ0sHVRfPPE=; b=gl1rcmLSizfukbF+kURWVeQ4WDc6GXknisCAooeJSK5KrUnRfxau5Ldv /f//mIHeegzZVbXychQYSUZfHzUbIjTOJl3EPoUtVvq0XVPY8jO9w8E0f JFQTqnqvp/ODv0keKt0KFlKUEfIConqJkvaLbciCSEKkPWCX2ydMGRxTB /VNcdAkmv/POalgQ2zYktLqTYvUeyp4OIpPWK9+t93vkosScOo/oJSXXW FqJSK9QNlzhI4JSLEPT/SLI1n+nXxkoFs9ikujHMKt71obVDrzjLH/1lI WBC0fvBjNjsGZiPDyOcx+S1S+Bf35DIwlTh1t7KKxyOO1uD2H7NZXhEnR w==; X-IronPort-AV: E=McAfee;i="6400,9594,10326"; a="265182519" X-IronPort-AV: E=Sophos;i="5.90,286,1643702400"; d="scan'208";a="265182519" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 01:07:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,286,1643702400"; d="scan'208";a="704146191" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.101]) by fmsmga001.fm.intel.com with ESMTP; 24 Apr 2022 01:07:45 -0700 Date: Sun, 24 Apr 2022 16:07:37 +0800 From: Chao Peng To: Paolo Bonzini Cc: Sean Christopherson , Quentin Perret , Andy Lutomirski , Steven Price , kvm list , Linux Kernel Mailing List , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Linux API , qemu-devel@nongnu.org, Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , the arch/x86 maintainers , "H. Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Mike Rapoport , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A. Shutemov" , "Nakajima, Jun" , Dave Hansen , Andi Kleen , David Hildenbrand , Marc Zyngier , Will Deacon Subject: Re: [PATCH v5 00/13] KVM: mm: fd-based approach for supporting KVM guest private memory Message-ID: <20220424080737.GA4207@chaop.bj.intel.com> Reply-To: Chao Peng References: <80aad2f9-9612-4e87-a27a-755d3fa97c92@www.fastmail.com> <83fd55f8-cd42-4588-9bf6-199cbce70f33@www.fastmail.com> <20220422105612.GB61987@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 22, 2022 at 01:06:25PM +0200, Paolo Bonzini wrote: > On 4/22/22 12:56, Chao Peng wrote: > > /* memfile notifier flags */ > > #define MFN_F_USER_INACCESSIBLE 0x0001 /* memory allocated in the file is inaccessible from userspace (e.g. read/write/mmap) */ > > #define MFN_F_UNMOVABLE 0x0002 /* memory allocated in the file is unmovable */ > > #define MFN_F_UNRECLAIMABLE 0x0003 /* memory allocated in the file is unreclaimable (e.g. via kswapd or any other pathes) */ > > You probably mean BIT(0/1/2) here. Right, it's BIT(n), Thanks. Chao > > Paolo > > > When memfile_notifier is being registered, memfile_register_notifier will > > need check these flags. E.g. for MFN_F_USER_INACCESSIBLE, it fails when > > previous mmap-ed mapping exists on the fd (I'm still unclear on how to do > > this). When multiple consumers are supported it also need check all > > registered consumers to see if any conflict (e.g. all consumers should have > > MFN_F_USER_INACCESSIBLE set). Only when the register succeeds, the fd is > > converted into a private fd, before that, the fd is just a normal (shared) > > one. During this conversion, the previous data is preserved so you can put > > some initial data in guest pages (whether the architecture allows this is > > architecture-specific and out of the scope of this patch).