From patchwork Fri Nov 11 09:34:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 18635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp649747wru; Fri, 11 Nov 2022 02:02:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TLOnFTy7Yxr48OSJZH/x3NGiJQ/VPEHkyh3TELyUJaBCYeJJv17iQ/gLRyw2ixXa+Udj4 X-Received: by 2002:a17:902:8489:b0:186:6e16:18dd with SMTP id c9-20020a170902848900b001866e1618ddmr1806519plo.131.1668160971368; Fri, 11 Nov 2022 02:02:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668160971; cv=none; d=google.com; s=arc-20160816; b=ZZX74RurZdqb8U/pCkffv9TxLbvQxzZpwYn1MaBNZy5g2Ha97Nb1/cErWWOjCiOt0Z CPcn7SDljHehaht2tk2HnRO1kqxz2qWe3QRTpAyv6nOr4eH0F12EcEXE5HsnOdd55VrZ X+vtWg5UZ2zio69ZMPsCiTjKzvpXBbKfuy2Ptd5/+KmW0VP4nLXcUSpaf5f6TO/LihbK G6sdw2bE0LtUd/0f5lbwXKXS3SJ9RReF3GseWWEnac7/w7+vaj6T+D+wDOBg9cgPqPlB 7zr18y426WB3rC9tLQCJDB1fdA9FK0qZl8ZBF7sxLA9kZuHzfLrwvMo8UzkxXE1dXf81 V6AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ya8JN9yy4rmdu/TIYieT5hT7htRFasa5OEKypwT3o2Y=; b=XqkmNiYf9ft+aeLoo6IEgwWNpxLhotUlSUgLKWyITja2xAtwUl6jLT6X8bO9zonqnY ouiGoQ/h51WGexerUWnldbJvgLYV5AD4sHlKBW79VJCLJ3OJCOmTt948iy6xPzckDKCV rcl7Pwg+15To+6+/MMDeIe/ayBMo1fDgRYiGyajKKlu2IAojstdDTyns0EsZ/k2PXzhA V2sS4YwOO3UNv33OaT/odH7XokcAZy8ECOwFWpPn6tiHMG/XGieVX0BDfEloCRRFder3 x1t5M7nma5hFEiLV82he2zqVKbz5Wu6b69FsDjFVWmclFAKRpwkw714ieO3wHxijanQU EbyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FRkzOhSH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a630e15000000b004622caf9ac4si2051858pgl.805.2022.11.11.02.02.33; Fri, 11 Nov 2022 02:02:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FRkzOhSH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233384AbiKKJ5u (ORCPT + 99 others); Fri, 11 Nov 2022 04:57:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233315AbiKKJ5s (ORCPT ); Fri, 11 Nov 2022 04:57:48 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D8168AD8; Fri, 11 Nov 2022 01:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668160667; x=1699696667; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=wt+vlOzCkH8SLs01r95Dnw3PuDC+sxswMNY5/OeykXY=; b=FRkzOhSH+0vQyTfGXoeSGe4tdYVL9o6MT8JQztsLh5sdm3Nb5DvYPtC/ 5+OTOwsRTcZeMo4VcHIGsNDyLEQWNKr4F1cfWOiNoogYbIn9nvjGP/6Nd HiKPHSgzk/+G+GmoeXr3ksoDj+AYDZiYwqgzBxPwkn3smKPxFD6CM2pxg PRTZuJrLcX2mFR+TDIQn2rLDVAfT++bbIhzCxgABBwBCx+PMfb2RVX/Uh Fsys345+njn4tLnPAxo0Kn1rguJIYNeZQsOnEGcANeid6/CfhzyeIBG59 mObDlgOX5hJmti+UZc7PqgEBsjAF7I7B2jkKPigB7Me66eIZit/bfidYn A==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="373700227" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="373700227" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 01:57:47 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="706496838" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="706496838" Received: from yzhao56-desk.sh.intel.com ([10.238.200.254]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 01:57:44 -0800 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, zhenyuw@linux.intel.com, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, Yan Zhao , Sean Christopherson Subject: [PATCH 1/3] KVM: x86: add a new page track hook track_remove_slot Date: Fri, 11 Nov 2022 17:34:45 +0800 Message-Id: <20221111093445.3212-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221111093222.3148-1-yan.y.zhao@intel.com> References: <20221111093222.3148-1-yan.y.zhao@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749193558799202601?= X-GMAIL-MSGID: =?utf-8?q?1749193558799202601?= Page track hook track_remove_slot is used to notify users that a slot has been removed and is called when a slot DELETE/MOVE is about to be completed. Users of this hook can drop write protections in the removed slot. Note: Since KVM_MR_MOVE currently never actually happens in KVM/QEMU, and has never been properly supported in the external page track user, we just use the hook track_remove_slot to notify users of the old slot being removed. Cc: Zhenyu Wang Suggested-by: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Yan Zhao --- arch/x86/include/asm/kvm_page_track.h | 11 +++++++++++ arch/x86/kvm/mmu/page_track.c | 26 ++++++++++++++++++++++++++ arch/x86/kvm/x86.c | 3 +++ 3 files changed, 40 insertions(+) diff --git a/arch/x86/include/asm/kvm_page_track.h b/arch/x86/include/asm/kvm_page_track.h index eb186bc57f6a..046b024d1813 100644 --- a/arch/x86/include/asm/kvm_page_track.h +++ b/arch/x86/include/asm/kvm_page_track.h @@ -44,6 +44,16 @@ struct kvm_page_track_notifier_node { */ void (*track_flush_slot)(struct kvm *kvm, struct kvm_memory_slot *slot, struct kvm_page_track_notifier_node *node); + /* + * It is called when memory slot is moved or removed + * users can drop write-protection for the pages in that memory slot + * + * @kvm: the kvm where memory slot being moved or removed + * @slot: the memory slot being moved or removed + * @node: this node + */ + void (*track_remove_slot)(struct kvm *kvm, struct kvm_memory_slot *slot, + struct kvm_page_track_notifier_node *node); }; int kvm_page_track_init(struct kvm *kvm); @@ -76,4 +86,5 @@ kvm_page_track_unregister_notifier(struct kvm *kvm, void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, int bytes); void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot); +void kvm_page_track_remove_slot(struct kvm *kvm, struct kvm_memory_slot *slot); #endif diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c index 2e09d1b6249f..4d6bab1d61c9 100644 --- a/arch/x86/kvm/mmu/page_track.c +++ b/arch/x86/kvm/mmu/page_track.c @@ -300,3 +300,29 @@ void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot) n->track_flush_slot(kvm, slot, n); srcu_read_unlock(&head->track_srcu, idx); } + +/* + * Notify the node that memory slot is removed or moved so that it can + * drop write-protection for the pages in the memory slot. + * + * The node should figure out it has any write-protected pages in this slot + * by itself. + */ +void kvm_page_track_remove_slot(struct kvm *kvm, struct kvm_memory_slot *slot) +{ + struct kvm_page_track_notifier_head *head; + struct kvm_page_track_notifier_node *n; + int idx; + + head = &kvm->arch.track_notifier_head; + + if (hlist_empty(&head->track_notifier_list)) + return; + + idx = srcu_read_lock(&head->track_srcu); + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node, + srcu_read_lock_held(&head->track_srcu)) + if (n->track_remove_slot) + n->track_remove_slot(kvm, slot, n); + srcu_read_unlock(&head->track_srcu, idx); +} diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 916ebbc81e52..a24a4a2ad1a0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12844,6 +12844,9 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, const struct kvm_memory_slot *new, enum kvm_mr_change change) { + if (change == KVM_MR_DELETE || change == KVM_MR_MOVE) + kvm_page_track_remove_slot(kvm, old); + if (!kvm->arch.n_requested_mmu_pages && (change == KVM_MR_CREATE || change == KVM_MR_DELETE)) { unsigned long nr_mmu_pages; From patchwork Fri Nov 11 09:37:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 18639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp651526wru; Fri, 11 Nov 2022 02:06:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Opmev01n6KzKhKqkbR38CIRGFMuM1QQlSrxT6TE3DWow7Ozy7CmeI0YFQv+KtJfEnD2d+ X-Received: by 2002:a63:3117:0:b0:462:644c:87ff with SMTP id x23-20020a633117000000b00462644c87ffmr980472pgx.552.1668161202649; Fri, 11 Nov 2022 02:06:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668161202; cv=none; d=google.com; s=arc-20160816; b=XGxcteEHz6IPPE4sNrpHN53z9DrWKMoSuM0ZxLWtDxGnQSJX8AOyk76bi5KZ16+ZO1 SkAyqIKjH9EcywDqDa7NNqRgVasfYwPH8v1EIjXzs+XnvaSJTF401i5FTjBrUSvDD6dL osCc7oRPFnZgmNewA90tJFFUsjjyV0BEjQ/H6YvtRGL8ACu9mSWALVeUCR9quilTiV23 0+VHvvl4bvl/VFZ+z3lpOlswrlOfuQLpUzbCO/Zm2vTpGXXwvfzC7Yuy66+jpRRPDASQ 4WGwtguLI20/LHJidvHbblZV6fvFdQumnXffdL5ufz4fozxPl+NtLgruHueL1PaaSYjq rXqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Fy7+EuVAn932SVqyHC0lTfWrwnmS7DUxKaHmWRZk6IE=; b=SCz3RyKOTuZNLWtzu2k6WQPEG1UVHD2ss/c3YhHpb6+O/3prBEWCPPPQ3baFDCI7lR nVtgnndEicf17Ah6TVqvyGEFRCyovSx6yUJ9HfGfFHI9LLZ/OXiNhkQvVWqw5eP4h3PI OYMYj+qipXaXeMiQwIu4vNF353aLYCWhbCT/J+KleilcxE+SdAiLyG8dIMn3280PDmkl zTbv312CocDLhA9K2sDZ3CKzAFp4fTobT50PErHCxYATbOPqi+KEWXo5Pe7bhb8F+muc ZshfStxHJC1wTJFL8PFu7TDRxhurFoE3nzSfVj9tOUy3lAj/8GA/tvjO0RQwVQPnrtLa nf9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HIA0we75; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix11-20020a170902f80b00b00174ea015ee8si1831232plb.592.2022.11.11.02.06.26; Fri, 11 Nov 2022 02:06:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HIA0we75; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233438AbiKKKAN (ORCPT + 99 others); Fri, 11 Nov 2022 05:00:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233413AbiKKKAB (ORCPT ); Fri, 11 Nov 2022 05:00:01 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2379C67F54; Fri, 11 Nov 2022 01:59:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668160795; x=1699696795; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=qWhXfxIEV1vi5i6wA8VHdj+5Ag2yRelX1mSNHmIqtBU=; b=HIA0we75JIBneUqIctvQoGMNLDNaWin1c40JltkglMcRBFWqXY5cGafa ODnd+kIe9L2qzAFKCSLZzQGGAoYyg2k+Wz2hkn22K73q2DoemdUg6Z0aB BAhnpJPLIp9+QYiTQtMlQUesgCIxvmf+l5pnCyzDbX4d4g7RA2jtbNuBU Rek1Tof7bS5Xa9MLUNXCqNjOSfbZCM4h9WNnZO139UJNEgoRAMfoHZ1xc bMCXtccZCNhe8XGahx9b2CZoMl7GY0YlzCelzKbdCwVf747vfmgR2izVN DKI9/TO7NkqZG2w7B86C702K714rZ0aD9Zzinup+i8GMkguQ8wXZ369fl g==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="375831178" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="375831178" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 01:59:54 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="966773398" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="966773398" Received: from yzhao56-desk.sh.intel.com ([10.238.200.254]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 01:59:52 -0800 From: Yan Zhao To: intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org Cc: zhenyuw@linux.intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, seanjc@google.com, Yan Zhao Subject: [PATCH 2/3] drm/i915/gvt: switch from track_flush_slot to track_remove_slot Date: Fri, 11 Nov 2022 17:37:10 +0800 Message-Id: <20221111093710.3270-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221111093222.3148-1-yan.y.zhao@intel.com> References: <20221111093222.3148-1-yan.y.zhao@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749193800988427518?= X-GMAIL-MSGID: =?utf-8?q?1749193800988427518?= KVMGT only cares about when a slot is indeed removed. So switch to use track_remove_slot which is called when a slot is removed. Cc: Zhenyu Wang Suggested-by: Sean Christopherson Signed-off-by: Yan Zhao --- drivers/gpu/drm/i915/gvt/kvmgt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index 714221f9a131..9582d047471f 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -109,7 +109,7 @@ struct gvt_dma { static void kvmgt_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *val, int len, struct kvm_page_track_notifier_node *node); -static void kvmgt_page_track_flush_slot(struct kvm *kvm, +static void kvmgt_page_track_remove_slot(struct kvm *kvm, struct kvm_memory_slot *slot, struct kvm_page_track_notifier_node *node); @@ -673,7 +673,7 @@ static int intel_vgpu_open_device(struct vfio_device *vfio_dev) gvt_cache_init(vgpu); vgpu->track_node.track_write = kvmgt_page_track_write; - vgpu->track_node.track_flush_slot = kvmgt_page_track_flush_slot; + vgpu->track_node.track_remove_slot = kvmgt_page_track_remove_slot; kvm_get_kvm(vgpu->vfio_device.kvm); kvm_page_track_register_notifier(vgpu->vfio_device.kvm, &vgpu->track_node); @@ -1617,7 +1617,7 @@ static void kvmgt_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, (void *)val, len); } -static void kvmgt_page_track_flush_slot(struct kvm *kvm, +static void kvmgt_page_track_remove_slot(struct kvm *kvm, struct kvm_memory_slot *slot, struct kvm_page_track_notifier_node *node) { From patchwork Fri Nov 11 09:38:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 18643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp655793wru; Fri, 11 Nov 2022 02:17:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6aM8DqzePn1Dk8q+oQDHQyIeqSAiUGh59KOKvumwmtGbX+KP0cdunVpk1DndrLPKhthpgc X-Received: by 2002:a17:907:c00b:b0:7ad:69eb:923b with SMTP id ss11-20020a170907c00b00b007ad69eb923bmr1409016ejc.19.1668161863760; Fri, 11 Nov 2022 02:17:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668161863; cv=none; d=google.com; s=arc-20160816; b=UTG088fXuc504kgiAy88GgNrui4wD3IcgW/btIEEQ+wukKCZy1dwzg2gKinicHQri1 mEyAZv4f9vSRmGZMG7X1X3PeCNYE57fYQGmjjFjAxlhsk8KIOsQWu5JLtkIy4dKN9BZ+ D4sIN7xhFWhTX3duv1AUJvAJTM2QZDc2q08s4OjLHK7DerReRFCx52a5m+hBSQ+aCxzf lnbE/8LBhO/Od0K6cEJyij58caF8OaaFvHiaH0b8eWVWlSqdz2++9uvxpkYZuvx+G82C +gnT+6neDv76C+oh+NaRnYFJU+OyclVvp5ffkh0+gZ9FzJTbBEV2rO1vmHj4ku1usTWA JMyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ngrsgmXp9dxqr0Yc/f4wzF3+cIWVgWRw92DA9R9UxsQ=; b=YLHgewNlkmrHRzC+IOnpurUCrYqoJHm3AD3lpJ0ix5lBN5/NpDo1FvZsKDNZU3OYRg iDGa+xdCd3p0RQLMWtk2/C1N5HLla0VRQ2teBr3lZi/ukMipgGBZYmRwHyh4pYoPo/3Y ygb1OM5O64oj+PvOrPiMU0j4nNiEyOMtqA5lksTp2xoZMrz0h8sTFzjXm+CFtiB6GNXD qw1nmQpnC+TxyPg/TomvFOzLk6IFudfPjdKqATyWlfu+iT3EDeYx80NK6jjQxiMOixEz FPaQVVO+R5sCaDt48lF4wh0JJjyoDHx5ILyiLLWLvQxL+LMYRORmhcoOb+RGYHM3OtEH xS+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ImYmb5VG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk35-20020a1709077fa300b00783698dd8b4si1621046ejc.722.2022.11.11.02.17.19; Fri, 11 Nov 2022 02:17:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ImYmb5VG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233291AbiKKKBS (ORCPT + 99 others); Fri, 11 Nov 2022 05:01:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233254AbiKKKBQ (ORCPT ); Fri, 11 Nov 2022 05:01:16 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B32B45CD1D; Fri, 11 Nov 2022 02:01:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668160868; x=1699696868; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Oq0v5r5lyxdfiPIBLLI4trHp9sSEgQSGrg182cZ3Cpo=; b=ImYmb5VGJDheRNebzQfZUfnpGQhlvUxgwILw4vSP3zJ9HUUbJS807zfE VDqhrQp3ey8qdGBW2E89RL3bv5cbP5WcBW3UzZzBSIDMp1xHYo9VHVint V9hbDRD5fXlDoc14OSwsjUzxjenTJRe/s9nmDltCJAO2CkRBaU8Sw8kY2 4eiHEuxpFDnOLgQnQ4F5SZA6PeAYwzDLF3aKzap5hayEKSNTaWChewMBD Evn32A23RhATFcGBF0Rl4fD5WvJtsK58wFt3bQu1LE2Ym/A7WRvDhP9TF HqiraiVOQv9Kg1TYAPAde4u/wPX4bxkx9J3kc7zbWSL+P1VybpSfJWZk0 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="397864621" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="397864621" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 02:01:08 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="706497697" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="706497697" Received: from yzhao56-desk.sh.intel.com ([10.238.200.254]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 02:01:06 -0800 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, zhenyuw@linux.intel.com, Yan Zhao Subject: [PATCH 3/3] KVM: x86: Remove the unused page track hook track_flush_slot Date: Fri, 11 Nov 2022 17:38:26 +0800 Message-Id: <20221111093826.3330-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221111093222.3148-1-yan.y.zhao@intel.com> References: <20221111093222.3148-1-yan.y.zhao@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749194494867354456?= X-GMAIL-MSGID: =?utf-8?q?1749194494867354456?= There's no users of hook track_remove_slot any more and no external page tracker user cares about slot flush. So remove this hook. Cc: Zhenyu Wang Suggested-by: Sean Christopherson Signed-off-by: Yan Zhao --- arch/x86/include/asm/kvm_page_track.h | 11 ----------- arch/x86/kvm/mmu/page_track.c | 26 -------------------------- arch/x86/kvm/x86.c | 2 -- 3 files changed, 39 deletions(-) diff --git a/arch/x86/include/asm/kvm_page_track.h b/arch/x86/include/asm/kvm_page_track.h index 046b024d1813..4f1d3c91fdc7 100644 --- a/arch/x86/include/asm/kvm_page_track.h +++ b/arch/x86/include/asm/kvm_page_track.h @@ -34,16 +34,6 @@ struct kvm_page_track_notifier_node { */ void (*track_write)(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, int bytes, struct kvm_page_track_notifier_node *node); - /* - * It is called when memory slot is being moved or removed - * users can drop write-protection for the pages in that memory slot - * - * @kvm: the kvm where memory slot being moved or removed - * @slot: the memory slot being moved or removed - * @node: this node - */ - void (*track_flush_slot)(struct kvm *kvm, struct kvm_memory_slot *slot, - struct kvm_page_track_notifier_node *node); /* * It is called when memory slot is moved or removed * users can drop write-protection for the pages in that memory slot @@ -85,6 +75,5 @@ kvm_page_track_unregister_notifier(struct kvm *kvm, struct kvm_page_track_notifier_node *n); void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, int bytes); -void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot); void kvm_page_track_remove_slot(struct kvm *kvm, struct kvm_memory_slot *slot); #endif diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c index 4d6bab1d61c9..f783aea618f8 100644 --- a/arch/x86/kvm/mmu/page_track.c +++ b/arch/x86/kvm/mmu/page_track.c @@ -275,32 +275,6 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, srcu_read_unlock(&head->track_srcu, idx); } -/* - * Notify the node that memory slot is being removed or moved so that it can - * drop write-protection for the pages in the memory slot. - * - * The node should figure out it has any write-protected pages in this slot - * by itself. - */ -void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot) -{ - struct kvm_page_track_notifier_head *head; - struct kvm_page_track_notifier_node *n; - int idx; - - head = &kvm->arch.track_notifier_head; - - if (hlist_empty(&head->track_notifier_list)) - return; - - idx = srcu_read_lock(&head->track_srcu); - hlist_for_each_entry_srcu(n, &head->track_notifier_list, node, - srcu_read_lock_held(&head->track_srcu)) - if (n->track_flush_slot) - n->track_flush_slot(kvm, slot, n); - srcu_read_unlock(&head->track_srcu, idx); -} - /* * Notify the node that memory slot is removed or moved so that it can * drop write-protection for the pages in the memory slot. diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a24a4a2ad1a0..260288f4d741 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12872,8 +12872,6 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) { kvm_mmu_zap_all_fast(kvm); - - kvm_page_track_flush_slot(kvm, slot); } static inline bool kvm_guest_apic_has_interrupt(struct kvm_vcpu *vcpu)