From patchwork Wed Oct 4 08:43:16 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: 729257 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp230509wrs; Wed, 4 Oct 2023 01:43:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoDF6F3truNcEt33b1ii7fJudVCkFIxyA5hp180Ca768doWmzbKybhLYGjvsGjbbJu1L40 X-Received: by 2002:a05:622a:296:b0:418:737:87d6 with SMTP id z22-20020a05622a029600b00418073787d6mr1756395qtw.55.1696409031346; Wed, 04 Oct 2023 01:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409031; cv=none; d=google.com; s=arc-20160816; b=CHGgOeG+FCkyobwSRZsIhymRBFlTqO3bP421jsDI6qT8Ip/X8g/Mknlp88Bmd4y9s7 GM5gvIwRTHtnNe5wfMQsWEvLJDYHPuT9eEf7YrsbX8hliDCDcuPOUIIhdXxheCpwdQVl dgRlK5yy2xbNb3B33TdxNIng11YQDT1x1ocy0FwR12S69Jppn4hRN4MyGLM0qUwmSaYf sLRLuUUb7Zc6uvBDovBCyi/51M78K9vPKDzE8vdwQgq7n+X8UtG9RF4cC+HpaOe2Rmdx HFoJbxEDxYrRz5zu7+lpn+FipZr+ZB6B9OD1bIlWAIrinVz8sjlkTK7k0AsJ2s+xXq6O gi3w== 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=vzViUkkCkJFPjQNxUT1vuuKF/bzLa6U727P5nTnI8K02JwPuvzxuwcyapmle0zV/wt Y7T+efKdBG8AjSFmH0+eFVJb7Bn1XE0olWkErTkYwrVMAq6ok5pkSOCUl6KSaE8TT72C 1+p9PWSxG9AQmXHUmNXGCoUXlrv6v0BBUs2ShAE5i/N5zqED10C5ok+iXPVIi4FoMJlx FbcLasYNFu0dcZtLCpFE/9RRpN2ttPy7L2RHYzuKOtrBGc6cK2dhFXm24HYujw9JQou1 8X26wPuP5/+17k2y89TQvfDortji57HCBMMIMrhejm0VABLeloHgwfXSs9duvMxHVKg6 ocEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fWYmquRy; 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 v2-20020a05622a014200b004009a10dcd0si1319745qtw.160.2023.10.04.01.43.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:43:51 -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=fWYmquRy; 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 1qnxTk-0002IV-8g; Wed, 04 Oct 2023 04:43:36 -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 1qnxTi-0002Eb-8J for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:34 -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 1qnxTg-0000uP-MF for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409011; 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=fWYmquRyTYk4Lt5GtfDpA/d+jtbUUdcI0pp8yn8YFvuO/LRu5KqOPdZMr383PbnfauJLZA 649cRXv1C3x0e8IG3aHrlDZAA6Kqk2JGkITRAWj0mvX/U6Q9osuHv96QKuGBAWeSvFAyzw To9VybFYmUI8FClAitA84N30b40+XJM= 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-538-k9SFH9qzNDWlay_fFAgqmw-1; Wed, 04 Oct 2023 04:43:20 -0400 X-MC-Unique: k9SFH9qzNDWlay_fFAgqmw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3248ebee5f4so1305429f8f.2 for ; Wed, 04 Oct 2023 01:43:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696408999; x=1697013799; 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=REyVPFFQfEWXUW7Huvtd9TxXaYo7dK6TUnWwgw//N+4zw06HckipdVxfr5jErXqZcM sNPw0moXW25y85HqKKSG3YCW+oO3wNuI7EQgmNKzMQcCi0QQoT+m0e9f8fjGxH7g5lcl db0mo9bT+sJJZwChHkhk6UQ/TCWg1Q8vIvKYp7++2ByiY5WwNiFF18b0vc2BtcKN9KyH cJtkHhM0B/6t3rWEsGHsMZc0PBkYAWOgNV28cEmRIF+CkhgOGdH7qG0raRoRB8y8wY3+ Zyl3UlCdIWvJNILTOgwiKAgv1Z8cgqqZlGb5NyI8YEa/tutTg/0ufl++kMA9j06ieTm2 Sl8A== X-Gm-Message-State: AOJu0YzHTNH22dGpstMo9+6CoeSIHUMG9099MD6bfU0RUOoWikIB+xib zoB/8lKDNjMzAU1dPy6qO5RxLAEDL2NTNySAV2D7ip+/0NhO9/u1ZJBqWu5RtHAwZnM7ECQvYhe N7rY7Yi94VnzGMxU94guXCz4cXRIhi47+DPAMQvMzYxANs0mQnfJjhaMqc6Me98AkAkyh X-Received: by 2002:a5d:6a4c:0:b0:31f:8a6d:e527 with SMTP id t12-20020a5d6a4c000000b0031f8a6de527mr1495199wrw.45.1696408998868; Wed, 04 Oct 2023 01:43:18 -0700 (PDT) X-Received: by 2002:a5d:6a4c:0:b0:31f:8a6d:e527 with SMTP id t12-20020a5d6a4c000000b0031f8a6de527mr1495182wrw.45.1696408998562; Wed, 04 Oct 2023 01:43:18 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id r5-20020a5d4e45000000b003176c6e87b1sm3461288wrt.81.2023.10.04.01.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:18 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:16 -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 02/63] hw/virtio: Propagate page_mask to vhost_vdpa_listener_skipped_section() 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é 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 Wed Oct 4 08:43:18 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: 729256 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp230504wrs; Wed, 4 Oct 2023 01:43:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS53jJlml6rxU6jTqcfNhKuXVuggGksv/tLw3ONOjcvsiqdSY4TjCVZ/J1rlbqRvpy1Vks X-Received: by 2002:a05:620a:1253:b0:76d:89c5:78a0 with SMTP id a19-20020a05620a125300b0076d89c578a0mr1491916qkl.63.1696409030507; Wed, 04 Oct 2023 01:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409030; cv=none; d=google.com; s=arc-20160816; b=IWg7f6+yy0Q1bmF5oPCnUn9zjiwmBsQHHNrRRp3Q2H1yyCE13J9yI18I/vB0tGd7/S FgJ3+4bUN9KJAQl/TU74FqaCpTrlon3iQQfLoNspHH6QvTAx6FT/RyllyLTkCFJdTyzN eOeB2U5EW+RORI0ugjHRfwHURS8LuA1pjajzg15IGsRbMSAXuZ7NKf6S8uXpbuB+571f C7UhZwt6LT0TA6RQRIRnoxKgAe3MK82iYEa3Z09Ze7A8ZfxczXDcB6HHV9Ck5BCZWMzE +x6PwoVt177L22PVpoAiEHwdX2KIs3lEnc7XUOhpLFATB3WOann5V585lJLXjyAY3Io3 LV0g== 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=VNjcEYCFtmKdVs4BFUFNU2ooJpDWHMH/Bi5kHSANkhvZvyR88YM6QrGPH+yoHRMYUV +i3AO7yO745lqvmbzh0LcjJ11106Eg6Tbbrm9G/lwugI+bhsjTS/5qaL60MiDJRtxLxH moIKvUFL/JZxij4T2lCVA4zDv9SiM1lahkBt6ADJehtrD/TxZcCtn7OwuUr7JkHyFWLl ao1xbiPm4/44INTuf7mXfSNzB/WQNeCPkzgQM3b+k0ZlEeifg25a3XXl42WEVEAZwSr3 FRo6OY4MmZvvuRK7h5d1x2eGi0/IsuVekSgWD++nbw2oo3lNm9Q4dL+DCFB9WN4/UEzQ u8sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RGCKn3Qh; 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 bs6-20020a05620a470600b00775a9cd3e75si1261306qkb.479.2023.10.04.01.43.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:43: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=RGCKn3Qh; 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 1qnxTe-0002BP-C6; Wed, 04 Oct 2023 04:43:30 -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 1qnxTc-00026i-90 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:28 -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 1qnxTZ-0000tJ-G1 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409004; 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=RGCKn3Qhq9MnHS2HLhKMIfUBQprb0Z42dv0QO06764zPGGrxtEHFQ4/rZdAN4y5aRm7qNc bUTzTTILzpGyueiIRtwVa69vHVvAcIfqELNeglxek9EoTpTNyRglvh/kSYhsp9UU99L3cT X4mR1VzJn+SMsRT0KmvE1/IWGk3WUh0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-AeRNtOT2PyCWU9xULHPEyA-1; Wed, 04 Oct 2023 04:43:23 -0400 X-MC-Unique: AeRNtOT2PyCWU9xULHPEyA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40554735995so13642665e9.1 for ; Wed, 04 Oct 2023 01:43:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409001; x=1697013801; 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=VG8mMO3rmnBpzmGod7m26FnmCJnAaqcOCb+I/2G4hLN4/Sl9iJp1YcbOyWr/3Y5fLI hLqt5lzAdUM9p4Uc3ViY05SnQHYE84+BvqNopg9nfjhtMoj9uM333FCMTj7ZWEZUPc1y yuT/tZxPCJaZZUvZ0AQYWRUF5P3hJTReuaDX3nR5GvlAFU9Cfx1R5RsZvRCw7SrnA5u5 gDZtQmOJRawCANrQitRSHYdPEyWAGfj3QmAoVfg09YoEJ/4JZFwQy2RstcXGlKETgYWF IOXfIn7fah6smuWyBCzFy8tz/FgjrKOD7PgUlfJ1Rq8R4sgrvldBN8dOGRx73q9bHssZ ET9w== X-Gm-Message-State: AOJu0YwAQSRTwS7lgD+dXfLEni6Bn+/1W4icG6eVPwngVzYh+htwj8D4 0Qkp/PUE4mASkiOq/vRjiYw+RKAE35ipeRxN34O4rZ3QCWHr9e0P+EZWCou0rIyZc+Y9YAxyQGi RQXTLbVEAgg12l1/IzBkw2/iD9N9me9rzqYC+xaQBDeRHI0z+RNBL5AcldUCepPt3CFIB X-Received: by 2002:a05:600c:1d9c:b0:406:8494:f684 with SMTP id p28-20020a05600c1d9c00b004068494f684mr951996wms.23.1696409001533; Wed, 04 Oct 2023 01:43:21 -0700 (PDT) X-Received: by 2002:a05:600c:1d9c:b0:406:8494:f684 with SMTP id p28-20020a05600c1d9c00b004068494f684mr951983wms.23.1696409001269; Wed, 04 Oct 2023 01:43:21 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id r7-20020a5d6c67000000b00327df8fcbd9sm3274619wrz.9.2023.10.04.01.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:20 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:18 -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 03/63] hw/virtio: Propagate page_mask to vhost_vdpa_section_end() Message-ID: <7867e42e54e7721ef944e8b767b6b1965096be82.1696408966.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_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 Wed Oct 4 08:43:21 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: 729255 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp230431wrs; Wed, 4 Oct 2023 01:43:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE69/YaxqfnRK3ukqxJoL23WAPKM57SH0pftKNuGS4/I7UwS4o41RIryPpSKmRoXKSlUTXb X-Received: by 2002:a05:6214:328c:b0:656:32a0:febd with SMTP id mu12-20020a056214328c00b0065632a0febdmr1784589qvb.35.1696409017754; Wed, 04 Oct 2023 01:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409017; cv=none; d=google.com; s=arc-20160816; b=Qj36/qH6DlQ66xVFYw3kwd/qD+MZFlqn1b/m3V5QtyaAUYl+pMY1XfAVypxtJ4xC1c A+lQYm1OjTMLOfYnFGUkI362/3s2rakAnD+A/ekdYv80n1Yc7/CtZyhCEVcMOvRdUkot oR6KP/sDhpwQeDZLfo3wYeA85HQC7WnPDuRWAKc6iWspIJfXg0foc1zk93uN8mWcNAiQ VKLe+0dq707RvyRUwo2GtlGF16A1U3nMM/qPLstLcsP05FDu6C/+mhprPm6qxTytFall bdswhjHSh/zUgtgn6oGBV4hH8+UP/EjMXGwHCC7txRMCzgv5pNgh/dIz6RipCGhrx/yx H1hg== 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=HdVXuqZqlFxJ5+q66fXZbe6zcoy6zl5QYkGeTcAdxyU/tAnGOsH8oFxt7zSUpHaYHF 4gmEjPEF6xNW3yQa/RYEaNTZXFXfk3e+AkTWhUK+XwZmgqAOLXnuzWga4eeBlWVHQVP9 3cFox93krgiU4Intm/ydcapTtSB4XxcbbJM/oB+bUVPUZH8zTHe1cf08v3KnXh1JjVpB 8ZcmpHk9069Jrv1tgojovfFu0p8yL9oYQt/UiFqTXyDda+OFlFQy+7fbh4v0EDlp5sBP RgVUGJNOi6ehnrNYDX6zSEBVomBmiICQ46NyrzKJBiKRZ7jTOY6dnAdGnShQXOIIs/Af vaiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ULDnp/nM"; 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 t18-20020a0ce2d2000000b006563889d9e8si1275429qvl.428.2023.10.04.01.43.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:43:37 -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="ULDnp/nM"; 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 1qnxTf-0002EF-6W; Wed, 04 Oct 2023 04: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 1qnxTd-000297-CH for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04: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 1qnxTb-0000tj-Pb for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409007; 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=ULDnp/nMFRk6/GV6rKWGkUa2Oj1bJ9fgObvejX03mK7qnecIT1UXzLD+c0Pr4vodQL7yqD kU3YmNyHqvIPuofuab3jv2rzqMMbUH+qbuf53MDK5fdpRVWUQh1x9b58q7LRwKazJtoexu RlezH9wXA6R9yIpmOBo9uyr5wOOOLCA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-5GByD0ClNg-yF6gpiFvsQw-1; Wed, 04 Oct 2023 04:43:25 -0400 X-MC-Unique: 5GByD0ClNg-yF6gpiFvsQw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3231f43fc5eso1406070f8f.2 for ; Wed, 04 Oct 2023 01:43:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409004; x=1697013804; 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=u1pRs4eIE/6/En4TvSyt1QDNTPQIchtdsILgMX1siIaCGXs9LIRrHypjj0yuxBWYrl 4tytiSHeeY46eCJ2blUKwJqbgPjbJuxX0PzOgBjMbQRY+tuH8UQ79Cp3OmGKDyIhxuUH BvcSyTt/btMtU1ME3hANHzoSKlcMW1bxDOX/PpG9ufLCsJLLojGFJeE4xd3NQ8dZqEZh ESzxYxXW9BczPHRmdaT7TG+ssRk9fdN8EivoUPuL1fU/x++lenefj56m//n3Qxqd0NUD WjANpbaDfbBvesehEJ7bh4+JTS/9GI30Gx1v+BYDitTl8/S7EA9NEqfdgS0of5CfCbfJ My3A== X-Gm-Message-State: AOJu0YyPyi+Vc2wJMKYvFs8X+fe22C/JeElbWEZ4FoKotLZwkHnze4OS WN817LoiXIFE3zyBfwrafbdWl+ZqyN4whjOV0a90VlWXTyYlPbX9WjBVJYjcTspFdG7WT7QCyjH dnZGWmuSwRDeT3+vjnFzofDQWlT13Yh8j8j3cIBFExAerfjlbVCORwA2w2wCUPDAWNvn/ X-Received: by 2002:a5d:654d:0:b0:322:5251:d798 with SMTP id z13-20020a5d654d000000b003225251d798mr1287098wrv.70.1696409004184; Wed, 04 Oct 2023 01:43:24 -0700 (PDT) X-Received: by 2002:a5d:654d:0:b0:322:5251:d798 with SMTP id z13-20020a5d654d000000b003225251d798mr1287084wrv.70.1696409003794; Wed, 04 Oct 2023 01:43:23 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id f16-20020adff590000000b0032326908972sm3440984wro.17.2023.10.04.01.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:23 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:21 -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 04/63] hw/virtio/vhost-vdpa: Inline TARGET_PAGE_ALIGN() macro 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é 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 Wed Oct 4 08:43:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 729259 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp230702wrs; Wed, 4 Oct 2023 01:44:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDwsiqN6sfA7UN4pndb+WoQl/XPclOSGxaCbAg8u1Q/ZmMjKuDd3Jfb3XhUMv7SjP7Lp1z X-Received: by 2002:a0c:cd8f:0:b0:64e:c5da:49e4 with SMTP id v15-20020a0ccd8f000000b0064ec5da49e4mr1730847qvm.60.1696409074363; Wed, 04 Oct 2023 01:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409074; cv=none; d=google.com; s=arc-20160816; b=WAaR/WG1Sg6SQD087gODK8H+vGYrtSeByGM7ZsYq3alHwTW7P53HshZwYZxRyY3/uW zwURZ3kX3EUZtvXQ7rBJV7LuCq2xZ5LrAyAdO0sIEOEM1vEBznkIq2iQBvDLiiXDIccv Y2ZVYVY7jeb/qkdKOR3Iou037VayrzWfqJt5fUV+j/yKJjAPOCYI3h4UYDjTU0Ao2Crb 0IR3lF0W8Dc8h4CnCta+nMtUNzNyWxq9UbHoFs3U8E+naFUBMS249KCk9v/PEU4wtWtA oebWUYesNG02YM4Cb+B/9iYZaBe/whdTA1VlrRVcOPeG08DNHdA8TbwiIU3vIGGcS+ou DEtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Qziaif5jFzedGkKOEqZ/+iEupJFwfjmUm3vm30zmedI=; fh=6kCN9vTKNVCSGTvmjcT1TuFe7NLSoSzjT5BiydqGMys=; b=kMO0QG1fjzwLmuNg52vDVxGO71O1eaSU/6PhwFL3hJJ1VS9VkrGf8pM2SuYq9Xp4h3 VwOfasPnAiRq1OOX7+o89VV4QiOkBICIQ9hr2N6Nq3sugdnvyoEllflnq3l+8kaHxMj9 tUqkDIkccKb3WMmENs5VYPTf45Gqj2ToRJDjudOWxK6RvrekqH6rUddUubEPbvAO7Nn5 xKekANMc3gjU+xU08ZKHc0Pc04H9H/GxicWCanUadqZUL4/IM+dJO/fzNoNZKirE6+WV G3rhG3Wg1eG13bhHWhttzGffU2yOuhF27tcvnky9b+dbO2cuqa1w+xe7T9jiL1hpwWYF DdPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TlIC+9nw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g19-20020a0caad3000000b006585e61c845si1287357qvb.100.2023.10.04.01.44.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TlIC+9nw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnxTr-0002Tq-W0; Wed, 04 Oct 2023 04:43:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnxTq-0002Ql-51 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnxTj-0000v3-MM for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qziaif5jFzedGkKOEqZ/+iEupJFwfjmUm3vm30zmedI=; b=TlIC+9nwTsRQtzIxCBjOaxI5XDuNy+Ml8oX9GNUExelcv49Lr3KvSo2Uummf3W+tNP//69 za+kStmDgnT1siynKCiqlyeweh2gjbY5QWN10aDVZ4gCxZ5/saipKBdQchRSZDLw6hrypS r4ZxXKMyuzNYxZ7/5mCyUCV/qJhMnXc= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-Ggog96xwOqqguAz5p6UiJQ-1; Wed, 04 Oct 2023 04:43:28 -0400 X-MC-Unique: Ggog96xwOqqguAz5p6UiJQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3233a13b47eso1468458f8f.1 for ; Wed, 04 Oct 2023 01:43:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409007; x=1697013807; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Qziaif5jFzedGkKOEqZ/+iEupJFwfjmUm3vm30zmedI=; b=uFGKWIR4D2tNN8LazlC/I1jwTKYSuS1DGHtZ9gy8xGVJc3Cvzq9V6JeIgFf38guS0X 7Nzat4yNckqaw/XA6HD/hrQjFcatw0beqQ7ETsEfiE1d64lLs7yaOVz25eJCZpILvoQ8 5Vv/lspdtmh9Hf20ndCvjWGX0pvVjjQuPQL5YSRqB60CDhHudVkOvrs54qSZk6o4jd6b zjzRzxnGxDJiTARriMq8liKuuPON7GtDKDzoa3ZQ9njxl6iaWK/+6ROOqFd4M3XjKKq+ 0wZW6GGv1CJSOE5bt0oeBq6Z7ILNO5UTMgVtchpeZ4YDQpTgEf96wBNajM9DfiVO5KmF mB2A== X-Gm-Message-State: AOJu0Yya7v1+Kamlp0IzbYiNXJKulGoSL7sZ5lfOvvcd63vfDQv72E6o yoIoO+IUfUxjngOrLl8dLTT3hcUqOVDbR/dIiw4uk8U5K7abWC9L0ngq/2/r5G3X6BMBS0UIYur uTN03pV+MSgXbdbJLihiuZqcPViS9ahYtI9ra7P8oijeH2eBVsv02QA7j0LZUe2FegvDs X-Received: by 2002:a5d:664d:0:b0:31f:d3e3:a53d with SMTP id f13-20020a5d664d000000b0031fd3e3a53dmr1544506wrw.2.1696409006895; Wed, 04 Oct 2023 01:43:26 -0700 (PDT) X-Received: by 2002:a5d:664d:0:b0:31f:d3e3:a53d with SMTP id f13-20020a5d664d000000b0031fd3e3a53dmr1544497wrw.2.1696409006568; Wed, 04 Oct 2023 01:43:26 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id v8-20020adfe4c8000000b003247d3e5d99sm3449577wrm.55.2023.10.04.01.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:26 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?q?Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL 05/63] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_mask() Message-ID: <44dc75dd15ca86317d9d892e0311f2721bfa4b41.1696408966.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Similarly to commit e414ed2c47 ("virtio-iommu: Use target-agnostic qemu_target_page_mask"), Replace the target-specific TARGET_PAGE_SIZE and TARGET_PAGE_MASK definitions by a call to the runtime qemu_target_page_size() helper which is target agnostic. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230710094931.84402-5-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 0e0ed6d7ac..50b932a930 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -14,6 +14,7 @@ #include #include #include +#include "exec/target_page.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "hw/virtio/virtio-net.h" @@ -23,7 +24,6 @@ #include "migration/blocker.h" #include "qemu/cutils.h" #include "qemu/main-loop.h" -#include "cpu.h" #include "trace.h" #include "qapi/error.h" @@ -313,9 +313,11 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, Int128 llend, llsize; void *vaddr; int ret; + int page_size = qemu_target_page_size(); + int page_mask = -page_size; if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first, - v->iova_range.last, TARGET_PAGE_MASK)) { + v->iova_range.last, page_mask)) { return; } if (memory_region_is_iommu(section->mr)) { @@ -323,16 +325,16 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, return; } - if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != - (section->offset_within_region & ~TARGET_PAGE_MASK))) { + if (unlikely((section->offset_within_address_space & ~page_mask) != + (section->offset_within_region & ~page_mask))) { trace_vhost_vdpa_listener_region_add_unaligned(v, section->mr->name, - section->offset_within_address_space & ~TARGET_PAGE_MASK, - section->offset_within_region & ~TARGET_PAGE_MASK); + section->offset_within_address_space & ~page_mask, + section->offset_within_region & ~page_mask); return; } - iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE); - llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); + iova = ROUND_UP(section->offset_within_address_space, page_size); + llend = vhost_vdpa_section_end(section, page_mask); if (int128_ge(int128_make64(iova), llend)) { return; } @@ -398,25 +400,27 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, hwaddr iova; Int128 llend, llsize; int ret; + int page_size = qemu_target_page_size(); + int page_mask = -page_size; if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first, - v->iova_range.last, TARGET_PAGE_MASK)) { + v->iova_range.last, page_mask)) { return; } if (memory_region_is_iommu(section->mr)) { vhost_vdpa_iommu_region_del(listener, section); } - if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != - (section->offset_within_region & ~TARGET_PAGE_MASK))) { + if (unlikely((section->offset_within_address_space & ~page_mask) != + (section->offset_within_region & ~page_mask))) { trace_vhost_vdpa_listener_region_del_unaligned(v, section->mr->name, - section->offset_within_address_space & ~TARGET_PAGE_MASK, - section->offset_within_region & ~TARGET_PAGE_MASK); + section->offset_within_address_space & ~page_mask, + section->offset_within_region & ~page_mask); return; } - iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE); - llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); + iova = ROUND_UP(section->offset_within_address_space, page_size); + llend = vhost_vdpa_section_end(section, page_mask); trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(int128_sub(llend, int128_one()))); From patchwork Wed Oct 4 08:43:26 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: 729258 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp230609wrs; Wed, 4 Oct 2023 01:44:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKaTRpHO6/PxNt3I07x/8TjGIa1g9CigDcl+ZbPMWhm2ekxr24EBDTzq2T7FIRJ0wwWjuY X-Received: by 2002:a05:620a:4489:b0:76f:20df:f038 with SMTP id x9-20020a05620a448900b0076f20dff038mr2174416qkp.12.1696409053158; Wed, 04 Oct 2023 01:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409053; cv=none; d=google.com; s=arc-20160816; b=l9uPN/F6WgmL9UyvKv2GqkiottSyAs+nMQ4/Bp1bes6joY0VcAuwgVcQSHoPb1jh5C mjN+RVs8EmNqsaDkG3q8WHrr+Ju6T9YcJdnY5loINKzG+qAcM+5uSp82NoAtKcO+CrtW QVW7CtJdTLpJp/DGJZW5vh+fLo3gI02IEKaOPSJjbg4kgxTgJNMSdQkuVjMtyC9B0s2t wak7kRF6BAWivl3HAbN033ruw2wRNl8j9oR66QV6pSFZZmEjo+JgPW/dAsCusQ9GGc4+ ZpcY88NIfSxumaJ7VbZSpeYTSKJ+eS1KupoAAUpiM5BZD55+AWhMPzh9BHs5JGdygE/4 D0eA== 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=e6gpTUhLPHxKG4d5Vv8sddHW0jktLS4t2IePXrCJX8ar2t3gsLsEpQXiFDik/3vJwP D1guDk7eMQ5gQphXgWs260bTpfa/a5AxVo7u15bK00Unk9NQDbNBmtQnm6bedhPMHacx jtyNTamR7opsu3osAUHfgIXkw/pIgJPyXHI4Tv0zilI2afMMYxV7xQPSUSgqLMHvb6VP YXh+xcgEXICujjKdpR357dXCJ5O6ZqIaq1rncxtSYSu22aLU3TpldnVygoK/h1c0VQ1l z0GQZt2HIAcULNzJLn27+MqHQygnoC1wcOFMJLKA0+C316wLbh+EpybncIx2GsmAkO1n ORsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QA2Eu4CD; 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 u10-20020a05622a198a00b0040fe2df28c6si1333326qtc.723.2023.10.04.01.44.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:44:13 -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=QA2Eu4CD; 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 1qnxTo-0002Nn-Vg; Wed, 04 Oct 2023 04:43:40 -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 1qnxTj-0002Gx-Jv for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:35 -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 1qnxTi-0000uZ-3N for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409013; 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=QA2Eu4CDBGQf94I+3GjtjkKIhJsk9zQOQxsu8O+aiRWPi9UKB5Ywn8FumMSV+n38kztjwz 9WLEvHtJV+beKE/gZXApeSMR1F2BerFAr9Rhf66IeD3+SX4NOvuwlh1sHa4MG97JJEFxDF JxXZzStozYyuYouwNhX4tckvmahPA6M= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-BPlVbzWpN3q9JfYcgFYjdA-1; Wed, 04 Oct 2023 04:43:31 -0400 X-MC-Unique: BPlVbzWpN3q9JfYcgFYjdA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-323306960e3so1345460f8f.1 for ; Wed, 04 Oct 2023 01:43:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409010; x=1697013810; 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=W7/RqWXR4mZkB05uIBGsmVjkTE32ZvjANy6NlbZ7wR5+w+HwaO4CEd9gzMoiJhSu/r Nq9Z4wxCUnuEOx7ds1OK1Yyo3w9w1i8QqQK1uT73/aPN0DlHZ1aRa1LVr+JZ2RbEz5lX d179GX6CP6YxISDf3l8+5y52yB08OJFu5KbU1T1yloMWJabqSjjDG7DhQBibWovXb8YG GkJxidJmmntHGIn2TCv5eLtFbHH3RVIUyYmj5RCUavjXi8sUcjokd/duDzQM7ZA58vvt Vm5LoJ1YyAurlQx8OUXeTJasMvRaFASEhxTTUazNO0XFaNcoKHxRSrvfeQiCAv2C9ECM ZhVA== X-Gm-Message-State: AOJu0Yz83dsamD76yhGhPBvwnREvU084f2irG32e5RdU9X/BjYNB9LEK SejU06KtdQHge0ywmvjNb3/9ZNhNkqSHRr4lGVIK/bl0MQjN6iObewKDONQIplXmR5Ah3arTfyT 79m4PNyv7OQ8Ty7gg2rX7uHsD6kNuLaDFY7YCiSz31yl8jqPlq7ykTXMSZ6B9boaLwrkZ X-Received: by 2002:adf:f2d2:0:b0:321:6953:6ad6 with SMTP id d18-20020adff2d2000000b0032169536ad6mr1315527wrp.16.1696409009821; Wed, 04 Oct 2023 01:43:29 -0700 (PDT) X-Received: by 2002:adf:f2d2:0:b0:321:6953:6ad6 with SMTP id d18-20020adff2d2000000b0032169536ad6mr1315515wrp.16.1696409009552; Wed, 04 Oct 2023 01:43:29 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id f16-20020adff590000000b0032326908972sm3441158wro.17.2023.10.04.01.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:28 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:26 -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 06/63] hw/virtio: Build vhost-vdpa.o once Message-ID: <3b8527dd1aa75330f3d7f937b828e75ebc66075b.1696408966.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.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 Wed Oct 4 08:43:29 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: 729262 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp231970wrs; Wed, 4 Oct 2023 01:49:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlsO7aytbunvkJ6QmxmuzM4emWqAxZXaRISAmSVPerGQhiIIPL/vLNdVjKZlHY2mB2J0zg X-Received: by 2002:a05:600c:2a4e:b0:3fe:fc0f:52e2 with SMTP id x14-20020a05600c2a4e00b003fefc0f52e2mr1621341wme.37.1696409366641; Wed, 04 Oct 2023 01:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409366; cv=none; d=google.com; s=arc-20160816; b=HKmq3ZYhdOjAW52nvuaUw8Y3J5feM08V7q80FsbTOLM3gyXEZeBW+EL93zy2XbVACV g0rYvSpUuUFUYyL209fggN9pSXqKoSBINKBmsfHhwPYbm7sDp+YNBxyymzxN9NmyFRK9 avfzLHpRzdsrVXrkeSOs35N9NFFqAM8bcAwl9EsZsH81nB6i2yb2tCEs3yDLSnmyidSP F02/kbkKDEz5xXLd3i/j25gfXlwB1E2AWzSllYXgZHL2GCq3a/blSVwKrzPlmUlZwIVy XBBEJcKtPTbeEl8Bh7L+ELOYpJecpHOlicO4fVhndD2FKc7GsLrpWNkbx8k5yyew6sec Of+g== 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=J3o43m8Oxy1Rqb9OO7Z+JuBf253E0/ZDt0RjvYiJAiE+8cVcm1xrVgemICXAQYG8s3 4Vmk0R0FbqU4eYBazHmVUYjeCJm+H6bCGAf8fLjPT9uNtyfKHnC+q2Z8tbaK7K9ljYsg ecrbvHdT27Xmm8JI4JUMCQj3y6iZX1e7xC1nylSxOOr8QijDhhcX9zLzyCw9HROGjMUK +H6C8POCTmB6GQU/T4xTxoDRIhNStItX3C2ZEH8pMZMUWTndFI/9IhnoMpde+jG39HXM t5OSISFBEKBhOOimiu/8HZh6CPNlm259jZFerpFHCLlvy/jqPhrm/fVPtVKJ/tO6hT7m te8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="bIj2oem/"; 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 ay34-20020a05600c1e2200b003fe9eb22077si589627wmb.110.2023.10.04.01.49.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:49:26 -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="bIj2oem/"; 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 1qnxTu-0002Wb-AN; Wed, 04 Oct 2023 04:43:46 -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 1qnxTs-0002Up-Ll for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:44 -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 1qnxTk-0000vM-OP for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409016; 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=bIj2oem/9ecK0SQm0er8YiUviINECY+KUT+P9OxVXOsVlRjgmt0+YHwJeEhgEkJdC5noPL /Ll2XfN+V6BFDLq84zkF/zyWGQUKByTx/iu2WAvALLckHENr4JegSodLOyJ8dFmb+XrnXO MLFfBHznvC+WvqcGEPXhhS4b2PWtv44= 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-612-Ly1weHnyMJ-FduMSBTJ23w-1; Wed, 04 Oct 2023 04:43:34 -0400 X-MC-Unique: Ly1weHnyMJ-FduMSBTJ23w-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-32320b3ee93so1406342f8f.3 for ; Wed, 04 Oct 2023 01:43:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409013; x=1697013813; 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=o1jlDSxRl9bOFpOP0uqI6OS9VnNSTt1zcJg2b7pob22N62FyZOasCCxKoyw23o41pD exTN3k2m+UiVVJ4/V2l9kGuA5FQNrXoSRLaVtpW5UyoQtQ546VMPQy3Po6u5CNObn5JN mltkqvbCPFtZvZrnlUxxVVI/ysZ0SnGC3kuBQu8z6/vxlfkqv0ncY+iryeqI2kjCyR8r fZWYK6OHrQWIK4pTsSfTXGrBA5xM2Dfuu24p46M5XVahRGB4KSNhqhBdb7ypboYwWf9i iZL1PprrTjj2OGlPTuzny9gad22L8LysVTelvz++JArmKly7irBAYgISYUtpTbJZadVt Srvg== X-Gm-Message-State: AOJu0YxJnOC6XPiMPv943Q+wx+G3wbBctyJkoWTJKVUgI0kgeYa5PTWc pWSOA28uj5TIqw5FE1CqM72+ycXVBZVe3E4ywndJ+RoN598YXIeQOXlkoZ9sg53DdgaMn++quns zq7+Of7ENvNoPrRG9v6ZrXLwEXtTtQXgmykM8v59pEVcIf0VAh9QETXmZNZJouHenbuU7 X-Received: by 2002:a5d:494f:0:b0:31a:d266:3d62 with SMTP id r15-20020a5d494f000000b0031ad2663d62mr1479509wrs.54.1696409012807; Wed, 04 Oct 2023 01:43:32 -0700 (PDT) X-Received: by 2002:a5d:494f:0:b0:31a:d266:3d62 with SMTP id r15-20020a5d494f000000b0031ad2663d62mr1479490wrs.54.1696409012456; Wed, 04 Oct 2023 01:43:32 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id e31-20020a5d595f000000b0031fbbe347e1sm3456960wri.65.2023.10.04.01.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:31 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:29 -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 07/63] 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 Wed Oct 4 08:43: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: 729261 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp231017wrs; Wed, 4 Oct 2023 01:45:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHz2UgMEEHaWjH7mAF1PAdGyluHIWAR0KMRrkIgJ4zR7EBX4TJwllaomkWzg71IUjTmrHe2 X-Received: by 2002:a05:622a:1a1a:b0:412:258f:1b76 with SMTP id f26-20020a05622a1a1a00b00412258f1b76mr2136100qtb.49.1696409152496; Wed, 04 Oct 2023 01:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409152; cv=none; d=google.com; s=arc-20160816; b=n9Ehj8ODMsD1tQITQJ61/3wMDte1RV96+MXCfR9i/Z+xRpy6LSMgkPpKAoZagD/WYi 2+FRI/2l5ahiuvTpLgnaSPwZ9IELSUZD2efJDkHbECxgE7B5UAEg2jW4HFaufo5q0mPo jL17QrUGxsJ7D+4JUGv1JTsmDLB4S5QsF3ooeFROnu5sJAG21agz8uNc8Z3EfsVsBMIi SN9L0oeOsbH/anmn+HDM1T4blJzNns/eyIbOz6aVKcGC+yWGkfRITkhHGq5gcjruO3QG l6lpqeWLNfmjAcrWB3ij+kbjScQXo+V7TVrFQUAgzpcGy8V/0Xg8DW1GALXyAh82N63C qVAQ== 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=kw0v8pBUhvXNvi+oi+1auQPTo7anxovGBLzkea/KYj0lQ+ZtaOROONsbjFnrOWkThW URvh2FLWcXd9sLRifzvA2Xjbx038UIDFk75E9pbG6HKEQ3s2zYm8aHMyA8b+L9OtmAg4 72AA164qjUpiNTXTCsXaIJJ8q+sBxr2aVV44jOxYQFAKLjN3aSoxtphT6Zjni2soUM0O CnY3rYIpm1PWdWSoqUpikEC7S+ZP6HXRjsjO6/hWoIEXkcIz59nXgPdY/HXkkp+ITCJt RktaeYidt+FnaeMIhqCiK8TckTDMKea3qdAddVs4F/X3RRnJHKMlxz86k7KtCjkokGxY o2BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VYHOKxmp; 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 14-20020ac8594e000000b004196644bd44si1313203qtz.731.2023.10.04.01.45.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:45:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VYHOKxmp; 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 1qnxUH-0003VU-Uv; Wed, 04 Oct 2023 04:44:10 -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 1qnxU1-0002rK-Hq for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:55 -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 1qnxTz-0000zt-3e for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:43:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409030; 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=VYHOKxmpdZ5GXL7499lrYoCzOvEXS0JpKy6KH3l+ClwkZ1flMouQmzt98I88KeM/HS6mIP jrS2BJqrtecFaObE58jjFHM5cmnYmATYq/hm4T2FjUid3xODuZ3eL8AtbNBpTjYTUzjnHq z0GeW4UBW8jmOiatmH2xiUm2MUiRIVo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-PbHKiFDvMkKJ-RoeqqN--w-1; Wed, 04 Oct 2023 04:43:39 -0400 X-MC-Unique: PbHKiFDvMkKJ-RoeqqN--w-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3251bc06680so1462875f8f.2 for ; Wed, 04 Oct 2023 01:43:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409017; x=1697013817; 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=BI/XDjT3odaY3WHjOqOw31oyQ1uuVMzrx/rCXbVZKoO2GsHP+uY0/mDIBqxfpJ1oOX HBVlylWJGbPezUgIbZ4XCBgtJOVr/fSn3U3Yenn475CgbIVAe8yZxGlhNBhV/yy1RR3g PiYGkOO5fa9nZ4wcz9qos8BEY3j0FfDlT3dgPhZLtMAVLmd3nqLEpdITmVAlXaE6IV5/ ZJjUjRMdC0Zt6aq0qMPv/fdygvAP1fch3OuAZ8q+HjRj4QQDH8957RnFZ+z8rEDVKIkq apdTOBLZU16DSdnZiis8GHHIFQOYYEbTJYv+UwqpUcIzz/xm/OABEa/MZQq77qzQOMMk jeCg== X-Gm-Message-State: AOJu0YwUtKXsF4skumEhkXTQT+I3YJraSa5fo1BmGTbWZapHY9Q2m+rd J3WsDHUWHzvaevO1sR8+tjjlMNu4k35ejHCxJEvVNBvLMjr2BrE4H8qnSnAFGS+V9bEnyXFmf+k RwKJvs/tNr8zFJ0NlLiV6tKyzI95V9BxRdqcaQvku/vnIWDjYT94Y8awzo0DY4tyPuTIZ X-Received: by 2002:adf:f9cc:0:b0:31f:98b4:4b62 with SMTP id w12-20020adff9cc000000b0031f98b44b62mr1299070wrr.37.1696409017536; Wed, 04 Oct 2023 01:43:37 -0700 (PDT) X-Received: by 2002:adf:f9cc:0:b0:31f:98b4:4b62 with SMTP id w12-20020adff9cc000000b0031f98b44b62mr1299055wrr.37.1696409017062; Wed, 04 Oct 2023 01:43:37 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id j14-20020a5d464e000000b0031f8a59dbeasm3424236wrs.62.2023.10.04.01.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:36 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 08/63] 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.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 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 Wed Oct 4 08:43:37 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: 729260 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp230807wrs; Wed, 4 Oct 2023 01:44:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGriDyUrIDFaqsbNFg6APCTlMRHcvPfTc9veuZyAPebN0vZSKhqaEXgpKkBwbtzdUU5VGNY X-Received: by 2002:ad4:57a1:0:b0:65d:d:a114 with SMTP id g1-20020ad457a1000000b0065d000da114mr1547804qvx.55.1696409096759; Wed, 04 Oct 2023 01:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409096; cv=none; d=google.com; s=arc-20160816; b=kQ39z0FvFPqtrNWSQXYFqj6BDhpcFDS3LuH+fzrBMUA1J9krPAoYycOdltTAxrYGCP xSnm1F66zrGApu23WPPFgVfZ43BdJsvDoALn6Em4xpeblkcP31awcpNrmLtpFy0hOHX6 OjAk+jFauu5C17kR0J2sJNMf0noIENKPhS3Of5t/vcm0s6S/roMKH+fQ7qh82UbdYMsw huIb3nZLfLzPJ/wfO8T8oOw9Uxl4RRqr94pwd84mnqxVtMqPK1iJSuTjO6mAdS+IbZi+ ExcYbaBVrWZTXfgb17XC11ivkfxHE8jFwwSCkGcKnhgmW0TjtyAuxf9fxEc+oPtsR32l Wjag== 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=e+6fbxbRmEeTNZuXRaIwvrtC4ahXu3GUaVHouZfHZTMdmiCRHTtWW3VZN2Qaj7wE9U J2VBJFw8WrlrudKJuGYkOCMJiGhgL+vmOMbkbT75IsaZqLhEZHQbJlFEcyvqoOonhyGt /z0qi53Qt/As/ItFT9rm51xjnapWEspXxM8wKSH1Ed7uN0DRzYhctpdxblWf8vR+gGvm wzP+Sx/LC7mLWBBbWFj3lo1sgd8QB7tivcsaMjytztCK5ApWrigBVBBhJ4UAl0hDmDGM 4RwKZsGqRZNHg7iL/XRehe00gOrtNddHLagDO1U1Y4pxOkaKv8hNXNFXLMCEQtp6NW9B 9rSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Oby9UZPO; 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 n15-20020a0c9d4f000000b0064f4589991esi1252208qvf.320.2023.10.04.01.44.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 01:44:56 -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=Oby9UZPO; 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 1qnxUK-0003je-GS; Wed, 04 Oct 2023 04:44:12 -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 1qnxUB-0003BS-Dc for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:44:05 -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 1qnxU9-00016k-E4 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 04:44:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696409040; 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=Oby9UZPOeEEhzzHgMmsY2KvsmOxmyoepmJnV0MjAseNik1/Dc02Pm+mVYuWvZGEMpLe2U5 yjsnGxbtVhp+BdXtZvxmLsy/Dhmg8UIuw5W+te42utVIG1eveeGyj/qHlNbjFXnp/umN6i aydvo1gUYLkSYwDRscMwPtaoRVBVhTY= 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-56-8cDxAEQqPNSrp_baVY66aw-1; Wed, 04 Oct 2023 04:43:42 -0400 X-MC-Unique: 8cDxAEQqPNSrp_baVY66aw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40566c578b7so14656265e9.0 for ; Wed, 04 Oct 2023 01:43:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696409021; x=1697013821; 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=X7EoW6PuuDVWOoFNc7gylmin2WZcwXSvUKenq/tvE3Urs/HY7K6Uvlmnnd7hbaqxmw 6qLutxbJkNv+QYNE9evAoMcEiuPQnF1lExLn7HVOJcRtK6i05NuTKAoQkRyGFNECnAtm aRzUApjp96RNY7Z1pu73YSObADj/xcfrt2brgcp/+7kSXtzpGWTMGYg0o+hXOxNvbv2d ej8szOfixn/k6JOhwEqUVpLts9Albx7vxAvqgb6JvCpPb4baXaN9tRwJBwgT0x2eMnBc m3WL3sSev8qd4EQ5y46Q4kI6ghiZVI+uaKVmIUtLXx4l4upy6mGhMk+1cIUd5SC83Xgw 0bJA== X-Gm-Message-State: AOJu0Yw2NM+jPgqOScAGxVM0rWoBF2Ux7DCTMLBUSjQrLln1aBJTHXbv FBeDIVR4c8bn4RSMCEARdR2yeqfn6EACvMZUZ7Kh2VKdYMRya75lLnk2VznWb0LA8sM7bnbNOGj +WedjdCsgh8J2T9yskr0laocwN0mgNwCsMZMKqmRxnC8lZweq6UHYCDxZL3+C1lyLWe1j X-Received: by 2002:a05:600c:2146:b0:401:daf2:2735 with SMTP id v6-20020a05600c214600b00401daf22735mr1581552wml.31.1696409020961; Wed, 04 Oct 2023 01:43:40 -0700 (PDT) X-Received: by 2002:a05:600c:2146:b0:401:daf2:2735 with SMTP id v6-20020a05600c214600b00401daf22735mr1581537wml.31.1696409020581; Wed, 04 Oct 2023 01:43:40 -0700 (PDT) Received: from redhat.com ([2.52.137.96]) by smtp.gmail.com with ESMTPSA id t25-20020a1c7719000000b004065daba6casm932528wmi.46.2023.10.04.01.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:43:39 -0700 (PDT) Date: Wed, 4 Oct 2023 04:43:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 09/63] hw/virtio: add config support to vhost-user-device Message-ID: <45387e1d94f4c7bad460b98bbf6b929b0fda27e6.1696408966.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_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(), };