From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635810888727491.1593158939771; Mon, 1 Nov 2021 16:54:48 -0700 (PDT) Received: from localhost ([::1]:60346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhh8Z-0007lc-GQ for importer@patchew.org; Mon, 01 Nov 2021 19:54:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgye-0001xL-HC for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24327) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyb-0004EN-PW for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:31 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-440-EkCow1UtPqKBD2PLGWkYUw-1; Mon, 01 Nov 2021 19:44:27 -0400 Received: by mail-ed1-f69.google.com with SMTP id h16-20020a05640250d000b003dd8167857aso17112962edb.0 for ; Mon, 01 Nov 2021 16:44:27 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id e11sm3252010ejs.86.2021.11.01.16.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810268; 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: in-reply-to:in-reply-to:references:references; bh=t0CVIufzFIccsDBoCkRGFq3WYs0bvTA+xkE09ZtdLKA=; b=DqhffrW8+ky2qPu+5qn38WFiKaSQIGAQ9ZhaBoldRJhmpAeJ4d7g0pz6NwtFcUQgtbBQcg P58pv1Gx4uZmEie+KhFrOC+2a5mf23y2xUdbHHT8MiCu32pZzExyLjlDzsyLZm5j/EOEdY llJjFbD9xHMMTLosGxb3dYEsQOa2Iyw= X-MC-Unique: EkCow1UtPqKBD2PLGWkYUw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=t0CVIufzFIccsDBoCkRGFq3WYs0bvTA+xkE09ZtdLKA=; b=5+LdFwu2HXx3BEg4Kot2r0O1KpV+MFk3DDfBRoaLTZgr4qR1PtXXmWL8JpkLw+IUgs ehw+53Z6CSumQEWLk1jM85ooDl954YugjCaquIS5m3JoxRUJjqB9MIwrJkd3I2ICIJzH eIb/GRTiuUKO3J5SEThUmjjUS3sq1+jOSt8Hj09orcr7B7STTcuQGDp1uxktbhRjn8l0 4Qo4+rK9mjYQLRu7MS+CthkXn1Pl09uy4AV6OLZalrQrZKyzMfTik5tPhWjtasOl/QDx mvRBsuxRQ+yWYJj7u572QedRuCc3Dyvm4yHzbGVly369ShmC2OXc6ruk63HOtR8boahE ojyw== X-Gm-Message-State: AOAM532ZfMlNErZsnjNzBntaMBSlbz9BmX3ezDpHaajF95udyaJexsAU aiTFR4ESypGaif2pj1/W/M7BVDDgJyIy/fizrGrxJCyslZ2XIP51GcQFeWVkEQgSvsBkKcBaCRa /JzXC1z1LPJlhAy/O3WdVJMKjWc7B9Fn/felhVCgb5YHwnqIZquPt/K4WVifj X-Received: by 2002:a17:906:ce2c:: with SMTP id sd12mr13166088ejb.45.1635810266076; Mon, 01 Nov 2021 16:44:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHPdCyXKSaC/rhWYPjAOVeprUaR2M4VBO/GnFqT6hLqc3HLYkUgPCAtZCQFsHd/k5Bc/eUNw== X-Received: by 2002:a17:906:ce2c:: with SMTP id sd12mr13166059ejb.45.1635810265834; Mon, 01 Nov 2021 16:44:25 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 1/9] qtest: fix 'expression is always false' build failure in qtest_has_accel() Message-ID: <20211101234358.582487-2-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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: , Cc: Peter Maydell , Thomas Huth , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Jason Andryuk , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635810889639100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov If KVM is disabled or not present, qtest library build may fail with: libqtest.c: In function 'qtest_has_accel': comparison of unsigned expression < 0 is always false [-Werror=3Dtype-limits] for (i =3D 0; i < ARRAY_SIZE(targets); i++) { due to empty 'targets' array. Fix it by making sure that CONFIG_KVM_TARGETS isn't empty. Fixes: e741aff0f43343 ("tests: qtest: add qtest_has_accel() to check if tes= ted binary supports accelerator") Reported-by: Jason Andryuk Suggested-by: "Michael S. Tsirkin" Signed-off-by: Igor Mammedov Message-Id: <20211027151012.2639284-1-imammedo@redhat.com> Tested-by: Jason Andryuk Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index b092728397..ab4a5723f0 100644 --- a/meson.build +++ b/meson.build @@ -75,7 +75,7 @@ else kvm_targets =3D [] endif =20 -kvm_targets_c =3D '' +kvm_targets_c =3D '""' if not get_option('kvm').disabled() and targetos =3D=3D 'linux' kvm_targets_c =3D '"' + '" ,"'.join(kvm_targets) + '"' endif --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635810866288583.4849390608683; Mon, 1 Nov 2021 16:54:26 -0700 (PDT) Received: from localhost ([::1]:59784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhh8D-0007NH-0F for importer@patchew.org; Mon, 01 Nov 2021 19:54:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyg-0001zM-Tu for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyd-0004Ev-Nz for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:32 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-eruyulRXNO-l4wVPWfQA-g-1; Mon, 01 Nov 2021 19:44:30 -0400 Received: by mail-ed1-f72.google.com with SMTP id i9-20020a508709000000b003dd4b55a3caso17100645edb.19 for ; Mon, 01 Nov 2021 16:44:30 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id j3sm7431963ejo.2.2021.11.01.16.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810271; 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: in-reply-to:in-reply-to:references:references; bh=A3LGy7m0a6Lv9FilCkeTDw+UTCQZG+QwE+4p+n4BnOY=; b=Bcz0dtDIUul7U5F9voDcaYf7NCcI2ugWtOjyfaPO1D2/Vu+jcZ1QNxZ1A0v5kP8ka5Zfe/ 7xP1B3iHJ+UWqTsp0QWBQXcsoi0RKcEavU1cP6uefcpPAn4UAYDUreJw72hxsjBM+Jz9Dw Gf07MngO+OE7F0aBMcuwdVrxlZf2UWA= X-MC-Unique: eruyulRXNO-l4wVPWfQA-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=A3LGy7m0a6Lv9FilCkeTDw+UTCQZG+QwE+4p+n4BnOY=; b=gT7MhWMvaSXC6L1GRg0Yac6H8BDOg1jnjr4pqOgJ2GfX6CViFE7LHfIzwE7vto9HKu LabAS+S7WuaJno8nYYibL7S13BKlaXT80I1kt3qSkm/tOb6AIJt6iqk71LJSYE+K5UL6 273wZQh1yXLXmSQKeCXrFYA1H9jWIOVm+it9VDeDXcm1SDwqAU1GlqEihsXXqFJZI0do r8JxQhrMdCMlM+Mjn3bwnlvh7OSMxL9YcOcPFQP1sYJK1xtLhKU/nKeFctzFSG6db1pQ rna0jyT2w2XI8pm38q26ORIldJ4B5GG8CKN191g5UyEKErAUUrhP4qMl+2CxS3nI5fDx VW1Q== X-Gm-Message-State: AOAM533wTU7u4UQgxz0kcN9+tbiWGKCQBHvorUepyZY/R4Mo9Yy+76fW +o3VURev4fk0+7WAse2ue79PDUO7+8kDohMy2ldq/L+gLvZn0kndA0ZY5WyWm+7xhBk5yMFyzxi AY9EyR1aNthLNmDoBa/LL+mrOqR21vk9MAmMzhZ357Xp64WWEdVDLUhfnBQcc X-Received: by 2002:a05:6402:42ce:: with SMTP id i14mr44798271edc.276.1635810268870; Mon, 01 Nov 2021 16:44:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq6JVtK2VavkmWztazy2cxKb37xep+Q3FtrzQ7fkjn3xyZ+wDOBX+5X9jnzB42xCGFbWjStA== X-Received: by 2002:a05:6402:42ce:: with SMTP id i14mr44798249edc.276.1635810268736; Mon, 01 Nov 2021 16:44:28 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 2/9] vhost-vdpa: Set discarding of RAM broken when initializing the backend Message-ID: <20211101234358.582487-3-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Cc: Peter Maydell , Jason Wang , Stefano Garzarella , Cindy Lu , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635810868519100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Similar to VFIO, vDPA will go ahead an map+pin all guest memory. Memory that used to be discarded will get re-populated and if we discard+re-access memory after mapping+pinning, the pages mapped into the vDPA IOMMU will go out of sync with the actual pages mapped into the user space page tables. Set discarding of RAM broken such that: - virtio-mem and vhost-vdpa run mutually exclusive - virtio-balloon is inhibited and no memory discards will get issued In the future, we might be able to support coordinated discarding of RAM as used by virtio-mem and already supported by vfio via the RamDiscardManager. Acked-by: Jason Wang Cc: Jason Wang Cc: Michael S. Tsirkin Cc: Cindy Lu Signed-off-by: David Hildenbrand Message-Id: <20211027130324.59791-1-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella --- hw/virtio/vhost-vdpa.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 12661fd5b1..0d8051426c 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -331,6 +331,17 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void= *opaque, Error **errp) struct vhost_vdpa *v; assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); trace_vhost_vdpa_init(dev, opaque); + int ret; + + /* + * Similar to VFIO, we end up pinning all guest memory and have to + * disable discarding of RAM. + */ + ret =3D ram_block_discard_disable(true); + if (ret) { + error_report("Cannot set discarding of RAM broken"); + return ret; + } =20 v =3D opaque; v->dev =3D dev; @@ -442,6 +453,8 @@ static int vhost_vdpa_cleanup(struct vhost_dev *dev) memory_listener_unregister(&v->listener); =20 dev->opaque =3D NULL; + ram_block_discard_disable(false); + return 0; } =20 --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16358111187411016.8239061406956; Mon, 1 Nov 2021 16:58:38 -0700 (PDT) Received: from localhost ([::1]:40614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhhCH-0005Hz-9T for importer@patchew.org; Mon, 01 Nov 2021 19:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyl-00020f-5C for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42917) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyi-0004FY-VO for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:38 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-f3syQuwOPGWGSg2ey36i3A-1; Mon, 01 Nov 2021 19:44:34 -0400 Received: by mail-ed1-f69.google.com with SMTP id h16-20020a05640250d000b003dd8167857aso17113113edb.0 for ; Mon, 01 Nov 2021 16:44:34 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id ho30sm1073398ejc.30.2021.11.01.16.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810275; 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: in-reply-to:in-reply-to:references:references; bh=V9FWr0j37d3VBNphNAtMkiS5bz48/xHnQY0wdPZWJX8=; b=fqDiaWz5XkXyw5kxYziPvHc89uhD+dVYVgKvacgQ18szH4hffOvrGyhmYF5NMjToQpejnx ZNKTlnJwtiwpgiglgIDq4IZ3MGwFtRVSEfgdWj543F67Jsc2Jubw09AjqwEKwchMK5zzgk pgSFCbUZLZn8J5/zBO8+EsNopb2+6/c= X-MC-Unique: f3syQuwOPGWGSg2ey36i3A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=V9FWr0j37d3VBNphNAtMkiS5bz48/xHnQY0wdPZWJX8=; b=Weijk+Y/thW6UrkZlWc/yF0CMLYVTdpv5malCu/TFdVPF6PGD0togQmCBt5x/SZZ+w bcOMr2sEnB0BAY8R1PW5KGY/Wb1TrUTf9rymkmBDo1NqeB6TMoSyXvu0GV5OrAYANxkl k6eN47q3cK2iHDpdjuCv3D/tIuB2s3J02vq32L+85o2JwFsiL7Tud2VFITpvrhf2P0Mp uR0rZCdK+CyaHPMjASiul1x06ZeqzZ5w2RAlEvP2OcRIp57oE2nqGLoq03pJyRNb/Jzv SxMcIHc4gyY3H5nEWoKW4M4FZVRHaApLMEJ4QljeM54+kOq1RRrpzskzYOJRZ+wAlwwZ 1p5Q== X-Gm-Message-State: AOAM533KMmLAKEAzx9DG5LKLyXJfOkAanOFUY3pxuKPUGPs/rTVNi1N5 5SzT/8lAD8tX1yKKYpr1rbeMgYGFLOjI4NGniWmBYZt9DdU5AbPJOgU8AxJHao8VfwIjzVu0A9/ awBvobDG+I3XFpJz72j6arRezxTp3yhdJlqyzK9D0yakZ+j5zToAXLpSCNAxq X-Received: by 2002:a50:d50c:: with SMTP id u12mr45760085edi.118.1635810272319; Mon, 01 Nov 2021 16:44:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0l+XQ3FouWeS8Qkde1Ap4Mqp4tBuTCKrA6kZDFEvfp2odEF0QdgdEXKgFPzeBXECWJuJoHA== X-Received: by 2002:a50:d50c:: with SMTP id u12mr45760044edi.118.1635810272068; Mon, 01 Nov 2021 16:44:32 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 3/9] hw/acpi: Add VIOT table Message-ID: <20211101234358.582487-4-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635811120291100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker Add a function that generates a Virtual I/O Translation table (VIOT), describing the topology of paravirtual IOMMUs. The table is created if a virtio-iommu device is present. It contains a virtio-iommu node and PCI Range nodes for endpoints managed by the IOMMU. By default, a single node describes all PCI devices. When passing the "default_bus_bypass_iommu" machine option and "bypass_iommu" PXB option, only buses that do not bypass the IOMMU are described by PCI Range nodes. Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20211026182024.2642038-2-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/viot.h | 13 +++++ hw/acpi/viot.c | 114 ++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/Kconfig | 4 ++ hw/acpi/meson.build | 1 + 4 files changed, 132 insertions(+) create mode 100644 hw/acpi/viot.h create mode 100644 hw/acpi/viot.c diff --git a/hw/acpi/viot.h b/hw/acpi/viot.h new file mode 100644 index 0000000000..9fe565bb87 --- /dev/null +++ b/hw/acpi/viot.h @@ -0,0 +1,13 @@ +/* + * ACPI Virtual I/O Translation Table implementation + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef VIOT_H +#define VIOT_H + +void build_viot(MachineState *ms, GArray *table_data, BIOSLinker *linker, + uint16_t virtio_iommu_bdf, const char *oem_id, + const char *oem_table_id); + +#endif /* VIOT_H */ diff --git a/hw/acpi/viot.c b/hw/acpi/viot.c new file mode 100644 index 0000000000..c1af75206e --- /dev/null +++ b/hw/acpi/viot.c @@ -0,0 +1,114 @@ +/* + * ACPI Virtual I/O Translation table implementation + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/viot.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_host.h" + +struct viot_pci_ranges { + GArray *blob; + size_t count; + uint16_t output_node; +}; + +/* Build PCI range for a given PCI host bridge */ +static int build_pci_range_node(Object *obj, void *opaque) +{ + struct viot_pci_ranges *pci_ranges =3D opaque; + GArray *blob =3D pci_ranges->blob; + + if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { + PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; + + if (bus && !pci_bus_bypass_iommu(bus)) { + int min_bus, max_bus; + + pci_bus_range(bus, &min_bus, &max_bus); + + /* Type */ + build_append_int_noprefix(blob, 1 /* PCI range */, 1); + /* Reserved */ + build_append_int_noprefix(blob, 0, 1); + /* Length */ + build_append_int_noprefix(blob, 24, 2); + /* Endpoint start */ + build_append_int_noprefix(blob, PCI_BUILD_BDF(min_bus, 0), 4); + /* PCI Segment start */ + build_append_int_noprefix(blob, 0, 2); + /* PCI Segment end */ + build_append_int_noprefix(blob, 0, 2); + /* PCI BDF start */ + build_append_int_noprefix(blob, PCI_BUILD_BDF(min_bus, 0), 2); + /* PCI BDF end */ + build_append_int_noprefix(blob, PCI_BUILD_BDF(max_bus, 0xff), = 2); + /* Output node */ + build_append_int_noprefix(blob, pci_ranges->output_node, 2); + /* Reserved */ + build_append_int_noprefix(blob, 0, 6); + + pci_ranges->count++; + } + } + + return 0; +} + +/* + * Generate a VIOT table with one PCI-based virtio-iommu that manages PCI + * endpoints. + * + * Defined in the ACPI Specification (Version TBD) + */ +void build_viot(MachineState *ms, GArray *table_data, BIOSLinker *linker, + uint16_t virtio_iommu_bdf, const char *oem_id, + const char *oem_table_id) +{ + /* The virtio-iommu node follows the 48-bytes header */ + int viommu_off =3D 48; + AcpiTable table =3D { .sig =3D "VIOT", .rev =3D 0, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + struct viot_pci_ranges pci_ranges =3D { + .output_node =3D viommu_off, + .blob =3D g_array_new(false, true /* clear */, 1), + }; + + /* Build the list of PCI ranges that this viommu manages */ + object_child_foreach_recursive(OBJECT(ms), build_pci_range_node, + &pci_ranges); + + /* ACPI table header */ + acpi_table_begin(&table, table_data); + /* Node count */ + build_append_int_noprefix(table_data, pci_ranges.count + 1, 2); + /* Node offset */ + build_append_int_noprefix(table_data, viommu_off, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); + + /* Virtio-iommu node */ + /* Type */ + build_append_int_noprefix(table_data, 3 /* virtio-pci IOMMU */, 1); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 1); + /* Length */ + build_append_int_noprefix(table_data, 16, 2); + /* PCI Segment */ + build_append_int_noprefix(table_data, 0, 2); + /* PCI BDF number */ + build_append_int_noprefix(table_data, virtio_iommu_bdf, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); + + /* PCI ranges found above */ + g_array_append_vals(table_data, pci_ranges.blob->data, + pci_ranges.blob->len); + g_array_free(pci_ranges.blob, true); + + acpi_table_end(linker, &table); +} + diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 3b5e118c54..622b0b50b7 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -51,6 +51,10 @@ config ACPI_VMGENID default y depends on PC =20 +config ACPI_VIOT + bool + depends on ACPI + config ACPI_HW_REDUCED bool select ACPI diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build index 7d8c0eb43e..adf6347bc4 100644 --- a/hw/acpi/meson.build +++ b/hw/acpi/meson.build @@ -20,6 +20,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghe= s.c'), if_false: files( acpi_ss.add(when: 'CONFIG_ACPI_PIIX4', if_true: files('piix4.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_true: files('pcihp.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_false: files('acpi-pci-hotplug-s= tub.c')) +acpi_ss.add(when: 'CONFIG_ACPI_VIOT', if_true: files('viot.c')) acpi_ss.add(when: 'CONFIG_ACPI_X86_ICH', if_true: files('ich9.c', 'tco.c')) acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'), if_false: files= ('ipmi-stub.c')) acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c')) --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635811565392450.3768743869655; Mon, 1 Nov 2021 17:06:05 -0700 (PDT) Received: from localhost ([::1]:49324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhhJT-0002nq-A8 for importer@patchew.org; Mon, 01 Nov 2021 20:06:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyp-00021J-AQ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyl-0004Fo-8Z for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:42 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-520-h1XGWQQ1MfC0TXJutb-TUw-1; Mon, 01 Nov 2021 19:44:37 -0400 Received: by mail-ed1-f71.google.com with SMTP id o22-20020a056402439600b003dd4f228451so17040017edc.16 for ; Mon, 01 Nov 2021 16:44:37 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id hv9sm7512045ejc.51.2021.11.01.16.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810278; 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: in-reply-to:in-reply-to:references:references; bh=jd+7SCo+cPq4PXfrJicKIgmeVY5J4cyEzVidCztEKUY=; b=aJMNHYOHogwzQ0ZqzG7Fr4zS3ftLrw5JBzEBE+3ZaLOOMsHgVc4USH8AdAkRvBfwsaOz8b /EXZJw6tvlt2q/M35iMLU+qKFl7INIfBwdILLR7zQVW7O+rVkCaLVfGW/Sie7WtBuSY06W K/eT8/pEi2FvbpHWtyAvrabDaTiTq2U= X-MC-Unique: h1XGWQQ1MfC0TXJutb-TUw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jd+7SCo+cPq4PXfrJicKIgmeVY5J4cyEzVidCztEKUY=; b=LQw08ADcgDTB82zTBrkqmT0fSqlnpNmuO8NqWeDwY57gew+6jbGXR/I7L0PGxlidPz R8uWLjXf8HIMxNFaQKaAu6QPggGQBULhZOXx7fCnB+1u45CqiaLTi30HVHX6a584GLx7 gRymlu9ieho/n5l5Uojih4Yk9cJC5Jl+MkfuTv+2XvZQZjN/r+pMIhnfIwmjv0AT2BAP SeCAQPWgSI7unQeEMCrtd/iJ5c3zBO5Rw9hpw/9T4M0qZbdyCJTTe07SASzyTaBJ51hy QC0CHxOdtBs2JTnztCwJaHrpoReWAXYmQuaGsoQeaLkOvbk9p/XgatjM4Lc0IGjnFwPx 7tqg== X-Gm-Message-State: AOAM533+88gmQfU2lcHHxmeVXQGcMaCp2KMjjngyb2WmO/AQYqqnv3+g y5g1vWiAr08ZGIj9Ce8npBTbI6jYzwHVcyza1sidNbKhT+lk3CfK8/8jG5mrLY5WR6CZH7n7zzp OQFx3+MYapgTanF40S6qvjnvGLYbNtdpWqirW6JKiNK3xv1bfPzVp3DI0qMR9 X-Received: by 2002:a17:906:1683:: with SMTP id s3mr27246301ejd.331.1635810275954; Mon, 01 Nov 2021 16:44:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwaPF4na+Y8jCWNtma8gH5bwC5KSi1PoF7JExA82Hi2H1mXvDEVDD9VEhKPBBhZD7tsK3Z4Q== X-Received: by 2002:a17:906:1683:: with SMTP id s3mr27246253ejd.331.1635810275628; Mon, 01 Nov 2021 16:44:35 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 4/9] hw/i386/pc: Remove x86_iommu_get_type() Message-ID: <20211101234358.582487-5-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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: , Cc: Peter Maydell , Eduardo Habkost , Jean-Philippe Brucker , Jason Wang , Richard Henderson , Peter Xu , Eric Auger , Paolo Bonzini , Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635811566664100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker To generate the IOMMU ACPI table, acpi-build.c can use base QEMU types instead of a special IommuType value. Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov Signed-off-by: Jean-Philippe Brucker Message-Id: <20211026182024.2642038-3-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/x86-iommu.h | 12 ------------ hw/i386/acpi-build.c | 20 +++++++++----------- hw/i386/amd_iommu.c | 2 -- hw/i386/intel_iommu.c | 3 --- hw/i386/x86-iommu-stub.c | 5 ----- hw/i386/x86-iommu.c | 5 ----- 6 files changed, 9 insertions(+), 38 deletions(-) diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h index 9de92d33a1..5ba0c056d6 100644 --- a/include/hw/i386/x86-iommu.h +++ b/include/hw/i386/x86-iommu.h @@ -33,12 +33,6 @@ OBJECT_DECLARE_TYPE(X86IOMMUState, X86IOMMUClass, X86_IO= MMU_DEVICE) typedef struct X86IOMMUIrq X86IOMMUIrq; typedef struct X86IOMMU_MSIMessage X86IOMMU_MSIMessage; =20 -typedef enum IommuType { - TYPE_INTEL, - TYPE_AMD, - TYPE_NONE -} IommuType; - struct X86IOMMUClass { SysBusDeviceClass parent; /* Intel/AMD specific realize() hook */ @@ -71,7 +65,6 @@ struct X86IOMMUState { OnOffAuto intr_supported; /* Whether vIOMMU supports IR */ bool dt_supported; /* Whether vIOMMU supports DT */ bool pt_supported; /* Whether vIOMMU supports pass-through */ - IommuType type; /* IOMMU type - AMD/Intel */ QLIST_HEAD(, IEC_Notifier) iec_notifiers; /* IEC notify list */ }; =20 @@ -140,11 +133,6 @@ struct X86IOMMU_MSIMessage { */ X86IOMMUState *x86_iommu_get_default(void); =20 -/* - * x86_iommu_get_type - get IOMMU type - */ -IommuType x86_iommu_get_type(void); - /** * x86_iommu_iec_register_notifier - register IEC (Interrupt Entry * Cache) notifiers diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 81418b7911..ab49e799ff 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2488,6 +2488,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) PCMachineState *pcms =3D PC_MACHINE(machine); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); X86MachineState *x86ms =3D X86_MACHINE(machine); + X86IOMMUState *iommu =3D x86_iommu_get_default(); GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; AcpiPmInfo pm; @@ -2604,17 +2605,14 @@ void acpi_build(AcpiBuildTables *tables, MachineSta= te *machine) build_mcfg(tables_blob, tables->linker, &mcfg, x86ms->oem_id, x86ms->oem_table_id); } - if (x86_iommu_get_default()) { - IommuType IOMMUType =3D x86_iommu_get_type(); - if (IOMMUType =3D=3D TYPE_AMD) { - acpi_add_table(table_offsets, tables_blob); - build_amd_iommu(tables_blob, tables->linker, x86ms->oem_id, - x86ms->oem_table_id); - } else if (IOMMUType =3D=3D TYPE_INTEL) { - acpi_add_table(table_offsets, tables_blob); - build_dmar_q35(tables_blob, tables->linker, x86ms->oem_id, - x86ms->oem_table_id); - } + if (object_dynamic_cast(OBJECT(iommu), TYPE_AMD_IOMMU_DEVICE)) { + acpi_add_table(table_offsets, tables_blob); + build_amd_iommu(tables_blob, tables->linker, x86ms->oem_id, + x86ms->oem_table_id); + } else if (object_dynamic_cast(OBJECT(iommu), TYPE_INTEL_IOMMU_DEVICE)= ) { + acpi_add_table(table_offsets, tables_blob); + build_dmar_q35(tables_blob, tables->linker, x86ms->oem_id, + x86ms->oem_table_id); } if (machine->nvdimms_state->is_enabled) { nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 9242a0d3ed..91fe34ae58 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1538,7 +1538,6 @@ static void amdvi_sysbus_realize(DeviceState *dev, Er= ror **errp) { int ret =3D 0; AMDVIState *s =3D AMD_IOMMU_DEVICE(dev); - X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(dev); MachineState *ms =3D MACHINE(qdev_get_machine()); PCMachineState *pcms =3D PC_MACHINE(ms); X86MachineState *x86ms =3D X86_MACHINE(ms); @@ -1548,7 +1547,6 @@ static void amdvi_sysbus_realize(DeviceState *dev, Er= ror **errp) amdvi_uint64_equal, g_free, g_free); =20 /* This device should take care of IOMMU PCI properties */ - x86_iommu->type =3D TYPE_AMD; if (!qdev_realize(DEVICE(&s->pci), &bus->qbus, errp)) { return; } diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 75f075547f..c27b20090e 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3806,9 +3806,6 @@ static void vtd_realize(DeviceState *dev, Error **err= p) X86MachineState *x86ms =3D X86_MACHINE(ms); PCIBus *bus =3D pcms->bus; IntelIOMMUState *s =3D INTEL_IOMMU_DEVICE(dev); - X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(dev); - - x86_iommu->type =3D TYPE_INTEL; =20 if (!vtd_decide_config(s, errp)) { return; diff --git a/hw/i386/x86-iommu-stub.c b/hw/i386/x86-iommu-stub.c index c5ba077f9d..781b5ff922 100644 --- a/hw/i386/x86-iommu-stub.c +++ b/hw/i386/x86-iommu-stub.c @@ -36,8 +36,3 @@ bool x86_iommu_ir_supported(X86IOMMUState *s) { return false; } - -IommuType x86_iommu_get_type(void) -{ - abort(); -} diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c index 86ad03972e..dc968c7a53 100644 --- a/hw/i386/x86-iommu.c +++ b/hw/i386/x86-iommu.c @@ -98,11 +98,6 @@ X86IOMMUState *x86_iommu_get_default(void) return x86_iommu_default; } =20 -IommuType x86_iommu_get_type(void) -{ - return x86_iommu_default->type; -} - static void x86_iommu_realize(DeviceState *dev, Error **errp) { X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(dev); --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163581111304360.02616842721159; Mon, 1 Nov 2021 16:58:33 -0700 (PDT) Received: from localhost ([::1]:40170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhhCB-0004zP-Ni for importer@patchew.org; Mon, 01 Nov 2021 19:58:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyr-00022h-Mp for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyo-0004GJ-Ue for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:45 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-N_zosMOtNuC2h-_vqyykaQ-1; Mon, 01 Nov 2021 19:44:40 -0400 Received: by mail-ed1-f70.google.com with SMTP id w11-20020a05640234cb00b003e0cd525777so12368942edc.12 for ; Mon, 01 Nov 2021 16:44:40 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id sd28sm1339174ejc.37.2021.11.01.16.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810281; 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: in-reply-to:in-reply-to:references:references; bh=dVILjbM3XJCaQkLgjAFWpZSW6dwsRFfaPUIs4btAH2g=; b=ckwqWhP703Z2VlSY6s9DvELMQLDF0NefhMYOtppkm8mNh5f3XugIN/OBFb1ZPTrkjLLqSS rwDYWqEwjKE2Rb/VDbmgte6pcVsVaokXFf3rcBaGUBbkbGf7v9C2jCDZw1wAjTRNmyKmVT BNQfEmdi6nLmT4OANUYEzQSkyrN/avM= X-MC-Unique: N_zosMOtNuC2h-_vqyykaQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dVILjbM3XJCaQkLgjAFWpZSW6dwsRFfaPUIs4btAH2g=; b=Dh/faa4yNxFwwtNO2Cim+dufDiGTRicT+LrMX3z2xNe3EWVjmAOHZHKqfJbdsBAigE FLuRwW4XsuA0SpLlQTr3McaIhpn9B6Gq879U/khNX3ELV2HuRBuqiYBQ1kOFaWagVAAr PHISAaHg3u05IKgAdpSE40oi5Bi0GJX5aNE9IOD5NBegwGIqcjBdrLJsEIgRg5FR1sqw cUJzfYmGhBUEu94znpryq2Y4cJwFGpGlWz2tQmbn2Xiu9hy8grVjCBbyM0p5C6uw1NtS 1tQaBtjJ3YTIyDYHdd4WWPvaHzt2OvzwVd0gFis32i7ZAgraOk4hVPVx3I0QW0vUXuAx jqFQ== X-Gm-Message-State: AOAM533ryTCZzDIWFx8cjPdAKDWK9j8KObsK0MPo9w29UP31V4zQYjUF 8uH9LsIKIy7GHa0qa7MMI2hbH4sIvUFlbDB5eafSD4V8418bKz4qXrwW30xxC6F1lyKO/X1Dk3s vPOWh5Z86rFaSWEGc4gYDAWe2KGG6k6csp7IzXbrNoMKqWm2Ye71Ib+fi6l01 X-Received: by 2002:a17:907:1b1f:: with SMTP id mp31mr39966529ejc.319.1635810279008; Mon, 01 Nov 2021 16:44:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz89k7tjClalT0XMcZIHxNVQkzsWOuJviFktKrirBVqK+CtxTnPtuXDWcj+Dw01yfXo2rvBkQ== X-Received: by 2002:a17:907:1b1f:: with SMTP id mp31mr39966489ejc.319.1635810278791; Mon, 01 Nov 2021 16:44:38 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 5/9] hw/i386/pc: Move IOMMU singleton into PCMachineState Message-ID: <20211101234358.582487-6-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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: , Cc: Peter Maydell , Eduardo Habkost , Jean-Philippe Brucker , Richard Henderson , Eric Auger , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635811114080100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker We're about to support a third vIOMMU for x86, virtio-iommu which doesn't inherit X86IOMMUState. Move the IOMMU singleton into PCMachineState, so it can be shared between all three vIOMMUs. The x86_iommu_get_default() helper is still needed by KVM and IOAPIC to fetch the default IRQ-remapping IOMMU. Since virtio-iommu doesn't support IRQ remapping, this interface doesn't need to change for the moment. We could later replace X86IOMMUState with an "IRQ remapping IOMMU" interface if necessary. Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov Signed-off-by: Jean-Philippe Brucker Message-Id: <20211026182024.2642038-4-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 1 + hw/i386/pc.c | 12 +++++++++++- hw/i386/x86-iommu.c | 28 +++++++++------------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 11426e26dc..b72e5bf9d1 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -35,6 +35,7 @@ typedef struct PCMachineState { I2CBus *smbus; PFlashCFI01 *flash[2]; ISADevice *pcspk; + DeviceState *iommu; =20 /* Configuration options: */ uint64_t max_ram_below_4g; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 86223acfd3..7b1c4f41cd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1330,6 +1330,15 @@ static void pc_machine_device_pre_plug_cb(HotplugHan= dler *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { pc_virtio_md_pci_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE)) { + PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + + if (pcms->iommu) { + error_setg(errp, "QEMU does not support multiple vIOMMUs " + "for x86 yet."); + return; + } + pcms->iommu =3D dev; } } =20 @@ -1384,7 +1393,8 @@ static HotplugHandler *pc_get_hotplug_handler(Machine= State *machine, if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_CPU) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE)) { return HOTPLUG_HANDLER(machine); } =20 diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c index dc968c7a53..01d11325a6 100644 --- a/hw/i386/x86-iommu.c +++ b/hw/i386/x86-iommu.c @@ -77,25 +77,17 @@ void x86_iommu_irq_to_msi_message(X86IOMMUIrq *irq, MSI= Message *msg_out) msg_out->data =3D msg.msi_data; } =20 -/* Default X86 IOMMU device */ -static X86IOMMUState *x86_iommu_default =3D NULL; - -static void x86_iommu_set_default(X86IOMMUState *x86_iommu) -{ - assert(x86_iommu); - - if (x86_iommu_default) { - error_report("QEMU does not support multiple vIOMMUs " - "for x86 yet."); - exit(1); - } - - x86_iommu_default =3D x86_iommu; -} - X86IOMMUState *x86_iommu_get_default(void) { - return x86_iommu_default; + MachineState *ms =3D MACHINE(qdev_get_machine()); + PCMachineState *pcms =3D + PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE)); + + if (pcms && + object_dynamic_cast(OBJECT(pcms->iommu), TYPE_X86_IOMMU_DEVICE)) { + return X86_IOMMU_DEVICE(pcms->iommu); + } + return NULL; } =20 static void x86_iommu_realize(DeviceState *dev, Error **errp) @@ -131,8 +123,6 @@ static void x86_iommu_realize(DeviceState *dev, Error *= *errp) if (x86_class->realize) { x86_class->realize(dev, errp); } - - x86_iommu_set_default(X86_IOMMU_DEVICE(dev)); } =20 static Property x86_iommu_properties[] =3D { --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635810785797652.1642565876675; Mon, 1 Nov 2021 16:53:05 -0700 (PDT) Received: from localhost ([::1]:57826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhh6u-00062q-IQ for importer@patchew.org; Mon, 01 Nov 2021 19:53:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyx-00023Y-PV for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgys-0004Gu-8P for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:51 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-Adw1jrjrMe-gIyADtn9f3w-1; Mon, 01 Nov 2021 19:44:44 -0400 Received: by mail-ed1-f71.google.com with SMTP id v9-20020a50d849000000b003dcb31eabaaso17145584edj.13 for ; Mon, 01 Nov 2021 16:44:44 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id o12sm9584008edw.84.2021.11.01.16.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810285; 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: in-reply-to:in-reply-to:references:references; bh=87si2iofmNbSxccGunRxGUaDXwE4hg4UwpFbhmuRxZ0=; b=f0ReRC6cEGafJdXpu4J7UG1BU8su5W8JeHjts+sDNcWnyp1MLb0lLE7R7BkQcWPvEdWWYV cpgZozfgVVdHpW0tcWsq0eUU+SwwwntYo6wJoT568rY/UYbn8P7ZVXiDnCQsSEMbyKz056 VdyTlg5dRdp36N2FAbtiH06RiNEKuYc= X-MC-Unique: Adw1jrjrMe-gIyADtn9f3w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=87si2iofmNbSxccGunRxGUaDXwE4hg4UwpFbhmuRxZ0=; b=nbd8SU+ky8G2Jh5/KJ0cNY3usU+mt8Eo0P7DXQrWWHBNpu8nnU55Mp4oKo5PydNGOk vXm4YR2dLlQTPd/Wm7azhzKZyxYxY+flHC8FqDdUWc/8yMNrTCc2x7gX8Qgzdksnmp0U RE7mLipc28W47DST/GCokMPCKNOLZ2S1rCgm/T8d9BQcnWhpj/Zwo2BzSSJUmsLpjPec hhlrFVK4dPScqqPDJHBNWaNtqkRRJGzz8EvEtm2KqGnxox/W+S04XIbMCaoq3Vo42o76 qEkLlLeGWpNK7u25mJfEFsaRGL9hwL51M8fdEZiMl6wPw+lAmu5KLqSwQQRIUaxeMz44 Qu4Q== X-Gm-Message-State: AOAM531ZYYPJ8rY8SYxF7Rx2OHRPJvm6eP9x93T9YQFLdq/CF7n26oXl jLbqo5aFGPzJgB00/DZGInT6mcI0vk8qAVoDC3h0zv1It5+q3/ibGV4I7DfLPQK/qVwUw9dcJtv DK/U4BJ+w8cK7thVzBQC9GpJ5s2pSGbhEzSKnfMBsTiKZ1tN0RheVJyNWKRE3 X-Received: by 2002:a50:ee01:: with SMTP id g1mr18447025eds.389.1635810283123; Mon, 01 Nov 2021 16:44:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP98rN7GBUGQx4nvmyvbrARnwtsVmN+v2WulGcuvBKfQE4Gsqep3W8sHo6Q/YiBiL3Kwsi1g== X-Received: by 2002:a50:ee01:: with SMTP id g1mr18446992eds.389.1635810282941; Mon, 01 Nov 2021 16:44:42 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 6/9] hw/i386/pc: Allow instantiating a virtio-iommu device Message-ID: <20211101234358.582487-7-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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: , Cc: Peter Maydell , Eduardo Habkost , Jean-Philippe Brucker , Richard Henderson , Eric Auger , Paolo Bonzini , Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635810787258100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker Allow instantiating a virtio-iommu device by adding an ACPI Virtual I/O Translation table (VIOT), which describes the relation between the virtio-iommu and the endpoints it manages. Add a hotplug handler for virtio-iommu on x86 and set the necessary reserved region property. On x86, the [0xfee00000, 0xfeefffff] DMA region is reserved for MSIs. DMA transactions to this range either trigger IRQ remapping in the IOMMU or bypasses IOMMU translation. Although virtio-iommu does not support IRQ remapping it must be informed of the reserved region so that it can forward DMA transactions targeting this region. Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov Tested-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20211026182024.2642038-5-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 10 +++++++++- hw/i386/pc.c | 16 +++++++++++++++- hw/i386/Kconfig | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index ab49e799ff..3ca6cc8118 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -68,9 +68,11 @@ #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" +#include "hw/virtio/virtio-iommu.h" =20 #include "hw/acpi/ipmi.h" #include "hw/acpi/hmat.h" +#include "hw/acpi/viot.h" =20 /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows @@ -2488,7 +2490,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) PCMachineState *pcms =3D PC_MACHINE(machine); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); X86MachineState *x86ms =3D X86_MACHINE(machine); - X86IOMMUState *iommu =3D x86_iommu_get_default(); + DeviceState *iommu =3D pcms->iommu; GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; AcpiPmInfo pm; @@ -2613,6 +2615,12 @@ void acpi_build(AcpiBuildTables *tables, MachineStat= e *machine) acpi_add_table(table_offsets, tables_blob); build_dmar_q35(tables_blob, tables->linker, x86ms->oem_id, x86ms->oem_table_id); + } else if (object_dynamic_cast(OBJECT(iommu), TYPE_VIRTIO_IOMMU_PCI)) { + PCIDevice *pdev =3D PCI_DEVICE(iommu); + + acpi_add_table(table_offsets, tables_blob); + build_viot(machine, tables_blob, tables->linker, pci_get_bdf(pdev), + x86ms->oem_id, x86ms->oem_table_id); } if (machine->nvdimms_state->is_enabled) { nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 7b1c4f41cd..e99017e662 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -83,6 +83,7 @@ #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" #include "standard-headers/asm-x86/bootparam.h" +#include "hw/virtio/virtio-iommu.h" #include "hw/virtio/virtio-pmem-pci.h" #include "hw/virtio/virtio-mem-pci.h" #include "hw/mem/memory-device.h" @@ -1330,7 +1331,19 @@ static void pc_machine_device_pre_plug_cb(HotplugHan= dler *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { pc_virtio_md_pci_pre_plug(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE)) { + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { + /* Declare the APIC range as the reserved MSI region */ + char *resv_prop_str =3D g_strdup_printf("0xfee00000:0xfeefffff:%d", + VIRTIO_IOMMU_RESV_MEM_T_MSI); + + object_property_set_uint(OBJECT(dev), "len-reserved-regions", 1, e= rrp); + object_property_set_str(OBJECT(dev), "reserved-regions[0]", + resv_prop_str, errp); + g_free(resv_prop_str); + } + + if (object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 if (pcms->iommu) { @@ -1394,6 +1407,7 @@ static HotplugHandler *pc_get_hotplug_handler(Machine= State *machine, object_dynamic_cast(OBJECT(dev), TYPE_CPU) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE)) { return HOTPLUG_HANDLER(machine); } diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 962d2c981b..d22ac4a4b9 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -59,6 +59,7 @@ config PC_ACPI select ACPI_X86 select ACPI_CPU_HOTPLUG select ACPI_MEMORY_HOTPLUG + select ACPI_VIOT select SMBUS_EEPROM select PFLASH_CFI01 depends on ACPI_SMBUS --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635811645041977.1146235852615; Mon, 1 Nov 2021 17:07:25 -0700 (PDT) Received: from localhost ([::1]:50498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhhKm-0003c0-11 for importer@patchew.org; Mon, 01 Nov 2021 20:07:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgz0-00024V-0i for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgyx-0004HN-6K for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:44:53 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-RlQUVO45PeyzvV7JKiG1rA-1; Mon, 01 Nov 2021 19:44:47 -0400 Received: by mail-ed1-f72.google.com with SMTP id i9-20020a508709000000b003dd4b55a3caso17101033edb.19 for ; Mon, 01 Nov 2021 16:44:47 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id e22sm10048998edu.35.2021.11.01.16.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810288; 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: in-reply-to:in-reply-to:references:references; bh=F4ZtjMfzkzyBWN2bg+JD6SzX6fqnOcm/U8VVQqdvDT8=; b=YkIOExOewYsBNsq0oxl9dseyqsMHODydpchu2S5XJl7vxfqY6L46ojhOTogvGk9jdX2sLE sENB9YPIXV5smAWjjmHnLeD2rO0gzjE6pFDkPu3U3b5aTH3Lvuj/UfYLi13oK1WoGfmXWx SDqOPydsAkJgw+qIQ7tpRUM2o9Q7sAw= X-MC-Unique: RlQUVO45PeyzvV7JKiG1rA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=F4ZtjMfzkzyBWN2bg+JD6SzX6fqnOcm/U8VVQqdvDT8=; b=mpB7F/WNZzCc3G9HBc+SS3YxdW7ejwn65WpsSyKk01DTFuGGTPu2HgxnlHJVXeLQw2 jAtZCfflP6EaB5NODHg7tQ0ZTI/0Fe3XI6YPZ3ncydr5C/KBf7z4vdSl4MdzrdK82Sox uAb+bob0lQJglkXzQLHp2ZFFU9XiJ5qUh8PBLY6OnXmoCmU+xKPhEEfnGw0m70dvnWC7 oSr9xeqbHN4HUKDqbMNQICTGJ7Jz6cvNgiH4vUtfcfIpBvgNbTfMs55I6NiSyDpCBPO8 lied++h8ajnWL0GI1gITAihqhik2fVKXcjy+fHAy4b7l7Zex7NRIc2481C+4hdR9vNtQ KIKw== X-Gm-Message-State: AOAM530/wovOJMM43R5Pj64er/4NvKdkJaqSG8YlhduY5ccCVT+6hvoB bu3+jrtetaZTy43Ckr+5RG/Kzl0/LH1uAB0HoS++e7HYyM4CIy7k0/4ODaaLFfkn1IM+nimv4Qt eyem6eFrdrVvo8jioJHmK5zoIlsm5dnfhiKuHMM9AdbNR6l+CmMpvrYrXCrm0 X-Received: by 2002:a17:907:ea0:: with SMTP id ho32mr11792581ejc.191.1635810286354; Mon, 01 Nov 2021 16:44:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV4ULqIeU5AMd3bmn/W7gMbtX/QpgqCSa8YVbbaL9cRv0XMFuuO0fy/Z9BW67w0NKG08vi6Q== X-Received: by 2002:a17:907:ea0:: with SMTP id ho32mr11792555ejc.191.1635810286113; Mon, 01 Nov 2021 16:44:46 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 7/9] pci: Define pci_bus_dev_fn/pci_bus_fn/pci_bus_ret_fn Message-ID: <20211101234358.582487-8-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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: , Cc: Peter Maydell , Eric Auger , Peter Xu , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635811646049100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu They're used in quite a few places of pci.[ch] and also in the rest of the = code base. Define them so that it doesn't need to be defined all over the place= s. The pci_bus_fn is similar to pci_bus_dev_fn that only takes a PCIBus* and an opaque. The pci_bus_ret_fn is similar to pci_bus_fn but it allows to retur= n a void* pointer. Reviewed-by: David Hildenbrand Reviewed-by: Eric Auger Signed-off-by: Peter Xu Message-Id: <20211028043129.38871-2-peterx@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 19 +++++++++---------- hw/pci/pci.c | 20 ++++++-------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 7fc90132cf..4a8740b76b 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -401,6 +401,10 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque,= int pin); OBJECT_DECLARE_TYPE(PCIBus, PCIBusClass, PCI_BUS) #define TYPE_PCIE_BUS "PCIE" =20 +typedef void (*pci_bus_dev_fn)(PCIBus *b, PCIDevice *d, void *opaque); +typedef void (*pci_bus_fn)(PCIBus *b, void *opaque); +typedef void *(*pci_bus_ret_fn)(PCIBus *b, void *opaque); + bool pci_bus_is_express(PCIBus *bus); =20 void pci_root_bus_init(PCIBus *bus, size_t bus_size, DeviceState *parent, @@ -458,23 +462,18 @@ static inline int pci_dev_bus_num(const PCIDevice *de= v) =20 int pci_bus_numa_node(PCIBus *bus); void pci_for_each_device(PCIBus *bus, int bus_num, - void (*fn)(PCIBus *bus, PCIDevice *d, void *opaqu= e), + pci_bus_dev_fn fn, void *opaque); void pci_for_each_device_reverse(PCIBus *bus, int bus_num, - void (*fn)(PCIBus *bus, PCIDevice *d, - void *opaque), + pci_bus_dev_fn fn, void *opaque); -void pci_for_each_bus_depth_first(PCIBus *bus, - void *(*begin)(PCIBus *bus, void *parent= _state), - void (*end)(PCIBus *bus, void *state), - void *parent_state); +void pci_for_each_bus_depth_first(PCIBus *bus, pci_bus_ret_fn begin, + pci_bus_fn end, void *parent_state); PCIDevice *pci_get_function_0(PCIDevice *pci_dev); =20 /* Use this wrapper when specific scan order is not required. */ static inline -void pci_for_each_bus(PCIBus *bus, - void (*fn)(PCIBus *bus, void *opaque), - void *opaque) +void pci_for_each_bus(PCIBus *bus, pci_bus_fn fn, void *opaque) { pci_for_each_bus_depth_first(bus, NULL, fn, opaque); } diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 186758ee11..17e59cb3a3 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1655,9 +1655,7 @@ static const pci_class_desc pci_class_descriptions[] = =3D }; =20 static void pci_for_each_device_under_bus_reverse(PCIBus *bus, - void (*fn)(PCIBus *b, - PCIDevice *d, - void *opaque), + pci_bus_dev_fn fn, void *opaque) { PCIDevice *d; @@ -1672,8 +1670,7 @@ static void pci_for_each_device_under_bus_reverse(PCI= Bus *bus, } =20 void pci_for_each_device_reverse(PCIBus *bus, int bus_num, - void (*fn)(PCIBus *b, PCIDevice *d, void *opaque), - void *opaque) + pci_bus_dev_fn fn, void *opaque) { bus =3D pci_find_bus_nr(bus, bus_num); =20 @@ -1683,9 +1680,7 @@ void pci_for_each_device_reverse(PCIBus *bus, int bus= _num, } =20 static void pci_for_each_device_under_bus(PCIBus *bus, - void (*fn)(PCIBus *b, PCIDevice = *d, - void *opaque), - void *opaque) + pci_bus_dev_fn fn, void *opaque) { PCIDevice *d; int devfn; @@ -1699,8 +1694,7 @@ static void pci_for_each_device_under_bus(PCIBus *bus, } =20 void pci_for_each_device(PCIBus *bus, int bus_num, - void (*fn)(PCIBus *b, PCIDevice *d, void *opaque), - void *opaque) + pci_bus_dev_fn fn, void *opaque) { bus =3D pci_find_bus_nr(bus, bus_num); =20 @@ -2078,10 +2072,8 @@ static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_= num) return NULL; } =20 -void pci_for_each_bus_depth_first(PCIBus *bus, - void *(*begin)(PCIBus *bus, void *parent= _state), - void (*end)(PCIBus *bus, void *state), - void *parent_state) +void pci_for_each_bus_depth_first(PCIBus *bus, pci_bus_ret_fn begin, + pci_bus_fn end, void *parent_state) { PCIBus *sec; void *state; --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635810345; cv=none; d=zohomail.com; s=zohoarc; b=YhyLuO9xccRZDi+wjgNGTS7ECdHe/0oTEq5jG2qUCn62IXf7Zir8qTqQ2LTAJuv0F2vKIRTj5zZPcefUhkrXFbh9fQRNHipCzjMzKGnwF7aMZWhmHr3RnycqjF+6HvnxxuFJip5GN6ep9h1RpUZm+Q3TbRZygbMgImvWkNX/YMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635810345; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hQpOeuAFUR/YU+yLEEiQzjlSsfEbb0a1M35err53O2c=; b=TJbjp30JaSmjOAIfaG+HV5q2oypHuBaEq5Fa4vsZm8fNrTReZ4J6w/PkaTA91oBDonDZsdziJK8OU8sCApFU7ux8qGvLJ/iYkj8+hG6o78LgOnpzcQQY+U8ev8D8QkRyGlkYpkN0/LjXJmsiTTfJ698P7UV+y3M0yFgYWD3Dijk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1635810345254823.5619428688698; Mon, 1 Nov 2021 16:45:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.219607.380461 (Exim 4.92) (envelope-from ) id 1mhgz3-0004o1-5I; Mon, 01 Nov 2021 23:44:57 +0000 Received: by outflank-mailman (output) from mailman id 219607.380461; Mon, 01 Nov 2021 23:44:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mhgz3-0004nu-2K; Mon, 01 Nov 2021 23:44:57 +0000 Received: by outflank-mailman (input) for mailman id 219607; Mon, 01 Nov 2021 23:44:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mhgz1-0004nk-AV for xen-devel@lists.xenproject.org; Mon, 01 Nov 2021 23:44:55 +0000 Received: from us-smtp-delivery-124.mimecast.com (unknown [170.10.133.124]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id c4a7ba2a-9e80-492e-8fb3-c93c84997b9e; Mon, 01 Nov 2021 23:44:53 +0000 (UTC) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-OOTu8dxFPXOK1VhXYfJ1ag-1; Mon, 01 Nov 2021 19:44:52 -0400 Received: by mail-ed1-f71.google.com with SMTP id t18-20020a056402021200b003db9e6b0e57so17058636edv.10 for ; Mon, 01 Nov 2021 16:44:52 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id s4sm1603180edd.32.2021.11.01.16.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:50 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c4a7ba2a-9e80-492e-8fb3-c93c84997b9e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810293; 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: in-reply-to:in-reply-to:references:references; bh=hQpOeuAFUR/YU+yLEEiQzjlSsfEbb0a1M35err53O2c=; b=OGYpZqdBuNXsmxiGgdvXdch14ocsrFIcHHVcklpqDlzrI5elMmodkVSXsNcftYNCxX7hu4 8UDRUUZIt2Rqdsp6V13ivOFTyMjwlNVptI6JoHjjHFO6v84BS/unbJJb79w0pG//nKS/kM X0an77UMXMXx/Tbi79GdpAroSQmQg0s= X-MC-Unique: OOTu8dxFPXOK1VhXYfJ1ag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hQpOeuAFUR/YU+yLEEiQzjlSsfEbb0a1M35err53O2c=; b=dE8PctFdwfQQCGN7/UoIhY1fVWmU1nClz5cRrxC4K+S7CJTNx1bWR8iRlWpkJXnFo8 f1OCewb4Y5ZaTLfmr7MoH3PHb8SX7KEAI4+AYVFZI3cOcjEuzbV6tNhfmO4V5+pTYP3m otP729wYbbyd+CQFgbq1cJtT731pvNRvq8ExRcFjEKppWPu5esmPQPYeb1dqG/QQP3i1 GvY33nMy9HbNcnKhdLYvDcgu6gGligREO7VkRGnRbGEuCuQ6G2grnc/WqQV/MwFVpTlM nt0KXTeqZYjtz+cI3elYVcjVw2tkM4pu7mwLr3z/g4C36KwwK1B2GdG1eRkT0p9hwTGk b2vQ== X-Gm-Message-State: AOAM5301SghOYOuK0gd5VMsZ8Ds3R+/zbPaaSyr58XjxvYx6F5ANcmx4 Oqh/CudUyBVTMsNAJ/VwYlfkjy4ICTBvDY40c/VMle9Vgev8HXEn3di9Lwg9Wve6zwKMqTJcnMG L+jB1ztIKmbGpdhxdW9IqF+TiSYU= X-Received: by 2002:a17:907:ea5:: with SMTP id ho37mr14408251ejc.133.1635810291054; Mon, 01 Nov 2021 16:44:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwukbwhcUWvJJuqHH8/khRQQjZoqF2HrG8wBex3bhnCrcMlXkuR308ikOKPoGaR9Bmsmei6wA== X-Received: by 2002:a17:907:ea5:: with SMTP id ho37mr14408220ejc.133.1635810290860; Mon, 01 Nov 2021 16:44:50 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Xu , David Hildenbrand , Eric Auger , David Gibson , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Greg Kurz , Matthew Rosato , Eric Farman , Cornelia Huck , Thomas Huth , Halil Pasic , Christian Borntraeger , Stefano Stabellini , Anthony Perard , Paul Durrant , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org Subject: [PULL 8/9] pci: Export pci_for_each_device_under_bus*() Message-ID: <20211101234358.582487-9-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635810348999100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu They're actually more commonly used than the helper without _under_bus, bec= ause most callers do have the pci bus on hand. After exporting we can switch a = lot of the call sites to use these two helpers. Reviewed-by: David Hildenbrand Reviewed-by: Eric Auger Signed-off-by: Peter Xu Message-Id: <20211028043129.38871-3-peterx@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: David Gibson Acked-by: Matthew Rosato --- include/hw/pci/pci.h | 5 +++++ hw/i386/acpi-build.c | 5 ++--- hw/pci/pci.c | 10 +++++----- hw/pci/pcie.c | 4 +--- hw/ppc/spapr_pci.c | 12 +++++------- hw/ppc/spapr_pci_nvlink2.c | 7 +++---- hw/ppc/spapr_pci_vfio.c | 4 ++-- hw/s390x/s390-pci-bus.c | 5 ++--- hw/xen/xen_pt.c | 4 ++-- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 4a8740b76b..5c4016b995 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -467,6 +467,11 @@ void pci_for_each_device(PCIBus *bus, int bus_num, void pci_for_each_device_reverse(PCIBus *bus, int bus_num, pci_bus_dev_fn fn, void *opaque); +void pci_for_each_device_under_bus(PCIBus *bus, + pci_bus_dev_fn fn, void *opaque); +void pci_for_each_device_under_bus_reverse(PCIBus *bus, + pci_bus_dev_fn fn, + void *opaque); void pci_for_each_bus_depth_first(PCIBus *bus, pci_bus_ret_fn begin, pci_bus_fn end, void *parent_state); PCIDevice *pci_get_function_0(PCIDevice *pci_dev); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 3ca6cc8118..a3ad6abd33 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2134,8 +2134,7 @@ dmar_host_bridges(Object *obj, void *opaque) PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; =20 if (bus && !pci_bus_bypass_iommu(bus)) { - pci_for_each_device(bus, pci_bus_num(bus), insert_scope, - scope_blob); + pci_for_each_device_under_bus(bus, insert_scope, scope_blob); } } =20 @@ -2341,7 +2340,7 @@ ivrs_host_bridges(Object *obj, void *opaque) PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; =20 if (bus && !pci_bus_bypass_iommu(bus)) { - pci_for_each_device(bus, pci_bus_num(bus), insert_ivhd, ivhd_b= lob); + pci_for_each_device_under_bus(bus, insert_ivhd, ivhd_blob); } } =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 17e59cb3a3..4a84e478ce 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1654,9 +1654,9 @@ static const pci_class_desc pci_class_descriptions[] = =3D { 0, NULL} }; =20 -static void pci_for_each_device_under_bus_reverse(PCIBus *bus, - pci_bus_dev_fn fn, - void *opaque) +void pci_for_each_device_under_bus_reverse(PCIBus *bus, + pci_bus_dev_fn fn, + void *opaque) { PCIDevice *d; int devfn; @@ -1679,8 +1679,8 @@ void pci_for_each_device_reverse(PCIBus *bus, int bus= _num, } } =20 -static void pci_for_each_device_under_bus(PCIBus *bus, - pci_bus_dev_fn fn, void *opaque) +void pci_for_each_device_under_bus(PCIBus *bus, + pci_bus_dev_fn fn, void *opaque) { PCIDevice *d; int devfn; diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 6e95d82903..914a9bf3d1 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -694,9 +694,7 @@ void pcie_cap_slot_write_config(PCIDevice *dev, (!(old_slt_ctl & PCI_EXP_SLTCTL_PCC) || (old_slt_ctl & PCI_EXP_SLTCTL_PIC_OFF) !=3D PCI_EXP_SLTCTL_PIC_OFF= )) { PCIBus *sec_bus =3D pci_bridge_get_sec_bus(PCI_BRIDGE(dev)); - pci_for_each_device(sec_bus, pci_bus_num(sec_bus), - pcie_unplug_device, NULL); - + pci_for_each_device_under_bus(sec_bus, pcie_unplug_device, NULL); pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_PDS); if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA || diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7430bd6314..5bfd4aa9e5 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1317,8 +1317,7 @@ static int spapr_dt_pci_bus(SpaprPhbState *sphb, PCIB= us *bus, RESOURCE_CELLS_SIZE)); =20 assert(bus); - pci_for_each_device_reverse(bus, pci_bus_num(bus), - spapr_dt_pci_device_cb, &cbinfo); + pci_for_each_device_under_bus_reverse(bus, spapr_dt_pci_device_cb, &cb= info); if (cbinfo.err) { return cbinfo.err; } @@ -2306,8 +2305,8 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bu= s, PCIDevice *pdev, return; } =20 - pci_for_each_device(sec_bus, pci_bus_num(sec_bus), - spapr_phb_pci_enumerate_bridge, bus_no); + pci_for_each_device_under_bus(sec_bus, spapr_phb_pci_enumerate_bridge, + bus_no); pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1); } =20 @@ -2316,9 +2315,8 @@ static void spapr_phb_pci_enumerate(SpaprPhbState *ph= b) PCIBus *bus =3D PCI_HOST_BRIDGE(phb)->bus; unsigned int bus_no =3D 0; =20 - pci_for_each_device(bus, pci_bus_num(bus), - spapr_phb_pci_enumerate_bridge, - &bus_no); + pci_for_each_device_under_bus(bus, spapr_phb_pci_enumerate_bridge, + &bus_no); =20 } =20 diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c index 8ef9b40a18..7fb0cf4d04 100644 --- a/hw/ppc/spapr_pci_nvlink2.c +++ b/hw/ppc/spapr_pci_nvlink2.c @@ -164,8 +164,7 @@ static void spapr_phb_pci_collect_nvgpu(PCIBus *bus, PC= IDevice *pdev, return; } =20 - pci_for_each_device(sec_bus, pci_bus_num(sec_bus), - spapr_phb_pci_collect_nvgpu, opaque); + pci_for_each_device_under_bus(sec_bus, spapr_phb_pci_collect_nvgpu, op= aque); } =20 void spapr_phb_nvgpu_setup(SpaprPhbState *sphb, Error **errp) @@ -183,8 +182,8 @@ void spapr_phb_nvgpu_setup(SpaprPhbState *sphb, Error *= *errp) sphb->nvgpus->nv2_atsd_current =3D sphb->nv2_atsd_win_addr; =20 bus =3D PCI_HOST_BRIDGE(sphb)->bus; - pci_for_each_device(bus, pci_bus_num(bus), - spapr_phb_pci_collect_nvgpu, sphb->nvgpus); + pci_for_each_device_under_bus(bus, spapr_phb_pci_collect_nvgpu, + sphb->nvgpus); =20 if (sphb->nvgpus->err) { error_propagate(errp, sphb->nvgpus->err); diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index f3b37df8ea..2a76b4e0b5 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -164,8 +164,8 @@ static void spapr_phb_vfio_eeh_clear_dev_msix(PCIBus *b= us, =20 static void spapr_phb_vfio_eeh_clear_bus_msix(PCIBus *bus, void *opaque) { - pci_for_each_device(bus, pci_bus_num(bus), - spapr_phb_vfio_eeh_clear_dev_msix, NULL); + pci_for_each_device_under_bus(bus, spapr_phb_vfio_eeh_clear_dev_msi= x, + NULL); } =20 static void spapr_phb_vfio_eeh_pre_reset(SpaprPhbState *sphb) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 6fafffb029..1b51a72838 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1163,8 +1163,7 @@ static void s390_pci_enumerate_bridge(PCIBus *bus, PC= IDevice *pdev, } =20 /* Assign numbers to all child bridges. The last is the highest number= . */ - pci_for_each_device(sec_bus, pci_bus_num(sec_bus), - s390_pci_enumerate_bridge, s); + pci_for_each_device_under_bus(sec_bus, s390_pci_enumerate_bridge, s); pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, s->bus_no, 1); } =20 @@ -1193,7 +1192,7 @@ static void s390_pcihost_reset(DeviceState *dev) * on every system reset, we also have to reassign numbers. */ s->bus_no =3D 0; - pci_for_each_device(bus, pci_bus_num(bus), s390_pci_enumerate_bridge, = s); + pci_for_each_device_under_bus(bus, s390_pci_enumerate_bridge, s); } =20 static void s390_pcihost_class_init(ObjectClass *klass, void *data) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index ca0a98187e..027190fa44 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -615,8 +615,8 @@ static void xen_pt_region_update(XenPCIPassthroughState= *s, } =20 args.type =3D d->io_regions[bar].type; - pci_for_each_device(pci_get_bus(d), pci_dev_bus_num(d), - xen_pt_check_bar_overlap, &args); + pci_for_each_device_under_bus(pci_get_bus(d), + xen_pt_check_bar_overlap, &args); if (args.rc) { XEN_PT_WARN(d, "Region: %d (addr: 0x%"FMT_PCIBUS ", len: 0x%"FMT_PCIBUS") is overlapped.\n", --=20 MST From nobody Wed May 8 06:54:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635812678125596.2116825952997; Mon, 1 Nov 2021 17:24:38 -0700 (PDT) Received: from localhost ([::1]:40506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhhbQ-0008Le-5k for importer@patchew.org; Mon, 01 Nov 2021 20:24:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgz7-0002Bq-EZ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:45:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46916) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhgz5-0004J8-7T for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:45:00 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555--PebGgTKMmafYRfw1AWeVA-1; Mon, 01 Nov 2021 19:44:56 -0400 Received: by mail-ed1-f72.google.com with SMTP id i22-20020a05640242d600b003e28aecc0afso4516229edc.1 for ; Mon, 01 Nov 2021 16:44:56 -0700 (PDT) Received: from redhat.com ([2.55.156.42]) by smtp.gmail.com with ESMTPSA id t6sm9812281edj.27.2021.11.01.16.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 16:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635810297; 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: in-reply-to:in-reply-to:references:references; bh=8hiU4jBSs673nJuzmbI+9Px2L2jLlgIA8UvIpSDnDMA=; b=S12MYMli41cXHlOWpkZmH+TnZtRX5sR4LJPgKoD6HWtjakYxK5YFSEd0LrqYBAKAo+8q4k HWGVzcmVcUM1F8H6TdyQck1KEPesS+bE6rQylnURvYX5iTv7XQNpBtNkhYDJAPRmnlZOgk esL8Adhlv1FBtXPwLC3P2d8KUAEua2Q= X-MC-Unique: -PebGgTKMmafYRfw1AWeVA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8hiU4jBSs673nJuzmbI+9Px2L2jLlgIA8UvIpSDnDMA=; b=n+SVoTdtw+85lATma5JUwSEyr4jJoohlZyWvU2cFB6bXa/AnwLMiplnRWBK8sBhLC8 IM+ErYi/o0FRmFuL33+/qxoM1/26AhFTbBMlwEZ8yRWec9DIYdwXadqsv8n+74FgdONW kqmvf/3NYz+I/e/mMYVBQ9++sSbKWfL0IN4pNkIAeq5WguKBGw9/wG3L1lCXbBfbXMnG WALJXvLhZ+bjIO0FCrVSy4KQw0B7jKC/Scr6yM+g1xIXVnOkUdOr5cmc8gQHeWRTxGJx J2aKQVFk5BTKQdQwrS4z547Wt1svIs8rViIueUe30xAXqdc2Okf8dd1STDMJvYN3d1IL zK0A== X-Gm-Message-State: AOAM532v75ODpjOvFiLWJnaJyuzhJ5ELO/MCd50WWZ/A5BqedPezUlqK 1g66DBojJNumx9Ew/O2aKCvIn0gZG1ccqKGk+0GNKrkeXgGgH6CG5pphAaKpYM6QHtj3PFJ4xkG IklroF8qgYknnz7SQefhVIjWiaBgejHme6xqIsfST1FkY7l7c4SQrGVjYZeuT X-Received: by 2002:a05:6402:4412:: with SMTP id y18mr9004963eda.103.1635810294100; Mon, 01 Nov 2021 16:44:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1Mpg4pWFPGDo8TreGk65P1HtrG4BWXooRIzP52gfaO/uSQwAm5i3WsPtz7ikyY2+5aNPK5Q== X-Received: by 2002:a05:6402:4412:: with SMTP id y18mr9004939eda.103.1635810293951; Mon, 01 Nov 2021 16:44:53 -0700 (PDT) Date: Mon, 1 Nov 2021 19:44:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 9/9] hw/i386: fix vmmouse registration Message-ID: <20211101234358.582487-10-mst@redhat.com> References: <20211101234358.582487-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211101234358.582487-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.734, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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: , Cc: Peter Maydell , Pavel Dovgalyuk , Eduardo Habkost , Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635812679427100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk According to the logic of vmmouse_update_handler function, vmmouse should be registered as an event handler when it's status is zero. vmmouse_read_id resets the status but does not register the handler. This patch adds vmmouse registration and activation when status is reset. Signed-off-by: Pavel Dovgalyuk Message-Id: <163524204515.1914131.16465061981774791228.stgit@pasha-ThinkPad= -X280> Signed-off-by: Michael S. Tsirkin --- hw/i386/vmmouse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index df4798f502..3d66368286 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -158,6 +158,7 @@ static void vmmouse_read_id(VMMouseState *s) =20 s->queue[s->nb_queue++] =3D VMMOUSE_VERSION; s->status =3D 0; + vmmouse_update_handler(s, s->absolute); } =20 static void vmmouse_request_relative(VMMouseState *s) --=20 MST