From patchwork Tue May 23 16:36:00 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: 685004 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1824805wrt; Tue, 23 May 2023 09:37:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XOICjNBn3rdMNVpcXT93gUwb8wX+gEf5F72X9QGmyOPlSwOileYGRHgjB2OG8oIMkkAlE X-Received: by 2002:a05:6214:d8a:b0:625:7802:f382 with SMTP id e10-20020a0562140d8a00b006257802f382mr9323091qve.50.1684859855794; Tue, 23 May 2023 09:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684859855; cv=none; d=google.com; s=arc-20160816; b=GiT78+wZqi+s4Wi/5RXr5k/9kMc0KiJGG3mNAgWRaL3AkQcUUzzDyCKqoKkKm6A/J3 5hKNHuulw9dQx9pIccpblB8I8MYD2gM/s6+q5dW7uhZzm9BXpGrmDBQp1KVKavYkzqOw j/RmeZaO/4fpUvw0RI8CBSwiCHYRXNbpEMjIuV84AAfkztiYJFMDFK3VcZVw7/ZGY7ra BrwtS2H9ZUGEB2cZKhkOm8vMJ8PM19EhSu0CLRANIRk+zKBYuaaYP6jBDgaUXZ4AkH+R 9uoXXXrUMyBbjzfbBs2Rf4cqtiXtCIpRTpwJBtL45Wv+3IRbHBvRN6r4pP9pxHSfPl5I T1BA== 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=nVars2hcHXmfzOaUijNnjb/uP3QrA6j+f0+XOdMOWuA=; b=FuxowhKitkT5reAbctlR7AZoYrPBbt0DrFSN3hf2vpMD4lUVeqxStv1s38rIZwxM5W e4ZAehY45B0y4yq7ydPdWZSH4nSLx+5AKTmn6g2+813x0U22Uz1zHR1z+Yzqx9U/ewyz ouIYvcHqo1R3Xr0875UTGZ2YrAdwc/rqAoPVfY/R9d/Z02igyJFnMmCSdGlI5fS2A1lp 2GlUEgp/3nr20PWsXzeFToFKF9An1Hd8CKxVxrpH2HwAnWB6FNH/XG6DLLUvu0+TRGWy z0dcw2AY/VjiKROjt1O4+UEPslRDEzGqRYBbeaJwuOHtPmtzozq19RzFVCz5AD570kqU 8qPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pIB+0FQc; 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 gc9-20020a056214230900b005e869240425si5356209qvb.300.2023.05.23.09.37.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 May 2023 09:37:35 -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=pIB+0FQc; 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 1q1V0i-0003s4-UC; Tue, 23 May 2023 12:37:20 -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 1q1V0h-0003nO-4P for qemu-devel@nongnu.org; Tue, 23 May 2023 12:37:19 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1V0f-0001p4-CK for qemu-devel@nongnu.org; Tue, 23 May 2023 12:37:18 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3063433fa66so4845396f8f.3 for ; Tue, 23 May 2023 09:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684859835; x=1687451835; 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=nVars2hcHXmfzOaUijNnjb/uP3QrA6j+f0+XOdMOWuA=; b=pIB+0FQclVihJoQQAR3rBWyPzHTIIQts36rTOrBW/T1AEVAk6ZfQq9LyMnJIGZKw2H uPmZAd7KHcbCyPEzSTnrwOuJDoorql8y+LMxEErZY6AGBZHFFaokV7rc02BBpX3m5+MC rTDVBB4SQS50eKcYozU0PZaDJ1Fy/ecVWsj5Lu/FTP4lkOdKM2J+Kj27vVgoK0z6jOSp 3Xhmh+Uw3zpw/61KcNaEE+s5TnxgnXWZ15MRUlfewF1HBuRuySCzCIpA42PcEBG9nKvu CFASc5BXp8DTGq6QEPEVmgBXgvFJl4bDKzyTzDwm4+yKKFlenP9zmG0z/Jlv2AJSo0IB 8z3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684859835; x=1687451835; 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=nVars2hcHXmfzOaUijNnjb/uP3QrA6j+f0+XOdMOWuA=; b=DMK7YI8SutmK/tzPM8IZXNjwMKAk8ecmSZYroJvOPh/Z9o5io8CIhFVGWfeWo1Jj6g bwVnYnJcOr3+5t+N2KVjLzGGxRs5APz0troObXlXx42/woscx0LFgaHedpx9qL1U/keD 9aA5jG7Kp5PjfaDrtWud8ZtowEmiqAkMpbUa/fKw1l4p2DtxdfyBAgXfpW1Y5wEbYtvi OMuqgLO7RH4On2LnsHKAHMddoejMekESQQc4XQJuBoBpilbuL8Pcb0rvJZ9W939wu2XM 4RC/QZrprbsEayXezcoyi5t+cWc+i5+0qnieJ7qkRc/TI3BUvuOmD90Z1ZlajWZMKkoO Id6A== X-Gm-Message-State: AC+VfDxGvhKkWKAmnD5drCGmXcNLVrBJEnLq4NQI7kM/nzXXxy6MdYnk iKXngpfQr9lODJoTsV1h4VpRa/NGrpHneSPM+1Q= X-Received: by 2002:a5d:6a09:0:b0:309:48b9:977b with SMTP id m9-20020a5d6a09000000b0030948b9977bmr9886121wru.22.1684859835749; Tue, 23 May 2023 09:37:15 -0700 (PDT) Received: from localhost.localdomain (vil69-h02-176-184-48-94.dsl.sta.abo.bbox.fr. [176.184.48.94]) by smtp.gmail.com with ESMTPSA id f18-20020adfdb52000000b00307d20546e6sm11831219wrj.27.2023.05.23.09.37.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 09:37:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Raphael Norwitz , Peter Xu , Halil Pasic , Thomas Huth , "Gonglei (Arei)" , David Hildenbrand , Christian Borntraeger , Paolo Bonzini , "Michael S. Tsirkin" , Kevin Wolf , qemu-block@nongnu.org, Eric Farman , Fam Zheng , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Stefan Hajnoczi , Hanna Reitz , Cornelia Huck , Eric Auger , Ilya Leoshkevich , qemu-s390x@nongnu.org Subject: [RFC PATCH 11/11] hw/virtio: Make vhost-vdpa.c target-agnostic to build it once Date: Tue, 23 May 2023 18:36:00 +0200 Message-Id: <20230523163600.83391-12-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230523163600.83391-1-philmd@linaro.org> References: <20230523163600.83391-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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 Replace TARGET_PAGE_MASK -> qemu_target_page_mask() and TARGET_PAGE_ALIGN() -> qemu_target_page_align() so we don't need the target-specific "cpu.h" header. These macros are used in the MemoryListener add/del handlers (vhost_vdpa_listener_skipped_section is only called by vhost_vdpa_listener_region_add) which are not hot-path. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/virtio/vhost-vdpa.c | 16 ++++++++-------- hw/virtio/meson.build | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 3c575a9a6e..a51497aaf1 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" @@ -35,7 +35,7 @@ static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section) { Int128 llend = int128_make64(section->offset_within_address_space); llend = int128_add(llend, section->size); - llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); + llend = int128_and(llend, int128_exts64(qemu_target_page_mask())); return llend; } @@ -321,13 +321,13 @@ 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 & ~qemu_target_page_mask()) != + (section->offset_within_region & ~qemu_target_page_mask()))) { error_report("%s received unaligned region", __func__); return; } - iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); + iova = qemu_target_page_align(section->offset_within_address_space); llend = vhost_vdpa_section_end(section); if (int128_ge(int128_make64(iova), llend)) { return; @@ -403,13 +403,13 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, 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 & ~qemu_target_page_mask()) != + (section->offset_within_region & ~qemu_target_page_mask()))) { error_report("%s received unaligned region", __func__); return; } - iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); + iova = qemu_target_page_align(section->offset_within_address_space); llend = vhost_vdpa_section_end(section); trace_vhost_vdpa_listener_region_del(v, iova, diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 16e64e1cf1..c29be98ab0 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -18,7 +18,8 @@ if have_vhost specific_virtio_ss.add(files('vhost-user.c')) endif if have_vhost_vdpa - specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c')) + softmmu_virtio_ss.add(files('vhost-vdpa.c')) + specific_virtio_ss.add(files('vhost-shadow-virtqueue.c')) endif else softmmu_virtio_ss.add(files('vhost-stub.c'))