From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749421; cv=none; d=zohomail.com; s=zohoarc; b=hLQYmHRVV8B1WFLM45ClMAeH/iqYVHhqcGvAUXpwOQd5X3xGj8qDhKerO0ebdpzE5IakeCcpyB4RpTrFkkISEVw8dkT4fELNCl37Y4+63fjJZ/TiFF3QKgsGMwXlGlnAuFrZJR3dYoRsPDsRnMFRhQIFYWo1bhzj/M3Zkl+RmLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749421; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/RlOOAJIsj8sNQPC+vg0meKbfG0P1/LohRE4XqjDmVU=; b=I/PK66FOUvL8shYnTF2kqWBJoFh9n2u4aW66MIfTLDEerHuEd+x8jg4L+CJ5H58EAiFHgTFwwFu/O805FPUE+gN1DIZmGrViHHw2/EyEc29XVWm8wniGB9Ob2iRmCNSZTL1wItasX89WAIbecaX4FpXPvrg+SQlmrbKVPYIH+GM= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749421749642.544998086161; Mon, 25 Nov 2019 22:23:41 -0800 (PST) Received: from localhost ([::1]:50496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUGC-0007En-ER for importer@patchew.org; Tue, 26 Nov 2019 01:23:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59763) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU91-0007Ip-AS for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvF-0004N5-Sy for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:03 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:39575 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvE-0004KO-W3; Tue, 26 Nov 2019 01:02:01 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFc2RSmz9sPW; Tue, 26 Nov 2019 17:01:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748116; bh=DBWNlmEdXRBvV4bu8GympRzKtyJTqOVJKjfUJEgfyh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h1ek9pH5qjU3bpzE4RCbtHRMi0rHSg0ypZIikEnBaSIOOW8bfcZX8VxKhYO6f2dmj /j/VPtVKau8b95drcRWdeB2JlthLqfFM/XSjF48R2f5mT5n+BdnWJ+Mkox7JLNhvYt kn4YJ/3haUbHMNPVnPDBPMEv7TVsEGmEZhrQSbWE= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 1/8] pseries: fix migration-test and pxe-test Date: Tue, 26 Nov 2019 17:01:44 +1100 Message-Id: <20191126060151.729845-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Thomas Huth , Juan Quintela , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Commit 29cb4187497d ("spapr: Set VSMT to smp_threads by default") has introduced a new default value for VSMT that is not supported by old kernels (before 4.13 kernel) and this breaks "make check" on these kernels. To fix that, explicitly set in the involved tests the value that was used as the default value before the change. Cc: Greg Kurz Signed-off-by: Laurent Vivier Message-Id: <20191120142539.236279-1-lvivier@redhat.com> Acked-by: Thomas Huth Reviewed-by: Juan Quintela Tested-by: Greg Kurz Signed-off-by: David Gibson --- tests/migration-test.c | 4 ++-- tests/pxe-test.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index ac780dffda..ebd77a581a 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -614,7 +614,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, end_address =3D S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") =3D=3D 0) { extra_opts =3D use_shmem ? get_shmem_opts("256M", shmem_path) : NU= LL; - cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 256M -nodefaul= ts" + cmd_src =3D g_strdup_printf("-machine accel=3D%s,vsmt=3D8 -m 256M = -nodefaults" " -name source,debug-threads=3Don" " -serial file:%s/src_serial" " -prom-env 'use-nvramrc?=3Dtrue' -prom-= env " @@ -623,7 +623,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, "until' %s %s", accel, tmpfs, end_addre= ss, start_address, extra_opts ? extra_opts := "", opts_src); - cmd_dst =3D g_strdup_printf("-machine accel=3D%s -m 256M" + cmd_dst =3D g_strdup_printf("-machine accel=3D%s,vsmt=3D8 -m 256M" " -name target,debug-threads=3Don" " -serial file:%s/dest_serial" " -incoming %s %s %s", diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 948b0fbdc7..aaae54f755 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -46,15 +46,15 @@ static testdef_t x86_tests_slow[] =3D { =20 static testdef_t ppc64_tests[] =3D { { "pseries", "spapr-vlan", - "-machine cap-cfpc=3Dbroken,cap-sbbc=3Dbroken,cap-ibs=3Dbroken" }, + "-machine cap-cfpc=3Dbroken,cap-sbbc=3Dbroken,cap-ibs=3Dbroken,vsmt= =3D8" }, { "pseries", "virtio-net-pci", - "-machine cap-cfpc=3Dbroken,cap-sbbc=3Dbroken,cap-ibs=3Dbroken" }, + "-machine cap-cfpc=3Dbroken,cap-sbbc=3Dbroken,cap-ibs=3Dbroken,vsmt= =3D8" }, { NULL }, }; =20 static testdef_t ppc64_tests_slow[] =3D { { "pseries", "e1000", - "-machine cap-cfpc=3Dbroken,cap-sbbc=3Dbroken,cap-ibs=3Dbroken" }, + "-machine cap-cfpc=3Dbroken,cap-sbbc=3Dbroken,cap-ibs=3Dbroken,vsmt= =3D8" }, { NULL }, }; =20 --=20 2.23.0 From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749292; cv=none; d=zohomail.com; s=zohoarc; b=AZmcqXI40f0td3fxSelw92rNx+AMsmm5CdX67hKQz3WAfvCNp+VBnn+/yPFb4pVE5aABGcCvY7xZu5ew+OgWi9BdNg04KARHxBVN/pxwGxCEPTFZ56zYVGCiiFvxuJHXXOPf75zU+iwGk1hgPq44VWdoSX4u/hFG0AjkwUWjweI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749292; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nYkliuA3thctItcR5z5eQIvyjnln3+Si/7kXH2zPF+Y=; b=gEFVJukeUWbOlu+1X8miWWtWnjV4el4ljnNGtMVLHjkIAicblKel7vqaOOFSfsudp68rnY3gI256Hj1tv56ACITHEDvXiCcR8nYYg8zD/Pe7TUhSFEveWE4mUZ7nkKMxV26A+MpCBWIgh3u9/7V7fGOC9JIGoK2XbpgWdPggO6Q= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749292757701.7720054746203; Mon, 25 Nov 2019 22:21:32 -0800 (PST) Received: from localhost ([::1]:50468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUE7-00050A-9G for importer@patchew.org; Tue, 26 Nov 2019 01:21:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59887) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU90-0007Mj-DE for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvF-0004Mv-QK for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:03 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:47519 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvF-0004KR-1J; Tue, 26 Nov 2019 01:02:01 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFc4CkQz9sQy; Tue, 26 Nov 2019 17:01:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748116; bh=cBWAaxRMUmAXyV+l5qyTcoCm3QGnkC4O/NUuXad1Dwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hkP6PPW0emxpvL8P7/4Ytg3ONKytAO5nND08tb22XllAjDLt06fIc2HnK25HEabtL KUxL/8GEmcLkYFLeT0OrSlizoS23NwBim+5I8VII9WiYAulcaujZPGhSPmipwsjEJo nSGEO4E8ScfJyrW0bfS0DzcAdpA3vQ+Qds4v2aes= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 2/8] kvm: Introduce KVM irqchip change notifier Date: Tue, 26 Nov 2019 17:01:45 +1100 Message-Id: <20191126060151.729845-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Alexey Kardashevskiy , qemu-devel@nongnu.org, groug@kaod.org, Alex Williamson , qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Awareness of an in kernel irqchip is usually local to the machine and its top-level interrupt controller. However, in a few cases other things need to know about it. In particular vfio devices need this in order to accelerate interrupt delivery. If interrupt routing is changed, such devices may need to readjust their connection to the KVM irqchip. pci_bus_fire_intx_routing_notifier() exists to do just this. However, for the pseries machine type we have a situation where the routing remains constant but the top-level irq chip itself is changed. This occurs because of PAPR feature negotiation which allows the guest to decide between the older XICS and newer XIVE irq chip models (both of which are paravirtualized). To allow devices like vfio to adjust to this change, introduce a new notifier for the purpose kvm_irqchip_change_notify(). Cc: Alex Williamson Cc: Alexey Kardashevskiy Signed-off-by: David Gibson Tested-by: Alex Williamson Reviewed-by: Alex Williamson Reviewed-by: Greg Kurz Acked-by: Alex Williamson --- accel/kvm/kvm-all.c | 18 ++++++++++++++++++ accel/stubs/kvm-stub.c | 12 ++++++++++++ include/sysemu/kvm.h | 5 +++++ 3 files changed, 35 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 140b0bd8f6..ca00daa2f5 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -149,6 +149,9 @@ static const KVMCapabilityInfo kvm_required_capabilites= [] =3D { KVM_CAP_LAST_INFO }; =20 +static NotifierList kvm_irqchip_change_notifiers =3D + NOTIFIER_LIST_INITIALIZER(kvm_irqchip_change_notifiers); + #define kvm_slots_lock(kml) qemu_mutex_lock(&(kml)->slots_lock) #define kvm_slots_unlock(kml) qemu_mutex_unlock(&(kml)->slots_lock) =20 @@ -1396,6 +1399,21 @@ void kvm_irqchip_release_virq(KVMState *s, int virq) trace_kvm_irqchip_release_virq(virq); } =20 +void kvm_irqchip_add_change_notifier(Notifier *n) +{ + notifier_list_add(&kvm_irqchip_change_notifiers, n); +} + +void kvm_irqchip_remove_change_notifier(Notifier *n) +{ + notifier_remove(n); +} + +void kvm_irqchip_change_notify(void) +{ + notifier_list_notify(&kvm_irqchip_change_notifiers, NULL); +} + static unsigned int kvm_hash_msi(uint32_t data) { /* This is optimized for IA32 MSI layout. However, no other arch shall diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 6feb66ed80..82f118d2df 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -138,6 +138,18 @@ void kvm_irqchip_commit_routes(KVMState *s) { } =20 +void kvm_irqchip_add_change_notifier(Notifier *n) +{ +} + +void kvm_irqchip_remove_change_notifier(Notifier *n) +{ +} + +void kvm_irqchip_change_notify(void) +{ +} + int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter) { return -ENOSYS; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 9d143282bc..9fe233b9bf 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -201,6 +201,7 @@ typedef struct KVMCapabilityInfo { struct KVMState; typedef struct KVMState KVMState; extern KVMState *kvm_state; +typedef struct Notifier Notifier; =20 /* external API */ =20 @@ -401,6 +402,10 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg); =20 void kvm_irqchip_add_irq_route(KVMState *s, int gsi, int irqchip, int pin); =20 +void kvm_irqchip_add_change_notifier(Notifier *n); +void kvm_irqchip_remove_change_notifier(Notifier *n); +void kvm_irqchip_change_notify(void); + void kvm_get_apic_state(DeviceState *d, struct kvm_lapic_state *kapic); =20 struct kvm_guest_debug; --=20 2.23.0 From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749454; cv=none; d=zohomail.com; s=zohoarc; b=IjL4jQJZCbHYB4+eKVc6pCBRxQcWO/532t4dBfAUie0qJKUIqWmMIcuOnIaDPaWOFZezEUh3mCKBMCVPJ1Q0yfBxtcQm0ABDKWqGSHCRrvVLKk6juZ1HsxAAznIa7QqyP8MH5tx8r1cRIEhXC90t+2k66VPYRGI+D9KUoK/7erk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749454; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+FzGZGE3IpD5RfJ7iJLN1FE/CRLaE2qvXuwwZtomxjA=; b=ZNphi1Wl/r8lSF3WGiVjw5gDPHjxU8XU3Wgeuxg9gu08EtNLd7XqFDg0PbiV4KtaBOBBKlVh2hwPDaBMbs4IeLsVoiGGg+wVlicWuyFe6qoVDJ2RuoUr9owTPOQBYW2wvSkSwUKx7SqtQtbJuC7bF0mTuRhcNaxVuwwcWeUT+T8= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749454277343.40939141873685; Mon, 25 Nov 2019 22:24:14 -0800 (PST) Received: from localhost ([::1]:50498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUGj-00089P-65 for importer@patchew.org; Tue, 26 Nov 2019 01:24:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59763) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU90-0007Ip-5j for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvG-0004NR-AL for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:03 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:60757) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvF-0004KY-W9; Tue, 26 Nov 2019 01:02:02 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFc6YbKz9sRC; Tue, 26 Nov 2019 17:01:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748116; bh=u7CAIhmTj0mlhyPuaW0tj6FxYD0XbxolACOl8eimYFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUhsoFTXYZrvlRFA1GCFWO2PLyy++9GCRHNK4fJpmRLxzyZydoqB4GyFu8xUlWDZa 0X6PHTTG5ri/1WzqJKUetm0nGQm2XUJk4bFg+148/M2eilQVeIFdtOlHbJTCJYqWZn f64xCBLUZZeyfVjHWNJv8VdCoTrEiGrZzZeTSFiE= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 3/8] vfio/pci: Split vfio_intx_update() Date: Tue, 26 Nov 2019 17:01:46 +1100 Message-Id: <20191126060151.729845-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Alexey Kardashevskiy , qemu-devel@nongnu.org, groug@kaod.org, Alex Williamson , qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This splits the vfio_intx_update() function into one part doing the actual reconnection with the KVM irqchip (vfio_intx_update(), now taking an argument with the new routing) and vfio_intx_routing_notifier() which handles calls to the pci device intx routing notifier and calling vfio_intx_update() when necessary. This will make adding support for the irqchip change notifier easier. Cc: Alex Williamson Cc: Alexey Kardashevskiy Signed-off-by: David Gibson Tested-by: Alex Williamson Reviewed-by: Alex Williamson Reviewed-by: Greg Kurz Acked-by: Alex Williamson --- hw/vfio/pci.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 0c55883bba..521289aa7d 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -216,30 +216,18 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev) #endif } =20 -static void vfio_intx_update(PCIDevice *pdev) +static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route) { - VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); - PCIINTxRoute route; Error *err =3D NULL; =20 - if (vdev->interrupt !=3D VFIO_INT_INTx) { - return; - } - - route =3D pci_device_route_intx_to_irq(&vdev->pdev, vdev->intx.pin); - - if (!pci_intx_route_changed(&vdev->intx.route, &route)) { - return; /* Nothing changed */ - } - trace_vfio_intx_update(vdev->vbasedev.name, - vdev->intx.route.irq, route.irq); + vdev->intx.route.irq, route->irq); =20 vfio_intx_disable_kvm(vdev); =20 - vdev->intx.route =3D route; + vdev->intx.route =3D *route; =20 - if (route.mode !=3D PCI_INTX_ENABLED) { + if (route->mode !=3D PCI_INTX_ENABLED) { return; } =20 @@ -252,6 +240,22 @@ static void vfio_intx_update(PCIDevice *pdev) vfio_intx_eoi(&vdev->vbasedev); } =20 +static void vfio_intx_routing_notifier(PCIDevice *pdev) +{ + VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); + PCIINTxRoute route; + + if (vdev->interrupt !=3D VFIO_INT_INTx) { + return; + } + + route =3D pci_device_route_intx_to_irq(&vdev->pdev, vdev->intx.pin); + + if (pci_intx_route_changed(&vdev->intx.route, &route)) { + vfio_intx_update(vdev, &route); + } +} + static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) { uint8_t pin =3D vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1= ); @@ -2967,7 +2971,8 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) if (vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1)) { vdev->intx.mmap_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, vfio_intx_mmap_enable, v= dev); - pci_device_set_intx_routing_notifier(&vdev->pdev, vfio_intx_update= ); + pci_device_set_intx_routing_notifier(&vdev->pdev, + vfio_intx_routing_notifier); ret =3D vfio_intx_enable(vdev, errp); if (ret) { goto out_teardown; --=20 2.23.0 From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749147; cv=none; d=zohomail.com; s=zohoarc; b=Csuwihc6NVq+Hmj9EIZmDrPupTWZE66AvBEvXyE/mA+kQ16MIXHDQi9Yit1MgaWVIw62aWGUwfGlSECb2vmrjvYHC+LDc3k5ZMKLJbf9bUatnJVcEew2h6J/QHep426hiKPJX4ddi8Sg/EazOuCsgVkWCcCSDbPPdCGpC1Wcka4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749147; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=55bBBBNumOLvxvqtJRkfKdV2Btv8Qt5WrEq/UJ5/qAU=; b=ccSBz6KyNMH54H4dL+yAP2ErsU4BruVP4Io4BNCyT4y7pOJYqxxf1nQpMFHlHPo4algbmuIrFM4jTJ+tNCPv6y6ziK3R3FA3FmzuG/b0BJlRMeqVsetV98oqzhPASIHUclz/dsJhQA0hOFRNwyFjI5dWzIDCcGZ4avzde2xvRDc= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749147249497.58368465195565; Mon, 25 Nov 2019 22:19:07 -0800 (PST) Received: from localhost ([::1]:50432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUBk-0001Bz-83 for importer@patchew.org; Tue, 26 Nov 2019 01:19:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59887) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU8x-0007Mj-WF for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvF-0004NH-Vu for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:06 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:35309 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvE-0004KU-Vp; Tue, 26 Nov 2019 01:02:01 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFc5Bnxz9sR5; Tue, 26 Nov 2019 17:01:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748116; bh=YXoCERS56wn75a8kv2DqcGF9kiUBlvFpYPk1X6VGAIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gnzxat47L3B+LmOVayyfyWe6k2iLrCe2i8CakVDjxthKFdK+fjNpO1XcfajASVxnp PJb4K/qIfd8s13ktJfjzPUazhyloi4xtUkEggc3egGCfyB2q4lL69IKuqYeefRq+c/ hx3X6JDF7m44IrqO/L3AS4kkmSEOa+uLuBMFxD94= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 4/8] vfio/pci: Respond to KVM irqchip change notifier Date: Tue, 26 Nov 2019 17:01:47 +1100 Message-Id: <20191126060151.729845-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Alexey Kardashevskiy , qemu-devel@nongnu.org, groug@kaod.org, Alex Williamson , qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" VFIO PCI devices already respond to the pci intx routing notifier, in order to update kernel irqchip mappings when routing is updated. However this won't handle the case where the irqchip itself is replaced by a different model while retaining the same routing. This case can happen on the pseries machine type due to PAPR feature negotiation. To handle that case, add a handler for the irqchip change notifier, which does much the same thing as the routing notifier, but is unconditional, rather than being a no-op when the routing hasn't changed. Cc: Alex Williamson Cc: Alexey Kardashevskiy Signed-off-by: David Gibson Tested-by: Alex Williamson Reviewed-by: Alex Williamson Reviewed-by: Greg Kurz Acked-by: Alex Williamson --- hw/vfio/pci.c | 25 +++++++++++++++++++------ hw/vfio/pci.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 521289aa7d..2d40b396f2 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -256,6 +256,14 @@ static void vfio_intx_routing_notifier(PCIDevice *pdev) } } =20 +static void vfio_irqchip_change(Notifier *notify, void *data) +{ + VFIOPCIDevice *vdev =3D container_of(notify, VFIOPCIDevice, + irqchip_change_notifier); + + vfio_intx_update(vdev, &vdev->intx.route); +} + static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) { uint8_t pin =3D vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1= ); @@ -2973,30 +2981,32 @@ static void vfio_realize(PCIDevice *pdev, Error **e= rrp) vfio_intx_mmap_enable, v= dev); pci_device_set_intx_routing_notifier(&vdev->pdev, vfio_intx_routing_notifier); + vdev->irqchip_change_notifier.notify =3D vfio_irqchip_change; + kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier); ret =3D vfio_intx_enable(vdev, errp); if (ret) { - goto out_teardown; + goto out_deregister; } } =20 if (vdev->display !=3D ON_OFF_AUTO_OFF) { ret =3D vfio_display_probe(vdev, errp); if (ret) { - goto out_teardown; + goto out_deregister; } } if (vdev->enable_ramfb && vdev->dpy =3D=3D NULL) { error_setg(errp, "ramfb=3Don requires display=3Don"); - goto out_teardown; + goto out_deregister; } if (vdev->display_xres || vdev->display_yres) { if (vdev->dpy =3D=3D NULL) { error_setg(errp, "xres and yres properties require display=3Do= n"); - goto out_teardown; + goto out_deregister; } if (vdev->dpy->edid_regs =3D=3D NULL) { error_setg(errp, "xres and yres properties need edid support"); - goto out_teardown; + goto out_deregister; } } =20 @@ -3020,8 +3030,10 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) =20 return; =20 -out_teardown: +out_deregister: pci_device_set_intx_routing_notifier(&vdev->pdev, NULL); + kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier); +out_teardown: vfio_teardown_msi(vdev); vfio_bars_exit(vdev); error: @@ -3064,6 +3076,7 @@ static void vfio_exitfn(PCIDevice *pdev) vfio_unregister_req_notifier(vdev); vfio_unregister_err_notifier(vdev); pci_device_set_intx_routing_notifier(&vdev->pdev, NULL); + kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier); vfio_disable_interrupts(vdev); if (vdev->intx.mmap_timer) { timer_free(vdev->intx.mmap_timer); diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index b329d50338..35626cd63e 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -169,6 +169,7 @@ typedef struct VFIOPCIDevice { bool enable_ramfb; VFIODisplay *dpy; Error *migration_blocker; + Notifier irqchip_change_notifier; } VFIOPCIDevice; =20 uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len); --=20 2.23.0 From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749209; cv=none; d=zohomail.com; s=zohoarc; b=MlRlOxyH+MKCca8AAuczcMLTNG+lLY+a39iVkAAWqqMJkrWjk7RdOJwEmRN4psS5uwMghQKiWTaTXqdTOxsiLqOa/bGBjqEGqjDZo01qf1t1pdMC5Wonfe+B++AfDFHXXnnd0UAztJkhVaw59hEQoRiv23Qh57zxVoBDnBZAA30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749209; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J6GPpPmFRzRceIl2QvddWodsB1cy5xRBD3V1PBMUC9o=; b=ElQ8fwDdvKlr29yVkUu1ji4IljiXBYXtciWnrNfstcZmxJggCKVyrWnEjfDbeqHRBQRm187kRYkgUP+oIlGrmEvuqvA1RG0YZ2m45ZQv3UB5cNbDE9CoC1Tm4ElaTp/c+ZeNpdOCyCSTQaAiwaekL/88QkNZ8D38GIHAni4qA9Y= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749209775306.6015336379638; Mon, 25 Nov 2019 22:20:09 -0800 (PST) Received: from localhost ([::1]:50438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUCm-0002iy-HM for importer@patchew.org; Tue, 26 Nov 2019 01:20:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59763) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU8z-0007Ip-2n for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvI-0004P2-Or for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:05 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:54781 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvI-0004NM-DQ; Tue, 26 Nov 2019 01:02:04 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFd0yGmz9sR7; Tue, 26 Nov 2019 17:01:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748117; bh=SxK6+XV9oC+qJiIgiSf0DCPEib3NB/uxEW2Hla1LRZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUcPwJBO+jIcmbBolMyUcx/sFb25lAdjRP48mt9mRMCwQ7m8od/Tg6Kf5o32wsKtp ExepQNiUR9SSLTjPAf+uMjAjp1ShKAb2PyJrhA9zqL2mmiMO3borZsJBM/DSQ6StsI +/ZL/W5TSX2tlUmoo3qE/GFxVCtUIsCFKBqIJHEk= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 5/8] spapr: Handle irq backend changes with VFIO PCI devices Date: Tue, 26 Nov 2019 17:01:48 +1100 Message-Id: <20191126060151.729845-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Alexey Kardashevskiy , qemu-devel@nongnu.org, groug@kaod.org, Alex Williamson , qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" pseries machine type can have one of two different interrupt controllers in use depending on feature negotiation with the guest. Usually this is invisible to devices, because they route to a common set of qemu_irqs which in turn dispatch to the correct back end. VFIO passthrough devices, however, wire themselves up directly to the KVM irqchip for performance, which means they are affected by this change in interrupt controller. To get them to adjust correctly for the change in irqchip, we need to fire the kvm irqchip change notifier. Cc: Alex Williamson Cc: Alexey Kardashevskiy Signed-off-by: David Gibson Reviewed-by: C=C3=A9dric Le Goater Tested-by: Alex Williamson Reviewed-by: Alex Williamson Reviewed-by: Greg Kurz Acked-by: Alex Williamson --- hw/ppc/spapr_irq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 168044be85..1d27034962 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -508,6 +508,12 @@ static void set_active_intc(SpaprMachineState *spapr, } =20 spapr->active_intc =3D new_intc; + + /* + * We've changed the kernel irqchip, let VFIO devices know they + * need to readjust. + */ + kvm_irqchip_change_notify(); } =20 void spapr_irq_update_active_intc(SpaprMachineState *spapr) --=20 2.23.0 From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749335; cv=none; d=zohomail.com; s=zohoarc; b=lFZ5o7H9WhHS96j4iQMBH/WXr6MmrkKYvc4fK1vFQt+tzNHY7j7S69Th7GMHkRcZB96XrcuLEKUyMEC9FkJ6J92igG0xcksUU7UG0h0703iEgP+GyOfE/Uxqp6Z/FOAETVZqjUX093i7SxZh2FyFOwxRtw89vKgCRTJGECA8ob4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749335; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yBede6MeeAkUMInJfT8r3yxtKLJwKG49v0dNSredQTQ=; b=WRLsBuToE+zVXxrDdbRZz5x/SGpFrdhlMHeBeG4xfOS3hkfJs19RuEnviBncs22OUVIF6o8PJoUvErjLBNeKxn8IH6YvuCwpxFsOfhRMMu6SM0W9rwc1S5Ci1+GSVK8JdGvH6MdkDvd/S3wnvDNupJkfGOmcBEoe1tiKBNmRH3Q= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749335058500.6113865808527; Mon, 25 Nov 2019 22:22:15 -0800 (PST) Received: from localhost ([::1]:50470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUEn-0005rU-Sp for importer@patchew.org; Tue, 26 Nov 2019 01:22:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59804) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU8y-0007Jf-Sd for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvI-0004PC-Un for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:06 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:38781 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvI-0004NP-JN; Tue, 26 Nov 2019 01:02:04 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFd3L5gz9sRG; Tue, 26 Nov 2019 17:01:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748117; bh=/Lv46GlVbuezd+dx9seCW3M8TgeG6tuTmE2nbMPiE+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RxoooOJCcQDnZLrDegDqBMfk7mb0FiKoGGjECSSrqvo9+edcGaeEiVyi0L0kcCEeU /kOnzJCMnJJ57QVgflOq3eVPoRlNWnmUx00mdCdBac+YFpwpvOgNmUzaRwNV2TJYFN 4/lll/+ry+7sGu3D28KW8aTErtGWOFSVsQv0jmAM= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 6/8] spapr: Work around spurious warnings from vfio INTx initialization Date: Tue, 26 Nov 2019 17:01:49 +1100 Message-Id: <20191126060151.729845-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Alexey Kardashevskiy , qemu-devel@nongnu.org, groug@kaod.org, Alex Williamson , qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Traditional PCI INTx for vfio devices can only perform well if using an in-kernel irqchip. Therefore, vfio_intx_update() issues a warning if an in kernel irqchip is not available. We usually do have an in-kernel irqchip available for pseries machines on POWER hosts. However, because the platform allows feature negotiation of what interrupt controller model to use, we don't currently initialize it until machine reset. vfio_intx_update() is called (first) from vfio_realize() before that, so it can issue a spurious warning, even if we will have an in kernel irqchip by the time we need it. To workaround this, make a call to spapr_irq_update_active_intc() from spapr_irq_init() which is called at machine realize time, before the vfio realize. This call will be pretty much obsoleted by the later call at reset time, but it serves to suppress the spurious warning from VFIO. Cc: Alex Williamson Cc: Alexey Kardashevskiy Signed-off-by: David Gibson Reviewed-by: C=C3=A9dric Le Goater Tested-by: Alex Williamson Reviewed-by: Alex Williamson Reviewed-by: Greg Kurz Acked-by: Alex Williamson --- hw/ppc/spapr_irq.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 1d27034962..d6bb7fd2d6 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -373,6 +373,14 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **= errp) =20 spapr->qirqs =3D qemu_allocate_irqs(spapr_set_irq, spapr, smc->nr_xirqs + SPAPR_XIRQ_BASE); + + /* + * Mostly we don't actually need this until reset, except that not + * having this set up can cause VFIO devices to issue a + * false-positive warning during realize(), because they don't yet + * have an in-kernel irq chip. + */ + spapr_irq_update_active_intc(spapr); } =20 int spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **e= rrp) @@ -528,7 +536,8 @@ void spapr_irq_update_active_intc(SpaprMachineState *sp= apr) * this. */ new_intc =3D SPAPR_INTC(spapr->xive); - } else if (spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { + } else if (spapr->ov5_cas + && spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { new_intc =3D SPAPR_INTC(spapr->xive); } else { new_intc =3D SPAPR_INTC(spapr->ics); --=20 2.23.0 From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749282; cv=none; d=zohomail.com; s=zohoarc; b=KSr3iEJyUhGOTqolI1pJ6gmAZoU27WSGjcswfoQnH3F2ZnQ97AfYc/XzubJFIn3OolO3iYqbF1ApZ3oppgZH77LnAsDXFRD0t1AVinYteSSza12yH4eacUf7vadisLQlDW4gLbGKJCgab8Njz8A2iYRL4PdRhxL4o6fkETqmnVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749282; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=211UEceJgUcYTat8P6zWFy71TLiLJP33mK7EAesjBsM=; b=fh0Qg/0zx8UH6geO53EiyzJlZzqxGCG969ymUW40i41+aE9EALul+r8PDfD0FgGOSFbQR1lF8W/bUl4NX5YV4tgR5yE05pZORJ3Iow5rP2bJJUYG9U8KrkrqvC2TWese8Rw8xR+CeQA/zgOVXntA/gELqKKLmPvEcUmMWPdh6XE= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749282288703.2973993082131; Mon, 25 Nov 2019 22:21:22 -0800 (PST) Received: from localhost ([::1]:50466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUDx-0004jw-3g for importer@patchew.org; Tue, 26 Nov 2019 01:21:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59862) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU8y-0007Ll-PF for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvJ-0004PX-4u for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:06 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:59837 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvI-0004Nd-PT; Tue, 26 Nov 2019 01:02:05 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFd4rHCz9sRK; Tue, 26 Nov 2019 17:01:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748117; bh=Yad6EHt74mRLNq20SFLUJExdglivkS35/7wuW+BoRaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SBQwqCNqSEHYYC3avOx751ogCk94YLb6q4hqLWmAZlJty6Vktx5Ez3nmexu3sATP3 XTjxgp51yBlnW+UOHsc7tTAhVvlww023g55YXDq3Jktl+57FD+9GuYrouAksuAyA8i K+XBYkex+bY4opS6ZSJR+Uc/e/QMnbIkoejiCgIw= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 7/8] mos6522: update counters when timer interrupts are off Date: Tue, 26 Nov 2019 17:01:50 +1100 Message-Id: <20191126060151.729845-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Laurent Vivier , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Randrianasulu , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Even if the interrupts are off, counters must be updated because they are running anyway and kernel can try to read them (it's the case with g3beige kernel). Reported-by: Andrew Randrianasulu Signed-off-by: Laurent Vivier Message-Id: <20191125141414.5015-1-laurent@vivier.eu> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Gibson --- hw/misc/mos6522.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index aa3bfe1afd..cecf0be59e 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -113,6 +113,10 @@ static int64_t get_next_irq_time(MOS6522State *s, MOS6= 522Timer *ti, int64_t d, next_time; unsigned int counter; =20 + if (ti->frequency =3D=3D 0) { + return INT64_MAX; + } + /* current counter value */ d =3D muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ti->load_time, ti->frequency, NANOSECONDS_PER_SECOND); @@ -149,10 +153,10 @@ static void mos6522_timer1_update(MOS6522State *s, MO= S6522Timer *ti, if (!ti->timer) { return; } + ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); if ((s->ier & T1_INT) =3D=3D 0 || (s->acr & T1MODE) !=3D T1MODE_CONT) { timer_del(ti->timer); } else { - ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); timer_mod(ti->timer, ti->next_irq_time); } } @@ -163,10 +167,10 @@ static void mos6522_timer2_update(MOS6522State *s, MO= S6522Timer *ti, if (!ti->timer) { return; } + ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); if ((s->ier & T2_INT) =3D=3D 0) { timer_del(ti->timer); } else { - ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); timer_mod(ti->timer, ti->next_irq_time); } } --=20 2.23.0 From nobody Tue May 14 16:13:14 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574749164; cv=none; d=zohomail.com; s=zohoarc; b=k5TMFY1TwToFbSoVVRtoaVyjhUX/4TzqSRJ7F0wpwNBWrtEFgyXHt+Cetg38BFQK1WFbvVI1i8FuCwHukiQ3b6HoKAF4dY99rGGFF1zynqELxR+OtjDjl/06yatn58xhDoze4GPLb9cBJbu0y85l36bimCl3PCosfmbZipT8W6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574749164; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3H7ya6IWdqagP1A8CxaB0BpK4JQs3Do/PhBO1gfcCDE=; b=BHXPB8y8/FL+tNV5ocWBUCIkmqaGWFQ+hNRug7YVGXvrbpJBHobulj+SMSFROAE8iPk/jd9w6gEeeKnMCUjvSFsXx0E5dHKbRJ+epM20vUTzxV0Bn5h07KGvv4NDljmMx1uOprTwmxzn9Z3589mkT3ybNUbH3sb8IyHE2vyywoI= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574749164466465.5100992845545; Mon, 25 Nov 2019 22:19:24 -0800 (PST) Received: from localhost ([::1]:50436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZUC2-0001e6-UP for importer@patchew.org; Tue, 26 Nov 2019 01:19:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59890) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZU8y-0007N4-KI for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:16:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZTvJ-0004Pj-EP for qemu-devel@nongnu.org; Tue, 26 Nov 2019 01:02:06 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:42401 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZTvJ-0004Na-3H; Tue, 26 Nov 2019 01:02:05 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47MYFf24d4z9sRV; Tue, 26 Nov 2019 17:01:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574748118; bh=6nijnx83CIQx6smDHZhFj8k2OJ6X4c5LVR42ACAGZd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z5059nwb27Uc4WlsET2gHPFa5d3mWr1zoc5zP74n/XWz1pNs6Cuiy/UdTuk3HZmtm ljeuonGdJrTAfc65PMMvpAsgxjCJ84b1Pt86slnMg2P9nb4Lo75hxbZ3H28N4sU4BP 8Q2M/QDGtQdXODjD9KxQxRePbLXWQ2WGU9M6oAOM= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 8/8] ppc/spapr_events: fix potential NULL pointer dereference in rtas_event_log_dequeue Date: Tue, 26 Nov 2019 17:01:51 +1100 Message-Id: <20191126060151.729845-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191126060151.729845-1-david@gibson.dropbear.id.au> References: <20191126060151.729845-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, PanNengyuan , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, Euler Robot , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: PanNengyuan This fixes coverity issues 68911917: 360 CID 68911917: (NULL_RETURNS) 361. dereference: Dereferencing "source", which is known to be "NULL". 361 if (source->mask & event_mask) { 362 break; 363 } Reported-by: Euler Robot Signed-off-by: PanNengyuan Message-Id: <1574685291-38176-1-git-send-email-pannengyuan@huawei.com> Signed-off-by: David Gibson --- hw/ppc/spapr_events.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 0e4c19523a..e355e000d0 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -358,6 +358,7 @@ static SpaprEventLogEntry *rtas_event_log_dequeue(Spapr= MachineState *spapr, rtas_event_log_to_source(spapr, spapr_event_log_entry_type(entry)); =20 + g_assert(source); if (source->mask & event_mask) { break; } --=20 2.23.0