From patchwork Thu Oct 5 03:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 729693 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp677607wrs; Wed, 4 Oct 2023 20:43:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOCKi21fklVMTGfXiT+WC2DX7Wk3dYmrqCMKjYFkgrsqBOM8RW3mOgc2rQlWqVbefqgNLL X-Received: by 2002:a0c:ae91:0:b0:658:9c61:4407 with SMTP id j17-20020a0cae91000000b006589c614407mr3845121qvd.63.1696477390187; Wed, 04 Oct 2023 20:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696477390; cv=none; d=google.com; s=arc-20160816; b=eT6gau8jenUuJhL3RCkD/6gYhnd9MiQsE3ascnZPX8Eqr5w1hPE1Flc8KYSgXaDQZf 6PQYthc65LwtIOg14Ujgs33X2m6K/IMm1aB+JVau5pqXnqFBIsN7umk1kkf2eAk4yXGR MmmH8fjxYsw75ztKk7w/B9yA0A/BO0e6Ado6qPgUBwtX18tAY/8bynhz5KTfQrVd4GnR jljXfEoXnme1/rgig/Zlj07FFtEVhJAB5h8R+SV2ECkC//zJQ6owujCdR7ElKJ+QmhUN sVM+Gx2bUjNX7GL0+lyOEa0lMYdy1waau4J8Dq1vdb+FojY9tfbIs29MhQmPTNG/Hupd xHqA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=W0fAAn8UFyb8KBtfxAsFqqpol8c8vZQYpO/ekzLxr6g=; fh=zhzFgY8F88gmLqhr0Gjm2ulsyPFhXBed6tbGp+K0bf4=; b=ARTc42EOYhOW7pt6CytUHhYDzS/l+2BByfELx4ynK1nW/QvuG9jYgjd8Ca3Mqs94ad ojz7s0YW2KXkewekGqLVbvySh8+GOhz3x9/p5rAEJDeqBUIHK0UZ+WVjaZ45s1p2Bd7u rDfayR9syECUg4moLxAWdGtneGcbdfKM0tgEgzu0fhMbd8AjY62DftCHsM0Us11S7HlQ 0vc+gvyyiXR0EKam6Yd0BbQ4N75ILl/gWrQAJmVIf3ZNhI2UNRaOiaVfXyUJ/pgq76cd xMOJWAdB7n4JFvCwOuDMN2XwfWxj+w5nkeoGPWNXbxN8CZyKp4cUp1lEZnYpzqk9fn6K bghw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JWXR5qL4; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x3-20020a0ce0c3000000b0065d07d589bdsi317265qvk.382.2023.10.04.20.43.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 20:43:10 -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=@redhat.com header.s=mimecast20190719 header.b=JWXR5qL4; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoFG2-0001AE-RI; Wed, 04 Oct 2023 23:42:38 -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 1qoFG1-0001A5-Gs for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoFG0-0007xF-0Z for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477355; 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=W0fAAn8UFyb8KBtfxAsFqqpol8c8vZQYpO/ekzLxr6g=; b=JWXR5qL4UWo7BZTOvmocW8YzgwkBEenZbYRhpiPpr2MZZVVeDdSDjx/yFs6GCPkzUz094c qJATvfhcHjBoxo4PDdBF7TZtMn65bgpYL65TjXzETJrLPDhVSLI90jWsYo9i+CZzPiVp/d g+4Ybf2CVLgfSxeq9B56GDSzj0zC2Xs= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-534-Hkojnh9GNYKQkDE35m5k2Q-1; Wed, 04 Oct 2023 23:42:33 -0400 X-MC-Unique: Hkojnh9GNYKQkDE35m5k2Q-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-32588c87716so430461f8f.1 for ; Wed, 04 Oct 2023 20:42:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477351; x=1697082151; h=in-reply-to:content-transfer-encoding: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=W0fAAn8UFyb8KBtfxAsFqqpol8c8vZQYpO/ekzLxr6g=; b=CMFWN5RlBmOwU6XqCPOLSzofybEsS6Ge6Of6nUkXrvKurDLYN0rOUbB3qxVkdErM2P gU2zJuuz5njbkJa0IoyaQBkGgLKyRro82HvrbwiMN8OBHZxFssqZwu+VQ/3xpAihOKH+ LWSaIK4f9YU56aJA2V/AV3P5HXQMbywxZ/iyUSRrIc069JsQpkq1GSb3Z7xaSCyvFLdX IAdje/kEwVQQTooC0n9KbUSzZG9hdsi69pFZM5Dn2kjUNFkU9IigJh7a2O4wZ3KhP2UT F1nIkP/5GJ5mQhYL/501iPRcX5d6A/WfpONP263ZVak2MUv5WDMMixRRikDrwP2TqOp8 mjDw== X-Gm-Message-State: AOJu0YwNxZNjcdwdOkklWpGdfDVFbwgoG0DjfjQoc5QblIz67N6RKO2q tM9u3lX6Cn5AsgObawZNLGGwlDC9p63njLmRoaw7cX31+iHRoLRFZE67QyUqfGL1o++FSJAR8EV Ov9SNBMwq/oc/13TJAkQ1u5gvIDR1+QEgdY83UwZH38MHVuO1AgP8kk8rRlt+WEkcmXiY X-Received: by 2002:adf:f546:0:b0:317:634c:46e9 with SMTP id j6-20020adff546000000b00317634c46e9mr3908353wrp.43.1696477351812; Wed, 04 Oct 2023 20:42:31 -0700 (PDT) X-Received: by 2002:adf:f546:0:b0:317:634c:46e9 with SMTP id j6-20020adff546000000b00317634c46e9mr3908343wrp.43.1696477351504; Wed, 04 Oct 2023 20:42:31 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id e13-20020a5d500d000000b003259b068ba6sm634352wrt.7.2023.10.04.20.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:30 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?q?Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Richard Henderson Subject: [PULL v2 02/53] hw/virtio: Propagate page_mask to vhost_vdpa_listener_skipped_section() Message-ID: <961d60e934e793a6065fb17d2312d5bced25031e.1696477105.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H3=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.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 From: Philippe Mathieu-Daudé 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 Message-Id: <20230710094931.84402-2-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 42f2a4bae9..118c588205 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)) { @@ -398,7 +399,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)) {