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 C0331C4332F for ; Mon, 30 Oct 2023 16:53:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 429CB6B0248; Mon, 30 Oct 2023 12:53:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DA126B024A; Mon, 30 Oct 2023 12:53:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27AB46B024F; Mon, 30 Oct 2023 12:53:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 17AB66B0248 for ; Mon, 30 Oct 2023 12:53:59 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E4E0BB5B96 for ; Mon, 30 Oct 2023 16:53:58 +0000 (UTC) X-FDA: 81402724956.27.C487A8A Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf03.hostedemail.com (Postfix) with ESMTP id 0E2FE20011 for ; Mon, 30 Oct 2023 16:53:55 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Aozv6/RK"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of dmatlack@google.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=dmatlack@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698684836; 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=g2Qy05fJV7O/T/e2KrUkQigx6UtJsi8HFmlOQKzP0uU=; b=1ZHIY8NfaWFVNVDUQ81W2minnhlYlONxU12MFK/FOtShiahfMLfPGnMa823xBz1Sc6DGBt PL/kE3HYI3zzw6s4kt7459/bvSVxEUXpphDJFlI3NoyAq+NeVrJNW4yMhMuQ/4nkrrgmGJ sDNfwcJO7Dnqi+meKkV7KZ2MfVNn4Bg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Aozv6/RK"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of dmatlack@google.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=dmatlack@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698684836; a=rsa-sha256; cv=none; b=UKBSripdRYtzaRYMbP5cYKM2rc6defKQBvatsN/AEuMs5kKbcKGnjUiodC2LMlsHwfvra6 E436ZbuesKPooR9VIlxBzuppQQCLLtwMpan8FOKM+7G2W3fdtxSjTGQiwc6vmkX5uBZGJt s2eeCXKXss08cIdxmfy9iqwDi2HPxZE= Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1cc34c3420bso9139395ad.3 for ; Mon, 30 Oct 2023 09:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698684835; x=1699289635; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=g2Qy05fJV7O/T/e2KrUkQigx6UtJsi8HFmlOQKzP0uU=; b=Aozv6/RKZS/XW+TSq1ExjzNvapwhKGuI19nuPNoHksu9A1ZPn76/AW5gT0esxoJesF zCg57e/8JnmzqvsdiIQjL7cxskenStAZ/2BiRROw15ssJtMt0qQ1GtKqCfMipWx9cxep qiIDl1jczOsyg9ohgaldTSYfjr5xN60LCLZTge1JFl7SGM1gl0ClUxedbmYVE4vlvr0z zYVenGOhqamVvEYh0nFHP0zEk3aclwatF4F5gFtrqieLUbK+oKto+1CRsI/HdNF7479t 6pDJsm5GxgQCc/1PTDCnVoM0qpzm3n1W6fyYbnMVZIUKydixlOSs7645PSwAw3SQvx45 ciaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698684835; x=1699289635; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=g2Qy05fJV7O/T/e2KrUkQigx6UtJsi8HFmlOQKzP0uU=; b=McTxkl96HlAKueJLFxh0i2T9l17HM2XTKUTO3wZK7BOvC1OzFlVe3ejSVJe4gBTlV/ t6Z216rB/G7D0LQZED2Y8SUkYkcqiGKJJ2a7dg7dHsinQSd+h0HQ9AJKr77iYYHw4ukI Wel0auq2XOOGiDNH3GYft4xi2Y5H1WpT61XkV4F+hGJnVHFY7EuhYUQaUUy3o8sQmhqN fPWFJQhk5DlbnXC0r7KjfcssU8at3Y0p2+GUIGuLKxRCMnmRq159SUgJmzzPTuoRVbe+ HXVRKzzeD5VrgpbjretNi04uToCgRnJkpqQ2ZflvrIC0dUOPGbTgrxxYP3awiSNkDwNW vfRA== X-Gm-Message-State: AOJu0Yxci/jKL1XgpZhY20FfpNRMF5IGljQiTyAYx2OLk0hB5w/pFyAW TnzBDboPuo1pg27uER5SaN+eRQ== X-Google-Smtp-Source: AGHT+IELyEzMPCZIK1jGGqzZjOjX483WaD7ycdUy6EWhivpECGBZ90269Yo9hhrNGYoSLvPayW0Jww== X-Received: by 2002:a17:902:d581:b0:1cc:32ce:bd9 with SMTP id k1-20020a170902d58100b001cc32ce0bd9mr5679200plh.69.1698684834654; Mon, 30 Oct 2023 09:53:54 -0700 (PDT) Received: from google.com (175.199.125.34.bc.googleusercontent.com. [34.125.199.175]) by smtp.gmail.com with ESMTPSA id c5-20020a170902d90500b001cc32f46757sm4438158plz.107.2023.10.30.09.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 09:53:53 -0700 (PDT) Date: Mon, 30 Oct 2023 09:53:48 -0700 From: David Matlack 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 , Yu Zhang , Isaku Yamahata , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Subject: Re: [PATCH v13 03/35] KVM: Use gfn instead of hva for mmu_notifier_retry Message-ID: References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-4-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231027182217.3615211-4-seanjc@google.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 0E2FE20011 X-Stat-Signature: ec4kdmon8s1fhjmy7ztm5a1wt4uohq14 X-Rspam-User: X-HE-Tag: 1698684835-691492 X-HE-Meta: U2FsdGVkX18gtbzKYdIv2/QKiU7cHQd74S7SDFBpgOqQgwhODpA8IqxETatpu9elhCsNG/kbH7z9RMwSVBKQhvQu6cvIrGhcktyDgIoFkIUZ79rMZf4+8sIeV+sT4LQv49NE99/a4AM/X0BSwk1XfoNlrJyDcGwC9xCW+E+Z/7PgGV9Lc65Ha6iyxA9WiCFqCA57N57PZO4w3phDWmmzvEvo/NkfijRbJymcoKlNNuE74GdqY956jGlkPaFbIc1ZRjGvUKGPmYR2eG9vAVsd2vfsGJ/8idRckJsErjiJYoGD4gIXbPF3/V6g4NNf9W/TtMXSSAhoSKJIsW1YDzrwqJd0l+3jjmI8br33Gluyp03JEqDCX5Mds0vsiCAC7j2Xe4KcWobVPOmTifztqXkFgeGJ2EK/A0tj8FEJCW2DvbGOjysw/PoIzobjyXG16EfjmYJvz543BDaQwo5brUc2B33Gq/2aijv25s5TT+KlspmRSJUfu6TPcHVXpVMOE8yYl+baxQhFA311+5heJQaviMhjU94Mi3FpHROgv09YLDkv7ommed5XsKL4oGMARA0vOgL0pKi8AhLA0xEB+KU9MbI4lyGgCu/eVxQIjfwmS8b1ago4O8nw7R0pmAedeAMKoSPlWN0GFgpIWRbu2mvzXT5Q8sM9/u3v1tYvekJzjyu5xzoBU/Cy1V+EB4PSHulM/VgWPc0ntj+chkHZf+By5NHsxYxS1YDMSgdtM5wBWExx/ud1YV/BtbdIeLY8Gh8IRuo2vKvvhhcCHpEevxgHl4IFYdwh/Jc3/LeLX0zzsiMtWo0O+XB0rkiRI9UqudM/8rcozjaOOuG/t6kJ+AiIHV++7r91W83Htk3zKNOUmF/hpqpJ6M36QTmLa1nU7s8cN9vObr02gfzM0rBv1p0YOBU0Z6CWhw2sCgBk6hcmvk651PQ4hwJjJoAiAUN4B11fFKnLaGq48d+pvJS6Vxv Py8p/NU7 6yNEX962d5fdY6UyTxr3VnVC537ysYRyxr1ce+5woVplQEyOB3zVEFwSEx5uBC8KYafGORv/0k/eQKAwZV6h0al1ZLecP4pqUqzLgO+F226YqRBlay71liqdDiHLhQgWYzmlVc25hY7S1ENOuk+mHzpDRuHH8Gyzhr2zvLDlUnX2BWXU9FaHDhOjcDWPuL3AR+2He5tJYLu169I/LL5e/35Pi/86/JU4qACpI2jb5vAhBeXo/+3RFJQ8DGmC1OuP2FC1oqW7R+vB1AYeJ8fKCiupT4DBs61oyid8m/qIghHQDC295q5RTMTsj+2ixxZrxT6ATbZwfUtS8v1M1+/xDPWy5XBkMbYsh3IDEluHnc7rrFRGTxsrYFXp2/0a2Q2U5C7b8BjPx1YI5K3BInHwOEkRsF8BmD4YF7KyWxMOdhnQABAFaxkVfiES7SIxzwRv6FJH54xZbUaQBjiUlsj7/ig4CI/27jdipG7/Za9JBdl+ISmxHRnTBRbA2G348dmUN9gNMiBUgnrd6PmObJk9v7/RfQQ== 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: List-Subscribe: List-Unsubscribe: On 2023-10-27 11:21 AM, Sean Christopherson wrote: > From: Chao Peng > > Currently in mmu_notifier invalidate path, hva range is recorded and > then checked against by mmu_notifier_retry_hva() in the page fault > handling path. However, for the to be introduced private memory, a page ^^^^^^^^^^^^^^^^^^^^^^^^ Is there a missing word here? > fault may not have a hva associated, checking gfn(gpa) makes more sense. > > For existing hva based shared memory, gfn is expected to also work. The > only downside is when aliasing multiple gfns to a single hva, the > current algorithm of checking multiple ranges could result in a much > larger range being rejected. Such aliasing should be uncommon, so the > impact is expected small. > > Suggested-by: Sean Christopherson > Cc: Xu Yilun > Signed-off-by: Chao Peng > Reviewed-by: Fuad Tabba > Tested-by: Fuad Tabba > [sean: convert vmx_set_apic_access_page_addr() to gfn-based API] > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/mmu/mmu.c | 10 ++++++---- > arch/x86/kvm/vmx/vmx.c | 11 +++++------ > include/linux/kvm_host.h | 33 ++++++++++++++++++++------------ > virt/kvm/kvm_main.c | 41 +++++++++++++++++++++++++++++++--------- > 4 files changed, 64 insertions(+), 31 deletions(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index f7901cb4d2fa..d33657d61d80 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -3056,7 +3056,7 @@ static void direct_pte_prefetch(struct kvm_vcpu *vcpu, u64 *sptep) > * > * There are several ways to safely use this helper: > * > - * - Check mmu_invalidate_retry_hva() after grabbing the mapping level, before > + * - Check mmu_invalidate_retry_gfn() after grabbing the mapping level, before > * consuming it. In this case, mmu_lock doesn't need to be held during the > * lookup, but it does need to be held while checking the MMU notifier. > * > @@ -4358,7 +4358,7 @@ static bool is_page_fault_stale(struct kvm_vcpu *vcpu, > return true; > > return fault->slot && > - mmu_invalidate_retry_hva(vcpu->kvm, fault->mmu_seq, fault->hva); > + mmu_invalidate_retry_gfn(vcpu->kvm, fault->mmu_seq, fault->gfn); > } > > static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) > @@ -6245,7 +6245,9 @@ void kvm_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end) > > write_lock(&kvm->mmu_lock); > > - kvm_mmu_invalidate_begin(kvm, 0, -1ul); > + kvm_mmu_invalidate_begin(kvm); > + > + kvm_mmu_invalidate_range_add(kvm, gfn_start, gfn_end); > > flush = kvm_rmap_zap_gfn_range(kvm, gfn_start, gfn_end); > > @@ -6255,7 +6257,7 @@ void kvm_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end) > if (flush) > kvm_flush_remote_tlbs_range(kvm, gfn_start, gfn_end - gfn_start); > > - kvm_mmu_invalidate_end(kvm, 0, -1ul); > + kvm_mmu_invalidate_end(kvm); > > write_unlock(&kvm->mmu_lock); > } > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 72e3943f3693..6e502ba93141 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -6757,10 +6757,10 @@ static void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu) > return; > > /* > - * Grab the memslot so that the hva lookup for the mmu_notifier retry > - * is guaranteed to use the same memslot as the pfn lookup, i.e. rely > - * on the pfn lookup's validation of the memslot to ensure a valid hva > - * is used for the retry check. > + * Explicitly grab the memslot using KVM's internal slot ID to ensure > + * KVM doesn't unintentionally grab a userspace memslot. It _should_ > + * be impossible for userspace to create a memslot for the APIC when > + * APICv is enabled, but paranoia won't hurt in this case. > */ > slot = id_to_memslot(slots, APIC_ACCESS_PAGE_PRIVATE_MEMSLOT); > if (!slot || slot->flags & KVM_MEMSLOT_INVALID) > @@ -6785,8 +6785,7 @@ static void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu) > return; > > read_lock(&vcpu->kvm->mmu_lock); > - if (mmu_invalidate_retry_hva(kvm, mmu_seq, > - gfn_to_hva_memslot(slot, gfn))) { > + if (mmu_invalidate_retry_gfn(kvm, mmu_seq, gfn)) { > kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu); > read_unlock(&vcpu->kvm->mmu_lock); > goto out; > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index fb6c6109fdca..11d091688346 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -787,8 +787,8 @@ struct kvm { > struct mmu_notifier mmu_notifier; > unsigned long mmu_invalidate_seq; > long mmu_invalidate_in_progress; > - unsigned long mmu_invalidate_range_start; > - unsigned long mmu_invalidate_range_end; > + gfn_t mmu_invalidate_range_start; > + gfn_t mmu_invalidate_range_end; > #endif > struct list_head devices; > u64 manual_dirty_log_protect; > @@ -1392,10 +1392,9 @@ void kvm_mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc); > void *kvm_mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc); > #endif > > -void kvm_mmu_invalidate_begin(struct kvm *kvm, unsigned long start, > - unsigned long end); > -void kvm_mmu_invalidate_end(struct kvm *kvm, unsigned long start, > - unsigned long end); > +void kvm_mmu_invalidate_begin(struct kvm *kvm); > +void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t end); What is the reason to separate range_add() from begin()? > +void kvm_mmu_invalidate_end(struct kvm *kvm); > > long kvm_arch_dev_ioctl(struct file *filp, > unsigned int ioctl, unsigned long arg); > @@ -1970,9 +1969,9 @@ static inline int mmu_invalidate_retry(struct kvm *kvm, unsigned long mmu_seq) > return 0; > } > > -static inline int mmu_invalidate_retry_hva(struct kvm *kvm, > +static inline int mmu_invalidate_retry_gfn(struct kvm *kvm, > unsigned long mmu_seq, > - unsigned long hva) > + gfn_t gfn) > { > lockdep_assert_held(&kvm->mmu_lock); > /* > @@ -1981,10 +1980,20 @@ static inline int mmu_invalidate_retry_hva(struct kvm *kvm, > * that might be being invalidated. Note that it may include some false > * positives, due to shortcuts when handing concurrent invalidations. > */ > - if (unlikely(kvm->mmu_invalidate_in_progress) && > - hva >= kvm->mmu_invalidate_range_start && > - hva < kvm->mmu_invalidate_range_end) > - return 1; > + if (unlikely(kvm->mmu_invalidate_in_progress)) { > + /* > + * Dropping mmu_lock after bumping mmu_invalidate_in_progress > + * but before updating the range is a KVM bug. > + */ > + if (WARN_ON_ONCE(kvm->mmu_invalidate_range_start == INVALID_GPA || > + kvm->mmu_invalidate_range_end == INVALID_GPA)) > + return 1; > + > + if (gfn >= kvm->mmu_invalidate_range_start && > + gfn < kvm->mmu_invalidate_range_end) > + return 1; > + } > + > if (kvm->mmu_invalidate_seq != mmu_seq) > return 1; > return 0; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 5a97e6c7d9c2..1a577a25de47 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -543,9 +543,7 @@ static inline struct kvm *mmu_notifier_to_kvm(struct mmu_notifier *mn) > > typedef bool (*gfn_handler_t)(struct kvm *kvm, struct kvm_gfn_range *range); > > -typedef void (*on_lock_fn_t)(struct kvm *kvm, unsigned long start, > - unsigned long end); > - > +typedef void (*on_lock_fn_t)(struct kvm *kvm); > typedef void (*on_unlock_fn_t)(struct kvm *kvm); > > struct kvm_mmu_notifier_range { > @@ -637,7 +635,8 @@ static __always_inline int __kvm_handle_hva_range(struct kvm *kvm, > locked = true; > KVM_MMU_LOCK(kvm); > if (!IS_KVM_NULL_FN(range->on_lock)) > - range->on_lock(kvm, range->start, range->end); > + range->on_lock(kvm); > + > if (IS_KVM_NULL_FN(range->handler)) > break; > } > @@ -742,16 +741,29 @@ static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn, > kvm_handle_hva_range(mn, address, address + 1, arg, kvm_change_spte_gfn); > } > > -void kvm_mmu_invalidate_begin(struct kvm *kvm, unsigned long start, > - unsigned long end) > +void kvm_mmu_invalidate_begin(struct kvm *kvm) > { > + lockdep_assert_held_write(&kvm->mmu_lock); > /* > * The count increase must become visible at unlock time as no > * spte can be established without taking the mmu_lock and > * count is also read inside the mmu_lock critical section. > */ > kvm->mmu_invalidate_in_progress++; > + > if (likely(kvm->mmu_invalidate_in_progress == 1)) { > + kvm->mmu_invalidate_range_start = INVALID_GPA; > + kvm->mmu_invalidate_range_end = INVALID_GPA; I don't think this is incorrect, but I was a little suprised to see this here rather than in end() when mmu_invalidate_in_progress decrements to 0. > + } > +} > + > +void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t end) > +{ > + lockdep_assert_held_write(&kvm->mmu_lock); Does this compile/function on KVM architectures with !KVM_HAVE_MMU_RWLOCK? I assumed we would get an email from the buildbot if it didn't compile but I don't know if buildbot builds with lockdep enabled. On this topic, I wonder if we should just bit the bullet and convert all architectures to a rwlock_t. > + > + WARN_ON_ONCE(!kvm->mmu_invalidate_in_progress); > + > + if (likely(kvm->mmu_invalidate_range_start == INVALID_GPA)) { > kvm->mmu_invalidate_range_start = start; > kvm->mmu_invalidate_range_end = end; > } else { > @@ -771,6 +783,12 @@ void kvm_mmu_invalidate_begin(struct kvm *kvm, unsigned long start, > } > } > > +static bool kvm_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range) > +{ > + kvm_mmu_invalidate_range_add(kvm, range->start, range->end); > + return kvm_unmap_gfn_range(kvm, range); > +} > + > static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, > const struct mmu_notifier_range *range) > { > @@ -778,7 +796,7 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, > const struct kvm_mmu_notifier_range hva_range = { > .start = range->start, > .end = range->end, > - .handler = kvm_unmap_gfn_range, > + .handler = kvm_mmu_unmap_gfn_range, > .on_lock = kvm_mmu_invalidate_begin, > .on_unlock = kvm_arch_guest_memory_reclaimed, > .flush_on_ret = true, > @@ -817,8 +835,7 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, > return 0; > } > > -void kvm_mmu_invalidate_end(struct kvm *kvm, unsigned long start, > - unsigned long end) > +void kvm_mmu_invalidate_end(struct kvm *kvm) > { > /* > * This sequence increase will notify the kvm page fault that > @@ -834,6 +851,12 @@ void kvm_mmu_invalidate_end(struct kvm *kvm, unsigned long start, Let's add a lockdep_assert_held_write(&kvm->mmu_lock) here too while we're at it? > */ > kvm->mmu_invalidate_in_progress--; > KVM_BUG_ON(kvm->mmu_invalidate_in_progress < 0, kvm); > + > + /* > + * Assert that at least one range was added between start() and end(). > + * Not adding a range isn't fatal, but it is a KVM bug. > + */ > + WARN_ON_ONCE(kvm->mmu_invalidate_range_start == INVALID_GPA); > } > > static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn, > -- > 2.42.0.820.g83a721a137-goog >