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)) { From patchwork Thu Oct 5 03:42:32 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: 729696 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp677959wrs; Wed, 4 Oct 2023 20:44:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMTo6wFqwdJSUu6zhvT5LI87qS/9oMwzLZ2iQMXzpuXZK0nf1OK5rKaAEYEiZvZZAKnwP+ X-Received: by 2002:a05:620a:240f:b0:772:63b3:2423 with SMTP id d15-20020a05620a240f00b0077263b32423mr2447096qkn.0.1696477468035; Wed, 04 Oct 2023 20:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696477468; cv=none; d=google.com; s=arc-20160816; b=DtEUsWyNPthUNl5V9ojMD1Xo/lC5uSCrOa4V1h9ZLTfHVz5QC+WyvqilDmyWVpwyga 5zTIPNaufDYn5I1IiyqUKkozHrtq0rJu+iTSnRQHukyrx/rIWpieWhERSPUC0gXLh7Ia 8cfC636n0fVS1cO6JksM7xYTYrkhpgS9yXkMlSnFIjaAF73SUvSv2gOENQb2fmG3rxoR yOIZK3hARxbZS3IfrSqE0QeV9vzkoZj04VE2IU6vNKKojBJkXa6EshSntwTexPxogkZ5 MXFY/+QkFyIS9dJKb/aH/HRm0CrdiaGWcicKWs7lolwE5qbG8HrxNfXcv+4OfBWLghel Tmqw== 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=ZPz4GnJfkENcst/YvbRzP3MUYaB7CKMx8l9nJBdXF6s=; fh=zhzFgY8F88gmLqhr0Gjm2ulsyPFhXBed6tbGp+K0bf4=; b=bjNsR6LlztHO8Q98u5EhDjiqmBMVrd/crvAkeoqTW3RhtcCV7G1Wg7Eh71awlpc7S5 9Jap6daHeYZl3qWl2vQ966cATXLD+7qJ/IzvtaDGvhfoms8OQA2AMOKIrfvbnRFA9yRk zx88YaQ972cSvmaFMg7ECo5zDkvIo/BgYLEP94h3Ta5p7zOG7i9ti+PRIzRjYsWnMUQa lL/YbBpyLDn9t/5VbFer0rfgrh52ZU73qwG92PqrbbsA63BHPwBcC1W/MKtJTMnTl5XI bIzaB23RoUKl43rCVdwT8wi/OpPnUijfbKB47uD1LY073Qfz4/q8pPxBpexVU38oF10g 1c5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="UKy/ksWe"; 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 c21-20020a37e115000000b00774350d04desi359014qkm.199.2023.10.04.20.44.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 20:44:28 -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="UKy/ksWe"; 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 1qoFGH-0001Dd-Gj; Wed, 04 Oct 2023 23:42:53 -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 1qoFGF-0001D7-7U for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:51 -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 1qoFGD-0007yr-R3 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477369; 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=ZPz4GnJfkENcst/YvbRzP3MUYaB7CKMx8l9nJBdXF6s=; b=UKy/ksWekDirJnj5y2rG8YFQsfDO0qn+i6iVQ1DxYn6kcFLrE8Lt7OYa/4SHbfp0pH/zFc gei2OyPDYZDALU3CPstRyk3OEFmiY5cqYp8pqytdUgpGfGWQ25dgvAoyEOqhbj206nhLrC YPNpG5vY7qBYLukbh0uup3fKylVOaG0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-FSkK6sFWPy-HU0h3q1V0Aw-1; Wed, 04 Oct 2023 23:42:37 -0400 X-MC-Unique: FSkK6sFWPy-HU0h3q1V0Aw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-326f05ed8f9so478398f8f.0 for ; Wed, 04 Oct 2023 20:42:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477356; x=1697082156; 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=ZPz4GnJfkENcst/YvbRzP3MUYaB7CKMx8l9nJBdXF6s=; b=Vyg7uPOMm7eIewO0qpull5mlxTktenTBvYPKfZiDXcQIv3DmXZPpCzP8TKCvRE/rfZ cwp8pK/ZgHGFCdBKYtlSBa6gjNwhZOgZSaDKSYYSffOJRSiCJI88MFIW8+INwi+s2vzK kjllrc7LJ8oB9xqIARAfz1fDDUCYTfHx0V7kEU9alDqm0qA7/f/SvUytotbQPs3/it0f YJ8Iq3z07Sb6kBE8xUAo3BZRMDSKwm6/fbk+EJ3CANBpfQgNYjOvJRHXueH/L/1Hwz4K 6nNhOel+Dg9Dt1ze1A5BvfR8Tpy+58CziPkQnxTgPUuZ4amjbCHzH0jYVJjdOM1o8+/0 9NlQ== X-Gm-Message-State: AOJu0YyCRzrfeBIubbboOat8cqkPwXzOP3GcGQIC1Q5UYl9uultDFenv TSAUo9AOH4amL9j+5Io+8sWIziiNRTVAgZp3x2ENcVkPtSnm+mUUC4KdEWXQIavzKnueJMQ67Oa MlvM3alF4RJuB4fgYAtq7Ko+vm5SAM5M4+6SvDjBMTmdm/N/7y27uIQhX9gRsklRJ4DA4 X-Received: by 2002:a5d:6991:0:b0:320:976:f940 with SMTP id g17-20020a5d6991000000b003200976f940mr3665981wru.13.1696477356160; Wed, 04 Oct 2023 20:42:36 -0700 (PDT) X-Received: by 2002:a5d:6991:0:b0:320:976:f940 with SMTP id g17-20020a5d6991000000b003200976f940mr3665970wru.13.1696477355843; Wed, 04 Oct 2023 20:42:35 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id c7-20020a5d4f07000000b00317e77106dbsm628436wru.48.2023.10.04.20.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:35 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:32 -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 03/53] hw/virtio: Propagate page_mask to vhost_vdpa_section_end() Message-ID: <8b1a8884c6aacd9a35863d18a757be17ec7b1369.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é Propagate TARGET_PAGE_MASK (see the previous commit for rationale). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230710094931.84402-3-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 118c588205..3ab0dc0b5b 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -31,11 +31,12 @@ * Return one past the end of the end of section. Be careful with uint64_t * conversions! */ -static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section) +static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section, + int page_mask) { 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(page_mask)); return llend; } @@ -69,7 +70,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section, */ if (!memory_region_is_iommu(section->mr)) { - llend = vhost_vdpa_section_end(section); + llend = vhost_vdpa_section_end(section, page_mask); if (int128_gt(llend, int128_make64(iova_max))) { error_report("RAM section out of device range (max=0x%" PRIx64 ", end addr=0x%" PRIx64 ")", @@ -331,7 +332,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); - llend = vhost_vdpa_section_end(section); + llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); if (int128_ge(int128_make64(iova), llend)) { return; } @@ -415,7 +416,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); - llend = vhost_vdpa_section_end(section); + llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(int128_sub(llend, int128_one()))); From patchwork Thu Oct 5 03:42:35 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: 729695 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp677772wrs; Wed, 4 Oct 2023 20:43:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFV7KvhZHDbar1+uweXMvPtTTh8nHg9aEt9HUUhq/+Ve9s5KbD/CB+5Ubni77BWs09dDFXG X-Received: by 2002:a0c:b304:0:b0:647:21d2:21d2 with SMTP id s4-20020a0cb304000000b0064721d221d2mr3253191qve.14.1696477423704; Wed, 04 Oct 2023 20:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696477423; cv=none; d=google.com; s=arc-20160816; b=Y0e9BMDL+n4s9ucHr+aJ10gf0JmBGTNX107/gHcQ3MI86gGrLri7wmq9CbEZxODDkX s3hiH3RURcpwUH/qVkYYrglZ4PHImO5zln84oMRiYJUdTQtu7cFsiIfJQywLYdOgF1Qf A8yk9RUhzbNX/Rm9l9Y3MXA/M4Rp5vg/HwU4idSTHVXu2MMRKub5AO0ecmqgSBc4RspW ggSCozMEe1bmc7Taz8FkeuEjMMgoqQwN54K1NqMH84ID0gWhNsUWr4JsNS5D3TiD24zw U3uAmWsZeDtLzmlEjxdKmSDxazQdhW7bzSwWzbF4ygV52U2c2MzByvNVQFRRhbTrUBeM St3w== 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=g3XainUJVMKa+Hs4fQFDx+vYokCoMuU5n+RMYZYnWdU=; fh=zhzFgY8F88gmLqhr0Gjm2ulsyPFhXBed6tbGp+K0bf4=; b=XD7J6lnNtjLPLYvgpLvi1mwmplhD7uGO19tds2RTr3EFBQp6XGbXI9Fvr9mUPnoBZC C/pTGqYIv6uqK0IK812i0YUBJHoWq1GH8kpsktcJ4v8AV4ukZlSbxdcRcTgqsOl/9hOd Tm14RsI6kgh0OIOQDuQDm/z6sKfG5EszWhOUlApAnRdWRZoj1z+MNQAaF3MaFzPxCK8m +XvkLiOsTQ7d8Woas31YBoxoldZIA3JitkVxTffExogmYBrYK6oxIWqJCWqIos/POZUz ySxmjLN8OPMTd69GM99aBcKVoydC9e1dyFQRNocNIBv8zdOvQ/f3ASFRjGjzNKfc+o2O tuNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CnO5siIQ; 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 m6-20020a0cf186000000b0065b22760974si326340qvl.504.2023.10.04.20.43.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 20:43:43 -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=CnO5siIQ; 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 1qoFGF-0001D8-8p; Wed, 04 Oct 2023 23:42:51 -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 1qoFGE-0001Ch-2f for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:50 -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 1qoFGC-0007yd-MJ for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477367; 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=g3XainUJVMKa+Hs4fQFDx+vYokCoMuU5n+RMYZYnWdU=; b=CnO5siIQZFD+l3pBY2kYJBrw5BLyKycwGg8iqsuUSClU0/Dy06FWIPxfunb6NS6Ry/FTWY Q4qNBWePpHoNoewKUOio84F/dsWOfTaCzz98YKaiWm/oGZD7dOuXl2Z3+p2o4d7f+6jmXU +axfYsiUG/V683RXYubxCrWLenhAGdc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-fnbvjn0bNjCYSit5ZEMirg-1; Wed, 04 Oct 2023 23:42:41 -0400 X-MC-Unique: fnbvjn0bNjCYSit5ZEMirg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-30e4943ca7fso462436f8f.3 for ; Wed, 04 Oct 2023 20:42:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477359; x=1697082159; 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=g3XainUJVMKa+Hs4fQFDx+vYokCoMuU5n+RMYZYnWdU=; b=cQr1rDJbS2idipLLdBLxlEDMOVycleCiN85IrcQJxIsV1ZNtlBtUtlA+PfMmeKIFvg 9+g+WVWVY/CCFWxDtN1dwJ9zRZyXvcNoiQ4MBI31/mzlMpdXvMqWd0BFGV55J4kScSg7 40/obFxetS1B3CmNceBeDCTrWQocq2XF9B5+ce4zv45/aXAbROnqqn/AyeInwR7YJNiG rgLuj21ZpjgMmCf25yrQ4qo6eGbgmZGsZpqRCYzKXoMQk5I61dzwA16W9W8rvEVVkTzj eYz40/xkAhIaLlY7Bv4TBE8j1cxo9AyW+G/URdzHk4S2WQ5sdxnXoK6v5Mq/nv3cHS+o 5TWw== X-Gm-Message-State: AOJu0YxvBLVoTU/T219lZ1bSd6e39b/bkJ76T8a2Ym9dm1O1EPrahLp6 QzYLGJ01D0eN7/5GEwUedrECxe1w2GBSq9tX7B2O1SvkJOpiYA0ZJS6IOmMhCzEvA5rJ8feXQq8 UVithWhfooJOqXenM5hNrYRgE2MpM1sSUf5JPaAlct57Z9tE+Xh1ynIKjSYnd+v6S/B3h X-Received: by 2002:a5d:46cf:0:b0:31f:8e7c:6ebe with SMTP id g15-20020a5d46cf000000b0031f8e7c6ebemr3975115wrs.5.1696477359748; Wed, 04 Oct 2023 20:42:39 -0700 (PDT) X-Received: by 2002:a5d:46cf:0:b0:31f:8e7c:6ebe with SMTP id g15-20020a5d46cf000000b0031f8e7c6ebemr3975103wrs.5.1696477359540; Wed, 04 Oct 2023 20:42:39 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id v2-20020a5d4b02000000b00326028b4dd5sm621110wrq.113.2023.10.04.20.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:38 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:35 -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 04/53] hw/virtio/vhost-vdpa: Inline TARGET_PAGE_ALIGN() macro Message-ID: <1dca36fb3d4f07354c9f6bc38b6e5c72fe1e9855.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é Use TARGET_PAGE_SIZE to calculate TARGET_PAGE_ALIGN (see the rationale in previous commits). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230710094931.84402-4-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 3ab0dc0b5b..0e0ed6d7ac 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -331,7 +331,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, return; } - iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); + iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE); llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); if (int128_ge(int128_make64(iova), llend)) { return; @@ -415,7 +415,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, return; } - iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); + iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE); llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); trace_vhost_vdpa_listener_region_del(v, iova, From patchwork Thu Oct 5 03:42:39 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: 729694 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp677610wrs; Wed, 4 Oct 2023 20:43:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHD9CNiOojAXyU9qmqPRNSbKIshrwARxYnPpZi0f4klqTVrHswpnrdvpziffmTlJHLtArBL X-Received: by 2002:a05:622a:1b89:b0:40f:2e2c:6df4 with SMTP id bp9-20020a05622a1b8900b0040f2e2c6df4mr5064559qtb.6.1696477390336; 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=CMHAlj415To9kNifLLwNMT8dfZGOURt8s42R12lYdncBpb93b7O0kYO/RuQYDecEid lZDYVIuFH+Qi0pTFfKp0mzq6xrfC659DXivBGE5skC3xcK1nv+agnN8oXJ3r3Afgn149 TPsLQDzDtQkl1362MbgBYyfgq9Tof+PPOiF4zsG4VNgQtdXQm0kvIV7BlcdMJuOv1It3 YUps0zgcZfzw5xMd5MRnYjRejB+Tob2pxdksjJiwUkt6SKYK9r1uxAVgiUY3BE2FM3Bo rIhEMu6UB+ybid2c+FSak8DXCN4LsZt7HqEgl3aDmMhD8FiLEFxOYdoU4qfb8R+ILOSZ FmpQ== 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=amo2Oz1m9ISxQMsz197vNM9UJKJ8w5QYst/LVTIWKWI9jEoKxOLV2DBRzj1+BmU3fx 9MEWHSOEVoHxDR48+BgohzJFTpz2xhf6asRYWFT8aCPTbvcNE6hHHQYnmrLIs9S0DrL/ P4Y0196ZxkZneUCqjVD1vs4vEJ/wEGVLWctXLsc/I68S/x2URZERCsLx0NQqJInYtV4t un6RE9PY0hauYFTUhoxYjeLMrCZC3zjDi77GQHUBd1KLdSl4X91unDeBwX9fyY1Rznqq /bWdNf8zwXxcqbi+bXUMUx2SAKvdA1JDuhkA91C59nPdcNqicf+rYqP61TTpabjGGcSJ cVug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KnkOBc4U; 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 s7-20020ac85cc7000000b0041992ce3a38si359789qta.805.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=KnkOBc4U; 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 1qoFGE-0001D4-NE; Wed, 04 Oct 2023 23:42:50 -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 1qoFGC-0001CT-KN for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoFGB-0007yD-3d for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477366; 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=KnkOBc4U3/hVlFMwgGA6t+qBSyXlDjLFMXQtyK6TpcJhdlnnoCjyisPDQkgEj+sKz+BQvi Zu7Lj1i4ullyO1PvcWh63n/El0M1BN1Adhm6ej9Vw55VP2lI3N39f0UdE5oDrCVVusWYE4 /+zpnKagDP4kLZzwCZlKj07YzcIQ75k= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-53-n8qsFWEzN1C_a9F48hl8ug-1; Wed, 04 Oct 2023 23:42:44 -0400 X-MC-Unique: n8qsFWEzN1C_a9F48hl8ug-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-325a78c806eso400746f8f.1 for ; Wed, 04 Oct 2023 20:42:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477363; x=1697082163; 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=aJpBc3XoemFDmwd9lF6EvEGuDFTDTJwirFl+YpOCV/uM2wp838o+Y5D/o6oAvm7WeY jIUKB84NUYsm7BGH3SqxUpjNBtCa6Y0s4zc8GmsFW1kowWBmB7/ueEjIA7pVhsRNjC7c tThKh/4gcfg+IkVdSzRYYNf3e+4h+wg9BPUkhwRMUa+/senpFnplbpEEfmXTmOaaTXVb o1thnNP+er1A8nYLT4YSG2tAfwXpx6DkvWNK6bIQQFfqVjxwgbQYDd14x8h/Wj7w/sef Gz/GUbgmQgjXyZvXWJcpFvO3RGs5k86Scy2p7H+Y5PZ5IwiCCo3zTHPIyjoyT8ySpqUj fZOA== X-Gm-Message-State: AOJu0YwW6dT+CTSeCzfY11faMW+jD4sSxdJlsgP3cVHBagZNyqwsEqgJ zS1CX3MN4+MI5Kn0u+QkVyGNFd4ecyRL/wTC1P+dvEQ1d2qZdhc8olRSJp4yrrhLQmYjH16ZLfU XajZA6yL5pj27FR43YOiLKHaKUJ+wDghAJ7fvDluOIMFTr0sFbNgnm/RSaq5KDGzlon5U X-Received: by 2002:a5d:4247:0:b0:31f:fa66:5852 with SMTP id s7-20020a5d4247000000b0031ffa665852mr3825758wrr.21.1696477362885; Wed, 04 Oct 2023 20:42:42 -0700 (PDT) X-Received: by 2002:a5d:4247:0:b0:31f:fa66:5852 with SMTP id s7-20020a5d4247000000b0031ffa665852mr3825749wrr.21.1696477362608; Wed, 04 Oct 2023 20:42:42 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id u17-20020a5d6ad1000000b003247f732c11sm624573wrw.76.2023.10.04.20.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:42 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:39 -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 v2 05/53] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_mask() Message-ID: <33f21860b766701f92c01094dcfc5390974d4020.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.129.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_H4=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()))); From patchwork Thu Oct 5 03:42:42 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: 729698 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp677973wrs; Wed, 4 Oct 2023 20:44:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0VPW+fpplDtJU1zQ/JOhoO+88ymN5moZ6xuUhSqb5H8PNxcjpoEBE7N4BWx7LTqrXP0UU X-Received: by 2002:a05:620a:1924:b0:774:179d:6576 with SMTP id bj36-20020a05620a192400b00774179d6576mr5166725qkb.50.1696477471464; Wed, 04 Oct 2023 20:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696477471; cv=none; d=google.com; s=arc-20160816; b=mmj/bFi/mfYuCK/+5CLJEeuxEDiI8pVmSyi0CRE2gZKte0TeGXOFfbR7azMZSboj5O NBLzuSpG7TfvX1UZ8dAb4bH+NrMg/zQnf2BUBsCwIwDOHw457+nTEim9Qv+rBCEZDP9r BInCs36BEDKeyt+Fll+6l5wZf/W7mElw9PbJPlhcOBIWMdftZyBMI4YWlfSovGxT6nkp PkxHlaEyDBsfmECCph7oZkYAlJFyxn6rUlUbkEwZ6VAWNOeC19wBNHGcKQ/GIK8ccyXB wl4IfU124GeykWToodoDxb0I7vhCl8KI2kQUYNkDx01z+wi/REfqZMV+uFr2EMT0EEbJ Z0Iw== 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=NW2NOMzgBdCNK5ZXMj4UrgviAiZWrBVJEYGFoltgO4I=; fh=Kpn8NUdv7wKUydTeMx58meD3bhQtHIgecefqqY6gi54=; b=uvayUPcSQ32OUA+zoaD6mIIJrkB/jvSohCQu1FKqysDPk0iGbAZcQdBWwl3Ibbh6K5 Y2c03dFcKUhGQqyRgJ5BPikGcLWBRG0fadfi0uHUEySfQ6P/DOQCfiRQNerM3DfLn2wd 0hDlNTIbyZSAdeSmjh+tGlHFCXZl5MwIJ2eSqjU+LMmls12JZMixHbAApy7rJU1sTFRV KV5dpOvm67VIyQzcknv0vRY3QB3680mNe5FYum2Eerj2CyPQPutSpzWQOfmF556mduT5 TTW0e30SjPYWJzwse7TpoIZxR9oe9xyJi0CsnQRZHc4D7ZFwyUbYzbAsyLV75EeoBJ5W Lp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gkj6KACq; 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 az35-20020a05620a172300b00775cadf4b83si349028qkb.249.2023.10.04.20.44.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 20:44:31 -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=gkj6KACq; 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 1qoFGP-0001IY-27; Wed, 04 Oct 2023 23:43:02 -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 1qoFGM-0001H4-9A for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoFGK-0007zN-Pz for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477376; 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=NW2NOMzgBdCNK5ZXMj4UrgviAiZWrBVJEYGFoltgO4I=; b=gkj6KACqsmoUoFIcy4NfKY/yMeZeEz8yRNp27KYx6o/+VIssSEK9WKOuBy6ps+YCaHNAis iJ9ABkaoWfqark4SoiJ+fnd/AebpQQEMH1wBxEt2XePlpF0xJTPMDkTaiLPEBv6sHXMEjE 6s6I1HxiHqLRWm9uxWkMK9UIYQ0Xmcs= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-49-lj1SKyVfPGK5XO4RmZ1HbA-1; Wed, 04 Oct 2023 23:42:49 -0400 X-MC-Unique: lj1SKyVfPGK5XO4RmZ1HbA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f42bcef2acso3144215e9.2 for ; Wed, 04 Oct 2023 20:42:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477367; x=1697082167; 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=NW2NOMzgBdCNK5ZXMj4UrgviAiZWrBVJEYGFoltgO4I=; b=gLtUzq/WWzGlo6KKEOc/Md+WyMgxMSqLBR64CH3KETf9XfEnZ9NdSQLMPdDkvwpWbw JxeQVw2TplJ80nHnK2gDkQwKfFVFE03um7cBFjvGgNRA9Z0i5H2K1/edcD7+QosCd1En kqKbs16OPXxgdVYaNxPRuNmKHev8XoGNB/ZEXwTGmkFMxkvmPA8mC8DnMRynnSdti0yW 9DA7hTEsPMwXolVq1QCxWLiflB/y5BaeX/liFuS0SCK6NQITh9N1Dnla17QwLY6DYglQ 8KA/Y6S+AcO/baAHNHOmWKQciZwljQylrv+Fs2y7OyGd1jepo/3uaFUo4gNTspuQuMUD bnog== X-Gm-Message-State: AOJu0Yxg1doQBP6QkaJT9htM3G3lnOFLmW58xPjg4N1Ry/wMYEIo46F5 gMTOWUzo3WnRQ5I588stESyLDuLBQaJDjJ+ipoc07KzqeOQEj5msXGkQ6tiMJDZhwHqnXtWE29S rmsFul3OZkHAUB3qSXHW6QcpX3zStEp2BSto7ev+RwxxxJ5p6c6w6SMfR5ox1dvxhQ+KA X-Received: by 2002:a7b:c851:0:b0:406:5301:4320 with SMTP id c17-20020a7bc851000000b0040653014320mr3855862wml.16.1696477367089; Wed, 04 Oct 2023 20:42:47 -0700 (PDT) X-Received: by 2002:a7b:c851:0:b0:406:5301:4320 with SMTP id c17-20020a7bc851000000b0040653014320mr3855850wml.16.1696477366867; Wed, 04 Oct 2023 20:42:46 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id x2-20020a1c7c02000000b003fe23b10fdfsm2760216wmc.36.2023.10.04.20.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:46 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:42 -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 , Alex =?utf-8?q?Benn=C3=A9?= =?utf-8?q?e?= , Stefano Garzarella Subject: [PULL v2 06/53] hw/virtio: Build vhost-vdpa.o once Message-ID: <05632635f84311f241ad4dbffdb591f97339a5dc.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.129.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_H4=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é The previous commit removed the dependencies on the target-specific TARGET_PAGE_FOO macros. We can now move vhost-vdpa.c to the 'softmmu_virtio_ss' source set to build it once for all our targets. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230710100432.84819-1-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 13e7c6c272..9737450afd 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')) From patchwork Thu Oct 5 03:42:47 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: 729699 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp678041wrs; Wed, 4 Oct 2023 20:44:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyTjmv660xVu2w36MXbyNCuvVJzI6hRD9uheAKGLV8D3G5sZ8tpSnupxeIOTuo8tS4vd98 X-Received: by 2002:a05:620a:3844:b0:774:1bb4:502d with SMTP id po4-20020a05620a384400b007741bb4502dmr3514607qkn.74.1696477490435; Wed, 04 Oct 2023 20:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696477490; cv=none; d=google.com; s=arc-20160816; b=lEb5ElAi86y+GenACIQ8xxQDLSegAu5/0zPUQlBW1d69H+MhulZ8VrHXrqNq1RNO3Y Y5l34L4ipUSaHl1hrJEi6/9KKQhQS3e4EIm0qy3DJriOwsXgGExWaJlItUNlV0AUWeod EV4TqwY8QzutdD4zk6gIkqnDB4PtZkTpJXVlWJAd9I6blp7/X44/bvdJ7gWFJzuRm/sK hxpD70Dwx6zIBol9PGz7Ap8CmRAkS8t/Q4CosbPokAzQ2sewc/Kh0eHu988j7onDHQj6 vEqTCTxngHw9QA2KEmmGLBmRHEStS64QgYKErTGaQ9L9XNU14FKHqDh9nMYQ/9ZjvJH3 vP+Q== 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=3t8WNSkxqBpAo+9P1uf7C/JabXh9XbItEnrkHWLRDt4=; fh=Kpn8NUdv7wKUydTeMx58meD3bhQtHIgecefqqY6gi54=; b=MAzO6LytqILm772AX0mSaorerks6hY6YcTmCPQod/bAAq6Xb/q1lChjoOEWG1c6fx9 HZz/d2W8h6LMpHi6OUXX/v0TUDLWpzBRFLPtZz+ZZVVriEZQtY0GAr6C5Oc5HtZivM// dLPIwS8z4Pgvu971WLDqwvrWCpB4/deAcGiuNhUk1v1LS+gE7LEC25/nPqSKc10R15An tDfKuQw/wWTpLhz9R9X7KA5mM7+NyDCVf8/7oMA5VeggCOX3kalliJ5FMMgETbF4tb5W 4MCLMXdmPYvUVgdCxX+toGOc7geFle6gyN4pXV6o8h54fOS6TpJ5nWMH3/PmzbOKWZDS Lj2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aCtCcmVb; 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 w23-20020a05620a0e9700b007759bdaeae5si364331qkm.94.2023.10.04.20.44.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 20:44:50 -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=aCtCcmVb; 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 1qoFGL-0001GO-Pm; Wed, 04 Oct 2023 23:42:57 -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 1qoFGK-0001E1-3d for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:56 -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 1qoFGI-0007zC-Fw for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:42:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477374; 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=3t8WNSkxqBpAo+9P1uf7C/JabXh9XbItEnrkHWLRDt4=; b=aCtCcmVbPHygB1qNdAsPR/sRPwzb5JqWacz+2aOTpj9tYWGlJcf6rp0kWSPMvJMgjkanMA nOWGraDRt01lKgmLX/UcXPxQYZ2d26gxAGB43j+k7HHybS/w+3Geuwt7BlpaP2jsf52i0+ PB43l43WjTBSZRIi0XoY/uSK8281vKM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-frtlXVBzOq2KzkqcusBzlQ-1; Wed, 04 Oct 2023 23:42:52 -0400 X-MC-Unique: frtlXVBzOq2KzkqcusBzlQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4065d52a83aso4021055e9.1 for ; Wed, 04 Oct 2023 20:42:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477371; x=1697082171; 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=3t8WNSkxqBpAo+9P1uf7C/JabXh9XbItEnrkHWLRDt4=; b=bEPvgI5sffLdErIB8e+0P60xOzSKuu8YtDpW0omhihNQ3z/n92sHj8JPRM4mes2VWj qGGIjHVOrzpB26qP9xzaF0xGryTEpoEzXDE4V4YCskzpNGZJ7eXFnEcssLCj0Adg+UuG P7pI+qDEZN1KtvtJvRTLxBszvmuTefd+SST5vEAsNIk+c+BTmdH3o2ziHEfFf1hb4Koi zPoA77yti/XLfyk8wKFrKWjxkiONuspCT1tzGj9MwoNojZkpEgGkZoiWSjVx687cQym3 H/BDBdCDKhbjwLM90sxE4m58FlrzbT1Gc1tlALLrWrQnauoLtLIeQNrn5mtodCq9dE4Z C3Gg== X-Gm-Message-State: AOJu0YwwCYdhhm1tcuCMgO4GjXHOg1YocF8jPSOOeLplOKSTHlQ/Qmqz vCVfDfJreHyzQ3b6YxzIWQJ6C2gbmV9nPf1uNoOwGSb24+Z/2lR0awI/kXiJOzSpCoeLeEJqNwx SLg+xZRMBEoAKl/zcBpk7kJ1UvAxO5Hf0r7JGCOqLqNZmJmEEr2bC8sq6XiVkpdIi+Tkt X-Received: by 2002:a7b:cb8b:0:b0:3fb:e189:3532 with SMTP id m11-20020a7bcb8b000000b003fbe1893532mr3965523wmi.20.1696477371024; Wed, 04 Oct 2023 20:42:51 -0700 (PDT) X-Received: by 2002:a7b:cb8b:0:b0:3fb:e189:3532 with SMTP id m11-20020a7bcb8b000000b003fbe1893532mr3965513wmi.20.1696477370734; Wed, 04 Oct 2023 20:42:50 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id 10-20020a05600c228a00b004065d72ab19sm2831323wmf.0.2023.10.04.20.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:50 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:47 -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 , Alex =?utf-8?q?Benn=C3=A9?= =?utf-8?q?e?= , Stefano Garzarella Subject: [PULL v2 07/53] hw/virtio/meson: Rename softmmu_virtio_ss[] -> system_virtio_ss[] Message-ID: 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é Similarly to commit de6cd7599b ("meson: Replace softmmu_ss -> system_ss"), rename the virtio source set common to all system emulation as 'system_virtio_ss[]'. This is clearer because softmmu can be used for user emulation. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230710100510.84862-1-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/meson.build | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 9737450afd..4e81d10834 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -1,28 +1,28 @@ -softmmu_virtio_ss = ss.source_set() -softmmu_virtio_ss.add(files('virtio-bus.c')) -softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pci.c')) -softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c')) -softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c')) -softmmu_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK_COMMON', if_true: files('vhost-vsock-common.c')) -softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c')) -softmmu_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')) +system_virtio_ss = ss.source_set() +system_virtio_ss.add(files('virtio-bus.c')) +system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pci.c')) +system_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c')) +system_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c')) +system_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK_COMMON', if_true: files('vhost-vsock-common.c')) +system_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c')) +system_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')) specific_virtio_ss = ss.source_set() specific_virtio_ss.add(files('virtio.c')) specific_virtio_ss.add(files('virtio-config-io.c', 'virtio-qmp.c')) if have_vhost - softmmu_virtio_ss.add(files('vhost.c')) + system_virtio_ss.add(files('vhost.c')) specific_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.c')) if have_vhost_user specific_virtio_ss.add(files('vhost-user.c')) endif if have_vhost_vdpa - softmmu_virtio_ss.add(files('vhost-vdpa.c')) + system_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')) + system_virtio_ss.add(files('vhost-stub.c')) endif specific_virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c')) @@ -68,7 +68,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MD', if_true: files('virtio-md-pci.c')) specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) -system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss) +system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: system_virtio_ss) system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) system_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) From patchwork Thu Oct 5 03:42:51 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: 729697 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp677961wrs; Wed, 4 Oct 2023 20:44:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP/QkBx/8jCCWlA3wikxikKZ1SYQTJgYthaT4aW1tBlaJ6qmuhgyL+Mh5qYl9ZUwzta7Pm X-Received: by 2002:ac8:7d55:0:b0:417:bb09:eba8 with SMTP id h21-20020ac87d55000000b00417bb09eba8mr4734078qtb.55.1696477469205; Wed, 04 Oct 2023 20:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696477469; cv=none; d=google.com; s=arc-20160816; b=jVZ4wDSlcz/mSpIH30WCYV7SECPJcie6rDkxbDEcotKti9h6RE4lpSVi+eFlaSwt1h dPgC2zKBvA1p4G1aJszCwv21MameWEfGogBWXcKitmkAgRcAjAJ4RNb0nAyoQOQDY93T rPjrxY9Xp8MIAIaKDhb+0hBvKkuIyB+ABjg8rtq60DDeCH7UXqlWYrL/m/m8cWLH1J3m QqT/dUyJ3HWYoZJV0pmCf1t4VDYgNo7lPGbVIe9Wkz8HwOvqYFMofooT6XiyNRvMqQTp paiDSoY1CuH1MHC37V50SJazs+Amk6LJaM0lLLCFV3/9GzrtUsi2ngi834MyjV5g/mO0 kI8A== 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=kYVXronMIRD9/a7cn4RGqS0rmhPV3UYDjMlYv2wpbt4=; fh=hPfGPwxY64xgddKZ9HPqIBAlYYHqezKlrNe4066q3nk=; b=TOjDLVtIlzXScs3SX/5rc4CMESFCQm45qGi54UsbCOsAnkUBi5+DvYgG7IxeJ7MzCB 7mxbIiKBEUYtQ8jmuoieguYPcy+j3JsXY6nSMqAImAkNgvkDAWq6LZDtnPcTeHwmu+nH xY/bJlNVLuPbM/B2IX31V/A5XzMEUnQowpuP+tB+bNWDbyaOiR1I2UuHqzBE0d0owpZX dlrNoxF768fpQSKaX93prWxP65ik5SHj6rwDMckf+YZsrzs51hoEq7hBQrwKdPxfwfqo 5aMq4y6NYosn/UgDl72+j2ZtPndHw8SfA9hK3dgUHJkm1WKTEdm6ACiSZz5wQsBRsQjd yZFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DH5tGlpb; 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 c12-20020ac85a8c000000b004122ededdfesi366339qtc.253.2023.10.04.20.44.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 20:44:29 -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=DH5tGlpb; 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 1qoFGg-0001Y4-F4; Wed, 04 Oct 2023 23:43:18 -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 1qoFGf-0001XM-9q for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:43:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoFGc-0008Ax-N1 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:43:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477393; 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=kYVXronMIRD9/a7cn4RGqS0rmhPV3UYDjMlYv2wpbt4=; b=DH5tGlpbxN2d57f00VDtsGElO8Y+g86SGhYv2feO6CDisNo+oA/fwOSUmQmJUGYwZcIwD+ 4VDru4OcKgqcJcdeZocsjYJvtjZeR1WrbUqoeFsPF9US3JqKbR7P2J0PfQHfctFe3yiTEm z859WxGv/7BU6Vw8ZwFn2OGnf8E21Dc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-7P1AUHSxMF-Cn01-WjUlkw-1; Wed, 04 Oct 2023 23:42:57 -0400 X-MC-Unique: 7P1AUHSxMF-Cn01-WjUlkw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fef5403093so2504855e9.0 for ; Wed, 04 Oct 2023 20:42:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477376; x=1697082176; 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=kYVXronMIRD9/a7cn4RGqS0rmhPV3UYDjMlYv2wpbt4=; b=Lu8sGleylx3omV+uOu+31S68rLEDV+/F7Xagb1YJ2nMVPB7sVb53zaOmDSFbMwBLr+ B9DgyluED7iz0zSSb3aCpuM6V8OnAW773A3yERPtyiRz5JTPrY6p2nnEcLdmYlDsqAJa H3+82c8xrvpgcvhUKL5I30hCtD/pDYjZ5d99nUUR/8Kb3crY0X4BYVIBrtitwGsZSASy 34tzvKKbP9C5WSMhkP0nUDbYmCm9wzBlXh1CZQ1JCnhfFNmNOwM9ErdF4NGu8Y9fLhyq GiHMJH6J+Q1bcHDQjg3Eg3ZApV0eAF3LHx/dwwrznkfHFM2KkgZXla7FGdDvWdKoU1rO l8YA== X-Gm-Message-State: AOJu0Yytp+zelNNxBsIRio75NhD65944RYFTvgp7cX1ePC2W19h2Set8 rkKYHEPFOX86SAJ0jnGf37yz72b0ftVzQUhg3qsT5Cdji0bXcTkAgbp+84xYx3i9KqKRVcc1J+j kAEAx7Nk3emA9rhpocyMH3SSaf7pMmPxJOpyDpEqA6F3OCVdzZ0IxhIe4dWyyEnbO98In X-Received: by 2002:a05:600c:21ca:b0:405:3924:3cad with SMTP id x10-20020a05600c21ca00b0040539243cadmr1021083wmj.15.1696477375982; Wed, 04 Oct 2023 20:42:55 -0700 (PDT) X-Received: by 2002:a05:600c:21ca:b0:405:3924:3cad with SMTP id x10-20020a05600c21ca00b0040539243cadmr1021069wmj.15.1696477375474; Wed, 04 Oct 2023 20:42:55 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id c5-20020a05600c0ac500b0040586360a36sm2765572wmr.17.2023.10.04.20.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:54 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL v2 08/53] virtio: add vhost-user-base and a generic vhost-user-device Message-ID: 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.129.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_H4=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: Alex Bennée In theory we shouldn't need to repeat so much boilerplate to support vhost-user backends. This provides a generic vhost-user-base QOM object and a derived vhost-user-device for which the user needs to provide the few bits of information that aren't currently provided by the vhost-user protocol. This should provide a baseline implementation from which the other vhost-user stub can specialise. Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-8-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-device.h | 45 ++++ hw/virtio/vhost-user-device-pci.c | 71 ++++++ hw/virtio/vhost-user-device.c | 324 ++++++++++++++++++++++++++ hw/virtio/meson.build | 3 + 4 files changed, 443 insertions(+) create mode 100644 include/hw/virtio/vhost-user-device.h create mode 100644 hw/virtio/vhost-user-device-pci.c create mode 100644 hw/virtio/vhost-user-device.c diff --git a/include/hw/virtio/vhost-user-device.h b/include/hw/virtio/vhost-user-device.h new file mode 100644 index 0000000000..9105011e25 --- /dev/null +++ b/include/hw/virtio/vhost-user-device.h @@ -0,0 +1,45 @@ +/* + * Vhost-user generic virtio device + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_VHOST_USER_DEVICE_H +#define QEMU_VHOST_USER_DEVICE_H + +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" + +#define TYPE_VHOST_USER_BASE "vhost-user-base" + +OBJECT_DECLARE_TYPE(VHostUserBase, VHostUserBaseClass, VHOST_USER_BASE) + +struct VHostUserBase { + VirtIODevice parent; + /* Properties */ + CharBackend chardev; + uint16_t virtio_id; + uint32_t num_vqs; + /* State tracking */ + VhostUserState vhost_user; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + GPtrArray *vqs; + bool connected; +}; + + /* needed so we can use the base realize after specialisation + tweaks */ +struct VHostUserBaseClass { + /*< private >*/ + VirtioDeviceClass parent_class; + /*< public >*/ + DeviceRealize parent_realize; +}; + +/* shared for the benefit of the derived pci class */ +#define TYPE_VHOST_USER_DEVICE "vhost-user-device" + +#endif /* QEMU_VHOST_USER_DEVICE_H */ diff --git a/hw/virtio/vhost-user-device-pci.c b/hw/virtio/vhost-user-device-pci.c new file mode 100644 index 0000000000..41f9b7905b --- /dev/null +++ b/hw/virtio/vhost-user-device-pci.c @@ -0,0 +1,71 @@ +/* + * Vhost-user generic virtio device PCI glue + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-device.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserDevicePCI { + VirtIOPCIProxy parent_obj; + VHostUserBase vub; +}; + +typedef struct VHostUserDevicePCI VHostUserDevicePCI; + +#define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserDevicePCI, + VHOST_USER_DEVICE_PCI, + TYPE_VHOST_USER_DEVICE_PCI) + +static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vub); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_device_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_device_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_device_pci_instance_init(Object *obj) +{ + VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(obj); + + virtio_instance_init_common(obj, &dev->vub, sizeof(dev->vub), + TYPE_VHOST_USER_DEVICE); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_device_pci_info = { + .base_name = TYPE_VHOST_USER_DEVICE_PCI, + .non_transitional_name = "vhost-user-device-pci", + .instance_size = sizeof(VHostUserDevicePCI), + .instance_init = vhost_user_device_pci_instance_init, + .class_init = vhost_user_device_pci_class_init, +}; + +static void vhost_user_device_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_device_pci_info); +} + +type_init(vhost_user_device_pci_register); diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-device.c new file mode 100644 index 0000000000..b0239fa033 --- /dev/null +++ b/hw/virtio/vhost-user-device.c @@ -0,0 +1,324 @@ +/* + * Generic vhost-user stub. This can be used to connect to any + * vhost-user backend. All configuration details must be handled by + * the vhost-user daemon itself + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-device.h" +#include "qemu/error-report.h" + +static void vub_start(VirtIODevice *vdev) +{ + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret = vhost_dev_enable_notifiers(&vub->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret = k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, true); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + vub->vhost_dev.acked_features = vdev->guest_features; + + ret = vhost_dev_start(&vub->vhost_dev, vdev, true); + if (ret < 0) { + error_report("Error starting vhost-user-device: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i = 0; i < vub->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&vub->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); +} + +static void vub_stop(VirtIODevice *vdev) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&vub->vhost_dev, vdev, true); + + ret = k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); +} + +static void vub_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + bool should_start = virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&vub->vhost_dev) == should_start) { + return; + } + + if (should_start) { + vub_start(vdev); + } else { + vub_stop(vdev); + } +} + +/* + * For an implementation where everything is delegated to the backend + * we don't do anything other than return the full feature set offered + * by the daemon (module the reserved feature bit). + */ +static uint64_t vub_get_features(VirtIODevice *vdev, + uint64_t requested_features, Error **errp) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + /* This should be set when the vhost connection initialises */ + g_assert(vub->vhost_dev.features); + return vub->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATURES); +} + +static void vub_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserBase *vub) +{ + vhost_user_cleanup(&vub->vhost_user); + + for (int i = 0; i < vub->num_vqs; i++) { + VirtQueue *vq = g_ptr_array_index(vub->vqs, i); + virtio_delete_queue(vq); + } + + virtio_cleanup(vdev); +} + +static int vub_connect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + + if (vub->connected) { + return 0; + } + vub->connected = true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vub_start(vdev); + } + + return 0; +} + +static void vub_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + + if (!vub->connected) { + return; + } + vub->connected = false; + + if (vhost_dev_is_started(&vub->vhost_dev)) { + vub_stop(vdev); + } +} + +static void vub_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vub_connect(dev) < 0) { + qemu_chr_fe_disconnect(&vub->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vub_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vub_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + int ret; + + if (!vub->chardev.chr) { + error_setg(errp, "vhost-user-device: missing chardev"); + return; + } + + if (!vub->virtio_id) { + error_setg(errp, "vhost-user-device: need to define device id"); + return; + } + + if (!vub->num_vqs) { + vub->num_vqs = 1; /* reasonable default? */ + } + + if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { + return; + } + + virtio_init(vdev, vub->virtio_id, 0); + + /* + * Disable guest notifiers, by default all notifications will be via the + * asynchronous vhost-user socket. + */ + vdev->use_guest_notifier_mask = false; + + /* Allocate queues */ + vub->vqs = g_ptr_array_sized_new(vub->num_vqs); + for (int i = 0; i < vub->num_vqs; i++) { + g_ptr_array_add(vub->vqs, + virtio_add_queue(vdev, 4, vub_handle_output)); + } + + vub->vhost_dev.nvqs = vub->num_vqs; + vub->vhost_dev.vqs = g_new0(struct vhost_virtqueue, vub->vhost_dev.nvqs); + + /* connect to backend */ + ret = vhost_dev_init(&vub->vhost_dev, &vub->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + + if (ret < 0) { + do_vhost_user_cleanup(vdev, vub); + } + + qemu_chr_fe_set_handlers(&vub->chardev, NULL, NULL, vub_event, NULL, + dev, NULL, true); +} + +static void vub_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + struct vhost_virtqueue *vhost_vqs = vub->vhost_dev.vqs; + + /* This will stop vhost backend if appropriate. */ + vub_set_status(vdev, 0); + vhost_dev_cleanup(&vub->vhost_dev); + g_free(vhost_vqs); + do_vhost_user_cleanup(vdev, vub); +} + +static void vub_class_init(ObjectClass *klass, void *data) +{ + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + vdc->realize = vub_device_realize; + vdc->unrealize = vub_device_unrealize; + vdc->get_features = vub_get_features; + vdc->set_status = vub_set_status; +} + +static const TypeInfo vub_info = { + .name = TYPE_VHOST_USER_BASE, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserBase), + .class_init = vub_class_init, + .class_size = sizeof(VHostUserBaseClass), + .abstract = true +}; + + +/* + * The following is a concrete implementation of the base class which + * allows the user to define the key parameters via the command line. + */ + +static const VMStateDescription vud_vmstate = { + .name = "vhost-user-device", + .unmigratable = 1, +}; + +static Property vud_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_UINT16("virtio-id", VHostUserBase, virtio_id, 0), + DEFINE_PROP_UINT32("num_vqs", VHostUserBase, num_vqs, 1), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vud_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + device_class_set_props(dc, vud_properties); + dc->vmsd = &vud_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); +} + +static const TypeInfo vud_info = { + .name = TYPE_VHOST_USER_DEVICE, + .parent = TYPE_VHOST_USER_BASE, + .instance_size = sizeof(VHostUserBase), + .class_init = vud_class_init, + .class_size = sizeof(VHostUserBaseClass), +}; + +static void vu_register_types(void) +{ + type_register_static(&vub_info); + type_register_static(&vud_info); +} + +type_init(vu_register_types) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 4e81d10834..c0055a7832 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -15,7 +15,10 @@ if have_vhost system_virtio_ss.add(files('vhost.c')) specific_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.c')) if have_vhost_user + # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) + system_virtio_ss.add(files('vhost-user-device.c')) + system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) From patchwork Thu Oct 5 03:42:56 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: 729700 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp678519wrs; Wed, 4 Oct 2023 20:46:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5y8/hR6fV66ws0YS916JR/7Jy+x8K3cfqLjAv4+z8VbRrGqmAxuw4bn9AuLLBDYkI3n+k X-Received: by 2002:a05:620a:22c6:b0:773:f7b5:107f with SMTP id o6-20020a05620a22c600b00773f7b5107fmr3172419qki.78.1696477610444; Wed, 04 Oct 2023 20:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696477610; cv=none; d=google.com; s=arc-20160816; b=kdTZFQW+LgMCmArvtxtC+qEsJdZS9hW8MkQ0rIw/FN1BGrvFyN2mAgXRKBK0NZ3Onf NzKaVgpsLg/YBivjYMeox69BCB8rkXTKhtcO+eg5kC9pPRbKR2KfWPw4z0ok6Yrr4tTu ksgqaJppTisctWdK1g+ue7B6zgnziRjenJyJ8NF/sbkAdWUpJDH52/6bwjuuHWJ9OkFo Dwwae+V0jh7vKnh0/TDBrceem34qMI2Tr9xS1mj6JLSMeL//91x7Tt92F2FWhvMRz5Xs NSkBnRQ98VtJyxvUjC9ZraQ7ABKAasSyile12i20/fOvyTwrqM8I6U0dlDU0m4KZu/AE K4gg== 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=VdkDMoSG0ALTkXUGlr32gq6+4cpswzQxj8odNE61Qs8=; fh=hPfGPwxY64xgddKZ9HPqIBAlYYHqezKlrNe4066q3nk=; b=EerXZgWYxvr5XCvDB1xFsWvr+sRILIUi8aMJLOlWXOzFBlMqE+Ly4fC12I1Qg8uDWR s211dbQzE0jdMlcLvkbtWK7WuLqUs6FiWiDxmk3Ke0jr8uT3oC6ETqpclzQmsoSl2EYy V4Ltj2/reqDIvoX1ze4nEAkCYin5XyML8nQ5P2PKIy9c3Ep6WCFfRaCabujjcLt2XWEE /HSiQC2rGYRxBfAnbNnAGUby/8h4CmeshQEi5wXQhaNHjj0Zpse1G67ocCmetNTjlS5s QDBCpVWTVUkVVjUTjXtWqTdb5+smJE12R/0Kz7ZcxFFOsnW0eMTcOet0WP1i0UBVqv3m kW9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b+ENg8Gk; 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 br11-20020a05620a460b00b0076db6af9392si362969qkb.254.2023.10.04.20.46.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 20:46:50 -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=b+ENg8Gk; 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 1qoFGt-0001kX-Dp; Wed, 04 Oct 2023 23:43:31 -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 1qoFGr-0001hW-I3 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:43:29 -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 1qoFGp-00008q-OY for qemu-devel@nongnu.org; Wed, 04 Oct 2023 23:43:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696477404; 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=VdkDMoSG0ALTkXUGlr32gq6+4cpswzQxj8odNE61Qs8=; b=b+ENg8Gkeez0uM84C0e3SqesSOQtIjAlzSUxIiMBrT/DBmNOU1U/aovh/NgL6OyduNiMzt cAelQO+PQOP66QB5ogR+7eJ5X/Mf1ROTJqcYOdKmTAyNWATCfwC3ojc9HZ1qVxHSy4TwkH wIsC/34xut5r00V2zn5NEctjmEs8/n8= 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-328-bMnsi3nAPLGi0j89S_jJQw-1; Wed, 04 Oct 2023 23:43:01 -0400 X-MC-Unique: bMnsi3nAPLGi0j89S_jJQw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32588c87716so430646f8f.1 for ; Wed, 04 Oct 2023 20:43:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696477380; x=1697082180; 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=VdkDMoSG0ALTkXUGlr32gq6+4cpswzQxj8odNE61Qs8=; b=qv/0rbFysPr0b7ZkkPW2lk3HqHnZuJjnYUjYK0BB0CMaMFkcTV3Gkn/ltWJo/QeLeS ybfYmFFVt13vCdZZhHKBj0+P3TzB53jW+gncvi+hEe8GqHt1EiS3M3V3SDIBYuoow8yi 7dGkSKtzKV2wbJ7Qd2tDFSmYdKdShq6RYM4sgW6SX1LeON08Wp1Hd3Juh3+ldg2mlui5 A2ATtdLGUa6pkVuBkaklPVDITVkHDOJg9ZGw07/jHEOAvMhGzN/3vstJQcL9AV8cMLY/ 33aeQhyww1gMDOVdswj8ml7oUEOJeQaF4krLAI7zSln5ahKOHRpHJKA1VJWeLanryJiq DgZA== X-Gm-Message-State: AOJu0YzB2vZ9AwGwx3jaUbPnuu5YLGpRYJHYYcWLRQU/VuXxFpKrvrlj vtVWykLKa5JsuQw8+1XTaYpuVCEB/0g3OFFaIWLc5Drc7/8KQSqf+e/925GUVEkvIc6lDdxpOfJ 7XOyOzt3r0rDI/i0FA8eWLhNpMcn/+kW9oqBjo1PlLegAoNwrUUQiQ7DohKOKljwbau55 X-Received: by 2002:adf:f286:0:b0:31f:db1b:7296 with SMTP id k6-20020adff286000000b0031fdb1b7296mr3834108wro.21.1696477379834; Wed, 04 Oct 2023 20:42:59 -0700 (PDT) X-Received: by 2002:adf:f286:0:b0:31f:db1b:7296 with SMTP id k6-20020adff286000000b0031fdb1b7296mr3834100wro.21.1696477379520; Wed, 04 Oct 2023 20:42:59 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id p14-20020a056000018e00b0031984b370f2sm632633wrx.47.2023.10.04.20.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 20:42:58 -0700 (PDT) Date: Wed, 4 Oct 2023 23:42:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL v2 09/53] hw/virtio: add config support to vhost-user-device Message-ID: 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: Alex Bennée To use the generic device the user will need to provide the config region size via the command line. We also add a notifier so the guest can be pinged if the remote daemon updates the config. With these changes: -device vhost-user-device-pci,virtio-id=41,num_vqs=2,config_size=8 is equivalent to: -device vhost-user-gpio-pci Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-11-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-device.h | 1 + hw/virtio/vhost-user-device.c | 58 ++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost-user-device.h b/include/hw/virtio/vhost-user-device.h index 9105011e25..3ddf88a146 100644 --- a/include/hw/virtio/vhost-user-device.h +++ b/include/hw/virtio/vhost-user-device.h @@ -22,6 +22,7 @@ struct VHostUserBase { CharBackend chardev; uint16_t virtio_id; uint32_t num_vqs; + uint32_t config_size; /* State tracking */ VhostUserState vhost_user; struct vhost_virtqueue *vhost_vq; diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-device.c index b0239fa033..2b028cae08 100644 --- a/hw/virtio/vhost-user-device.c +++ b/hw/virtio/vhost-user-device.c @@ -117,6 +117,42 @@ static uint64_t vub_get_features(VirtIODevice *vdev, return vub->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATURES); } +/* + * To handle VirtIO config we need to know the size of the config + * space. We don't cache the config but re-fetch it from the guest + * every time in case something has changed. + */ +static void vub_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + Error *local_err = NULL; + + /* + * There will have been a warning during vhost_dev_init, but lets + * assert here as nothing will go right now. + */ + g_assert(vub->config_size && vub->vhost_user.supports_config == true); + + if (vhost_dev_get_config(&vub->vhost_dev, config, + vub->config_size, &local_err)) { + error_report_err(local_err); + } +} + +/* + * When the daemon signals an update to the config we just need to + * signal the guest as we re-read the config on demand above. + */ +static int vub_config_notifier(struct vhost_dev *dev) +{ + virtio_notify_config(dev->vdev); + return 0; +} + +const VhostDevConfigOps vub_config_ops = { + .vhost_dev_config_notifier = vub_config_notifier, +}; + static void vub_handle_output(VirtIODevice *vdev, VirtQueue *vq) { /* @@ -141,12 +177,21 @@ static int vub_connect(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VHostUserBase *vub = VHOST_USER_BASE(vdev); + struct vhost_dev *vhost_dev = &vub->vhost_dev; if (vub->connected) { return 0; } vub->connected = true; + /* + * If we support VHOST_USER_GET_CONFIG we must enable the notifier + * so we can ping the guest when it updates. + */ + if (vub->vhost_user.supports_config) { + vhost_dev_set_config_notifier(vhost_dev, &vub_config_ops); + } + /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { vub_start(vdev); @@ -214,11 +259,20 @@ static void vub_device_realize(DeviceState *dev, Error **errp) vub->num_vqs = 1; /* reasonable default? */ } + /* + * We can't handle config requests unless we know the size of the + * config region, specialisations of the vhost-user-device will be + * able to set this. + */ + if (vub->config_size) { + vub->vhost_user.supports_config = true; + } + if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { return; } - virtio_init(vdev, vub->virtio_id, 0); + virtio_init(vdev, vub->virtio_id, vub->config_size); /* * Disable guest notifiers, by default all notifications will be via the @@ -268,6 +322,7 @@ static void vub_class_init(ObjectClass *klass, void *data) vdc->realize = vub_device_realize; vdc->unrealize = vub_device_unrealize; vdc->get_features = vub_get_features; + vdc->get_config = vub_get_config; vdc->set_status = vub_set_status; } @@ -295,6 +350,7 @@ static Property vud_properties[] = { DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_UINT16("virtio-id", VHostUserBase, virtio_id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserBase, num_vqs, 1), + DEFINE_PROP_UINT32("config_size", VHostUserBase, config_size, 0), DEFINE_PROP_END_OF_LIST(), };