From nobody Mon Feb 9 19:53:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634726122275134.40819570750966; Wed, 20 Oct 2021 03:35:22 -0700 (PDT) Received: from localhost ([::1]:41964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1md8wL-0006up-9y for importer@patchew.org; Wed, 20 Oct 2021 06:35:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1md8hb-0004NB-Qe for qemu-devel@nongnu.org; Wed, 20 Oct 2021 06:20:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1md8ha-0003E3-7i for qemu-devel@nongnu.org; Wed, 20 Oct 2021 06:20:07 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-1kR-ezE0N--TatzENKUUKA-1; Wed, 20 Oct 2021 06:20:04 -0400 Received: by mail-ed1-f70.google.com with SMTP id t18-20020a056402021200b003db9e6b0e57so20535284edv.10 for ; Wed, 20 Oct 2021 03:20:04 -0700 (PDT) Received: from redhat.com ([2.55.24.172]) by smtp.gmail.com with ESMTPSA id m3sm1016985edc.11.2021.10.20.03.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 03:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634725205; 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=QiJ0iHIZ1ouAmADpp/YMcXYNacyY5H2Zjhw9Phv+fQ0=; b=D8GK+p2qvR0jnLnCcZnpDA5ApGHcnlpxP0vyVL1GZPXwrZAQAEg7x8PKBxHE97+XIQ1vw6 KLHzHY33+CXSwb5iKyVBwKJ+Gi53+gps/65FOi7l3rRsi4C5Op2KKq47s0MbTkKZdFgyVx 9XQ/hWRrbecLbJog9tVvblH/frGR7/4= X-MC-Unique: 1kR-ezE0N--TatzENKUUKA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=QiJ0iHIZ1ouAmADpp/YMcXYNacyY5H2Zjhw9Phv+fQ0=; b=KczwBhhi4Pa/hKcPxM4cqLh3iMzQE2Otxc3IN5hm7GZRuCGMcdnqoAaLvUYRsvP0ZI VU90rTuAX2ITG1KsaXBRAq+VfKunR6AXmzASVMfTDycObT6poYl365h4X0D4oSgrOro2 ekY6FWYV5WYV6UzmmCHs/nv0C2y3dnwBW7zpk7ljU6kFOD5u1XvqtSMoJQIkGTCcrAob 9TvzbKl/bazra54PsUGE36CRA0bot64u6eK/Xzq6WTV6RRsVJlyWM9gpkUVbyTZJMNWl +QEXaZ1F9p/BGjUk6LcR5w6gGzW7WqtUv5yaeOhiVUPrph+YXriguG8GBYdiEaVXuKqi 0bQw== X-Gm-Message-State: AOAM5314zv+Jg/bvCQ1G0fChPqNIawwGKDclBpp7e0lPxt4sJPoKxis4 0DP1MaQ2WpnrnmG7sD4u3zAf4CKKXmKNt0LFEHJ8NHW/rLSWrIGIVBvJmtkT4Y91nLmEXhPEc+L s4HzDv8sCNYg5WX585cDLSFEXWqEn36vkKfPLTzsg222YjsQJ8PDhBqAcEaqF X-Received: by 2002:a05:6402:1c94:: with SMTP id cy20mr61495767edb.144.1634725202930; Wed, 20 Oct 2021 03:20:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKpCrjtT++ML6oQXSfAq1NLBKAjhAt/Oe8FxM7FsLfcYarOzBRcEFDOCoHmpk2O3suYsWkaA== X-Received: by 2002:a05:6402:1c94:: with SMTP id cy20mr61495740edb.144.1634725202757; Wed, 20 Oct 2021 03:20:02 -0700 (PDT) Date: Wed, 20 Oct 2021 06:19:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 17/44] vdpa: Add vhost_vdpa_section_end Message-ID: <20211020101844.988480-18-mst@redhat.com> References: <20211020101844.988480-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211020101844.988480-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Stefano Garzarella , Eugenio =?utf-8?B?UMOpcmV6?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634726122692100001 From: Eugenio P=C3=A9rez Abstract this operation, that will be reused when validating the region against the iova range that the device supports. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Message-Id: <20211014141236.923287-3-eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella --- hw/virtio/vhost-vdpa.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index ea1aa71ad8..be7c63b4ba 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -24,6 +24,19 @@ #include "trace.h" #include "qemu-common.h" =20 +/* + * Return one past the end of the end of section. Be careful with uint64_t + * conversions! + */ +static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section) +{ + Int128 llend =3D int128_make64(section->offset_within_address_space); + llend =3D int128_add(llend, section->size); + llend =3D int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); + + return llend; +} + static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *secti= on) { return (!memory_region_is_ram(section->mr) && @@ -160,10 +173,7 @@ static void vhost_vdpa_listener_region_add(MemoryListe= ner *listener, } =20 iova =3D TARGET_PAGE_ALIGN(section->offset_within_address_space); - llend =3D int128_make64(section->offset_within_address_space); - llend =3D int128_add(llend, section->size); - llend =3D int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); - + llend =3D vhost_vdpa_section_end(section); if (int128_ge(int128_make64(iova), llend)) { return; } @@ -221,9 +231,7 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, } =20 iova =3D TARGET_PAGE_ALIGN(section->offset_within_address_space); - llend =3D int128_make64(section->offset_within_address_space); - llend =3D int128_add(llend, section->size); - llend =3D int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); + llend =3D vhost_vdpa_section_end(section); =20 trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(llend)); =20 --=20 MST