From patchwork Fri Jul 7 15:17:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 700031 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp3929284wrs; Fri, 7 Jul 2023 08:18:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEn73AK0+8Jj3sB3ki8/9J7+7lI08XWsCbiCKTGloAcwUrfIV/mEbtSmY0c0k5+PsNtCXjP X-Received: by 2002:a05:620a:2485:b0:767:2412:f269 with SMTP id i5-20020a05620a248500b007672412f269mr5934168qkn.61.1688743124674; Fri, 07 Jul 2023 08:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688743124; cv=none; d=google.com; s=arc-20160816; b=NNH2Pxd9TjAW+Lf7eKymQ7GtgQgMT/+bZNW8seEbs4g8sTL+XZH845zwItQZ3k24uh cMYy4p2X+phXq0Q9QiAxCRPsTK00aNbpB0AGkJO58A7nYthxHjvyMmtS8rkd9KqdvVGh 5qYfpVsGFWOK5BYqOV5biWP8kQi885HEN7bGqqOUzCcMjn0e/MyHikFTzCuIL+hpS/wx wL9hiuPNw+1DhYpS3wZz9Ba9EF1CwXNWoh9kpqtR/PXJaw2QGqoXGOBRmKsuRYSEC4M0 z/Z5CrSKLMavRKkEwIZUiZfF32WUBHbYjO3nDZz+VCJO7jV+Xo6LzMwW9/RD+VVCTBwA +rWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tEOl601lp/glMFLXL/Pb6sc13gALwOrVo4hgtvYuZtU=; fh=aRxBrgA7CrSouwdXoZUw1AmyeDG9xQchBaflhNgNTHQ=; b=RcbNBsaPOQcAWOASXHZeQoEB1ceVHhzJ6ycaTHYeSosdVzzUV0h/NgNZx9hj31EKmA gNRWyJ6RSfPs9tQ05Y/3bgQTaAK+TNJrqn7eitkYe982EFjy6pAjdGk17gu+zNfRWKA0 C3IPInnZzyme3ctVMAOWUkm8CkmeE3Bp9GDPWJMz8v+GKVnd2CAM5X8Hb+HYjgB3IB7E lxyy2NcVlAsZ8JWqwm3lcPmE3OR72MrEBHMeIDaUNnrYThKGvdLcPoBeaIeeopoJRr4u 26srJUUZgp0tIGgEEhs6Lmpt2yM2eRxcnuQpPDrhfr5R214wClwpuc+BScllVDMJl9ok R3dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kll5WQn6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u6-20020a05620a454600b00767bad28805si48915qkp.667.2023.07.07.08.18.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jul 2023 08:18:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kll5WQn6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHnDF-0000wh-QJ; Fri, 07 Jul 2023 11:17:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHnDD-0000vW-DB for qemu-devel@nongnu.org; Fri, 07 Jul 2023 11:17:35 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHnDA-0000cp-UW for qemu-devel@nongnu.org; Fri, 07 Jul 2023 11:17:34 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-98377c5d53eso250651466b.0 for ; Fri, 07 Jul 2023 08:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688743049; x=1691335049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tEOl601lp/glMFLXL/Pb6sc13gALwOrVo4hgtvYuZtU=; b=Kll5WQn67GmCtCbgfLbz0kZBHaf3DtxlBXW26nBe5Yjus3MKNiDMnx8CBTJwTz1XVi MkjlFtpS+4WOLEXopN/+krO56C/G+3TG6Kf8KY5yK9IU0Q7FQrA1Su/7dMZSpNpfTbIL oFyqjh8H+KbZLKRyVNIHmu3N0m8dKMsd+ZmpqaIoOYKCeOQGoSMgo0DgGDvENd9qfXT/ yQaPHAo19xXg8nQdQCrEPIbFvMlKJVChBeaGLdISqg283RHnIH1njEC9H7/Tl1mGSqr2 8pLqTXWHrc5i08/95Ne2dmYEn2t+kAallPfQIKf4sKPwBoxjp+k2Ax5vECrZovyjQ0PZ bS3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688743049; x=1691335049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tEOl601lp/glMFLXL/Pb6sc13gALwOrVo4hgtvYuZtU=; b=SB5Brh5YPyzi1TpUuU80VNqUhwzPc2kRG6fsFd8tnX0ItwsGxi/zcKgW3WM/bEkj2o AZXbRCD5ulo3Vcts0Keso+RooWHz6I7nF13x3+3laaMspEXXH5Lp+uXRsuHiEEnUyzAh 3Q//xrgsmx8G5EixabnOZTpNCrO7FfmzQVFi6BARJ59KxgIz9Hx9y0TjQZySLgiIIFNz LIxi+DdyEoZJ654uoerWXUTaHqsJFnKLOBSl2s6C1qxUXFAyb0ezfZnh6IPW9HYtP0Kl IzuWNjBlaUPXGeJjpGGNBdznuen8mLHVDNE3IZaBsXLtCcYB98swFHtKODKfeWoW7Eit gsAg== X-Gm-Message-State: ABy/qLaJWPusGbFSQhYkHKo9+8RhSjleON3xF7v9s5gU0Xsk1u+a68GO XM/khgSzKtowdKi+00tlMYlqAMoH0eM+yj4pnwc= X-Received: by 2002:a17:906:57da:b0:98f:ab82:8893 with SMTP id u26-20020a17090657da00b0098fab828893mr3762991ejr.73.1688743049834; Fri, 07 Jul 2023 08:17:29 -0700 (PDT) Received: from m1x-phil.lan ([176.187.215.192]) by smtp.gmail.com with ESMTPSA id t3-20020a170906268300b0098e42bef736sm2322459ejc.176.2023.07.07.08.17.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 07 Jul 2023 08:17:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , "Michael S. Tsirkin" , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/6] hw/virtio: Propagate page_mask to vhost_vdpa_listener_skipped_section() Date: Fri, 7 Jul 2023 17:17:14 +0200 Message-Id: <20230707151719.70613-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230707151719.70613-1-philmd@linaro.org> References: <20230707151719.70613-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=philmd@linaro.org; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to make vhost-vdpa.c a target-agnostic source unit, we need to remove the TARGET_PAGE_SIZE / TARGET_PAGE_MASK / TARGET_PAGE_ALIGN uses. TARGET_PAGE_SIZE will be replaced by the runtime qemu_target_page_size(). The other ones will be deduced from TARGET_PAGE_SIZE. Since the 3 macros are used in 3 related functions (sharing the same call tree), we'll refactor them to only depend on TARGET_PAGE_SIZE. Having the following call tree: vhost_vdpa_listener_region_del() -> vhost_vdpa_listener_skipped_section() -> vhost_vdpa_section_end() The first step is to propagate TARGET_PAGE_MASK to vhost_vdpa_listener_skipped_section(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/virtio/vhost-vdpa.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 3c575a9a6e..87653bf841 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -42,7 +42,8 @@ static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section) static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section, uint64_t iova_min, - uint64_t iova_max) + uint64_t iova_max, + int page_mask) { Int128 llend; @@ -313,7 +314,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, int ret; if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first, - v->iova_range.last)) { + v->iova_range.last, TARGET_PAGE_MASK)) { return; } if (memory_region_is_iommu(section->mr)) { @@ -396,7 +397,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, int ret; if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first, - v->iova_range.last)) { + v->iova_range.last, TARGET_PAGE_MASK)) { return; } if (memory_region_is_iommu(section->mr)) {