From nobody Sat May 18 14:10:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659963833; cv=none; d=zohomail.com; s=zohoarc; b=PeKy0H17IyQ/mMFyQbipH6YJXFZS6U9iMfjtJuEomc0/GLkdgPwiyBS2vi+zKR2fapaB/GezIXnqerQrvl+4xxdwtg7/rsfBz/a5EFcod99w6qmMErZmkbt+51bwpqS5ZYFtcwpkzDRU+Lw7pRU9gv3+mgi86EGr29vZQleLtrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659963833; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lZKtAmOvwM/HfqCxTkAgfhpyJ9CCy9mshoUccwFyE7Q=; b=FZreW9MPAuHfOHJPabCHRlGYbwbuvEaAhueTqnHfKJ1fepmbq4KXPURqi0iPoNLhU+bT4Oc/SRO/F7Oq6O2d+IdWgWy4oRV5vxVbZJDSjFRUFeqXzM92NiOT5I9onIRCCihS84/zphy3c2bUL9Qp7vCpmNh+SUPKnAWR7BK2Cwo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1659963833630744.6705099182165; Mon, 8 Aug 2022 06:03:53 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-8-vOqII4ArOI6kruMqDVvkdQ-1; Mon, 08 Aug 2022 09:03:51 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65BCE802D2C; Mon, 8 Aug 2022 13:03:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A23F940315F; Mon, 8 Aug 2022 13:03:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 416F41946A4F; Mon, 8 Aug 2022 13:03:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 825B61946A49 for ; Mon, 8 Aug 2022 13:03:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 72FA01415125; Mon, 8 Aug 2022 13:03:45 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E720140EBE3 for ; Mon, 8 Aug 2022 13:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659963832; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lZKtAmOvwM/HfqCxTkAgfhpyJ9CCy9mshoUccwFyE7Q=; b=bnJ/LeBpSBNFOJ507mwiS37YG+eVAPXVV+p9+O/UB4MS5TQoheyOKAuTJfY7NIvw8DLX4T 4oxsvROfy4ojiQh1MamPzKMPD4Bzw9BkO8FOsJXlItfGOV7S5hOfo9g1KcWMTee6nxpLnm zrPjIZZZpB6Ac/ETnNhwbf50UnoeD+E= X-MC-Unique: vOqII4ArOI6kruMqDVvkdQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] conf: Check IOMMU for unsupported attributes Date: Mon, 8 Aug 2022 15:03:43 +0200 Message-Id: <0344a8d971deacf9595ef0495edec560ddb44301.1659963823.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659963834395100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Currently, it's possible to pass various attributes to an IOMMU's element hoping that we enable them in underlying hypervisor. However, depending on the IOMMU model, some of these attributes can't be enabled and are simply ignored. This is suboptimal and we should reject such configuration in the validate phase. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2101633 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_validate.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index d4d72037d5..88205c64e0 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2632,8 +2632,20 @@ static int virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu) { switch (iommu->model) { - case VIR_DOMAIN_IOMMU_MODEL_INTEL: case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: + if (iommu->intremap !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->caching_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->eim !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->iotlb !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->aw_bits !=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("iommu model '%s' doesn't support additional = attributes"), + virDomainIOMMUModelTypeToString(iommu->model)); + return -1; + } + G_GNUC_FALLTHROUGH; + + case VIR_DOMAIN_IOMMU_MODEL_INTEL: if (iommu->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%s' can't have address"), @@ -2643,6 +2655,18 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *i= ommu) break; =20 case VIR_DOMAIN_IOMMU_MODEL_VIRTIO: + if (iommu->intremap !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->caching_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->eim !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->iotlb !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->aw_bits !=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("iommu model '%s' doesn't support additional = attributes"), + virDomainIOMMUModelTypeToString(iommu->model)); + return -1; + } + break; + case VIR_DOMAIN_IOMMU_MODEL_LAST: break; } --=20 2.35.1