From nobody Sun Dec 22 01:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1734523057369923.5744746449529; Wed, 18 Dec 2024 03:57:37 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id F14D61542; Wed, 18 Dec 2024 06:57:35 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DCBB51544; Wed, 18 Dec 2024 06:57:11 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E013A1463; Wed, 18 Dec 2024 06:57:08 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4F4CAA53 for ; Wed, 18 Dec 2024 06:57:08 -0500 (EST) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-186-2cFO50hlNJ-CNKRDMUbhPw-1; Wed, 18 Dec 2024 06:57:06 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 71EBC195608E for ; Wed, 18 Dec 2024 11:57:05 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.3.236]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B414E1956096 for ; Wed, 18 Dec 2024 11:57:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734523027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jTGo/qHbBLm4Drs1rmzU6tR+P9QwjTKzyRN4Igsrf9Q=; b=QaLUk/5hHJQv9Rbymn42ICoeqhNrK1leiMfWVESNSYy08iypBwLFQ0vK+QCAjT4nPTZRTx Hf5BLMVEKTeYlsgT44WtiTbnkiRwyJvgZaFczJRFDi89o5DdkkaBv1ilXcInj4qUg2EBTV /6WCx9x2gZs2nM82Hs26JUChvi9qMdY= X-MC-Unique: 2cFO50hlNJ-CNKRDMUbhPw-1 X-Mimecast-MFC-AGG-ID: 2cFO50hlNJ-CNKRDMUbhPw From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] qemu: Enable I/O APIC even more frequently Date: Wed, 18 Dec 2024 12:57:02 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lzBks3ttKy4W1GxuFAE_Rs5DCSKaHVV8VtY2tkcMaT0_1734523025 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JHXXQVB2QZIRMKXNZ7QJVZW4AOQ7LMPT X-Message-ID-Hash: JHXXQVB2QZIRMKXNZ7QJVZW4AOQ7LMPT X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1734523058503116600 Content-Type: text/plain; charset="utf-8"; x-default="true" In my previous commit v10.10.0-48-g2d222ecf6e I've made us enable I/O APIC when there is an IOMMU with EIM. This works well. What does not work is case when there's just an IOMMU without EIM but with 256+ vCPUS. Problem is that post parsing happens in two stages: general domain post parse (where qemuDomainDefEnableDefaultFeatures() is called) and then per device post parse (where qemuDomainIOMMUDefPostParse() is called). Now, in aforementioned case it is the device post parse phase where EIM is enabled but the code that would enable VIR_DOMAIN_FEATURE_IOAPIC has already run. To resolve this, make the domain post parse callback "foresee" the future enabling of EIM so that it can turn on I/O APIC beforehand. Resolves: https://issues.redhat.com/browse/RHEL-65844 Fixes: 2d222ecf6e73614a400b830ac56e9aaa1bc55ecc Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark --- src/qemu/qemu_postparse.c | 21 +++++++++--- ...m-autoadd-v2.x86_64-latest.abi-update.args | 1 + ...im-autoadd-v2.x86_64-latest.abi-update.xml | 1 + .../intel-iommu-eim-autoadd-v2.xml | 32 +++++++++++++++++++ tests/qemuxmlconftest.c | 1 + 5 files changed, 51 insertions(+), 5 deletions(-) create mode 120000 tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64= -latest.abi-update.args create mode 120000 tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64= -latest.abi-update.xml create mode 100644 tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.xml diff --git a/src/qemu/qemu_postparse.c b/src/qemu/qemu_postparse.c index 4fbd849ebf..34b95ece1b 100644 --- a/src/qemu/qemu_postparse.c +++ b/src/qemu/qemu_postparse.c @@ -783,6 +783,15 @@ qemuDomainPstoreDefPostParse(virDomainPstoreDef *pstor= e, } =20 =20 +static bool +qemuDomainNeedsIOMMUWithEIM(const virDomainDef *def) +{ + return ARCH_IS_X86(def->os.arch) && + virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM && + qemuDomainIsQ35(def); +} + + static int qemuDomainIOMMUDefPostParse(virDomainIOMMUDef *iommu, const virDomainDef *def, @@ -793,9 +802,7 @@ qemuDomainIOMMUDefPostParse(virDomainIOMMUDef *iommu, * (EIM) is not explicitly turned off, let's enable it. If we didn't t= hen * guest will have troubles with interrupts. */ if (parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE && - ARCH_IS_X86(def->os.arch) && - virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM && - qemuDomainIsQ35(def) && + qemuDomainNeedsIOMMUWithEIM(def) && iommu && iommu->model =3D=3D VIR_DOMAIN_IOMMU_MODEL_INTEL) { =20 /* eim requires intremap. */ @@ -1548,9 +1555,13 @@ qemuDomainDefEnableDefaultFeatures(virDomainDef *def, def->features[VIR_DOMAIN_FEATURE_GIC] =3D VIR_TRISTATE_SWITCH_ON; } =20 - /* IOMMU with intremap requires split I/O APIC */ + /* IOMMU with intremap requires split I/O APIC. But it may happen that + * domain already has IOMMU without inremap. This will be fixed in + * qemuDomainIOMMUDefPostParse() but there domain definition can't be + * modified so change it now. */ if (def->iommu && - def->iommu->intremap =3D=3D VIR_TRISTATE_SWITCH_ON && + (def->iommu->intremap =3D=3D VIR_TRISTATE_SWITCH_ON || + qemuDomainNeedsIOMMUWithEIM(def)) && def->features[VIR_DOMAIN_FEATURE_IOAPIC] =3D=3D VIR_DOMAIN_IOAPIC_= NONE) { def->features[VIR_DOMAIN_FEATURE_IOAPIC] =3D VIR_DOMAIN_IOAPIC_QEM= U; } diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest= .abi-update.args b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-= latest.abi-update.args new file mode 120000 index 0000000000..a7fdee3d71 --- /dev/null +++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-up= date.args @@ -0,0 +1 @@ +intel-iommu-eim-autoadd.x86_64-latest.abi-update.args \ No newline at end of file diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest= .abi-update.xml b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-l= atest.abi-update.xml new file mode 120000 index 0000000000..928ea1b4c8 --- /dev/null +++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-up= date.xml @@ -0,0 +1 @@ +intel-iommu-eim-autoadd.x86_64-latest.abi-update.xml \ No newline at end of file diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.xml b/tests/q= emuxmlconfdata/intel-iommu-eim-autoadd-v2.xml new file mode 100644 index 0000000000..b39ee55786 --- /dev/null +++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 288 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + +
+ + + + +