From nobody Fri May 17 06:07:30 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1598027539; cv=none; d=zohomail.com; s=zohoarc; b=V6JnC2oWb36zhCGsqFkiSN167s07UxwZEsq887m2ZzxhBkEB6qBPTlgkfQ3Iqe353ATPOJwjHJC8QRvQMovEPcQGPDjPN0DF9Rh5fO30uo10LI9Xm4ggpSVPEz35DNaQKecOHF4EnJT2Q9kz+P5IAYXuLnY2NSjt3ypn8Dz2JIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598027539; 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=OuI8xnJndStSpo+ETjU3EU4hq5mCXR/FiYpus8sMWls=; b=S7AQDg+jNPjh2CAY3WjdYMHwvD1u3bV52yXdWJANu2j5/qAbul1afi58XzK9u3nE6Xs60ZrGSMNTKiWYohIZXqvU5FPeDqIuI/Alz28ahUXBbEx6ZGtVCpj5WBnd0k2behGFUlwjKSei/ZA23QD3SVMtLYwzgDClU1EzF12A8Zc= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598027539536380.3486099560754; Fri, 21 Aug 2020 09:32:19 -0700 (PDT) Received: from localhost ([::1]:34006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k99xi-0001fY-2g for importer@patchew.org; Fri, 21 Aug 2020 12:32:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k99vx-0007tc-Rp for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:30 -0400 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]:32796) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k99vt-0006na-KE for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:29 -0400 Received: by mail-ej1-x644.google.com with SMTP id u21so2335586ejz.0 for ; Fri, 21 Aug 2020 09:30:25 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id dk28sm1398030edb.90.2020.08.21.09.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:30:23 -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=OuI8xnJndStSpo+ETjU3EU4hq5mCXR/FiYpus8sMWls=; b=RtBd0+/tA0QB1kHWt9+BsloshL2hCQZsnr/oWm+0HJJVwqLPFyn6AT+SofxvLmuImX PsAfS3QcpNvxXPTTMzY3cg6GuW96O0nt20YxLWuOGab+e7ycvFO3onzdsygv0zXeSGCm gYk+MvS8rqcGAYFuVDwVYaUqZk7juHUkq9QcyCJc/eXlChsskoDjukYCLbfPuTNafalP QDS9V8yzFoUdYxgtAC7XBfW5fVgxkgfXSNcj86Ohb4gMrHsqlCCf0qhOsxs6Lr3MgLT4 cfYA588+j0y5p9YHHNgRaceedtGSBwmhCMKDLafRTMjagMg3ykvVBSqTwK/dVu4jpvJe a1rQ== 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=OuI8xnJndStSpo+ETjU3EU4hq5mCXR/FiYpus8sMWls=; b=g7gt+i2CVTcVEBdcaLTOciHqx772YhugYi5iJGHkeAv/TIeA8apiy/tlEwK3dRew31 CulBLMaaVYPi3YB9om0gjl4Ty7/vmjjc7vEgVPd6AH/vgrws9r5kVnzbd3f9c7/OFlgT YxJZB2GCGwrxBiJs8V6zhV7SsYuX4MHVKRNnyOJ0PLIHhvhgAcZsm51fy/mtoSvKr3L6 wZoLWnJv1pMtcG8mFpDtdGvdmmqYmONmiVtJUXaQWHEhDxvohvXfChq3Zze4hcMmw/7e OpwEbQvwzMs6NcKLB4MfTauGa0zwKJ2L0OJrrgOKUWGJxikdVR7vJuVMPPxKp/1BTOVl XYvw== X-Gm-Message-State: AOAM531w/oJan7q+fqTM7IAebVer3In/B0U80jcRzbK0JEfADOVrotkY zweDQG5BDud5kddDALoD0yXElw== X-Google-Smtp-Source: ABdhPJwMXGGsR4gh8umR9SklPbRw5s4nq1puTvleMsU70gLFRDo151sSV9Us4kSCKKUpuk9waTQ+KQ== X-Received: by 2002:a17:906:3e06:: with SMTP id k6mr3616203eji.37.1598027423946; Fri, 21 Aug 2020 09:30:23 -0700 (PDT) From: Jean-Philippe Brucker To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 1/5] virtio-iommu: Default to bypass during boot Date: Fri, 21 Aug 2020 18:28:35 +0200 Message-Id: <20200821162839.3182051-2-jean-philippe@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200821162839.3182051-1-jean-philippe@linaro.org> References: <20200821162839.3182051-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::644; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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.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, eric.auger@redhat.com, Jean-Philippe Brucker , pbonzini@redhat.com, rth@twiddle.net 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" When a virtio-iommu is present, we currently require the guest to configure it before it can use DMA in any other PCI device. This prevents, for example, a bootloader that doesn't know how to drive virtio-iommu from loading an OS from storage. Add the "boot-bypass" option, defaulting to true, to let DMA bypass the virtio-iommu during boot similarly to the other vIOMMUs. It makes the system vulnerable to malicious endpoints during boot, but that isn't much of a concern in virtual systems. Signed-off-by: Jean-Philippe Brucker --- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-io= mmu.h index 49eb105cd84..ae57efab1f3 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -58,6 +58,7 @@ typedef struct VirtIOIOMMU { GTree *domains; QemuMutex mutex; GTree *endpoints; + bool boot_bypass; } VirtIOIOMMU; =20 #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 5d56865e569..3b821fc005d 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -595,6 +595,24 @@ static void virtio_iommu_report_fault(VirtIOIOMMU *vio= mmu, uint8_t reason, =20 } =20 +static bool virtio_iommu_bypass_is_allowed(VirtIOIOMMU *s) +{ + VirtIODevice *vdev =3D &s->parent_obj; + /* + * Allow bypass if: + * - boot_bypass is enabled and the BYPASS feature hasn't yet been + * acknowledged. + * - the BYPASS feature has been negotiated. + */ + if (s->boot_bypass && !(vdev->status & VIRTIO_CONFIG_S_FEATURES_OK)) { + return true; + } + if (virtio_vdev_has_feature(vdev, VIRTIO_IOMMU_F_BYPASS)) { + return true; + } + return false; +} + static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr = addr, IOMMUAccessFlags flag, int iommu_idx) @@ -621,8 +639,7 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemory= Region *mr, hwaddr addr, .perm =3D IOMMU_NONE, }; =20 - bypass_allowed =3D virtio_vdev_has_feature(&s->parent_obj, - VIRTIO_IOMMU_F_BYPASS); + bypass_allowed =3D virtio_iommu_bypass_is_allowed(s); =20 sid =3D virtio_iommu_get_bdf(sdev); =20 @@ -947,6 +964,7 @@ static const VMStateDescription vmstate_virtio_iommu = =3D { =20 static Property virtio_iommu_properties[] =3D { DEFINE_PROP_LINK("primary-bus", VirtIOIOMMU, primary_bus, "PCI", PCIBu= s *), + DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.28.0 From nobody Fri May 17 06:07:30 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1598027662; cv=none; d=zohomail.com; s=zohoarc; b=lrbaB31USrOYGIlHqYbHpSXaaA5wQqxi6zAZV0dSAtwB+zGaEXXT98Pwb3eXTdvBu8Ot6QTc/k6UfzL/hpbdq5XaAf+BsLGtC9fwbrqKvLVqrOWikrSF6nAGHxZDl1v4ok3o9R9AJKgTQ7uact3rZ0bnWywajVYP6ilR3SuTV3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598027662; 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=cfGEtVcjgxqVubuTMIgt6HrOoNGCRwyjjLNrvoUWZIE=; b=T2trO1blR0QcejfObFwu45/rCLp1GwBHGYKNGtAm8r8jJIrKE/lGSF/u/ulwhU718KiuGyrcKR3WgHwXfuT0HfdVTcd5UxU63HTMGVQikzvSia6hBmoIKcQ2o/ft9sYY/K2JrDFwS1CfxdIYSBaQSfWM5G6wdEwrqQZdLuMc3d8= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598027662092969.0180506105269; Fri, 21 Aug 2020 09:34:22 -0700 (PDT) Received: from localhost ([::1]:41846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k99zg-0005UO-KO for importer@patchew.org; Fri, 21 Aug 2020 12:34:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k99vz-0007u9-3w for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:31 -0400 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:33843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k99vv-0006nm-K8 for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:30 -0400 Received: by mail-ej1-x643.google.com with SMTP id o23so3030129ejr.1 for ; Fri, 21 Aug 2020 09:30:26 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id dk28sm1398030edb.90.2020.08.21.09.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:30:24 -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=cfGEtVcjgxqVubuTMIgt6HrOoNGCRwyjjLNrvoUWZIE=; b=FcVI/YAV+PBNs/h35+luBqIu5MBgP4JC3OJUnM+kHCHF8ZyBBS5CkJCszjSsrW53QR YY3GkGj2Lf01ntsQIcD/7onmQKw9EeGyAjZX4BjlVFjH7m44yVGxOyu0OYcdsrCop0Wv 1Z16aIRw/4al5FceE09chtSY4OibYq+/HOsq0oZuuIn2gW6w+CAcIUs+jbGb2731gsyS DtcrE4QQmJ8v00DC7ktgUZHN4ORb1qjBh+GRrAVFhusNI1ZZfQBiDfNI+OLxxLu7dex4 SP5gdCu7ykqhNMW2y9C/uShqtv48zYfuvxd20DThCDj2EJKLHtdceZtLiLUpPoVkgi9n uHvQ== 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=cfGEtVcjgxqVubuTMIgt6HrOoNGCRwyjjLNrvoUWZIE=; b=V1d6EOLKxsGU3fYrsEfOf3rca15dB0auuYZwoZcbF43yZqDziy3tbxri8+CsYUgHxP Qc2qONwpyc1yyN1kqOn2TPj/PyyXuXiJjbQYsvjtLZrtNCdWOQqy9FiXp//eoR5NS2Cv ISWM4ukqmS6JFJJPQuXSfhCTCHl6V3mP0odpyY/l0LqDPds1pDKGiKWnyGqo52nNPxxt LTAk21Pe6/fhFxAINK4NP/gAkWiym8Ll6e9o/ulHigGdZpHdt+qnER98kGER5Gsh1Wb/ XubsnMRWRAhStjeTOYpPpSZiffIU2SB5SEnnynxXalQUN8fL1TLJhzFONvm42NuOvIYl 9miw== X-Gm-Message-State: AOAM53242XsuR8tTmNhY3arFv4nsFQCxehhHztPUtJEEt7a5rzEGF7pi BBp2JoZgrxQbXxHZKNkx5WJ7Jw== X-Google-Smtp-Source: ABdhPJz6ycDFGslYAKVe3XafSFgwZH19GNj3LKMVVzVuLVIv+62GHiDvGCjt/XSNwnDm4w8RB8P1cg== X-Received: by 2002:a17:906:9989:: with SMTP id af9mr3498328ejc.385.1598027425104; Fri, 21 Aug 2020 09:30:25 -0700 (PDT) From: Jean-Philippe Brucker To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 2/5] linux headers: Import virtio-iommu header from Linux Date: Fri, 21 Aug 2020 18:28:36 +0200 Message-Id: <20200821162839.3182051-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200821162839.3182051-1-jean-philippe@linaro.org> References: <20200821162839.3182051-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::643; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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.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, eric.auger@redhat.com, Jean-Philippe Brucker , pbonzini@redhat.com, rth@twiddle.net 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" Import virtio-iommu topology definitions from Linux. These changes haven't been upstreamed yet. Signed-off-by: Jean-Philippe Brucker --- include/standard-headers/linux/virtio_iommu.h | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/include/standard-headers/linux/virtio_iommu.h b/include/standa= rd-headers/linux/virtio_iommu.h index b9443b83a13..ee158c37c36 100644 --- a/include/standard-headers/linux/virtio_iommu.h +++ b/include/standard-headers/linux/virtio_iommu.h @@ -16,6 +16,7 @@ #define VIRTIO_IOMMU_F_BYPASS 3 #define VIRTIO_IOMMU_F_PROBE 4 #define VIRTIO_IOMMU_F_MMIO 5 +#define VIRTIO_IOMMU_F_TOPOLOGY 6 =20 struct virtio_iommu_range_64 { uint64_t start; @@ -27,6 +28,17 @@ struct virtio_iommu_range_32 { uint32_t end; }; =20 +struct virtio_iommu_topo_config { + /* Number of topology description structures */ + uint16_t count; + /* + * Offset to the first topology description structure + * (virtio_iommu_topo_*) from the start of the virtio_iommu config + * space. Aligned on 8 bytes. + */ + uint16_t offset; +}; + struct virtio_iommu_config { /* Supported page sizes */ uint64_t page_size_mask; @@ -36,6 +48,38 @@ struct virtio_iommu_config { struct virtio_iommu_range_32 domain_range; /* Probe buffer size */ uint32_t probe_size; + struct virtio_iommu_topo_config topo_config; +}; + +#define VIRTIO_IOMMU_TOPO_PCI_RANGE 0x1 +#define VIRTIO_IOMMU_TOPO_MMIO 0x2 + +struct virtio_iommu_topo_pci_range { + /* VIRTIO_IOMMU_TOPO_PCI_RANGE */ + uint8_t type; + uint8_t reserved; + /* Length of this structure */ + uint16_t length; + /* First endpoint ID in the range */ + uint32_t endpoint_start; + /* PCI domain number */ + uint16_t segment; + /* PCI Bus:Device.Function range */ + uint16_t bdf_start; + uint16_t bdf_end; + uint16_t padding; +}; + +struct virtio_iommu_topo_mmio { + /* VIRTIO_IOMMU_TOPO_MMIO */ + uint8_t type; + uint8_t reserved; + /* Length of this structure */ + uint16_t length; + /* Endpoint ID */ + uint32_t endpoint; + /* Address of the first MMIO region */ + uint64_t address; }; =20 /* Request types */ --=20 2.28.0 From nobody Fri May 17 06:07:30 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1598027542; cv=none; d=zohomail.com; s=zohoarc; b=m+yTrUaKrIXOX8DTS6gqjxH+lZKxVhbPk1NvpZRBTreDT0DfbhOgVXQYXqzYREaJs63twBrmAG8oN8lNaZJjEEMEpD4/v75d6CWW1uJFLhZTQIMp2meOzp0ExupUKAn9Yh7mtsUpF5B+WyCcyLa531UJl9qo9Y8rTL4QpG5Edo8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598027542; 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=TxGD9EzF0atjNPI3j2WNYptRLPX7AMvR+MeE+NZH67c=; b=RNpmynI0TWKk0W7qIhrtgdjM+KqfRHwWm1g76Pa2/G3h9T7Y/8LM1hzpiPj4u2HrgjGWW+5s1W9rz3d8VFZm91ozPtTJgzSBx8M0oOFN7RVZAn9IiY7Fk92dz2IIYZQdTP3nCA1YATa5wJFUXhFSZs5Cukr7pe7SDg+IYK0WcIQ= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598027542707152.9238667787397; Fri, 21 Aug 2020 09:32:22 -0700 (PDT) Received: from localhost ([::1]:34332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k99xl-0001o9-5t for importer@patchew.org; Fri, 21 Aug 2020 12:32:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k99vz-0007ut-Ri for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:33 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:34488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k99vv-0006oC-KG for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:31 -0400 Received: by mail-ed1-x543.google.com with SMTP id bs17so1953410edb.1 for ; Fri, 21 Aug 2020 09:30:27 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id dk28sm1398030edb.90.2020.08.21.09.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:30:25 -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=TxGD9EzF0atjNPI3j2WNYptRLPX7AMvR+MeE+NZH67c=; b=kO3g8v1q0f7H3hTLphPPV3FBTUrC4poIBwQrOkiQ5YjlAeyRY/IITAyhLYuiRHSXFh c3NB7mo/7qnxxY/ihLkoHeg8/18q0nDWDfDvZuTYey8yKzlZcJEYC9/66cwVdlh+OX7U jhLvNcpG5ypJgcmlWNVnt5AaCZlW4+HeWmhgbH2XU5tvjoK873ogHchZCoenXe8LOSz2 Ib1y+dHARnQqGYhJvd+MY35KiSc2wo5OaMJhxH3tgOqL3D+lvm57Y83p9XbSaq1v6wGa V7Fnj00TSWZCNfJEVuJfUain8Ra5POsr34dzX3JUFm5IQBuwzAxtpVrInvLTZ1q+G93O IR8A== 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=TxGD9EzF0atjNPI3j2WNYptRLPX7AMvR+MeE+NZH67c=; b=mAEEyQwQ5S6hCRNwCtoIiJgSemV0vbi+nPO2NHQYbyMZD88jw2Qx/0xlkmBJHAo3eu DP8UgH05KipkRwhQZiCx8FwRM5MwfB3O78kQC0McvhmDdQkD2/Fx8p+QP5Kd5MDWzDth OERRsJEc7rZbRJ6nIGxItYadLC5wOArNJ0EfiLA7TwB0kiR0r2bFF2RaWeleM68eFMdV E6hWoe8Ek4jelsXKluE2Sa+ocB6pAhVfnOdMDkdQMzn+j70/K295L+8F60bbAcud4ZTq MIQPnN+ZYm3yOd1S8MR4g9vuLlMxAHcF7iJcfRZcEowgA/azTQvarc8cC+droDQVJ2ot mBXg== X-Gm-Message-State: AOAM533+AGori5fcyasXzfuEX3LwoqvUzcwthg/0WrSoZH7TrBfsLxcy eiGAu/LbmiL1Xu0u2mhvGeHWcw== X-Google-Smtp-Source: ABdhPJwtORdgeJH4zWU3nHnM9Cze/sPsDJdTJdTCj5radZQVQ3aEsuBnpSYyPoFftZY3NC/vPuMnYw== X-Received: by 2002:a05:6402:22ab:: with SMTP id cx11mr3816150edb.102.1598027426267; Fri, 21 Aug 2020 09:30:26 -0700 (PDT) From: Jean-Philippe Brucker To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 3/5] virtio-iommu: Declare topology in config space Date: Fri, 21 Aug 2020 18:28:37 +0200 Message-Id: <20200821162839.3182051-4-jean-philippe@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200821162839.3182051-1-jean-philippe@linaro.org> References: <20200821162839.3182051-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::543; envelope-from=jean-philippe@linaro.org; helo=mail-ed1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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, eric.auger@redhat.com, Jean-Philippe Brucker , pbonzini@redhat.com, rth@twiddle.net 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" When requested on the command-line, by adding topology=3Don to the virtio-iommu device, provide the IOMMU topology in the virtio config space. It describes which endpoints are managed by the IOMMU - all PCI devices - and allows to support: * virtio-iommu for platforms without ACPI or DT (e.g. microvm), * virtio-iommu for ACPI platforms, temporarily. A new ACPI table will be introduced to handle those, but this provides a boot method in the meantime. Signed-off-by: Jean-Philippe Brucker --- include/hw/virtio/virtio-iommu.h | 3 +++ hw/virtio/virtio-iommu.c | 40 ++++++++++++++++++++++++++++---- hw/virtio/trace-events | 4 ++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-io= mmu.h index ae57efab1f3..7ba1dacf75d 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -49,6 +49,7 @@ typedef struct VirtIOIOMMU { VirtQueue *req_vq; VirtQueue *event_vq; struct virtio_iommu_config config; + struct virtio_iommu_topo_pci_range pci_topo; uint64_t features; GHashTable *as_by_busptr; IOMMUPciBus *iommu_pcibus_by_bus_num[PCI_BUS_MAX]; @@ -59,6 +60,8 @@ typedef struct VirtIOIOMMU { QemuMutex mutex; GTree *endpoints; bool boot_bypass; + /* Declare topology in config space */ + bool topology; } VirtIOIOMMU; =20 #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 3b821fc005d..08ab457ccf1 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -731,15 +731,24 @@ unlock: =20 static void virtio_iommu_get_config(VirtIODevice *vdev, uint8_t *config_da= ta) { + off_t offset; VirtIOIOMMU *dev =3D VIRTIO_IOMMU(vdev); struct virtio_iommu_config *config =3D &dev->config; + struct virtio_iommu_topo_pci_range *pci_topo =3D &dev->pci_topo; =20 trace_virtio_iommu_get_config(config->page_size_mask, config->input_range.start, config->input_range.end, config->domain_range.end, - config->probe_size); - memcpy(config_data, &dev->config, sizeof(struct virtio_iommu_config)); + config->probe_size, + config->topo_config.offset, + config->topo_config.count); + memcpy(config_data, config, sizeof(*config)); + + offset =3D config->topo_config.offset; + if (offset) { + memcpy(config_data + offset, pci_topo, sizeof(*pci_topo)); + } } =20 static void virtio_iommu_set_config(VirtIODevice *vdev, @@ -747,12 +756,14 @@ static void virtio_iommu_set_config(VirtIODevice *vde= v, { struct virtio_iommu_config config; =20 - memcpy(&config, config_data, sizeof(struct virtio_iommu_config)); + memcpy(&config, config_data, sizeof(config)); trace_virtio_iommu_set_config(config.page_size_mask, config.input_range.start, config.input_range.end, config.domain_range.end, - config.probe_size); + config.probe_size, + config.topo_config.offset, + config.topo_config.count); } =20 static uint64_t virtio_iommu_get_features(VirtIODevice *vdev, uint64_t f, @@ -776,9 +787,10 @@ static void virtio_iommu_device_realize(DeviceState *d= ev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOIOMMU *s =3D VIRTIO_IOMMU(dev); + size_t aligned_config_size =3D QEMU_ALIGN_UP(sizeof(s->config), 8); =20 virtio_init(vdev, "virtio-iommu", VIRTIO_ID_IOMMU, - sizeof(struct virtio_iommu_config)); + aligned_config_size + sizeof(s->pci_topo)); =20 memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_nu= m)); =20 @@ -791,6 +803,12 @@ static void virtio_iommu_device_realize(DeviceState *d= ev, Error **errp) s->config.domain_range.end =3D 32; s->config.probe_size =3D VIOMMU_PROBE_SIZE; =20 + if (s->topology) { + s->config.topo_config.offset =3D aligned_config_size; + s->config.topo_config.count =3D 1; + virtio_add_feature(&s->features, VIRTIO_IOMMU_F_TOPOLOGY); + } + virtio_add_feature(&s->features, VIRTIO_RING_F_EVENT_IDX); virtio_add_feature(&s->features, VIRTIO_RING_F_INDIRECT_DESC); virtio_add_feature(&s->features, VIRTIO_F_VERSION_1); @@ -810,6 +828,17 @@ static void virtio_iommu_device_realize(DeviceState *d= ev, Error **errp) } else { error_setg(errp, "VIRTIO-IOMMU is not attached to any PCI bus!"); } + + if (s->topology) { + s->pci_topo =3D (struct virtio_iommu_topo_pci_range) { + .type =3D cpu_to_le16(VIRTIO_IOMMU_TOPO_PCI_RANG= E), + .length =3D cpu_to_le16(sizeof(s->pci_topo)), + .endpoint_start =3D 0, + .segment =3D 0, + .bdf_start =3D 0, + .bdf_end =3D 0xffff, + }; + } } =20 static void virtio_iommu_device_unrealize(DeviceState *dev) @@ -965,6 +994,7 @@ static const VMStateDescription vmstate_virtio_iommu = =3D { static Property virtio_iommu_properties[] =3D { DEFINE_PROP_LINK("primary-bus", VirtIOIOMMU, primary_bus, "PCI", PCIBu= s *), DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true), + DEFINE_PROP_BOOL("topology", VirtIOIOMMU, topology, false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 045e89cae69..6c5830ca47c 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -59,8 +59,8 @@ virtio_mmio_setting_irq(int level) "virtio_mmio setting I= RQ %d" virtio_iommu_device_reset(void) "reset!" virtio_iommu_get_features(uint64_t features) "device supports features=3D0= x%"PRIx64 virtio_iommu_device_status(uint8_t status) "driver status =3D %d" -virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_range, uint32_t probe_size) "page_size_mask=3D0x%"PRIx= 64" start=3D0x%"PRIx64" end=3D0x%"PRIx64" domain_range=3D%d probe_size=3D0x= %x" -virtio_iommu_set_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_range, uint32_t probe_size) "page_size_mask=3D0x%"PRIx= 64" start=3D0x%"PRIx64" end=3D0x%"PRIx64" domain_bits=3D%d probe_size=3D0x%= x" +virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_range, uint32_t probe_size, uint16_t topo_offset, uint= 16_t topo_count) "page_size_mask=3D0x%"PRIx64" start=3D0x%"PRIx64" end=3D0x= %"PRIx64" domain_range=3D%d probe_size=3D0x%x topo_off=3D0x%x topo_count=3D= %u" +virtio_iommu_set_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_range, uint32_t probe_size, uint16_t topo_offset, uint= 16_t topo_count) "page_size_mask=3D0x%"PRIx64" start=3D0x%"PRIx64" end=3D0x= %"PRIx64" domain_bits=3D%d probe_size=3D0x%x topo_off=3D0x%x topo_count=3D%= u" virtio_iommu_attach(uint32_t domain_id, uint32_t ep_id) "domain=3D%d endpo= int=3D%d" virtio_iommu_detach(uint32_t domain_id, uint32_t ep_id) "domain=3D%d endpo= int=3D%d" virtio_iommu_map(uint32_t domain_id, uint64_t virt_start, uint64_t virt_en= d, uint64_t phys_start, uint32_t flags) "domain=3D%d virt_start=3D0x%"PRIx6= 4" virt_end=3D0x%"PRIx64 " phys_start=3D0x%"PRIx64" flags=3D%d" --=20 2.28.0 From nobody Fri May 17 06:07:30 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1598027680; cv=none; d=zohomail.com; s=zohoarc; b=b4b+jCkFoDz9qcex4El7Rghd9RX+kce5VgSDnzWMbIhiutZasC3XoCBulwaakFVUt0Kf5eYHpM85oDUlNJFJmv0H1au/SRmE9vs7CXOx2sktv0H6JiJIP26PxjXIiOCDiAu0Iboq0tMm8f/4Mw0T1yb6xzRFcUfrUL3CCUtsS8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598027680; 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=2+K4uxN0kyhXy6kN+ijSa8qFKCUtC4za1XiAKyb7Tws=; b=lUXMm1iZLBxWAwKxAu4LBDgk/9J7hv8FB22Imw+KQuBopba7uialMq7O7f46Yafu+1O6wmSkBRBPuNfAFYCT6i9IFYQuiRIjmL3DFA+J6KIiDKW8w+WMcqMFZzM23IAC9qf0ozWYkxhf8KiGeNNNWRiyBj4lYqU2YOIwXKOx1sk= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598027680566341.34248838938424; Fri, 21 Aug 2020 09:34:40 -0700 (PDT) Received: from localhost ([::1]:42422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k99zz-0005kw-6u for importer@patchew.org; Fri, 21 Aug 2020 12:34:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k99w1-0007w6-LP for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:33 -0400 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]:41121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k99vw-0006og-U6 for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:33 -0400 Received: by mail-ej1-x641.google.com with SMTP id t10so2996474ejs.8 for ; Fri, 21 Aug 2020 09:30:28 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id dk28sm1398030edb.90.2020.08.21.09.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:30:26 -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=2+K4uxN0kyhXy6kN+ijSa8qFKCUtC4za1XiAKyb7Tws=; b=abinKzoj5alQRqRp3d9/Y8vcOnoqK1So6bFU7ki3PlKlt1uvNdKbCPdngAzKsy+y5W OiHVOyZwhIeMR2BcuDAYXgAk1APbs4CV2S2fPd2D0+YlQDbzD+AVHl1Q+usVPUibVRQz 5RVjIt8AbuNJIv5DrBzz9ScYlA8i0Xa9wXdALwwG/0LGLXznK0Nwbl3Luk7tfG4dvBaq eGUs4kBH/Lgaoagre6TlxJQ85DG9o65B+tuQovOEobP4vja1JlZkys8FrODbhoVAo25i ZN5HzeYw5T1hKUXYIBBScrItkssCoWKu1V0E8N3hmRJbqhfFByZ8xDOivB0exQ0srG6U 0AOQ== 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=2+K4uxN0kyhXy6kN+ijSa8qFKCUtC4za1XiAKyb7Tws=; b=OmUnTDEATtjW9RnB5Ro5FVYlvIFdyyLhGhndV7M/K7mtIBBScQe0E3NVm/hCpny4Iy CT0N0Bx61Tv6nF0RibnPWW5jz4+nydIlcjioeZj1Rub8q/B1Jsnx2PYb49ZMNv+C1d0F OgU/I6kauqgr5gtlIx1t6+1GZdcDNzkiBMsrNfep/TQBC01CgxqcMD5lDecC5a3R6i6o Fkdpprc+VuxuaBFQAks13GM9MvCZ55cnU4L4815s/2SQg/zt0F9Ui6VM176JpQmFgIcE FoFiQNduvK7RrZGWi8f781eu3tPr3eZ9NDCvUnqfyHGg7TKoyS5NTIs2LbXiuiPWtnow jGug== X-Gm-Message-State: AOAM5329AqxjCQ6i1fOHO3vXOuBEVPsHxQTvRWkPVok/xcLmsMTiY9h3 RGaRFvEAjR5FkIWLW+XiMoGqHQ== X-Google-Smtp-Source: ABdhPJyUnVb8/3qw1H3CVTRWIncK4qlWEp5LRMfAHEJuKl69PJdPSjmADy7i7NpXLTVuyBo4NBI7cg== X-Received: by 2002:a17:907:7292:: with SMTP id dt18mr3849992ejc.512.1598027427415; Fri, 21 Aug 2020 09:30:27 -0700 (PDT) From: Jean-Philippe Brucker To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 4/5] hw/arm/virt: Remove device-tree restriction on virtio-iommu Date: Fri, 21 Aug 2020 18:28:38 +0200 Message-Id: <20200821162839.3182051-5-jean-philippe@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200821162839.3182051-1-jean-philippe@linaro.org> References: <20200821162839.3182051-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::641; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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.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, eric.auger@redhat.com, Jean-Philippe Brucker , pbonzini@redhat.com, rth@twiddle.net 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" Now that the virtio-iommu has a built-in topology mechanism, it can be used without a device tree. Remove the restriction on !ACPI or !firmware. Signed-off-by: Jean-Philippe Brucker --- hw/arm/virt.c | 10 ++-------- hw/virtio/virtio-iommu-pci.c | 2 -- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ecfee362a18..2742c28054a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2358,16 +2358,10 @@ static HotplugHandler *virt_machine_get_hotplug_han= dler(MachineState *machine, DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || - (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { return HOTPLUG_HANDLER(machine); } - if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { - VirtMachineState *vms =3D VIRT_MACHINE(machine); - - if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { - return HOTPLUG_HANDLER(machine); - } - } return NULL; } =20 diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c index ba62d60a0a0..240e85e6363 100644 --- a/hw/virtio/virtio-iommu-pci.c +++ b/hw/virtio/virtio-iommu-pci.c @@ -54,8 +54,6 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci= _dev, Error **errp) error_append_hint(errp, "Check your machine implements a hotplug handler= " "for the virtio-iommu-pci device\n"); - error_append_hint(errp, "Check the guest is booted without FW or w= ith " - "-no-acpi\n"); return; } for (int i =3D 0; i < s->nb_reserved_regions; i++) { --=20 2.28.0 From nobody Fri May 17 06:07:30 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1598027583; cv=none; d=zohomail.com; s=zohoarc; b=ama9PMyHtk2QLjl0oghhAVOk0AEn/7rCw+0EOIayqrWLKrIV5u2yEbi/TPDmwL6ApONpewzyDGz38VS9UOyrlMLSDe9nEAYAYbLDQQhjLJJq7B4bjsyJnmpVZywNo4DCiDyFMyT8rfStdrSkYAOcKxOqIj5FoHsSS4b7g2YCjjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598027583; 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=5joFadNGRqyI9ygkH+sBW3/GPpVUuhHiLgETPkq0zN0=; b=BuJbek14NDdg3TpSHgzVY/NRlcB8unYAuFtyCIwuCEVuAQxURx+rtM+3QwZqhT74h25kKiJ9mshVr+e3ufkgxb1mS/nk2kNjzxZndt6rgXjQV5/cHeLQmdqJaHh26SAbMi7zg9Lth6rEU/fiklWMb8nJPduNsZ2Dvk5Ii5fEG2o= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598027583976404.1725831470443; Fri, 21 Aug 2020 09:33:03 -0700 (PDT) Received: from localhost ([::1]:36318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k99yQ-0002zM-MM for importer@patchew.org; Fri, 21 Aug 2020 12:33:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k99w3-0007yf-2Y for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:35 -0400 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:37850) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k99vy-0006pb-0c for qemu-devel@nongnu.org; Fri, 21 Aug 2020 12:30:34 -0400 Received: by mail-ej1-x643.google.com with SMTP id qc22so3011602ejb.4 for ; Fri, 21 Aug 2020 09:30:29 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id dk28sm1398030edb.90.2020.08.21.09.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:30:27 -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=5joFadNGRqyI9ygkH+sBW3/GPpVUuhHiLgETPkq0zN0=; b=jntCwjwlK6crnSoYOahrPvHKLeFtEckXfw2hh1SxYdy8zvZRkGBTDC7kyuk+AJ4irn Vd55WK82KWEK389HYCg5/i8x/nsjNVwPhom0R7zpGPQG5/QEzYuucs8ZvUumzaOQcVpm geyPsJSuCj+KSksJx+KRTvVWA5dxqb1ywvYYQ3XIeL6PgyA+DsUJ9trFRE/+lMsJ4N43 NVPAYfVd0ttx31V148K8N4GYmK7hoj0iBoZbmQ79NRdn8jq+GkqNtdqfRBvd+X0Pr6Aa J/e88DIeNq0Enx0PVMS00hV3q6XDys/PanmjcxMz9Ag1YNkrcDkzd7WY86PDrHBIywWX yQXA== 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=5joFadNGRqyI9ygkH+sBW3/GPpVUuhHiLgETPkq0zN0=; b=a0B7GM46+kWyJgGTXcuStlD8VuIgv/39TQAfjp+sRzJsdSpUECm0Fhj8uNtMHISzBM stcHrJ7kIbVtbDyf3CBYKD+8r7or+LHxyafVj5joN91xMs20N2DGPgn3b+NXyn+RRMSa 2o8JOLlEwd5ecpnOdZQ7K3hQatDrjJsWAqLmECxEn/wr25X6yaVI6olKDs43JkvJGOzq Z4XEN8J3FILjnKc3UmdKv7D3MXkS7R5dmGAIJuLBQ3wAkfg7CZJ5B1HfonJX7fqpxYDf yLF/Y3P+pDCnARF7hAgCPGaXRUMtcof4xg1xJg1XN0SjOWD6eSABXoRbb4fIjVjiK5Cx zoKQ== X-Gm-Message-State: AOAM531LycN5HaJTcELdm3iSZ11IwMHhXf7i552LAjN4HA8svbiNBK/L vm8sgIO4w6OGazUWQAq7chgJ2w== X-Google-Smtp-Source: ABdhPJz2WOH3L1Y9o/9IqBJyR0Kl+3FnrqpRdbQP+VMigE2Wxl/iUXed7ql32cL8Lhd0lF5onc2uSg== X-Received: by 2002:a17:906:cc51:: with SMTP id mm17mr3734323ejb.137.1598027428558; Fri, 21 Aug 2020 09:30:28 -0700 (PDT) From: Jean-Philippe Brucker To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 5/5] hw/i386/pc: Add support for virtio-iommu-pci Date: Fri, 21 Aug 2020 18:28:39 +0200 Message-Id: <20200821162839.3182051-6-jean-philippe@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200821162839.3182051-1-jean-philippe@linaro.org> References: <20200821162839.3182051-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::643; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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, eric.auger@redhat.com, Jean-Philippe Brucker , pbonzini@redhat.com, rth@twiddle.net 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: Eric Auger The virtio-iommu-pci is instantiated through the -device QEMU option. Declare the [0xfee00000 - 0xfeefffff] MSI reserved region so that it gets bypassed by the IOMMU. Signed-off-by: Eric Auger Signed-off-by: Jean-Philippe Brucker --- hw/i386/pc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 47c5ca3e342..79ab7e06066 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -89,6 +89,7 @@ #include "standard-headers/asm-x86/bootparam.h" #include "hw/virtio/virtio-pmem-pci.h" #include "hw/virtio/virtio-mem-pci.h" +#include "hw/virtio/virtio-iommu.h" #include "hw/mem/memory-device.h" #include "sysemu/replay.h" #include "qapi/qmp/qerror.h" @@ -1698,6 +1699,11 @@ 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_VIRTIO_IOMMU_PCI)) { + /* we declare a VIRTIO_IOMMU_RESV_MEM_T_MSI region */ + qdev_prop_set_uint32(dev, "len-reserved-regions", 1); + qdev_prop_set_string(dev, "reserved-regions[0]", + "0xfee00000:0xfeefffff:1"); } } =20 @@ -1752,7 +1758,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_VIRTIO_IOMMU_PCI)) { return HOTPLUG_HANDLER(machine); } =20 --=20 2.28.0