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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4580AC433F5 for ; Sun, 22 May 2022 10:22:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E06D10E147; Sun, 22 May 2022 10:22:29 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 27E4210E355 for ; Sun, 22 May 2022 10:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653214947; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MgC5JNYrsgqgs2qTUiLYfjxLufYrNUR4cj0BHzuGBF0=; b=NO/wVBfoEq/wzcGI612y3hJmdg8hcWaAvcMEimVinsezXr0nAGM2TSu0DUOMpmM/hIdUbg JH62sp0WTi01lDE181s1RqBOsWnk1ixHyH9S+fAIj2SODv4XZ67JRTtVQ3YT00mzAbmjMy yBtIB+vBJQU2X1KphkDsI0ZFjzrF81I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-UAk-XDoQNkam0zGc1orlpg-1; Sun, 22 May 2022 06:22:22 -0400 X-MC-Unique: UAk-XDoQNkam0zGc1orlpg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9CE8C185A79C; Sun, 22 May 2022 10:22:21 +0000 (UTC) Received: from starship (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12FEE7C2A; Sun, 22 May 2022 10:22:15 +0000 (UTC) Message-ID: <71290b6ab1a269b518214721fd233b03440ff636.camel@redhat.com> Subject: Re: [RFC PATCH v3 06/19] KVM: x86: mmu: add gfn_in_memslot helper From: Maxim Levitsky To: Sean Christopherson Date: Sun, 22 May 2022 13:22:14 +0300 In-Reply-To: References: <20220427200314.276673-1-mlevitsk@redhat.com> <20220427200314.276673-7-mlevitsk@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , kvm@vger.kernel.org, David Airlie , Dave Hansen , dri-devel@lists.freedesktop.org, "H. Peter Anvin" , Brijesh Singh , Joerg Roedel , x86@kernel.org, Ingo Molnar , Zhi Wang , Tom Lendacky , intel-gfx@lists.freedesktop.org, Borislav Petkov , Rodrigo Vivi , Thomas Gleixner , intel-gvt-dev@lists.freedesktop.org, Jim Mattson , Tvrtko Ursulin , linux-kernel@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, 2022-05-19 at 16:43 +0000, Sean Christopherson wrote: > On Wed, Apr 27, 2022, Maxim Levitsky wrote: > > This is a tiny refactoring, and can be useful to check > > if a GPA/GFN is within a memslot a bit more cleanly. > > This doesn't explain the actual motivation, which is to use the new helper from > arch code. I'll add this in the next version > > > Signed-off-by: Maxim Levitsky > > --- > > include/linux/kvm_host.h | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > index 252ee4a61b58b..12e261559070b 100644 > > --- a/include/linux/kvm_host.h > > +++ b/include/linux/kvm_host.h > > @@ -1580,6 +1580,13 @@ int kvm_request_irq_source_id(struct kvm *kvm); > > void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); > > bool kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args); > > > > + > > +static inline bool gfn_in_memslot(struct kvm_memory_slot *slot, gfn_t gfn) > > +{ > > + return (gfn >= slot->base_gfn && gfn < slot->base_gfn + slot->npages); > > +} > > + > > Spurious newline. > > > + > > /* > > * Returns a pointer to the memslot if it contains gfn. > > * Otherwise returns NULL. > > @@ -1590,12 +1597,13 @@ try_get_memslot(struct kvm_memory_slot *slot, gfn_t gfn) > > if (!slot) > > return NULL; > > > > - if (gfn >= slot->base_gfn && gfn < slot->base_gfn + slot->npages) > > + if (gfn_in_memslot(slot, gfn)) > > return slot; > > else > > return NULL; > > At this point, maybe: No objections. Thanks for the review. Best regards, Maxim Levitsky > > if (!slot || !gfn_in_memslot(slot, gfn)) > return NULL; > > return slot; > > > } > > > > + > > /* > > * Returns a pointer to the memslot that contains gfn. Otherwise returns NULL. > > * > > -- > > 2.26.3 > >