From patchwork Mon Jul 10 09:49:26 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: 701006 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5079154wrs; Mon, 10 Jul 2023 02:50:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlE+D4OlKw/IWYupLtqrGi/ThOxPBo+9G9cE83sDJDxZObDDR7UP4T9ulb9l2j4SUY8BQQJW X-Received: by 2002:a05:620a:2450:b0:767:4cb2:3145 with SMTP id h16-20020a05620a245000b007674cb23145mr17825908qkn.41.1688982652305; Mon, 10 Jul 2023 02:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688982652; cv=none; d=google.com; s=arc-20160816; b=wfVUSZ/p7f5LKb3iY1kilU02weUZjBhFCRc36i33rLuKAIBG6WYE2FDpISqpQoZ0ou t9SHKRldREHkz59vs/FV/6leRthnO0WX4oY0gZOL79BQq8DmlVIaAd7tCjNhz+Dwv39v ZBkZBXRfj42uOZFYohqKUs0WBIVPNfVuO6dlhrWFJ4kJVRfAd+SkLbMNEF5PoPgmKe9w peWCrkD7pN1o+9Ot0KQfUfa17md9NeqJmd+u9uyyG/DYjkkAfo9w8MjU3cjKe6HDD4eD LCXwagXH6lsol0Ev+q8Ikf9YyvullPtlGJQmmodvf1mlgoIogmqIXupTU7XcRxXj6nwi rraw== 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=ufBOjc9SeZsogN9rwEOZ+B47n6rE09TymenxbvkIAQo=; fh=FilpW137HyWOg2zjOJR+HkXqOM9xEmodh7UtIP57FfE=; b=glGKRG319MuliTV0kGAED4fnsX9cvLrRD+LGc4Q6v5Kf3oROrLuVNvhyYIpXNERkNz j4nbYwoPQo16b69MrgsWXDY9kaCH/JlngG5DChOUahsz6O2ipXssu5Ry0Yt6CEuXTaWp duGBtuB24OPrvGRJKfAlTPQb2VuGo6Y5Mv5N2L2e5dG+6Uke9+IhtfJVeAWi40SHZHLP ypikpuddS8pEI/2UHJr0vv0mGxPd0IWTB0T9Se51I3T1s6Nb0HxlYFR5IVihNahPWUpt 9JgNxHsPSaynXnXSsdd7jVfRDAu+VkuigfHNDZ5Yz5tM7Sj51U+WNEuNGYKNUVaw9vWk VjHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=if41VYgY; 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 v17-20020a05620a123100b0076719f3f70dsi5406110qkj.165.2023.07.10.02.50.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 02:50:52 -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=if41VYgY; 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 1qInXJ-00023P-Tb; Mon, 10 Jul 2023 05:50:29 -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 1qInXB-00022D-SY for qemu-devel@nongnu.org; Mon, 10 Jul 2023 05:50:22 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qInXA-0003pF-6l for qemu-devel@nongnu.org; Mon, 10 Jul 2023 05:50:21 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31441dfbf97so4898556f8f.1 for ; Mon, 10 Jul 2023 02:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688982618; x=1691574618; 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=ufBOjc9SeZsogN9rwEOZ+B47n6rE09TymenxbvkIAQo=; b=if41VYgY9HRpi/UF+rX9jd2ntN8W88hbcyzYqEqrd0BgWJhl+aCqQLaEyGJbERWNBn PWnZU5cT8MKWutksHQ/gtGFPJGfTKVs6IquodXklRBm8aXAGAjJP7ZCcqp4bXtrEJ7fK pqn0qaLbZYtxECfZl3PH9ktSvbmSUIi+vABPyoiq8nWlcNg1B5VcjzREiufcLfnlT3F0 CyPOX+XNXIGuUfsb9E2dh9dnYLYCpA3mlQU6E7S9G9ZeVd/TQHQvSSeeEmpb4XJ3o5eV 1aZKbNsGho/wFxdnipUhkftjRrMl87xwPnP60ytPIPFjbQYZY8fqsW/DAYtVO76Q3Snu pasw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688982618; x=1691574618; 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=ufBOjc9SeZsogN9rwEOZ+B47n6rE09TymenxbvkIAQo=; b=epEKhhpmt6y+P/1q5aATV/rsi6I2LpNlL0HmQ46DhhX4ZQnYuLcuIiOpCRRsQt/Jsb ZZw3AtkNPLqh66MdUrnfWAXoGeslO+I7KLSqY0gbWfRNBBMbptFzuZswCLrjIXDV7zaz JDDACAFxttQd1fIplsvoQ9mlR/XNYWFxVSP0EhLXCbECNAp0pTZw+kUeyFxs2ApPobnp uLk7rPokbnRnMeCM5tmanMNvsn087DhJYUZuxL/lXfQBwGEnAYsMrN9DDyLSjRWVjioM kbtcuW/BJ7KUPBWb2crNCU0gH2XPHt3JrI/Un5s0pH0tKWbTkVYzw+1WHO2FgN9dMsnO RZ7Q== X-Gm-Message-State: ABy/qLaPBbRkqRChTJ3YSjud3F8qENrs6b3huU4OYYZkzkZyEp+SzOqH 0an5ywuzCP90QA2K+k39Vy2RuEPcOJcwh7rypqWjqw== X-Received: by 2002:a5d:49cb:0:b0:313:ef24:6feb with SMTP id t11-20020a5d49cb000000b00313ef246febmr12334865wrs.3.1688982618115; Mon, 10 Jul 2023 02:50:18 -0700 (PDT) Received: from localhost.localdomain (70.red-88-28-30.dynamicip.rima-tde.net. [88.28.30.70]) by smtp.gmail.com with ESMTPSA id k6-20020a05600c0b4600b003fc00892c13sm8617369wmr.35.2023.07.10.02.50.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 02:50:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 1/6] hw/virtio: Propagate page_mask to vhost_vdpa_listener_skipped_section() Date: Mon, 10 Jul 2023 11:49:26 +0200 Message-Id: <20230710094931.84402-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710094931.84402-1-philmd@linaro.org> References: <20230710094931.84402-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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_MASK. 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)) {