Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp170169rdb; Wed, 1 Nov 2023 23:00:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUiM34Yw/xLxBKret8XpfUtrh1rZ9/ei9l1zYqQVPyJ6gO99VGlMpayba82fCKh2Dwiccx X-Received: by 2002:a05:6830:1c7:b0:6b9:8ea6:fbc2 with SMTP id r7-20020a05683001c700b006b98ea6fbc2mr20019148ota.27.1698904819435; Wed, 01 Nov 2023 23:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698904819; cv=none; d=google.com; s=arc-20160816; b=Zz7RK35CNBWNxiOTtXODgrzUD0ekoSFt6ZE7MptFm8kVz6ISJNQmolVPTfnGJofjwl w8sAnvN8mfex6cgdqiicVWpAo3+QBeUXZqoXAjeSFEqJXRaxeghiwgXd2OfIU1SRvDUw MbJUFXctG+wYqpzslr7EUAW6KBOIgFT9S1JOHpdgfKzysyoBtk1cppw+7JBgSscXMLV4 kM162HqHG4Ik9X2Nyk9YQ08X8lBq/VDhzGweuXWJq3ntclhmCeiOphbTENVeHwNqm5fa OGEtjtTbQ39DwIQmTLMHhPGjA7tcHpMRYT62mhOEePu349JkeaQVHJjdWxO+MKgNahU0 b6mw== 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:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=oR97yPYlrGAYI4MEB3INBwckQ/ErHV9EtrMLwwPmQQA=; fh=cBQgmvSoLL6HCxm+cWCCSLFuIxFuVl+MNfFSCNiGSaI=; b=0Qu4eTq0Udg6PLnQ6qA11q6xV6XVIh0pxHgDaN6+vp8CMLFB/Qpgmpxj73mNTnwTJm L+9W5OK72tf3p2qV8lOZPv+csSslIvGg1ogUkzCtJ77pArmY7eDTLjJxnSejmCG85vGJ aqMe31Mj1pkcRUD1BsnjU1rfl49BiLl/LHpWSXqA5EjrVy7QNEsBk0UdOhJUOAR8bz0f vZbIhfXjJdGXFjELWoBbsKSppShw9V8CT7GlqE176Hmp4FH5LfexIHpnf8anmVc5qDSA wyFMLOw3zRIijs2HlaTteURmsC8kRsKV464qapUUfwk/9kQzmEHJylZX950HR0LQIL2X eJzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OiUIPTMY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y5-20020a655285000000b005859b1b34f7si1348041pgp.862.2023.11.01.23.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 23:00:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OiUIPTMY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3495E81CC869; Wed, 1 Nov 2023 23:00:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231876AbjKBGAO (ORCPT + 99 others); Thu, 2 Nov 2023 02:00:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjKBGAM (ORCPT ); Thu, 2 Nov 2023 02:00:12 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0217FD7; Wed, 1 Nov 2023 23:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698904807; x=1730440807; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ou5/8bq0/RVZthvT/yQo+QsMVA9om+MCO0TErMQh5Kw=; b=OiUIPTMYdM3Qa7HpDEbjmeZjJDIhxPjHoNLRTODRHbP+kCowzQ1Q2xfF g9fbUSi8hz0O7rvlE4GC2vwJvYEWPR5r0RhH64NbcacAsGiZFoRL/y/WO DBaz0+yxMxQJEWHe6zuNISMzNLvz65QHE4zh6wIbHpjU/Tx598YMKL/cl zTB2EhyGiw86ZpkM6mFPU62OfY1bexN5tsvlGTOjekPiXdRT55sA3jyU4 BUfAgNMiBGYIhefuHzOkcaDkDaGG3mqrojqBzQJQw/PJ7xFFodReSx5sx zykyYeYTcNAftpAr1U7+6ZSl73RtoKQhDED8Jsv1y7f0cU7g14oAz+tV9 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="10174671" X-IronPort-AV: E=Sophos;i="6.03,270,1694761200"; d="scan'208";a="10174671" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 23:00:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="884777553" X-IronPort-AV: E=Sophos;i="6.03,270,1694761200"; d="scan'208";a="884777553" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.2.253]) ([10.238.2.253]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 22:59:55 -0700 Message-ID: <9963b77c-3a38-4f89-b21e-48d0fdda8f53@linux.intel.com> Date: Thu, 2 Nov 2023 13:59:53 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v13 12/35] KVM: Prepare for handling only shared mappings in mmu_notifier events To: Sean Christopherson Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8?= =?UTF-8?Q?n?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-13-seanjc@google.com> From: Binbin Wu In-Reply-To: <20231027182217.3615211-13-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 23:00:18 -0700 (PDT) On 10/28/2023 2:21 AM, Sean Christopherson wrote: > Add flags to "struct kvm_gfn_range" to let notifier events target only > shared and only private mappings, and write up the existing mmu_notifier > events to be shared-only (private memory is never associated with a > userspace virtual address, i.e. can't be reached via mmu_notifiers). > > Add two flags so that KVM can handle the three possibilities (shared, > private, and shared+private) without needing something like a tri-state > enum. I see the two flags are set/cleared in __kvm_handle_hva_range() in this patch and kvm_handle_gfn_range() from the later patch 13/35, but I didn't see they are used/read in this patch series if I didn't miss anything.  How are they supposed to be used in KVM? > > Link: https://lore.kernel.org/all/ZJX0hk+KpQP0KUyB@google.com > Signed-off-by: Sean Christopherson > --- > include/linux/kvm_host.h | 2 ++ > virt/kvm/kvm_main.c | 7 +++++++ > 2 files changed, 9 insertions(+) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 96aa930536b1..89c1a991a3b8 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -263,6 +263,8 @@ struct kvm_gfn_range { > gfn_t start; > gfn_t end; > union kvm_mmu_notifier_arg arg; > + bool only_private; > + bool only_shared; > bool may_block; > }; > bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range); > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index cb9376833c18..302ccb87b4c1 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -635,6 +635,13 @@ static __always_inline kvm_mn_ret_t __kvm_handle_hva_range(struct kvm *kvm, > * the second or later invocation of the handler). > */ > gfn_range.arg = range->arg; > + > + /* > + * HVA-based notifications aren't relevant to private > + * mappings as they don't have a userspace mapping. > + */ > + gfn_range.only_private = false; > + gfn_range.only_shared = true; > gfn_range.may_block = range->may_block; > > /*