From patchwork Wed Oct 4 08:43:24 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: 729259 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp230702wrs; Wed, 4 Oct 2023 01:44:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDwsiqN6sfA7UN4pndb+WoQl/XPclOSGxaCbAg8u1Q/ZmMjKuDd3Jfb3XhUMv7SjP7Lp1z X-Received: by 2002:a0c:cd8f:0:b0:64e:c5da:49e4 with SMTP id v15-20020a0ccd8f000000b0064ec5da49e4mr1730847qvm.60.1696409074363; Wed, 04 Oct 2023 01:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409074; cv=none; d=google.com; s=arc-20160816; b=WAaR/WG1Sg6SQD087gODK8H+vGYrtSeByGM7ZsYq3alHwTW7P53HshZwYZxRyY3/uW zwURZ3kX3EUZtvXQ7rBJV7LuCq2xZ5LrAyAdO0sIEOEM1vEBznkIq2iQBvDLiiXDIccv Y2ZVYVY7jeb/qkdKOR3Iou037VayrzWfqJt5fUV+j/yKJjAPOCYI3h4UYDjTU0Ao2Crb 0IR3lF0W8Dc8h4CnCta+nMtUNzNyWxq9UbHoFs3U8E+naFUBMS249KCk9v/PEU4wtWtA oebWUYesNG02YM4Cb+B/9iYZaBe/whdTA1VlrRVcOPeG08DNHdA8TbwiIU3vIGGcS+ou DEtQ== 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=Qziaif5jFzedGkKOEqZ/+iEupJFwfjmUm3vm30zmedI=; fh=6kCN9vTKNVCSGTvmjcT1TuFe7NLSoSzjT5BiydqGMys=; b=kMO0QG1fjzwLmuNg52vDVxGO71O1eaSU/6PhwFL3hJJ1VS9VkrGf8pM2SuYq9Xp4h3 VwOfasPnAiRq1OOX7+o89VV4QiOkBICIQ9hr2N6Nq3sugdnvyoEllflnq3l+8kaHxMj9 tUqkDIkccKb3WMmENs5VYPTf45Gqj2ToRJDjudOWxK6RvrekqH6rUddUubEPbvAO7Nn5 xKekANMc3gjU+xU08ZKHc0Pc04H9H/GxicWCanUadqZUL4/IM+dJO/fzNoNZKirE6+WV G3rhG3Wg1eG13bhHWhttzGffU2yOuhF27tcvnky9b+dbO2cuqa1w+xe7T9jiL1hpwWYF DdPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TlIC+9nw; 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 g19-20020a0caad3000000b006585e61c845si1287357qvb.100.2023.10.04.01.44.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:44:34 -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=TlIC+9nw; 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 1qnxTr-0002Tq-W0; Wed, 04 Oct 2023 04:43:44 -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 1qnxTq-0002Ql-51 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:42 -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 1qnxTj-0000v3-MM for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409015; 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=Qziaif5jFzedGkKOEqZ/+iEupJFwfjmUm3vm30zmedI=; b=TlIC+9nwTsRQtzIxCBjOaxI5XDuNy+Ml8oX9GNUExelcv49Lr3KvSo2Uummf3W+tNP//69 za+kStmDgnT1siynKCiqlyeweh2gjbY5QWN10aDVZ4gCxZ5/saipKBdQchRSZDLw6hrypS r4ZxXKMyuzNYxZ7/5mCyUCV/qJhMnXc= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-Ggog96xwOqqguAz5p6UiJQ-1; Wed, 04 Oct 2023 04:43:28 -0400 X-MC-Unique: Ggog96xwOqqguAz5p6UiJQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3233a13b47eso1468458f8f.1 for ; Wed, 04 Oct 2023 01:43:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409007; x=1697013807; 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=Qziaif5jFzedGkKOEqZ/+iEupJFwfjmUm3vm30zmedI=; b=uFGKWIR4D2tNN8LazlC/I1jwTKYSuS1DGHtZ9gy8xGVJc3Cvzq9V6JeIgFf38guS0X 7Nzat4yNckqaw/XA6HD/hrQjFcatw0beqQ7ETsEfiE1d64lLs7yaOVz25eJCZpILvoQ8 5Vv/lspdtmh9Hf20ndCvjWGX0pvVjjQuPQL5YSRqB60CDhHudVkOvrs54qSZk6o4jd6b zjzRzxnGxDJiTARriMq8liKuuPON7GtDKDzoa3ZQ9njxl6iaWK/+6ROOqFd4M3XjKKq+ 0wZW6GGv1CJSOE5bt0oeBq6Z7ILNO5UTMgVtchpeZ4YDQpTgEf96wBNajM9DfiVO5KmF mB2A== X-Gm-Message-State: AOJu0Yya7v1+Kamlp0IzbYiNXJKulGoSL7sZ5lfOvvcd63vfDQv72E6o yoIoO+IUfUxjngOrLl8dLTT3hcUqOVDbR/dIiw4uk8U5K7abWC9L0ngq/2/r5G3X6BMBS0UIYur uTN03pV+MSgXbdbJLihiuZqcPViS9ahYtI9ra7P8oijeH2eBVsv02QA7j0LZUe2FegvDs X-Received: by 2002:a5d:664d:0:b0:31f:d3e3:a53d with SMTP id f13-20020a5d664d000000b0031fd3e3a53dmr1544506wrw.2.1696409006895; Wed, 04 Oct 2023 01:43:26 -0700 (PDT) X-Received: by 2002:a5d:664d:0:b0:31f:d3e3:a53d with SMTP id f13-20020a5d664d000000b0031fd3e3a53dmr1544497wrw.2.1696409006568; Wed, 04 Oct 2023 01:43:26 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id v8-20020adfe4c8000000b003247d3e5d99sm3449577wrm.55.2023.10.04.01.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:26 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:24 -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?= Subject: [PULL 05/63] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_mask() Message-ID: <44dc75dd15ca86317d9d892e0311f2721bfa4b41.1696408966.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_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é Similarly to commit e414ed2c47 ("virtio-iommu: Use target-agnostic qemu_target_page_mask"), Replace the target-specific TARGET_PAGE_SIZE and TARGET_PAGE_MASK definitions by a call to the runtime qemu_target_page_size() helper which is target agnostic. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230710094931.84402-5-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 0e0ed6d7ac..50b932a930 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -14,6 +14,7 @@ #include #include #include +#include "exec/target_page.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "hw/virtio/virtio-net.h" @@ -23,7 +24,6 @@ #include "migration/blocker.h" #include "qemu/cutils.h" #include "qemu/main-loop.h" -#include "cpu.h" #include "trace.h" #include "qapi/error.h" @@ -313,9 +313,11 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, Int128 llend, llsize; void *vaddr; int ret; + int page_size = qemu_target_page_size(); + int page_mask = -page_size; if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first, - v->iova_range.last, TARGET_PAGE_MASK)) { + v->iova_range.last, page_mask)) { return; } if (memory_region_is_iommu(section->mr)) { @@ -323,16 +325,16 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, return; } - if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != - (section->offset_within_region & ~TARGET_PAGE_MASK))) { + if (unlikely((section->offset_within_address_space & ~page_mask) != + (section->offset_within_region & ~page_mask))) { trace_vhost_vdpa_listener_region_add_unaligned(v, section->mr->name, - section->offset_within_address_space & ~TARGET_PAGE_MASK, - section->offset_within_region & ~TARGET_PAGE_MASK); + section->offset_within_address_space & ~page_mask, + section->offset_within_region & ~page_mask); return; } - iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE); - llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); + iova = ROUND_UP(section->offset_within_address_space, page_size); + llend = vhost_vdpa_section_end(section, page_mask); if (int128_ge(int128_make64(iova), llend)) { return; } @@ -398,25 +400,27 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, hwaddr iova; Int128 llend, llsize; int ret; + int page_size = qemu_target_page_size(); + int page_mask = -page_size; if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first, - v->iova_range.last, TARGET_PAGE_MASK)) { + v->iova_range.last, page_mask)) { return; } if (memory_region_is_iommu(section->mr)) { vhost_vdpa_iommu_region_del(listener, section); } - if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != - (section->offset_within_region & ~TARGET_PAGE_MASK))) { + if (unlikely((section->offset_within_address_space & ~page_mask) != + (section->offset_within_region & ~page_mask))) { trace_vhost_vdpa_listener_region_del_unaligned(v, section->mr->name, - section->offset_within_address_space & ~TARGET_PAGE_MASK, - section->offset_within_region & ~TARGET_PAGE_MASK); + section->offset_within_address_space & ~page_mask, + section->offset_within_region & ~page_mask); return; } - iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE); - llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); + iova = ROUND_UP(section->offset_within_address_space, page_size); + llend = vhost_vdpa_section_end(section, page_mask); trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(int128_sub(llend, int128_one())));