Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp264424rdb; Mon, 18 Sep 2023 14:31:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBVu31scWWUc+1Hq7EqFWfpQaiqPmf+q9wPA3fdyGBbvJdA/JMAEFNEHWaMmKKhI6QO1GM X-Received: by 2002:a17:902:e74a:b0:1c1:e7b2:27af with SMTP id p10-20020a170902e74a00b001c1e7b227afmr11525374plf.57.1695072704261; Mon, 18 Sep 2023 14:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695072704; cv=none; d=google.com; s=arc-20160816; b=xUK7V5vui1cn7EXaMFK7AyH6q27LhDIqQrIzfOoWFVkQSRnuOGdFQPzr6UK/vMQQMc i+AKHIepqlsJ5Gu4r6Pp49nqNQIme7G2TLnpY8D+5JoT779GvuB8d4QK2HkO4VHwevqs EdqY1hgK3zTFLuELsR8masMqHyhKVBcxChzmUuLVsscFVlgsjExCe/pzY+A2BICn4VfH 6iXQjd9l8biRLJ3IAsiD2YFAjXvrPZlplMkzjCgkwzts43XyMYvw7VM5kQQSJcFq1r7B 6RccObh5VVqN+0sw6wPYpAd2OwHznWbDtqdyCLz8CaAJPcXp25gg5eZNTMWu50DTklT6 d3ow== 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=B/NgBo3CFrOi4QufxnzUplspQHg45sZuhOOGXWvcR3Q=; fh=6tIgcrdU5AWeDZ1pzFQo9ftoyyjK82pQ36403WCtu0Q=; b=iLJYhSaL6PhGCT6hPhHye8uvSEKpgatsORxSc8FxBVdCDV1Sd6ZbWazmgrqcpS9Zhd 85JIdqT+UzqYnsZ9hwSwKFad7PoRtQW8XjkbneCuTCBkaIeIZxx2HH1gOyVQsNMg+OTd vl5NxGwMbXNbWIdAHP/sT6VgGsu4j0Gm2/h/QQ01ezaVkOtBoTTjCFsW5XIrbFRZD4qZ y6U7gCDZ82jEmEJjakLqfrA1lAouxMrFKYLsPzTcuMgS/8fnEip5AME9E4O7p8Yk4Tw9 qNVRbmTto2hK74PKCwVr8t/aHLZa/M5l6SfjK+GLwdGWQNKeIOcWDXpfyQ55Wv2xPIWP lCwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="XNC0i8/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id m7-20020a170902db0700b001bb3bcd05bbsi8718532plx.471.2023.09.18.14.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 14:31:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="XNC0i8/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 5ECA8801CA69; Sun, 17 Sep 2023 18:18:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235865AbjIRBOr (ORCPT + 99 others); Sun, 17 Sep 2023 21:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjIRBOb (ORCPT ); Sun, 17 Sep 2023 21:14:31 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA21124; Sun, 17 Sep 2023 18:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694999666; x=1726535666; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=oa/nrZXu3pJ1XHmH6ZVv7iF/X9/VnJhZeXvizU+honc=; b=XNC0i8/3WoZYSa3FV5A0gKvhuxa/IPj6toJJwkiWG5xWauzfcgmillHd X1ID5rQsktH3AoFEjIpUzJzUjSO4JggJkinLN2dOIwBl2YHlJfu+N8bbx 55QV2kE+rqlGdOG6ADule1ZUqf+aO/cNWe8cyjazcIXa9LMpqhz5w+BaG yJO9Edd15z9Axywn0IGnjIWQYSIcFw2rqUGPIv4oInTryWh57qXb1TZT5 f3izvD5TPQtR+rqm4X3FrxCi6gQSRG9mC1luYXdMk0c1WwJI7e1FT1Ocv KfHhQrz1ecSPE7uYAFsq5VUp1uXsndcCVeENPqS16VB0SVV2rq7UXoLtr Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="383364151" X-IronPort-AV: E=Sophos;i="6.02,155,1688454000"; d="scan'208";a="383364151" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 18:14:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="835840579" X-IronPort-AV: E=Sophos;i="6.02,155,1688454000"; d="scan'208";a="835840579" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.8.84]) ([10.238.8.84]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 18:14:15 -0700 Message-ID: <9925e01b-7fa9-95e4-dc21-1d760ef9cde4@linux.intel.com> Date: Mon, 18 Sep 2023 09:14:13 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC PATCH v12 10/33] KVM: Set the stage for handling only shared mappings in mmu_notifier events To: Sean Christopherson Cc: 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-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , Yu Zhang , Isaku Yamahata , Xu Yilun , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" References: <20230914015531.1419405-1-seanjc@google.com> <20230914015531.1419405-11-seanjc@google.com> From: Binbin Wu In-Reply-To: <20230914015531.1419405-11-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Sun, 17 Sep 2023 18:18:55 -0700 (PDT) On 9/14/2023 9:55 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. How to understand the word "stage" in short log? > > 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 d8c6ce6c8211..b5373cee2b08 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 174de2789657..a41f8658dfe0 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; > > /*