From patchwork Fri Sep 3 14:32:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 506530 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1053934jai; Fri, 3 Sep 2021 07:34:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwznsQJZWIB4+zBMYANRx8+b4TftRcoMz2IvERpJrxCSgBEAW9+tqBbvBEnRgOaHG5CB8T5 X-Received: by 2002:a1c:791a:: with SMTP id l26mr726105wme.100.1630679641213; Fri, 03 Sep 2021 07:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630679641; cv=none; d=google.com; s=arc-20160816; b=SfQ2XuPspxgfYw6qKVgEeg5uJnbWSeMQm1BasW7Sgn1GCebOhAnmAUAffPH5Nf2usC rcAd0wTDymopX1xXMhkAh5rz31vkNP1BR5mGWEg7PBCTcDusv4BiEnqjXsERLtuavC0c S0fKeglJikh7hNuUd05H8qfYrU81LanVfOECYasqPsKbPjbUFSO+aMrnrBC/Zt4UOGd9 c8vK1bbvjam/1uUj6seNDp9jIhaUGFTl2g/eK2gQb3RRJycv34SlLVcNqO8rhOgo+7Cf nA/AO1N3RsEW8GFcbm7M70EkVXxK2gCMEFke9OCO0cknKbiTaZPrQLpjDvNemfC8XaM3 UYug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UxcqYjdwb5grCsEtYCrZaLaggu6vBfiVHeFPBWbw7CM=; b=LuiaGeydE1TuSw2ncyJ4QNq5aXnDUEyw4kO7AZFnEmuFWMHlKFtRKSL8CxE1JHnxFE DN8Yu9eAa3ifILdPTJEL1qXKErS6W/T1GC+gGSqB7imJC9US+Dkds/txQZZNplkFU0+t 0nkwhtpxjCUZhYONc+KuHaJsAKwTsq7SNWhnNA/xM56R/1HCMRgak5933PRhFPLtfwCV RZVYOIFjq3ozvdIRIR0AhNc/bGM56eIMaV1GRLypifwaC9j1cr9mVnbQ5A+DUcVEQ/Uu l7Ax6I0Lrhj3T7aKR9kL9q1VhkjpUX5xbegh9ZHw1DUM+SX7kIqTxYafZjbPm/q5gZ7e y+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IIV+j1dS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v16si5166206wrn.119.2021.09.03.07.34.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Sep 2021 07:34:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IIV+j1dS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMAGW-0005DS-6g for patch@linaro.org; Fri, 03 Sep 2021 10:34:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMAFI-0004JH-KG for qemu-devel@nongnu.org; Fri, 03 Sep 2021 10:32:45 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:38472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMAFG-0005eI-Rf for qemu-devel@nongnu.org; Fri, 03 Sep 2021 10:32:44 -0400 Received: by mail-wm1-x329.google.com with SMTP id k5-20020a05600c1c8500b002f76c42214bso3923203wms.3 for ; Fri, 03 Sep 2021 07:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UxcqYjdwb5grCsEtYCrZaLaggu6vBfiVHeFPBWbw7CM=; b=IIV+j1dSH7z4li39LHeHXAEnltDMk8/0yqjw3UGhfTaou44HOQt01kRTmhHTbqbbhS dOqkINoUG3zl8a5fk5ugqT4AxUiZ311Q0zm0kmsTZ5QaJNt3V2v+WUBqobInRJzJIprR OUDypIGqYuC74QcEDsrUAWOdiMckpab4lu0riCvmPqfNGwBIKqOTx8Bl1c8ag5VAbHV4 bFMvnhJ+OyIBu3mrNHcQyf5XfkiSwfgGCy1gA55qruSsqDWNZjrnN6e8r0r6x0PBfJZr t8bmNKekRLCMTmEirEVmmEcEdnfVeY9O7Qk1a97Jj+jsXkDTn6M2z7KkjoQr0hjJzHop Gv3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UxcqYjdwb5grCsEtYCrZaLaggu6vBfiVHeFPBWbw7CM=; b=Iu2hmUT2YMjF8fBv+RtNzn6pkRmpPc1nepFah2b4jxqi0YxaCJEDZugPfTixdnV0lR kzoPj7BYzgDS9zKnq8aXQaxYGQyUufF+CQjUfx0bCkR7o6BULCehkNUoMDRVw76zhO98 3D/AR4PwGWJ6JOgiyhMwQce5bKYz7/9QXRhq8+KUyz5iiMUWR3Lq2GDDQeeNtyexJyNf +WdAQMWwXHfiQmSihwlJtNCrMo9eW4GkLkrIjxN5qLzR8Fkw3ij8yqLsXvq8wJUxttez 9aUSUfes5CQsLGNaHEVsjTxt+uiMnJvAvFT9sxI4zTQIST1iNVkavMgIAUrYnj1GUyRJ gR3A== X-Gm-Message-State: AOAM533jDmF4iXvPJEMIKHpTp/bTGJQn5eqLOAdrDEmyN16GGWCXRzEG 5+r0NOyqFYUBr0g0iK3AnhEX5g== X-Received: by 2002:a1c:a903:: with SMTP id s3mr648689wme.171.1630679561543; Fri, 03 Sep 2021 07:32:41 -0700 (PDT) Received: from localhost.localdomain (19.11.114.78.rev.sfr.net. [78.114.11.19]) by smtp.gmail.com with ESMTPSA id z2sm4314843wma.45.2021.09.03.07.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 07:32:41 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH v2 5/8] hw/arm/virt: Reject instantiation of multiple IOMMUs Date: Fri, 3 Sep 2021 16:32:06 +0200 Message-Id: <20210903143208.2434284-6-jean-philippe@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210903143208.2434284-1-jean-philippe@linaro.org> References: <20210903143208.2434284-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=jean-philippe@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com, Jean-Philippe Brucker , qemu-arm@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We do not support instantiating multiple IOMMUs. Before adding a virtio-iommu, check that no other IOMMU is present. This will detect both "iommu=smmuv3" machine parameter and another virtio-iommu instance. Signed-off-by: Jean-Philippe Brucker --- hw/arm/virt.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.33.0 Reviewed-by: Eric Auger diff --git a/hw/arm/virt.c b/hw/arm/virt.c index b4598d3fe6..5ca225291f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2475,6 +2475,11 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { PCIDevice *pdev = PCI_DEVICE(dev); + if (vms->iommu != VIRT_IOMMU_NONE) { + error_setg(errp, "virt machine does not support multiple IOMMUs"); + return; + } + vms->iommu = VIRT_IOMMU_VIRTIO; vms->virtio_iommu_bdf = pci_get_bdf(pdev); create_virtio_iommu_dt_bindings(vms);