From nobody Fri May 10 09:55:45 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448639367324.3550565952586; Fri, 16 Jul 2021 08:17:19 -0700 (PDT) Received: from localhost ([::1]:51688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4PaY-0003kt-7B for importer@patchew.org; Fri, 16 Jul 2021 11:17:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYV-0000mh-Eg for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60277) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYT-0003pq-Cb for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:11 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-T-S7-NdjMh280pn9fqJioQ-1; Fri, 16 Jul 2021 11:15:07 -0400 Received: by mail-wr1-f70.google.com with SMTP id m4-20020adffa040000b02901404c442853so4954434wrr.12 for ; Fri, 16 Jul 2021 08:15:07 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id b9sm12933902wrh.81.2021.07.16.08.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3i4DyvYX94w5eyf6eVKq7jHnyEBcb4z6P2pthb6TVgs=; b=M7x/IVyRddoFGW7Z6JcQOADnqVZa670uEut23Y416tV9gCB42hGMCD/6tKNWt6yLa4jjE0 b0qTk4kyt2GI11lXbxfBJdaZ6LZebPN0n0BDP4wX13+tKLVcMHyUrSPWw0jeg3qyzL38Sg 4qBeoTtuxGhX7spKOGDnkiJQM16Dn2s= X-MC-Unique: T-S7-NdjMh280pn9fqJioQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3i4DyvYX94w5eyf6eVKq7jHnyEBcb4z6P2pthb6TVgs=; b=ldantl/99x3irse9/r6x0ASpz10gnS5/plyYxIAD29SsIt/Xw6+8/91eYPZ7EfJrCf wCoVgTGpIP8XPcpQSE/LxOPjvRunot2OO9/TM2XSm6DGbBm78aojVTr3EOL8ZRfnBHQ7 qKzshoMG4lPNHzoA7WO4GXEKwB6LyhY5hY7GEz3im6MeZ0qrl7f2qLtmhys2zEmAu6Yd TbTi8FpQT9wq/FDTXXvDPfr/6mssdP4EMQ5ashbEIIyMz9XjP9eaLbCdugvP3b0fvupw EfXULZHtM5EaH000PTFnvwDy5AOaqt80k9PBp5WWKTSnioPiX5sc/quKc32vb1HUonFU /wgg== X-Gm-Message-State: AOAM530NKMUiqUkdkS4Rw3GRrVTYS7W0dR8ybvwS9m6OeS7BzNhkmavt G5Inzd893QJZWWUzvdUN97cB7EfByPzzucbd3OcpAjxmbr0BEpU5UpkxAWZGUNEI6u4FyxwFPfN 7poat4CK93IIiR3mz0dGSoRySK7HIefkBqKXGatpBfzuxqPju4/lNs2yxnsX/ X-Received: by 2002:a5d:46c8:: with SMTP id g8mr12900503wrs.341.1626448505817; Fri, 16 Jul 2021 08:15:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHGw2HxaaqsrwOQ9K8oFRu2w+zrfka4XHcacOTOgQ4FdPweGKfRNlbFP4DPBeOvcHGE+UJWg== X-Received: by 2002:a5d:46c8:: with SMTP id g8mr12900469wrs.341.1626448505593; Fri, 16 Jul 2021 08:15:05 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 01/19] hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35 Message-ID: <20210716151416.155127-2-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Eduardo Habkost , Richard Henderson , Julia Suvorova , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Igor Mammedov , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448641681100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Julia Suvorova Implement notifications and gpe to support q35 ACPI PCI hot-plug. Use 0xcc4 - 0xcd7 range for 'acpi-pci-hotplug' io ports. Signed-off-by: Julia Suvorova Reviewed-by: Igor Mammedov Reviewed-by: Marcel Apfelbaum Message-Id: <20210713004205.775386-2-jusual@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Gibson --- hw/i386/acpi-build.h | 4 ++++ include/hw/acpi/ich9.h | 2 ++ include/hw/acpi/pcihp.h | 3 ++- hw/acpi/pcihp.c | 6 +++--- hw/acpi/piix4.c | 4 +++- hw/i386/acpi-build.c | 30 +++++++++++++++++++----------- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h index 74df5fc612..487ec7710f 100644 --- a/hw/i386/acpi-build.h +++ b/hw/i386/acpi-build.h @@ -5,6 +5,10 @@ =20 extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; =20 +/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */ +#define ACPI_PCIHP_SEJ_BASE 0x8 +#define ACPI_PCIHP_BNMR_BASE 0x10 + void acpi_setup(void); =20 #endif diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index df519e40b5..596120d97f 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -28,6 +28,8 @@ #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h" =20 +#define ACPI_PCIHP_ADDR_ICH9 0x0cc4 + typedef struct ICH9LPCPMRegs { /* * In ich9 spec says that pm1_cnt register is 32bit width and diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index 2dd90aea30..af1a169fc3 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -55,7 +55,8 @@ typedef struct AcpiPciHpState { } AcpiPciHpState; =20 void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root, - MemoryRegion *address_space_io, bool bridges_enabled); + MemoryRegion *address_space_io, bool bridges_enabled, + uint16_t io_base); =20 void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 4999277d57..d98a284b7a 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -37,7 +37,6 @@ #include "qom/qom-qobject.h" #include "trace.h" =20 -#define ACPI_PCIHP_ADDR 0xae00 #define ACPI_PCIHP_SIZE 0x0018 #define PCI_UP_BASE 0x0000 #define PCI_DOWN_BASE 0x0004 @@ -488,10 +487,11 @@ static const MemoryRegionOps acpi_pcihp_io_ops =3D { }; =20 void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus, - MemoryRegion *address_space_io, bool bridges_enabled) + MemoryRegion *address_space_io, bool bridges_enabled, + uint16_t io_base) { s->io_len =3D ACPI_PCIHP_SIZE; - s->io_base =3D ACPI_PCIHP_ADDR; + s->io_base =3D io_base; =20 s->root =3D root_bus; s->legacy_piix =3D !bridges_enabled; diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 0bd23d74e2..48f7a1edbc 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -49,6 +49,8 @@ #define GPE_BASE 0xafe0 #define GPE_LEN 4 =20 +#define ACPI_PCIHP_ADDR_PIIX4 0xae00 + struct pci_status { uint32_t up; /* deprecated, maintained for migration compatibility */ uint32_t down; @@ -607,7 +609,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion= *parent, =20 if (s->use_acpi_hotplug_bridge || s->use_acpi_root_pci_hotplug) { acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); + s->use_acpi_hotplug_bridge, ACPI_PCIHP_ADDR_PIIX4); } =20 s->cpu_hotplug_legacy =3D true; diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 357437ff1d..e1c246d6e8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -219,10 +219,6 @@ static void acpi_get_pm_info(MachineState *machine, Ac= piPmInfo *pm) /* w2k requires FADT(rev1) or it won't boot, keep PC compatible */ pm->fadt.rev =3D 1; pm->cpu_hp_io_base =3D PIIX4_CPU_HOTPLUG_IO_BASE; - pm->pcihp_io_base =3D - object_property_get_uint(obj, ACPI_PCIHP_IO_BASE_PROP, NULL); - pm->pcihp_io_len =3D - object_property_get_uint(obj, ACPI_PCIHP_IO_LEN_PROP, NULL); } if (lpc) { uint64_t smi_features =3D object_property_get_uint(lpc, @@ -238,6 +234,10 @@ static void acpi_get_pm_info(MachineState *machine, Ac= piPmInfo *pm) pm->smi_on_cpu_unplug =3D !!(smi_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT)); } + pm->pcihp_io_base =3D + object_property_get_uint(obj, ACPI_PCIHP_IO_BASE_PROP, NULL); + pm->pcihp_io_len =3D + object_property_get_uint(obj, ACPI_PCIHP_IO_LEN_PROP, NULL); =20 /* The above need not be conditional on machine type because the reset= port * happens to be the same on PIIX (pc) and ICH9 (q35). */ @@ -392,6 +392,9 @@ static void build_append_pci_bus_devices(Aml *parent_sc= ope, PCIBus *bus, =20 if (!pdev) { if (bsel) { /* add hotplug slots for non present devices */ + if (pci_bus_is_express(bus) && slot > 0) { + break; + } dev =3D aml_device("S%.02X", PCI_DEVFN(slot, 0)); aml_append(dev, aml_name_decl("_SUN", aml_int(slot))); aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16))= ); @@ -521,7 +524,7 @@ static void build_append_pci_bus_devices(Aml *parent_sc= ope, PCIBus *bus, QLIST_FOREACH(sec, &bus->child, sibling) { int32_t devfn =3D sec->parent_dev->devfn; =20 - if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) { + if (pci_bus_is_root(sec)) { continue; } =20 @@ -1251,7 +1254,7 @@ static void build_piix4_isa_bridge(Aml *table) aml_append(table, scope); } =20 -static void build_piix4_pci_hotplug(Aml *table) +static void build_x86_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr) { Aml *scope; Aml *field; @@ -1260,20 +1263,22 @@ static void build_piix4_pci_hotplug(Aml *table) scope =3D aml_scope("_SB.PCI0"); =20 aml_append(scope, - aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(0xae00), 0x08)= ); + aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(pcihp_addr), 0= x08)); field =3D aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZE= ROS); aml_append(field, aml_named_field("PCIU", 32)); aml_append(field, aml_named_field("PCID", 32)); aml_append(scope, field); =20 aml_append(scope, - aml_operation_region("SEJ", AML_SYSTEM_IO, aml_int(0xae08), 0x04)); + aml_operation_region("SEJ", AML_SYSTEM_IO, + aml_int(pcihp_addr + ACPI_PCIHP_SEJ_BASE), 0x= 04)); field =3D aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZER= OS); aml_append(field, aml_named_field("B0EJ", 32)); aml_append(scope, field); =20 aml_append(scope, - aml_operation_region("BNMR", AML_SYSTEM_IO, aml_int(0xae10), 0x08)= ); + aml_operation_region("BNMR", AML_SYSTEM_IO, + aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0= x08)); field =3D aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZE= ROS); aml_append(field, aml_named_field("BNUM", 32)); aml_append(field, aml_named_field("PIDX", 32)); @@ -1407,7 +1412,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, build_piix4_isa_bridge(dsdt); build_isa_devices_aml(dsdt); if (pm->pcihp_bridge_en || pm->pcihp_root_en) { - build_piix4_pci_hotplug(dsdt); + build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base); } build_piix4_pci0_int(dsdt); } else { @@ -1455,6 +1460,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, } build_q35_isa_bridge(dsdt); build_isa_devices_aml(dsdt); + if (pm->pcihp_bridge_en) { + build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base); + } build_q35_pci0_int(dsdt); if (pcms->smbus && !pcmc->do_not_add_smb_acpi) { build_smb0(dsdt, pcms->smbus, ICH9_SMB_DEV, ICH9_SMB_FUNC); @@ -1489,7 +1497,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, { aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006"))); =20 - if (misc->is_piix4 && (pm->pcihp_bridge_en || pm->pcihp_root_en)) { + if (pm->pcihp_bridge_en || pm->pcihp_root_en) { method =3D aml_method("_E01", 0, AML_NOTSERIALIZED); aml_append(method, aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF)); --=20 MST From nobody Fri May 10 09:55:45 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448765308251.29029960869923; Fri, 16 Jul 2021 08:19:25 -0700 (PDT) Received: from localhost ([::1]:59944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pca-0000oS-43 for importer@patchew.org; Fri, 16 Jul 2021 11:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYY-0000qP-85 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYW-0003rq-0A for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:14 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-6ytNm25QOxybW31IURs4jA-1; Fri, 16 Jul 2021 11:15:10 -0400 Received: by mail-wm1-f70.google.com with SMTP id d16-20020a1c73100000b02901f2d21e46efso3283634wmb.6 for ; Fri, 16 Jul 2021 08:15:09 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id g18sm8280457wmk.37.2021.07.16.08.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9QZG8Wl50+7PmAQdBrLDebzFMtsRxXny/OdYWszhAo8=; b=d/YS3hDMrQ6s16alSArH7e/DmjWEf1yVf5sKsBwlxlcJtjB53ap7M2GrODl2dFp3Fg0u64 dv6CAN+t7a4hamiqK3lRhqYCudXAMDLBwXfEy9dzUiWgt+i0LvIIeZIaFsgjVxXwPXMavV BSxBqOWgF5FTZlsVsk2KtoQ8zk1thvU= X-MC-Unique: 6ytNm25QOxybW31IURs4jA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9QZG8Wl50+7PmAQdBrLDebzFMtsRxXny/OdYWszhAo8=; b=iVnB6EdgdOLb/T5vE86skNDYDTnTLUYbm44hbA3BKwPHSCjC8jVCU4qdF4SirVrd+v AhD9WE8bTjWt27M49pq2z8d54+/3wQ/SF9t41rQue6Z38YYcuZrCLktqtoVIF7t7PrbS QDV+hCazSQlXliOtawTWZTXOS6zadWqgPd8Rfe3tBh8G+KPumC1wFjijFuhxrBmbfLnz U3MnpCW65PXlsdP9pp+cdM6fkrIq2tFuatroRUqGyY69g7OnRXGY77crgvjueVioTOmy 2ljYyYG4JQeQ89DFR2b38qPne9SP1/gjqmYMn3YxzHRyAQcGJw5fGnEVXEHwLreF7P9u XIHQ== X-Gm-Message-State: AOAM530bKfRg2YDJHcw7Pt26Shg/Q/W6eTtNDtpwU/zPWvEi4eBrOxi5 Y1Q/oYFLOj6LN81yKv4R8avsdSV4p4c8rBjcxR1UwGc8rhCSRUohYE5wCiL7lc6lWoyCK8qP+7y jqAzKxgvNgASekgZsqiFobzdOkT7I69rHVRjrfrrlvkIFlPK6dfCPpCa2+l6g X-Received: by 2002:a5d:4e08:: with SMTP id p8mr12915555wrt.425.1626448508398; Fri, 16 Jul 2021 08:15:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0uHz5PUfTOPHWHhb9I6CJkY3qEJNsPpTaGr1q2YLH9h/hCbya0pf2fTATEWYfGWCq6y3wYQ== X-Received: by 2002:a5d:4e08:: with SMTP id p8mr12915512wrt.425.1626448508049; Fri, 16 Jul 2021 08:15:08 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 02/19] hw/acpi/ich9: Enable ACPI PCI hot-plug Message-ID: <20210716151416.155127-3-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Eduardo Habkost , Richard Henderson , Julia Suvorova , Igor Mammedov , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448767051100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Julia Suvorova Add acpi_pcihp to ich9_pm as part of 'acpi-pci-hotplug-with-bridge-support' option. Set default to false. Signed-off-by: Julia Suvorova Signed-off-by: Marcel Apfelbaum Reviewed-by: Igor Mammedov Message-Id: <20210713004205.775386-3-jusual@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Gibson --- hw/i386/acpi-build.h | 1 + include/hw/acpi/ich9.h | 3 ++ hw/acpi/acpi-x86-stub.c | 6 ++++ hw/acpi/ich9.c | 70 +++++++++++++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 12 +++++-- hw/i386/acpi-build.c | 14 ++++++--- 6 files changed, 100 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h index 487ec7710f..0dce155c8c 100644 --- a/hw/i386/acpi-build.h +++ b/hw/i386/acpi-build.h @@ -10,5 +10,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_ds= mio; #define ACPI_PCIHP_BNMR_BASE 0x10 =20 void acpi_setup(void); +Object *acpi_get_i386_pci_host(void); =20 #endif diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 596120d97f..a329ce43ab 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -24,6 +24,7 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/pcihp.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h" @@ -55,6 +56,8 @@ typedef struct ICH9LPCPMRegs { AcpiCpuHotplug gpe_cpu; CPUHotplugState cpuhp_state; =20 + bool use_acpi_hotplug_bridge; + AcpiPciHpState acpi_pci_hotplug; MemHotplugState acpi_memory_hotplug; =20 uint8_t disable_s3; diff --git a/hw/acpi/acpi-x86-stub.c b/hw/acpi/acpi-x86-stub.c index f88d6a090b..e9e46c5c5f 100644 --- a/hw/acpi/acpi-x86-stub.c +++ b/hw/acpi/acpi-x86-stub.c @@ -1,7 +1,13 @@ #include "qemu/osdep.h" #include "hw/i386/pc.h" +#include "hw/i386/acpi-build.h" =20 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, const CPUArchIdList *apic_ids, GArray *entry) { } + +Object *acpi_get_i386_pci_host(void) +{ + return NULL; +} diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 4daa79ec8d..2f4eb453ac 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -217,6 +217,26 @@ static const VMStateDescription vmstate_cpuhp_state = =3D { } }; =20 +static bool vmstate_test_use_pcihp(void *opaque) +{ + ICH9LPCPMRegs *s =3D opaque; + + return s->use_acpi_hotplug_bridge; +} + +static const VMStateDescription vmstate_pcihp_state =3D { + .name =3D "ich9_pm/pcihp", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmstate_test_use_pcihp, + .fields =3D (VMStateField[]) { + VMSTATE_PCI_HOTPLUG(acpi_pci_hotplug, + ICH9LPCPMRegs, + NULL, NULL), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_ich9_pm =3D { .name =3D "ich9_pm", .version_id =3D 1, @@ -238,6 +258,7 @@ const VMStateDescription vmstate_ich9_pm =3D { &vmstate_memhp_state, &vmstate_tco_io_state, &vmstate_cpuhp_state, + &vmstate_pcihp_state, NULL } }; @@ -259,6 +280,10 @@ static void pm_reset(void *opaque) } pm->smi_en_wmask =3D ~0; =20 + if (pm->use_acpi_hotplug_bridge) { + acpi_pcihp_reset(&pm->acpi_pci_hotplug, true); + } + acpi_update_sci(&pm->acpi_regs, pm->irq); } =20 @@ -297,6 +322,18 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *p= m, pm->enable_tco =3D true; acpi_pm_tco_init(&pm->tco_regs, &pm->io); =20 + if (pm->use_acpi_hotplug_bridge) { + acpi_pcihp_init(OBJECT(lpc_pci), + &pm->acpi_pci_hotplug, + pci_get_bus(lpc_pci), + pci_address_space_io(lpc_pci), + true, + ACPI_PCIHP_ADDR_ICH9); + + qbus_set_hotplug_handler(BUS(pci_get_bus(lpc_pci)), + OBJECT(lpc_pci)); + } + pm->irq =3D sci_irq; qemu_register_reset(pm_reset, pm); pm->powerdown_notifier.notify =3D pm_powerdown_req; @@ -368,6 +405,20 @@ static void ich9_pm_set_enable_tco(Object *obj, bool v= alue, Error **errp) s->pm.enable_tco =3D value; } =20 +static bool ich9_pm_get_acpi_pci_hotplug(Object *obj, Error **errp) +{ + ICH9LPCState *s =3D ICH9_LPC_DEVICE(obj); + + return s->pm.use_acpi_hotplug_bridge; +} + +static void ich9_pm_set_acpi_pci_hotplug(Object *obj, bool value, Error **= errp) +{ + ICH9LPCState *s =3D ICH9_LPC_DEVICE(obj); + + s->pm.use_acpi_hotplug_bridge =3D value; +} + void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) { static const uint32_t gpe0_len =3D ICH9_PMIO_GPE0_LEN; @@ -376,6 +427,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs = *pm) pm->disable_s3 =3D 0; pm->disable_s4 =3D 0; pm->s4_val =3D 2; + pm->use_acpi_hotplug_bridge =3D false; =20 object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE, &pm->pm_io_base, OBJ_PROP_FLAG_READ); @@ -399,6 +451,9 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs = *pm) object_property_add_bool(obj, ACPI_PM_PROP_TCO_ENABLED, ich9_pm_get_enable_tco, ich9_pm_set_enable_tco); + object_property_add_bool(obj, "acpi-pci-hotplug-with-bridge-support", + ich9_pm_get_acpi_pci_hotplug, + ich9_pm_set_acpi_pci_hotplug); } =20 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *= dev, @@ -406,6 +461,11 @@ void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplu= g_dev, DeviceState *dev, { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); =20 + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_pre_plug_cb(hotplug_dev, dev, errp); + return; + } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) && !lpc->pm.acpi_memory_hotplug.is_enabled) { error_setg(errp, @@ -441,6 +501,9 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev= , DeviceState *dev, } else { acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.cpuhp_state, dev, errp); } + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_plug_cb(hotplug_dev, &lpc->pm.acpi_pci_hotplug, + dev, errp); } else { error_setg(errp, "acpi: device plug request for not supported devi= ce" " type: %s", object_get_typename(OBJECT(dev))); @@ -473,6 +536,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *= hotplug_dev, =20 acpi_cpu_unplug_request_cb(hotplug_dev, &lpc->pm.cpuhp_state, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_unplug_request_cb(hotplug_dev, + &lpc->pm.acpi_pci_hotplug, + dev, errp); } else { error_setg(errp, "acpi: device unplug request for not supported de= vice" " type: %s", object_get_typename(OBJECT(dev))); @@ -490,6 +557,9 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_d= ev, DeviceState *dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && !lpc->pm.cpu_hotplug_legacy) { acpi_cpu_unplug_cb(&lpc->pm.cpuhp_state, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_unplug_cb(hotplug_dev, &lpc->pm.acpi_pci_hotplug, + dev, errp); } else { error_setg(errp, "acpi: device unplug for not supported device" " type: %s", object_get_typename(OBJECT(dev))); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index d98a284b7a..9fdc6342b0 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -30,6 +30,8 @@ #include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" +#include "hw/pci/pci_host.h" +#include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h" #include "migration/vmstate.h" @@ -103,6 +105,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque) static void acpi_set_pci_info(void) { static bool bsel_is_set; + Object *host =3D acpi_get_i386_pci_host(); PCIBus *bus; unsigned bsel_alloc =3D ACPI_PCIHP_BSEL_DEFAULT; =20 @@ -111,7 +114,11 @@ static void acpi_set_pci_info(void) } bsel_is_set =3D true; =20 - bus =3D find_i440fx(); /* TODO: Q35 support */ + if (!host) { + return; + } + + bus =3D PCI_HOST_BRIDGE(host)->bus; if (bus) { /* Scan all PCI buses. Set property to enable acpi based hotplug. = */ pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc= ); @@ -121,13 +128,14 @@ static void acpi_set_pci_info(void) static void acpi_pcihp_disable_root_bus(void) { static bool root_hp_disabled; + Object *host =3D acpi_get_i386_pci_host(); PCIBus *bus; =20 if (root_hp_disabled) { return; } =20 - bus =3D find_i440fx(); + bus =3D PCI_HOST_BRIDGE(host)->bus; if (bus) { /* setting the hotplug handler to NULL makes the bus non-hotplugga= ble */ qbus_set_hotplug_handler(BUS(bus), NULL); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e1c246d6e8..bc966a4110 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -299,7 +299,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info) * Because of the PXB hosts we cannot simply query TYPE_PCI_HOST_BRIDGE. * On i386 arch we only have two pci hosts, so we can look only for them. */ -static Object *acpi_get_i386_pci_host(void) +Object *acpi_get_i386_pci_host(void) { PCIHostState *host; =20 @@ -320,7 +320,10 @@ static void acpi_get_pci_holes(Range *hole, Range *hol= e64) Object *pci_host; =20 pci_host =3D acpi_get_i386_pci_host(); - g_assert(pci_host); + + if (!pci_host) { + return; + } =20 range_set_bounds1(hole, object_property_get_uint(pci_host, @@ -1765,6 +1768,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, PCIBus *bus =3D NULL; =20 pci_host =3D acpi_get_i386_pci_host(); + if (pci_host) { bus =3D PCI_HOST_BRIDGE(pci_host)->bus; } @@ -2321,7 +2325,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) QObject *o; =20 pci_host =3D acpi_get_i386_pci_host(); - g_assert(pci_host); + if (!pci_host) { + return false; + } =20 o =3D object_property_get_qobject(pci_host, PCIE_HOST_MCFG_BASE, NULL); if (!o) { @@ -2351,7 +2357,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) AcpiPmInfo pm; AcpiMiscInfo misc; AcpiMcfgInfo mcfg; - Range pci_hole, pci_hole64; + Range pci_hole =3D {}, pci_hole64 =3D {}; uint8_t *u; size_t aml_len =3D 0; GArray *tables_blob =3D tables->table_data; --=20 MST From nobody Fri May 10 09:55:45 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448681791691.5419798949353; Fri, 16 Jul 2021 08:18:01 -0700 (PDT) Received: from localhost ([::1]:54812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4PbE-0005oD-OR for importer@patchew.org; Fri, 16 Jul 2021 11:18:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYa-0000tF-17 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYY-0003ti-4p for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:15 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-GBU9Jh0-NG-0XeSA7rAzkw-1; Fri, 16 Jul 2021 11:15:12 -0400 Received: by mail-wm1-f69.google.com with SMTP id p9-20020a7bcc890000b02902190142995dso2439276wma.4 for ; Fri, 16 Jul 2021 08:15:12 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id v15sm12164113wmj.39.2021.07.16.08.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=22V64z3S3pf3htvQigxiY1h3bVoBWv3sW5oYyQggWRw=; b=at8zylieJMAJ70xIDJuxwNjB9uB6Inrl3Sg7S5R+PtwJZt6Ha/19jJf+ThubyyoOyX0vU7 6XeOcuvY2eH/7ypi3kJE1j45PKALQA6FSFNNyM0rwubswiNNYboici7hcbawCwWy+9dqgM 7c5jl/JE8GwNHJ0DTaIzwxo/GXeCgzk= X-MC-Unique: GBU9Jh0-NG-0XeSA7rAzkw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=22V64z3S3pf3htvQigxiY1h3bVoBWv3sW5oYyQggWRw=; b=qGwrFrkK10BvZsgNCBSuASUGPSdxiBbnkMUGb3kXBKT6VxEtR8qsNs79x27BDH+oub RY6YQpveAlqklWyz8gOr3PpU7pMcIZWhrjY5DZRCynmwtkQlgRUuQurXyvUVNhnbd1ks GKlmgkWlmqCK41dX95ZlchNDrjHLVpXpGAQ/XMQLR/sG3ulNyRwywQ5oSQ1hmiK4cO9g S5fbHKs9WDDRuduYIqg/oYZslqGBB+YzaUeCSXuHK4z5mFV2PKp0dylVYLpSXSNM/2sn jGo8wN98BNi5ORBT87BBSwlfk0GByPSTDkVAlQnKGa8ZY+FQPElObMathVAyNWccdjWb Po1g== X-Gm-Message-State: AOAM5331uaXx1UTevuBJhkMPuTShdcDJ3ZDFo3H4oNgk+V0yaHUaUqSm OFukAtBMGRWnafMfhw3earFuAo6/ML7N97wGilaNePXjGTtms4pmzU82kKj9yEIvJWff8Vu8Amq FZQKj78mQwaEa8cysVApwr1/Y6qaSfTyxryZL3VHCQwPCknN3bj8oPldqt6mD X-Received: by 2002:a1c:cc02:: with SMTP id h2mr11020112wmb.39.1626448510698; Fri, 16 Jul 2021 08:15:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/W5T8jDB0uSIJKiZWWt6dOk52PPnhLpCDzZzOEPFmRlg97MoKN3NQ8TXMKRAWd8BSlYbKJw== X-Received: by 2002:a1c:cc02:: with SMTP id h2mr11020082wmb.39.1626448510479; Fri, 16 Jul 2021 08:15:10 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 03/19] hw/pci/pcie: Do not set HPC flag if acpihp is used Message-ID: <20210716151416.155127-4-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Eduardo Habkost , Richard Henderson , Julia Suvorova , Paolo Bonzini , Igor Mammedov , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448682653100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Julia Suvorova Instead of changing the hot-plug type in _OSC register, do not set the 'Hot-Plug Capable' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge. The ability to control hot-plug for each downstream port is retained, while 'hotplug=3Doff' on the port means all hot-plug types are disabled. Signed-off-by: Julia Suvorova Reviewed-by: Igor Mammedov Reviewed-by: Marcel Apfelbaum Reviewed-by: David Gibson Message-Id: <20210713004205.775386-4-jusual@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie_port.h | 5 ++++- hw/acpi/pcihp.c | 8 ++++++++ hw/core/machine.c | 1 - hw/i386/pc_q35.c | 11 +++++++++++ hw/pci/pcie.c | 8 +++++++- hw/pci/pcie_port.c | 1 + 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/hw/pci/pcie_port.h b/include/hw/pci/pcie_port.h index bea8ecad0f..e25b289ce8 100644 --- a/include/hw/pci/pcie_port.h +++ b/include/hw/pci/pcie_port.h @@ -57,8 +57,11 @@ struct PCIESlot { /* Disable ACS (really for a pcie_root_port) */ bool disable_acs; =20 - /* Indicates whether hot-plug is enabled on the slot */ + /* Indicates whether any type of hot-plug is allowed on the slot */ bool hotplug; + + bool native_hotplug; + QLIST_ENTRY(PCIESlot) next; }; =20 diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 9fdc6342b0..f4d706e47d 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -31,6 +31,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_host.h" +#include "hw/pci/pcie_port.h" #include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h" @@ -336,6 +337,13 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug= _dev, AcpiPciHpState *s, object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { PCIBus *sec =3D pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); =20 + /* Remove all hot-plug handlers if hot-plug is disabled on slo= t */ + if (object_dynamic_cast(OBJECT(dev), TYPE_PCIE_SLOT) && + !PCIE_SLOT(pdev)->hotplug) { + qbus_set_hotplug_handler(BUS(sec), NULL); + return; + } + qbus_set_hotplug_handler(BUS(sec), OBJECT(hotplug_dev)); /* We don't have to overwrite any other hotplug handler yet */ assert(QLIST_EMPTY(&sec->child)); diff --git a/hw/core/machine.c b/hw/core/machine.c index 6f59fb0b7f..775add0795 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -584,7 +584,6 @@ static void machine_set_memdev(Object *obj, const char = *value, Error **errp) ms->ram_memdev_id =3D g_strdup(value); } =20 - static void machine_init_notify(Notifier *notifier, void *data) { MachineState *machine =3D MACHINE(qdev_get_machine()); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 46a0f196f4..04b4a4788d 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -37,6 +37,7 @@ #include "sysemu/kvm.h" #include "hw/kvm/clock.h" #include "hw/pci-host/q35.h" +#include "hw/pci/pcie_port.h" #include "hw/qdev-properties.h" #include "hw/i386/x86.h" #include "hw/i386/pc.h" @@ -136,6 +137,7 @@ static void pc_q35_init(MachineState *machine) ram_addr_t lowmem; DriveInfo *hd[MAX_SATA_PORTS]; MachineClass *mc =3D MACHINE_GET_CLASS(machine); + bool acpi_pcihp; =20 /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory * and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping @@ -236,6 +238,15 @@ static void pc_q35_init(MachineState *machine) object_property_set_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, OBJECT(lpc), &error_abort); =20 + acpi_pcihp =3D object_property_get_bool(OBJECT(lpc), + "acpi-pci-hotplug-with-bridge-su= pport", + NULL); + + if (acpi_pcihp) { + object_register_sugar_prop(TYPE_PCIE_SLOT, "native-hotplug", + "false", true); + } + /* irq lines */ gsi_state =3D pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); =20 diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index fd0fa157e8..6e95d82903 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -529,7 +529,13 @@ void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s) PCI_EXP_SLTCAP_PIP | PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_ABP); - if (s->hotplug) { + + /* + * Enable native hot-plug on all hot-plugged bridges unless + * hot-plug is disabled on the slot. + */ + if (s->hotplug && + (s->native_hotplug || DEVICE(dev)->hotplugged)) { pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCAP, PCI_EXP_SLTCAP_HPS | PCI_EXP_SLTCAP_HPC); diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c index eb563ad435..da850e8dde 100644 --- a/hw/pci/pcie_port.c +++ b/hw/pci/pcie_port.c @@ -148,6 +148,7 @@ static Property pcie_slot_props[] =3D { DEFINE_PROP_UINT8("chassis", PCIESlot, chassis, 0), DEFINE_PROP_UINT16("slot", PCIESlot, slot, 0), DEFINE_PROP_BOOL("hotplug", PCIESlot, hotplug, true), + DEFINE_PROP_BOOL("native-hotplug", PCIESlot, native_hotplug, true), DEFINE_PROP_END_OF_LIST() }; =20 --=20 MST From nobody Fri May 10 09:55:45 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448946391924.3958961265491; Fri, 16 Jul 2021 08:22:26 -0700 (PDT) Received: from localhost ([::1]:40250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4PfV-0006bj-8p for importer@patchew.org; Fri, 16 Jul 2021 11:22:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYc-0000xM-4T for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYa-0003vz-G8 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:17 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-xi9p5p7INeGuHQ0vGdDAFQ-1; Fri, 16 Jul 2021 11:15:14 -0400 Received: by mail-wr1-f70.google.com with SMTP id 5-20020a0560001565b029013fe432d176so4927559wrz.23 for ; Fri, 16 Jul 2021 08:15:14 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id x18sm9936188wrw.19.2021.07.16.08.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448515; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rnZmrpdt3JApfVreMKFcNarnw8Jq+7AjA6w24KOMdJg=; b=NAy2/fTiw332r3qRwe1YSksRe8KwX4Mq2i0NlV9fhvq80C928ZntTWxskcuYGXasBUEFjb ZflmzBfxTz/UqH2xnX3htAhsx72gl63TB+7lGCsKzKYDJMEHTtsmMHE7q/+91rwDIQqJR5 ERHZkTKbaqg9PAHVLxuh0TidyiNCG8A= X-MC-Unique: xi9p5p7INeGuHQ0vGdDAFQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rnZmrpdt3JApfVreMKFcNarnw8Jq+7AjA6w24KOMdJg=; b=CoYdOWdclDDeQBBriYqwVNjI++KC0fyomXwbOe3MDEqEMcAn80jXwJlWAYje5xIZhz IAtLFBK0f5QFaWfyKscRbPX+8LZcXfXHxP7wfbCDEPYUx8kXDwZLS8Ac9RavnZSG8eG+ xZ77njEz/KFkW0W2+L0z/Iu0jiba+4wpIdU5jM6ctdaa7P+jjUOrjNDxsCgBvcH+qXd1 DtTyx5/2UJP0iMzFYPZu+6l93xSOpWEvrUmSvNWLkkLFJxbZO5vhLrJSJ2CQzRvRoHnU BpqlO41TX6TTCtTL6MrqEJM/YRTxfHQxfpsFyU7bXHCxE1lCpHHvhjovfjhoXn/U2Tck eo+Q== X-Gm-Message-State: AOAM53360XcKuJ9DXuQXX0QoUQPgC182JqYu7+rraQHfCAjRrimElqff 0ogouCrqIdJeomxfZjGrBfkBegFYUEWdiMG5lmAXGW96GYydPNs9OlKnpKpckGys7+eSb9kfeCV T3IK0IvCm14kR0xXhIKA4stjTlu3BZAHfYoMJ5rrkDhux2IHxyRD2WTkg+PNf X-Received: by 2002:a5d:4527:: with SMTP id j7mr12889629wra.137.1626448512984; Fri, 16 Jul 2021 08:15:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYVrfIE7EUczMkmHlPekVLUSyoYfY2LK07NyR/fBlLmupG6BzSQANhTMAU4hvJus/DJVgShg== X-Received: by 2002:a5d:4527:: with SMTP id j7mr12889610wra.137.1626448512839; Fri, 16 Jul 2021 08:15:12 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 04/19] bios-tables-test: Allow changes in DSDT ACPI tables Message-ID: <20210716151416.155127-5-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Julia Suvorova , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448946905100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Julia Suvorova All DSDT Q35 tables will be modified because ACPI hot-plug is enabled by default. Signed-off-by: Julia Suvorova Reviewed-by: Igor Mammedov Reviewed-by: Marcel Apfelbaum Message-Id: <20210713004205.775386-5-jusual@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..c5167f48af 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,12 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT", +"tests/data/acpi/q35/DSDT.tis", +"tests/data/acpi/q35/DSDT.bridge", +"tests/data/acpi/q35/DSDT.mmio64", +"tests/data/acpi/q35/DSDT.ipmibt", +"tests/data/acpi/q35/DSDT.cphp", +"tests/data/acpi/q35/DSDT.memhp", +"tests/data/acpi/q35/DSDT.acpihmat", +"tests/data/acpi/q35/DSDT.numamem", +"tests/data/acpi/q35/DSDT.dimmpxm", +"tests/data/acpi/q35/DSDT.nohpet", --=20 MST From nobody Fri May 10 09:55:45 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448774295346.7883618566243; Fri, 16 Jul 2021 08:19:34 -0700 (PDT) Received: from localhost ([::1]:60148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pcj-0000wM-2J for importer@patchew.org; Fri, 16 Jul 2021 11:19:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYg-00011t-Md for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYe-0003x6-Jh for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:22 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-133-7KpLB_pzPUm5wLjX9_M_yA-1; Fri, 16 Jul 2021 11:15:17 -0400 Received: by mail-wr1-f72.google.com with SMTP id d8-20020adf9c880000b0290141a87409b5so4123646wre.16 for ; Fri, 16 Jul 2021 08:15:16 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id w3sm10211324wrt.55.2021.07.16.08.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=s44RkB8U7U2bDJqZ7dxzv9YhTcSDJCpv+fLZfJ2i0D0=; b=Hn3a2kCNnThCgwOeww2WPS/PzOp1TT4VhEMPIP7GABo7BW/XgTlrsjMhIEufDx+LWHbNG5 CqN6mtg8AguFBE3kmGCBRmzaK2vI2595VxZduEkFQmSp96lt9Ko+glN2CYd6gjwRDoaKD7 ps95ws2a7xwkkd4tmGo+iA1jJIN1b98= X-MC-Unique: 7KpLB_pzPUm5wLjX9_M_yA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s44RkB8U7U2bDJqZ7dxzv9YhTcSDJCpv+fLZfJ2i0D0=; b=LENuEHy87SXNwfhXFPkt2iJTDDRTZHuW2xfE9Hog27Bv5f6lsrqrDjXX2dKJPxK4Nn W911ZRCJcWDpm5sgU47OxCxbizzZ3ettLKThTeydBoX6YEwlUOwZyvt41+TZzgCE/O4F w8RxJmoyJ8GwAR9UovE00q4dNRthYU/0RF01EA4jzkVKuOo8rP7DStQ6Ggq5CE1R4uUA VG/2mP6aN0Piumq/dLLHashdSiaVfRhicsPBhWWg5qquOfNWtdMvHcfNQvuFEqnBR+Ew EG/6b+I5mT+HexEEz5L0tijLbi8SPftf8g2+aO+xJFnHsev2hG1DrpOUjD787B0UztLL uoqg== X-Gm-Message-State: AOAM532Aro95iSFcbfXA8oMO/mT3uc9/rtO+Er4pwl86L77WPn6qQqW/ rvy3qn/XKCpK6Apw7wCioMgw1yHEdVmDlt8iGMxXqZtAamdkugQjHxitZZXESq0El3BbkgS78zw vbiRJL8fRXcIhi/q57nXvuDqEGQdyWpuGTXjnI/4bRL8nC5BRvyug6LmhbKXK X-Received: by 2002:a05:600c:22c9:: with SMTP id 9mr17038464wmg.25.1626448515548; Fri, 16 Jul 2021 08:15:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFiMtNoc6vBPxP8zVwKQ59wl3qf5pH1Ood5tKHN7j7OuDZ4GdukLs6U/m4QohJT/lQ6Ep/Og== X-Received: by 2002:a05:600c:22c9:: with SMTP id 9mr17038429wmg.25.1626448515240; Fri, 16 Jul 2021 08:15:15 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 05/19] hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35 Message-ID: <20210716151416.155127-6-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Eduardo Habkost , Richard Henderson , Julia Suvorova , Igor Mammedov , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448775874100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Julia Suvorova Q35 has three different types of PCI devices hot-plug: PCIe Native, SHPC Native and ACPI hot-plug. This patch changes the default choice for cold-plugged bridges from PCIe Native to ACPI Hot-plug with ability to use SHPC and PCIe Native for hot-plugged bridges. This is a list of the PCIe Native hot-plug issues that led to this change: * no racy behavior during boot (see 110c477c2ed) * no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug: https://bugzilla.redhat.com/show_bug.cgi?id=3D1594168 * no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable. * fixes: * https://bugzilla.redhat.com/show_bug.cgi?id=3D1752465 * https://bugzilla.redhat.com/show_bug.cgi?id=3D1690256 To return to PCIe Native hot-plug: -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=3Doff Known issue: older linux guests need the following flag to allow hotplugged pci express devices to use io: -device pcie-root-port,io-reserve=3D4096. io is unusual for pci express so this seems minor. We'll fix this by a follow up patch. Signed-off-by: Julia Suvorova Reviewed-by: Igor Mammedov Message-Id: <20210713004205.775386-6-jusual@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Gibson --- hw/acpi/ich9.c | 2 +- hw/i386/pc.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 2f4eb453ac..778e27b659 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -427,7 +427,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs = *pm) pm->disable_s3 =3D 0; pm->disable_s4 =3D 0; pm->s4_val =3D 2; - pm->use_acpi_hotplug_bridge =3D false; + pm->use_acpi_hotplug_bridge =3D true; =20 object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE, &pm->pm_io_base, OBJ_PROP_FLAG_READ); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index aa79c5e0e6..f4c7a78362 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -99,6 +99,7 @@ GlobalProperty pc_compat_6_0[] =3D { { "qemu64" "-" TYPE_X86_CPU, "model", "6" }, { "qemu64" "-" TYPE_X86_CPU, "stepping", "3" }, { TYPE_X86_CPU, "x-vendor-cpuid-only", "off" }, + { "ICH9-LPC", "acpi-pci-hotplug-with-bridge-support", "off" }, }; const size_t pc_compat_6_0_len =3D G_N_ELEMENTS(pc_compat_6_0); =20 --=20 MST From nobody Fri May 10 09:55:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1626448850; cv=none; d=zohomail.com; s=zohoarc; b=jnIZwlMSqFQE49+azFBbIWi9C9wwKv/hwBivRt8HTLZzH/JMezmYGcZt7zYvnyDvghfIZyS0asNa2Ax4p3Qak2eRx46NXXf7cMmM//sjRGlHCD4kPtWZoUyGmA8Cmb7q8iirFdPLJralWDmrn7C2dMe1SpiLIlHNI10nWdj0gGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626448850; h=Content-Type: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=pxbNJIFUIVQZ8eiUNei7sLj1LzsgmxfPLrXR8qYMHRc=; b=a5JHBN0si5MRB8uCQF6dOmoGHkkIIKI8j+FiXchYjsRc0X9F1kF6SqG5HvqwRVVULQEdMmDC3MkKeHjeoeUbf+bx5IGSZ0DNtf0U4kJLKUCpEl/8GnMnlfEvHfvpDPwc9ta6cxzB9SncXHJk/oRSwmuSLqqfCaDZw61eo0rR3HE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448850425725.9786401483881; Fri, 16 Jul 2021 08:20:50 -0700 (PDT) Received: from localhost ([::1]:34152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pdx-0002Rt-7W for importer@patchew.org; Fri, 16 Jul 2021 11:20:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYi-00013G-Mx for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYf-0003zv-MQ for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:24 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-513-LdYleWTkMAqWJ1s9XwvuRA-1; Fri, 16 Jul 2021 11:15:19 -0400 Received: by mail-wr1-f70.google.com with SMTP id i10-20020a5d55ca0000b029013b976502b6so4979733wrw.2 for ; Fri, 16 Jul 2021 08:15:19 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id w9sm8608533wmc.19.2021.07.16.08.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pxbNJIFUIVQZ8eiUNei7sLj1LzsgmxfPLrXR8qYMHRc=; b=Tx89s3kfOlf6+Xyae4pCTb7uOPOnbheTTwCO638z/39SP/TDOYBxtQ9GRANuTmeLnZsZpE bryCMbZt1tBfEA//7cPBciAoCoGkba7x9eQ/P2DJxALtncDEDep1uj3sqyHHq7pX0VEFxI l3MakG7o4hxXxcQF2+7KDkQTunnBFzI= X-MC-Unique: LdYleWTkMAqWJ1s9XwvuRA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pxbNJIFUIVQZ8eiUNei7sLj1LzsgmxfPLrXR8qYMHRc=; b=kB0eG92SWISdCRUGCBd+HPwy+yx3n0GdPDvhsaDoU/0/MIBum9dFxCpc68d6AkdY9y 1960ZP+0+1ULJxmrSYAJxbbTI4DzX/MdXX8wS4I6kTP2bQ6dUEFhX0YNGXnS0Zddtr+7 6FyqtSknyfL4Sudidz3dDXgxXTfKz4k45ko9OZDcP3ymvIkt8NQk6krqPR3KRN2rbc7n iJNClpCIkz+4fHk/pEuPJdWAzSWtAnJ0OuQ/HWR0W2LAefCb6vXBCAl4JbEHovyohbVU tsbyx46HIzcdbXCa2shtUWqhZVd+vSEnDLCbPuGFtSwA1HTfPGVpeM2dBFMe9jvfgAxi J+nQ== X-Gm-Message-State: AOAM532J+GYRwPNq2ceR9bGlcQBO2noxU6vn6uDwzWpko7ESvmgGBwXP zTmuD6R7PASRZwIBS+TdNjWfRuCSWLReRyOaR6Sb79ejIPqmkbPTyv8VTyxAwiZgQXU5QU3mZWD qgd7swGycabNusC9lCqLFE5E4sX9lz3mH9ZfW8cYRcLv+ajzsmgl3EoWhzGQH X-Received: by 2002:adf:e4d1:: with SMTP id v17mr12649551wrm.206.1626448517876; Fri, 16 Jul 2021 08:15:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUjZGXgerS9f3rQOphryEJ3MA4nJqJj5Iy6eWpCiXQzWOwQkXUCyvzCkd5M3VPOg/h8SK/hg== X-Received: by 2002:adf:e4d1:: with SMTP id v17mr12649511wrm.206.1626448517523; Fri, 16 Jul 2021 08:15:17 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 06/19] bios-tables-test: Update golden binaries Message-ID: <20210716151416.155127-7-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Julia Suvorova , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626448851629100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Julia Suvorova Add ACPI hot-plug registers to DSDT Q35 tables. Changes in the tables: + Scope (_SB.PCI0) + { + OperationRegion (PCST, SystemIO, 0x0CC4, 0x08) + Field (PCST, DWordAcc, NoLock, WriteAsZeros) + { + PCIU, 32, + PCID, 32 + } + + OperationRegion (SEJ, SystemIO, 0x0CCC, 0x04) + Field (SEJ, DWordAcc, NoLock, WriteAsZeros) + { + B0EJ, 32 + } + + OperationRegion (BNMR, SystemIO, 0x0CD4, 0x08) + Field (BNMR, DWordAcc, NoLock, WriteAsZeros) + { + BNUM, 32, + PIDX, 32 + } + + Mutex (BLCK, 0x00) + Method (PCEJ, 2, NotSerialized) + { + Acquire (BLCK, 0xFFFF) + BNUM =3D Arg0 + B0EJ =3D (One << Arg1) + Release (BLCK) + Return (Zero) + } + + Method (AIDX, 2, NotSerialized) + { + Acquire (BLCK, 0xFFFF) + BNUM =3D Arg0 + PIDX =3D (One << Arg1) + Local0 =3D PIDX /* \_SB_.PCI0.PIDX */ + Release (BLCK) + Return (Local0) + } + + Method (PDSM, 6, Serialized) + { + If ((Arg0 =3D=3D ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d= ") /* Device Labeling Interface */)) + { + Local0 =3D AIDX (Arg4, Arg5) + If ((Arg2 =3D=3D Zero)) + { + If ((Arg1 =3D=3D 0x02)) + { + If (!((Local0 =3D=3D Zero) | (Local0 =3D=3D 0xFFFF= FFFF))) + { + Return (Buffer (One) + { + 0x81 = // . + }) + } + } + + Return (Buffer (One) + { + 0x00 = // . + }) + } + ElseIf ((Arg2 =3D=3D 0x07)) + { + Local1 =3D Package (0x02) + { + Zero, + "" + } + Local1 [Zero] =3D Local0 + Return (Local1) + } + } + } + } + ... Scope (_GPE) { Name (_HID, "ACPI0006" /* GPE Block Device */) // _HID: Hardware = ID + Method (_E01, 0, NotSerialized) // _Exx: Edge-Triggered GPE, xx= =3D0x00-0xFF + { + Acquire (\_SB.PCI0.BLCK, 0xFFFF) + \_SB.PCI0.PCNT () + Release (\_SB.PCI0.BLCK) + } ... + + Device (PHPR) + { + Name (_HID, "PNP0A06" /* Generic Container Device */) // _HID= : Hardware ID + Name (_UID, "PCI Hotplug resources") // _UID: Unique ID + Name (_STA, 0x0B) // _STA: Status + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Set= tings + { + IO (Decode16, + 0x0CC4, // Range Minimum + 0x0CC4, // Range Maximum + 0x01, // Alignment + 0x18, // Length + ) + }) + } } ... And if there is a port in configuration: Device (S10) { Name (_ADR, 0x00020000) // _ADR: Address + Name (BSEL, Zero) + Device (S00) + { + Name (_SUN, Zero) // _SUN: Slot User Number + Name (_ADR, Zero) // _ADR: Address + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device= , x=3D0-9 + { + PCEJ (BSEL, _SUN) + } + + Method (_DSM, 4, Serialized) // _DSM: Device-Specific= Method + { + Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN)) + } + } + ... + Method (DVNT, 2, NotSerialized) + { + If ((Arg0 & One)) + { + Notify (S00, Arg1) + } ... Signed-off-by: Julia Suvorova Message-Id: <20210713004205.775386-7-jusual@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 11 ----------- tests/data/acpi/q35/DSDT | Bin 7859 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9184 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7877 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8323 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9513 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7934 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9218 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8990 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 7717 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 8295 bytes tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 8894 bytes 12 files changed, 11 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index c5167f48af..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,12 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT", -"tests/data/acpi/q35/DSDT.tis", -"tests/data/acpi/q35/DSDT.bridge", -"tests/data/acpi/q35/DSDT.mmio64", -"tests/data/acpi/q35/DSDT.ipmibt", -"tests/data/acpi/q35/DSDT.cphp", -"tests/data/acpi/q35/DSDT.memhp", -"tests/data/acpi/q35/DSDT.acpihmat", -"tests/data/acpi/q35/DSDT.numamem", -"tests/data/acpi/q35/DSDT.dimmpxm", -"tests/data/acpi/q35/DSDT.nohpet", diff --git a/tests/data/acpi/q35/DSDT b/tests/data/acpi/q35/DSDT index cccf92f0466fa4eaf2e9e06675b3b102c7a8eb86..842533f53e6db40935c3cdecd1d= 182edba6c17d4 100644 GIT binary patch delta 466 zcmdmN`_O^QCDauXIPPtIak zAUQdci)n%Iq}s^|43iUh{sRHS5=3DB8~#>OQ;f?=3DWf0@2A?TpzYIYyru7HSX=3DAqfOH`-McSBME?12>6O_{w~AM zs2<(q#S-8V5X2Gh;pxH~;1^)vXkf;`5g!WTIeRL2LFaQ7^vWU|F delta 57 zcmaFpu-TT&CD*D+yKS90tV5j&1XHSFZh5+Z_5Jv7JJX{>njRGK! zGf+HK0Z6zgL^lMxdc`wxpW)$RiEiWuah#nDT)lu2PJX^YjNDfs+CUsOVt(t-l7wM diff --git a/tests/data/acpi/q35/DSDT.bridge b/tests/data/acpi/q35/DSDT.bri= dge index eb5d27d95b2cdeda5f7e1f6b151cfea02e6bd907..55ad4bd7ab4759d68031b2f1d03= 07355a7332fe7 100644 GIT binary patch delta 3198 zcmb7{PjBNy7{Ebzd(?3;ItCjk3cyfap1s>(;m2R;mDzf?)%1mvr$RXI0q}wJmcRyGxq%P zuaBe_71=3D%4P#92N&%?#cyB()e z^@POlsv^1P2^2=3DTP^p4ZwrWR0;?LkV6h_&q*Yfs(`BB~#%7@1LOn=3D=3DrDpk>4M|FMO zZeor0*IZ~Zgt!}6-edZkCAjH-)u0x_+IVS%bsM@lW1CKGzIzz=3Do2j&-{ju}g-_F)I zweK_k)Uv-AwKlSzeAei$`=3D_j%^;?SAP5%-q`jNitRSFN7yZ-pC7>!!cp`ilXu#Vl0p#rR- z)s~+Bx3VB?xEEE)-nWlrZ~wqd+Lm1?6}Fk|)lnG-`TftoXg~S#6aPgnH*=3D|8s=3D~4_ zt)9+3dyMUAd(Zr@R^R2;PtJpaCwnFHNM%f9a@naIGWX&gr+~#y-2x(*OkeaW)q;Ry zk5$moGaihZ+QYGHwoX5#a`&PnIfY_yyFhGV6oQXul%*gUG^B_G5l2BLGr}B7j2N*Y z2A`rc5ajJ}EEI_#(hy`y1_g-|BhGXlWmF-^CIy)x$V}uQn-pYL_IU8zXCp%%QV^Mf z$k7=3D^kN00OWsV?oks(_YL?MO}fx#{J0)};qh9p6dL4h2~t$ii62I7X3zXvENNGWg_m1cDSPNQxk-n~+-> zyA))R7>gl;Pr0B$kX;IrCP+GRkP-#aLk4GhbO;4mq999=3D8RaktSMCtxPIL$b$q*wG zmBAf@hGdx_%TXbYK|!*_$WF=3DN{f(@@2ACA&E?lZtPL|bof*dM;kuPGKeUd;ZsM#d zu%~z`X?4}JrXr#!hC%`X$C$v8QIMm7fZaQA@+ipJ1F^};>Yzd^dDcuYYzcO_P+?OK z2OhQsn@;FqW3YRK3R{DHAXL~KEa;)a_F!oa6}AU!EN^ue&YE!Y5*QS~f=3DOEJYrHw| zCDgEvk(T@Vm9L?O<%RrwU%&GAP{XVzzth)6J}Bt-873oDfV1FJoLB>m{f0R*(AaZx z$j83Jt2^-XsE7PL(C|hL{0?dyR(%c6xvb6bAde3lzZ8VttC4dw%|4LxXsZct@8Y9tH*`1^^Ot5>o&G diff --git a/tests/data/acpi/q35/DSDT.cphp b/tests/data/acpi/q35/DSDT.cphp index e55d12990c98d8eed760b858ce18a036b612da1c..ccde2add9f87db0c0eaf0cc1557= 17d5744e4ef40 100644 GIT binary patch delta 466 zcmZp6+~~sP66_LUsKmg)=3D(&;WH&eZUpP*iRuv2`1v!_9HLx6K|2qX6q9xjgPMgb7V z87LmA03=3D)#q8ox;z2X_U&+u@uL^pDSIL=3DN6u3kV1CqLgHM(!&RZ6J=3DblV7N>LV%}B zghDi|3JX7L{X5Lv2h8IU|1-=3DKy-2z7khyaD-#1RLt;TfM$Fl2~Uj?rg^g&M>|NCE-Qej(B7NCF@g0=3D}Y~kIV5h zsz*0@u>^Po1aZWBc)IWg_yrg^8kjL~#D{`-&YlV$`6UH8rRkG5%FD7H;W@&?C^7kp Zd?uG4OAN?D0XLS(ZVI;SB5WXA7y#g;hnxTa delta 57 zcmdn!((K6P66_MvtiZs)7_^b=3DH`8VnmetaXB9kx53o{Ei3T{?Z;Afm%qnOU=3D#u5`B N>=3DZ9xH~FoiEdbPr5E}ph diff --git a/tests/data/acpi/q35/DSDT.dimmpxm b/tests/data/acpi/q35/DSDT.di= mmpxm index 95901f94c0d445919cb84dd1f6d98c646ae8176e..b062e30117f955c7a2ac9629a05= 12324bbd28bf2 100644 GIT binary patch delta 500 zcmZ4Kb=3D{ZCCDauXIPPtIak zAUQdci)n%Iq}s^|43iUh{sRHS5=3DB8~#>OQ;f?=3DWf0@2A?T6g=3D`v3UW%*Cx@%ZvK`?$!ow&rxk@FI%a0`nG&EEVc?F8u9J{t{m|mo-VwO&H~3^jZa^I-tdz5?tSm&`@XmD^P=3DGxwR;r+n0^pBTugx@MNxhi+R{7=3DIs)ae{Qa zZmGCv?5hOoWwZyBMU2c+h-5h%4*eE)_@@`J4R{F2alH?er92z@XJalN=3D5z3Vy`Ex3 zu;EyfL3x6oj4YpLbq~EDOFJM))3z82Qn%;S1Jsj-?1BD5 zG7Nit2HQ7IEKms&<@45*_wY1#%*wp>$N z10>s64gcM6wBDG2kzFIXF@ZZ|Yvxg(pMp7ZRT6LkS4YX%##){Q$J{#WVOLiRN5_8m iauXIPPtIak zAUQdci)n%Iq}s^|43iUh{sRHS5=3DB8~#>OQ;f?=3DWf0@2A?T<+5bHs-N?E!|mf=3D7NyK~8DaL66_Mfq{6_!cz+|;Z>G&EEL!s7BJu74t{m|mo-VwO&H4 b7bx>HPX4Wu&gsSy6CdmpFJL!0N7WVpu^|&B diff --git a/tests/data/acpi/q35/DSDT.mmio64 b/tests/data/acpi/q35/DSDT.mmi= o64 index 77d46369e48efca9a9e5024542c77cd26144beff..2e0a772a85275c9c3b4c9317d98= cc7c3d27417f3 100644 GIT binary patch delta 479 zcmZWl%}T>S7~Ji@Y1C9x)PoXRr3XPH_=3DDb>O|+>dU78kztt36!iee6WP!L;BUUlyh zp)Vjlg1v}>9()BazJiCkOBDq7Ffg<8&G3D<8_%YoJ9_1L1^`I!g|E&)Y6Qrp|k$q^kRffs;{un1nv#XYZ zO?^ipP}@dZK%T|OD27OuvtG|{aEE_-0h@q_kQ~=3DLK%UF9p?@~!;$c1q@5k%OdJOB1 zH56<|X(Kf%NN=3Dl8AI|cbbv^cJO*|sY=3DUE4bUXZ2xAef*{Ary?>oKp`_PwcS=3DI@75z zY89Gf~gPY5jIs-T>1(DGmt(vHd;|L@ije>S delta 71 zcmX@@InRyDCDauXIPPtIak zAUQdci)n%Iq}s^|43iUh{sRHS5=3DB8~#>OQ;f?=3DWf0@2A?TqMI{i_!+&To4i;8JOY9sCI|Qh7&rnA=3D7D+yKS90tV5j&1XHSFZh5+Z_5Jv7JJX{>njRGK! zGf+HK0Z6zgL^lMxdc`wxpW)$RiEiWuah#nDT)lu2PJX^YjNDfs+CUsylgPr07oIMSq8v>kzLm0V_@NjWNHwu6_ z&Oq@{1t8&~5Zw^$>J`t(eTIjNCAyIt#Bp{qaP+slXajMao%}+56#_h6 zA{3$-oqU|V8AMbAoL#+`qLo3s|NjdzKq?9<>lrf{K!!xCgT$9Gh-f>7t;daNwt#`7$zt1{09PtC5nQ~jEzfx1j9n{1)`I)xY!GXSeY1j84?Q;IuaQe zmLzUwWxg%RBR&+wbM{p5$S*0#DNUdJR#ukn2+t87Mv2J+ da+#d|nlT^?1>7e$$=3DR`quz@Vuyk9Pe2>{`!ixL0; delta 62 zcmdnzI?;*CCD (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449072221430.81749394099677; Fri, 16 Jul 2021 08:24:32 -0700 (PDT) Received: from localhost ([::1]:48862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4PhX-00049W-4b for importer@patchew.org; Fri, 16 Jul 2021 11:24:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYj-00013I-SY for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43050) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYh-000416-Gm for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:25 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-vuruMx0zNXuDb4P5RMnS6g-1; Fri, 16 Jul 2021 11:15:21 -0400 Received: by mail-wr1-f72.google.com with SMTP id 5-20020a0560001565b029013fe432d176so4927713wrz.23 for ; Fri, 16 Jul 2021 08:15:21 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id l16sm12460216wmj.47.2021.07.16.08.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=w3eXmWnE8Tatrf5dOCIdZm/pZHSR55bqkuDwM3WIMCA=; b=hNE2mzGCBfujedISTQrnig2O574YjU16OH8GBuNcRcAPMxLBvppmX5PmP4CwpQ8w7A+2gE dBvmh5GMZy5jyKFA8caMVlmhn6EkkGIukTO0+G4fGOQhm5v9R1sQmLDl4wAE/k9TtoJvWq +ANdbr7cQNfrLmRrTR3XaUqCjsgjiaI= X-MC-Unique: vuruMx0zNXuDb4P5RMnS6g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=w3eXmWnE8Tatrf5dOCIdZm/pZHSR55bqkuDwM3WIMCA=; b=SizwQPK4WGl8uesxqPZElxETzjxC7vTdMBARNodAul8mJYudkNdlQ1OjUnzPKkK1+k 3Xuvz0ebKhtSvXjyYc+oYjAbtkPYR5GzmXl3TiyGrHD18VCKQs3xDhVVatnMQ4uQDnXs OPvEAHchqbnfDMpYj2M7zfgw7NoQvFlSNak7LE8D5Plyb2mSn1Avj31tL0+TxelWzRFG hvMUaiNeOVzFNWaq6T9VBkWjddtc/omM6w8dmpC8U8QtQi+qgwMMZP3d0u+ndqJnmm0W rh59lF5eyZ7nwUJshxQQRgWDlK3F8FkI0zsO82LKssX9swvzi2QsXvArtVmhpZ8w8ko5 DR7A== X-Gm-Message-State: AOAM532EKKym8tnw4S3lvZx1DlxwBtl/vR+sj1BL6t8wdyLyJuSRm8C3 BxJpJCF+WtxlcCLkhXyfUw3iEa4H8lkvXtxrbI9hSpu/jniA8i7DIs9H10k7NOB/AIX+4tGVTBn R3/vodrJP7ZlO15t9eZqhwq1Z5nrNNY7MIZqMkpHmIqHfLkp2rpak6QxYZIXe X-Received: by 2002:adf:eacb:: with SMTP id o11mr13742149wrn.62.1626448519831; Fri, 16 Jul 2021 08:15:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyS7LGqhpVusq0EahWFG1q6KiG4F3xnrJa4jylp+ut0nn2HbO+5TJKh4hLoXoRlyqFhhGSOJA== X-Received: by 2002:adf:eacb:: with SMTP id o11mr13742119wrn.62.1626448519538; Fri, 16 Jul 2021 08:15:19 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 07/19] hw/virtio: add boilerplate for vhost-user-i2c device Message-ID: <20210716151416.155127-8-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Viresh Kumar Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626449074248100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Viresh Kumar This creates the QEMU side of the vhost-user-i2c device which connects to the remote daemon. It is based of vhost-user-fs code. Signed-off-by: Viresh Kumar Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-i2c.h | 28 +++ hw/virtio/vhost-user-i2c.c | 288 +++++++++++++++++++++++++++++ hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + 4 files changed, 322 insertions(+) create mode 100644 include/hw/virtio/vhost-user-i2c.h create mode 100644 hw/virtio/vhost-user-i2c.c diff --git a/include/hw/virtio/vhost-user-i2c.h b/include/hw/virtio/vhost-u= ser-i2c.h new file mode 100644 index 0000000000..deae47a76d --- /dev/null +++ b/include/hw/virtio/vhost-user-i2c.h @@ -0,0 +1,28 @@ +/* + * Vhost-user i2c virtio device + * + * Copyright (c) 2021 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _QEMU_VHOST_USER_I2C_H +#define _QEMU_VHOST_USER_I2C_H + +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" + +#define TYPE_VHOST_USER_I2C "vhost-user-i2c-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserI2C, VHOST_USER_I2C) + +struct VHostUserI2C { + VirtIODevice parent; + CharBackend chardev; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *vq; + bool connected; +}; + +#endif /* _QEMU_VHOST_USER_I2C_H */ diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c new file mode 100644 index 0000000000..d172632bb0 --- /dev/null +++ b/hw/virtio/vhost-user-i2c.c @@ -0,0 +1,288 @@ +/* + * Vhost-user i2c virtio device + * + * Copyright (c) 2021 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-i2c.h" +#include "qemu/error-report.h" +#include "standard-headers/linux/virtio_ids.h" + +/* Remove this once the header is updated in Linux kernel */ +#ifndef VIRTIO_ID_I2C_ADAPTER +#define VIRTIO_ID_I2C_ADAPTER 34 +#endif + +static void vu_i2c_start(VirtIODevice *vdev) +{ + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret =3D vhost_dev_enable_notifiers(&i2c->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret =3D k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, true= ); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + i2c->vhost_dev.acked_features =3D vdev->guest_features; + + ret =3D vhost_dev_start(&i2c->vhost_dev, vdev); + if (ret < 0) { + error_report("Error starting vhost-user-i2c: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i =3D 0; i < i2c->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&i2c->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&i2c->vhost_dev, vdev); +} + +static void vu_i2c_stop(VirtIODevice *vdev) +{ + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&i2c->vhost_dev, vdev); + + ret =3D k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, fals= e); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&i2c->vhost_dev, vdev); +} + +static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + bool should_start =3D status & VIRTIO_CONFIG_S_DRIVER_OK; + + if (!vdev->vm_running) { + should_start =3D false; + } + + if (i2c->vhost_dev.started =3D=3D should_start) { + return; + } + + if (should_start) { + vu_i2c_start(vdev); + } else { + vu_i2c_stop(vdev); + } +} + +static uint64_t vu_i2c_get_features(VirtIODevice *vdev, + uint64_t requested_features, Error **e= rrp) +{ + /* No feature bits used yet */ + return requested_features; +} + +static void vu_i2c_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void vu_i2c_guest_notifier_mask(VirtIODevice *vdev, int idx, bool m= ask) +{ + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + + vhost_virtqueue_mask(&i2c->vhost_dev, vdev, idx, mask); +} + +static bool vu_i2c_guest_notifier_pending(VirtIODevice *vdev, int idx) +{ + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + + return vhost_virtqueue_pending(&i2c->vhost_dev, idx); +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserI2C *i2c) +{ + vhost_user_cleanup(&i2c->vhost_user); + virtio_delete_queue(i2c->vq); + virtio_cleanup(vdev); + g_free(i2c->vhost_dev.vqs); + i2c->vhost_dev.vqs =3D NULL; +} + +static int vu_i2c_connect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + + if (i2c->connected) { + return 0; + } + i2c->connected =3D true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_i2c_start(vdev); + } + + return 0; +} + +static void vu_i2c_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + + if (!i2c->connected) { + return; + } + i2c->connected =3D false; + + if (i2c->vhost_dev.started) { + vu_i2c_stop(vdev); + } +} + +static void vu_i2c_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vu_i2c_connect(dev) < 0) { + qemu_chr_fe_disconnect(&i2c->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vu_i2c_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vu_i2c_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserI2C *i2c =3D VHOST_USER_I2C(dev); + int ret; + + if (!i2c->chardev.chr) { + error_setg(errp, "vhost-user-i2c: missing chardev"); + return; + } + + if (!vhost_user_init(&i2c->vhost_user, &i2c->chardev, errp)) { + return; + } + + virtio_init(vdev, "vhost-user-i2c", VIRTIO_ID_I2C_ADAPTER, 0); + + i2c->vhost_dev.nvqs =3D 1; + i2c->vq =3D virtio_add_queue(vdev, 4, vu_i2c_handle_output); + i2c->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, i2c->vhost_dev.n= vqs); + + ret =3D vhost_dev_init(&i2c->vhost_dev, &i2c->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + if (ret < 0) { + do_vhost_user_cleanup(vdev, i2c); + } + + qemu_chr_fe_set_handlers(&i2c->chardev, NULL, NULL, vu_i2c_event, NULL, + dev, NULL, true); +} + +static void vu_i2c_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserI2C *i2c =3D VHOST_USER_I2C(dev); + + /* This will stop vhost backend if appropriate. */ + vu_i2c_set_status(vdev, 0); + vhost_dev_cleanup(&i2c->vhost_dev); + do_vhost_user_cleanup(vdev, i2c); +} + +static const VMStateDescription vu_i2c_vmstate =3D { + .name =3D "vhost-user-i2c", + .unmigratable =3D 1, +}; + +static Property vu_i2c_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserI2C, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_i2c_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_i2c_properties); + dc->vmsd =3D &vu_i2c_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize =3D vu_i2c_device_realize; + vdc->unrealize =3D vu_i2c_device_unrealize; + vdc->get_features =3D vu_i2c_get_features; + vdc->set_status =3D vu_i2c_set_status; + vdc->guest_notifier_mask =3D vu_i2c_guest_notifier_mask; + vdc->guest_notifier_pending =3D vu_i2c_guest_notifier_pending; +} + +static const TypeInfo vu_i2c_info =3D { + .name =3D TYPE_VHOST_USER_I2C, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VHostUserI2C), + .class_init =3D vu_i2c_class_init, +}; + +static void vu_i2c_register_types(void) +{ + type_register_static(&vu_i2c_info); +} + +type_init(vu_i2c_register_types) diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index 0eda25c4e1..35ab45e209 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -58,3 +58,8 @@ config VIRTIO_MEM depends on LINUX depends on VIRTIO_MEM_SUPPORTED select MEM_DEVICE + +config VHOST_USER_I2C + bool + default y + depends on VIRTIO && VHOST_USER diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index fbff9bc9d4..1a0d736a0d 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -25,6 +25,7 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: f= iles('vhost-user-vsock. virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'= )) virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) +virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2= c.c')) =20 virtio_pci_ss =3D ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-= pci.c')) --=20 MST From nobody Fri May 10 09:55:45 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162644867024176.35016167489619; Fri, 16 Jul 2021 08:17:50 -0700 (PDT) Received: from localhost ([::1]:53856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pb3-0005Bd-6v for importer@patchew.org; Fri, 16 Jul 2021 11:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYl-00013N-R8 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYj-00042g-Fu for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:27 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-537-K0SvUndhNsCGm0qwg6GqTg-1; Fri, 16 Jul 2021 11:15:23 -0400 Received: by mail-wr1-f70.google.com with SMTP id m9-20020a5d4a090000b029013e2b4a9d1eso4967377wrq.4 for ; Fri, 16 Jul 2021 08:15:23 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id y19sm11329116wma.21.2021.07.16.08.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L7iObvtBFmPk0+FN/s4T6VgVW41+HOKgYbVN1kxGfA8=; b=fyiJmYIxpyKXk2TAE7paFHn8gzbkunsbF/24kl1oP1HctLgvXIMpEas/0aJm+2/RNVr6ws g2Va2TLQJJRkxD0bfMDW1RoLbb1Sk+azJ0j0ibm2wjB7bnZmUIxRSFU4EE+X7FPN9ZE+kO Zmsx/CKsL8uaSxgDTkcCa7WJYZcFVSY= X-MC-Unique: K0SvUndhNsCGm0qwg6GqTg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=L7iObvtBFmPk0+FN/s4T6VgVW41+HOKgYbVN1kxGfA8=; b=atSTJRZiz3WDnG6GRqcEjugOlM3c6DOqsSHcY65YUNgty6KIXpdGZkWHo6V+W8LB7F 4T2QiKXlOpRn7Gyx0LK+MF7rjH6clz9l/sfYF90GUjUAz++D5WIJhjEk4BScVnh2zdGE XH6p4wFeFnFqIj3zeJEpKi+wkvxSnHAkKBF0/jpm0TrrW//jlyV7qyAlRsA3qaSML5IR 76hpd9xElUNujC5dHDRGV/DZUTNFM0ZFLR9YWP0XtiWeq7w5j//j79ctm+7M4Ttru1dR xtJ9KTNVHSYvRaXJoram+HsoSvd0kWuHUDnE+IH12pN/+31uc6P8SAnzAiESwsy74OUG tAZA== X-Gm-Message-State: AOAM5307imHtOFF2gAr3TnmvtexVSjV65ldqz0rHBRwMDpt4s/J3TS1b 04JHL+ynVcKRuy1nLW7vdw6Xd8UVgPVZ6eeYYDXTmkAg2oc8hvhqxe1JEr5PcZaabuOzam2FEHR hg3DBRYMBtadsMEkmsLP447DXkRM4jC59HjZTEU1fH7H7vJ1ozcBNBJguYNtk X-Received: by 2002:a1c:741a:: with SMTP id p26mr11153016wmc.47.1626448522080; Fri, 16 Jul 2021 08:15:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhTVNyymByhSQRKOzh8dPwxIMNmTIHzlv0awm0hRLmndHotZOL5KmVdFt3M0+nIifvaZcSJw== X-Received: by 2002:a1c:741a:: with SMTP id p26mr11152988wmc.47.1626448521790; Fri, 16 Jul 2021 08:15:21 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 08/19] hw/virtio: add vhost-user-i2c-pci boilerplate Message-ID: <20210716151416.155127-9-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Alex =?utf-8?Q?Benn=C3=A9e?= , Viresh Kumar Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448671632100001 From: Viresh Kumar This allows is to instantiate a vhost-user-i2c device as part of a PCI bus. It is mostly boilerplate which looks pretty similar to the vhost-user-fs-pci device. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Viresh Kumar Message-Id: <8a083eaa57d93feaab12acd1f94b225879212f20.1625806763.git.viresh= .kumar@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-i2c-pci.c | 69 ++++++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 2 files changed, 70 insertions(+) create mode 100644 hw/virtio/vhost-user-i2c-pci.c diff --git a/hw/virtio/vhost-user-i2c-pci.c b/hw/virtio/vhost-user-i2c-pci.c new file mode 100644 index 0000000000..70b7b65fd9 --- /dev/null +++ b/hw/virtio/vhost-user-i2c-pci.c @@ -0,0 +1,69 @@ +/* + * Vhost-user i2c virtio device PCI glue + * + * Copyright (c) 2021 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-i2c.h" +#include "virtio-pci.h" + +struct VHostUserI2CPCI { + VirtIOPCIProxy parent_obj; + VHostUserI2C vdev; +}; + +typedef struct VHostUserI2CPCI VHostUserI2CPCI; + +#define TYPE_VHOST_USER_I2C_PCI "vhost-user-i2c-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserI2CPCI, VHOST_USER_I2C_PCI, + TYPE_VHOST_USER_I2C_PCI) + +static void vhost_user_i2c_pci_realize(VirtIOPCIProxy *vpci_dev, Error **e= rrp) +{ + VHostUserI2CPCI *dev =3D VHOST_USER_I2C_PCI(vpci_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + + vpci_dev->nvectors =3D 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_i2c_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + k->realize =3D vhost_user_i2c_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision =3D 0x00; + pcidev_k->class_id =3D PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_i2c_pci_instance_init(Object *obj) +{ + VHostUserI2CPCI *dev =3D VHOST_USER_I2C_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_I2C); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_i2c_pci_info =3D { + .base_name =3D TYPE_VHOST_USER_I2C_PCI, + .non_transitional_name =3D "vhost-user-i2c-pci", + .instance_size =3D sizeof(VHostUserI2CPCI), + .instance_init =3D vhost_user_i2c_pci_instance_init, + .class_init =3D vhost_user_i2c_pci_class_init, +}; + +static void vhost_user_i2c_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_i2c_pci_info); +} + +type_init(vhost_user_i2c_pci_register); diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 1a0d736a0d..bc352a6009 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -26,6 +26,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('= virtio-rng.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'= )) virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2= c.c')) +virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2C'], if_tru= e: files('vhost-user-i2c-pci.c')) =20 virtio_pci_ss =3D ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-= pci.c')) --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448990731878.532537971804; Fri, 16 Jul 2021 08:23:10 -0700 (PDT) Received: from localhost ([::1]:42854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4PgD-0008TI-BF for importer@patchew.org; Fri, 16 Jul 2021 11:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYp-00014M-Jb for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYn-00046g-Al for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:30 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-cXcCLAaSN06-8H2e0S4MeA-1; Fri, 16 Jul 2021 11:15:26 -0400 Received: by mail-wr1-f70.google.com with SMTP id y15-20020a5d614f0000b029013cd60e9baaso4939715wrt.7 for ; Fri, 16 Jul 2021 08:15:26 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id o11sm11228033wmc.2.2021.07.16.08.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=umcXGg1ajUcx6yGPrHNc9sdCDLC76+6T/qWiwvzG+eo=; b=X5lH541dmgDJ+yyKPcg0nVly+Kr9wGIOvvYoJO2Bj7Ytd8EY8aECrTgBmrL5/8kf3qcyVr oWM6G7Vt5tGQdaoEm1CKG8+ssC5y8DDHubYIPM4WyPxUJyDRyBHWdVNI6cPsH033Xok6Ro 0v38Nj10QUoTccT06bW3rjSOPAthsyc= X-MC-Unique: cXcCLAaSN06-8H2e0S4MeA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=umcXGg1ajUcx6yGPrHNc9sdCDLC76+6T/qWiwvzG+eo=; b=FxIKctRa8SNq+yYb5f6BxywU5Z0BZWv54ASCiO4ykW6HndgLqwNk2+ehDxaEpr32H4 bqk6uKsOa4u0HuPUOdui6AWVRf0y0o4a2UBf2opVYR1WbqvhqdfH9q7mocoM660tYntd 81gGHY6mVg8q837B7Tp3ajLpNIT781mcopN24wvJGlsY9VNNTng65uEOfc3G4SqPxAV/ UqvsSiqbY1jQLOTzoUmWR4pjJXm6SPuw4sPHj83Wht+y83kl6vGEldPqHRrVJtW0h880 KNXDqUt79Ah4nxrKikmiOc9H5HmZdySeHN2HnHhW/9pMBuJWjvVTP6bk4xlPYZ+w7N92 5cOA== X-Gm-Message-State: AOAM532WKxzJaxIOGPi7BsMMv48GNlFPpuGAwZtxIdZiWQ4plKXfeDqr 3VtStQ7yU4XuGZtcwq2JnvijNtIyut23jNyYl2aA80p7cYFNTQ3RB11++r+MSiFXe4t+YWnN3WP B04ltXlvKzgLrofXkOrGGJN28MvQ91eLwnHJL0EMDeN2lmEOYYjdKE1U0MQfw X-Received: by 2002:a05:600c:4e8f:: with SMTP id f15mr11391395wmq.174.1626448525074; Fri, 16 Jul 2021 08:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS95IQCfIxAx04E0C5296m5STU8EYCPd09dJfjBsgVEai7bCrZBkwwsolbB4/QTtrbFNAq9w== X-Received: by 2002:a05:600c:4e8f:: with SMTP id f15mr11391351wmq.174.1626448524833; Fri, 16 Jul 2021 08:15:24 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 09/19] docs: Add '-device intel-iommu' entry Message-ID: <20210716151416.155127-10-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Thomas Huth , Yi Liu , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Jason Wang , Peter Xu , Maxim Levitsky , Eric Auger , Alex Williamson , Jing Zhao , Gerd Hoffmann , Paolo Bonzini , Lei Yang , Chao Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448991327100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu The parameters of intel-iommu device are non-trivial to understand. Add an entry for it so that people can reference to it when using. There're actually a few more options there, but I hide them explicitly beca= use they shouldn't be used by normal QEMU users. Cc: Chao Yang Cc: Lei Yang Cc: Jing Zhao Cc: Jason Wang Cc: Michael S. Tsirkin Cc: Alex Williamson Reviewed-by: Jason Wang Reviewed-by: Yi Liu Signed-off-by: Peter Xu Message-Id: <20210707154114.197580-1-peterx@redhat.com> Reviewed-by: Maxim Levitsky Reviewed-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qemu-options.hx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 214c477dcc..0c9ddc0274 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -939,6 +939,39 @@ SRST =20 ``-device pci-ipmi-bt,bmc=3Did`` Like the KCS interface, but defines a BT interface on the PCI bus. + +``-device intel-iommu[,option=3D...]`` + This is only supported by ``-machine q35``, which will enable Intel VT= -d + emulation within the guest. It supports below options: + + ``intremap=3Don|off`` (default: auto) + This enables interrupt remapping feature. It's required to enable + complete x2apic. Currently it only supports kvm kernel-irqchip mo= des + ``off`` or ``split``, while full kernel-irqchip is not yet support= ed. + The default value is "auto", which will be decided by the mode of + kernel-irqchip. + + ``caching-mode=3Don|off`` (default: off) + This enables caching mode for the VT-d emulated device. When + caching-mode is enabled, each guest DMA buffer mapping will genera= te an + IOTLB invalidation from the guest IOMMU driver to the vIOMMU devic= e in + a synchronous way. It is required for ``-device vfio-pci`` to work + with the VT-d device, because host assigned devices requires to se= tup + the DMA mapping on the host before guest DMA starts. + + ``device-iotlb=3Don|off`` (default: off) + This enables device-iotlb capability for the emulated VT-d device.= So + far virtio/vhost should be the only real user for this parameter, + paired with ats=3Don configured for the device. + + ``aw-bits=3D39|48`` (default: 39) + This decides the address width of IOVA address space. The address + space has 39 bits width for 3-level IOMMU page tables, and 48 bits= for + 4-level IOMMU page tables. + + Please also refer to the wiki page for general scenarios of VT-d + emulation in QEMU: https://wiki.qemu.org/Features/VT-d. + ERST =20 DEF("name", HAS_ARG, QEMU_OPTION_name, --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448948830606.1490510283762; Fri, 16 Jul 2021 08:22:28 -0700 (PDT) Received: from localhost ([::1]:40464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4PfX-0006kK-Eg for importer@patchew.org; Fri, 16 Jul 2021 11:22:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYq-00015b-5R for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYo-000485-I9 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:31 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-MpdlAX5RM2qbp6gj501uJw-1; Fri, 16 Jul 2021 11:15:28 -0400 Received: by mail-wm1-f70.google.com with SMTP id k8-20020a05600c1c88b02901b7134fb829so1303744wms.5 for ; Fri, 16 Jul 2021 08:15:28 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id y16sm10477648wrw.42.2021.07.16.08.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448530; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x7ZuFpyOa5DAu/c2wYuyH48s1IkBMXPNPbP+hmJeKHY=; b=JPkxbaw1IKCCZNkKMRSRaf0arCL7RkjABdFxBv2EbwRP0emRf1kudOJMFQth6ooooDuLEf yImyN5w+WMf8ZKhGBtzlJJnDMjdnTDIFsmbqvP6WD8IE+Ph7N20qgNJXL5dxOTxH3j3oU+ vrlGJdow/E7bthHb6u9aro6Ql32uUuE= X-MC-Unique: MpdlAX5RM2qbp6gj501uJw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=x7ZuFpyOa5DAu/c2wYuyH48s1IkBMXPNPbP+hmJeKHY=; b=q4q08hTkbAcHohH2TTqTq6INJ3mjj9cqjG/WrUSmTLPZLuHhM00VMHragZ8C53GvTw HVDBXs0kuHJahjlJstNmX6n7/H9n6LCbN1E6B4KYxwWFCCfBdaBXZ06xUNuIlY7qluyx Pn8e55666RcPG434MoCHHAubttKGn8tgHpP/1STg5kmA+sFAiaIQIT7TYo6373m6keiD HPv1NkSc3Q2HfA3BfpOnG7/5PhnUWoHWV7qdMNPxJezs5SCuptUcFj5r0KEJ8Y+Iz7kO hmotHak7RK1mrsdXh9q3PhIatlB4DnYstKMBh6bRAAfk3Gkqd+pestf/fxPhiiIBvZWh BoRA== X-Gm-Message-State: AOAM531xP+oPpgosBSAZXmcd9CH7ZKZfoxYCBrx6TZb+PhLiHuYf165W GRtevpFBjRov6PxrUnGxiy/ikpd9vwXs/uPJYt912nE6XL+yklntiXpX4sLXYDRry2+8UOVjLjI v/i+Ky1kPFl9WR0uAFMQwxMnP7NG8VbkNbEMoI01GxSSMcd6M4Yd4gX3d1SNw X-Received: by 2002:adf:cf07:: with SMTP id o7mr12927931wrj.216.1626448527226; Fri, 16 Jul 2021 08:15:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzojQ1LWq/fooruqcVvE/wmaOfDiMpi0kgKlvczK5lesIaIrZSXvygBUS8+3QtZC61cLlg/cw== X-Received: by 2002:adf:cf07:: with SMTP id o7mr12927909wrj.216.1626448527050; Fri, 16 Jul 2021 08:15:27 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 10/19] hw/pci/pci_host: Allow PCI host to bypass iommu Message-ID: <20210716151416.155127-11-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Xingang Wang , Eric Auger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448949122100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang Add a new bypass_iommu property for PCI host and use it to check whether devices attached to the PCI root bus will bypass iommu. In pci_device_iommu_address_space(), check the property and avoid getting iommu address space for devices bypass iommu. Signed-off-by: Xingang Wang Reviewed-by: Eric Auger Message-Id: <1625748919-52456-2-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 1 + include/hw/pci/pci_host.h | 1 + hw/pci/pci.c | 18 +++++++++++++++++- hw/pci/pci_host.c | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 6be4e0c460..f4d51b672b 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -480,6 +480,7 @@ void pci_for_each_bus(PCIBus *bus, =20 PCIBus *pci_device_root_bus(const PCIDevice *d); const char *pci_root_bus_path(PCIDevice *dev); +bool pci_bus_bypass_iommu(PCIBus *bus); PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn); int pci_qdev_find_device(const char *id, PCIDevice **pdev); void pci_bus_get_w64_range(PCIBus *bus, Range *range); diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h index 52e038c019..c6f4eb4585 100644 --- a/include/hw/pci/pci_host.h +++ b/include/hw/pci/pci_host.h @@ -43,6 +43,7 @@ struct PCIHostState { uint32_t config_reg; bool mig_enabled; PCIBus *bus; + bool bypass_iommu; =20 QLIST_ENTRY(PCIHostState) next; }; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 377084f1a8..27d588e268 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -416,6 +416,22 @@ const char *pci_root_bus_path(PCIDevice *dev) return rootbus->qbus.name; } =20 +bool pci_bus_bypass_iommu(PCIBus *bus) +{ + PCIBus *rootbus =3D bus; + PCIHostState *host_bridge; + + if (!pci_bus_is_root(bus)) { + rootbus =3D pci_device_root_bus(bus->parent_dev); + } + + host_bridge =3D PCI_HOST_BRIDGE(rootbus->qbus.parent); + + assert(host_bridge->bus =3D=3D rootbus); + + return host_bridge->bypass_iommu; +} + static void pci_root_bus_init(PCIBus *bus, DeviceState *parent, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, @@ -2718,7 +2734,7 @@ AddressSpace *pci_device_iommu_address_space(PCIDevic= e *dev) =20 iommu_bus =3D parent_bus; } - if (iommu_bus && iommu_bus->iommu_fn) { + if (!pci_bus_bypass_iommu(bus) && iommu_bus && iommu_bus->iommu_fn) { return iommu_bus->iommu_fn(bus, iommu_bus->iommu_opaque, devfn); } return &address_space_memory; diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index 8ca5fadcbd..cf02f0d6a5 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -222,6 +222,7 @@ const VMStateDescription vmstate_pcihost =3D { static Property pci_host_properties_common[] =3D { DEFINE_PROP_BOOL("x-config-reg-migration-enabled", PCIHostState, mig_enabled, true), + DEFINE_PROP_BOOL("bypass-iommu", PCIHostState, bypass_iommu, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626448862930374.81944027121244; Fri, 16 Jul 2021 08:21:02 -0700 (PDT) Received: from localhost ([::1]:35062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pe9-000356-Pu for importer@patchew.org; Fri, 16 Jul 2021 11:21:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYs-00015h-7k for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYq-0004D7-Pd for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:34 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-9Zd5n1K_M1GnhEW5-w7yzw-1; Fri, 16 Jul 2021 11:15:31 -0400 Received: by mail-wr1-f69.google.com with SMTP id p4-20020a5d63840000b0290126f2836a61so4986393wru.6 for ; Fri, 16 Jul 2021 08:15:30 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id r18sm10570005wrt.96.2021.07.16.08.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZFXStzDbpHZ3x7owVBtjJeqaH/pfDgxn4UIZ7oQ1Es0=; b=E93cBCTihyuhuwlsuTlRdOaezc/Bx3kBDXlg+hSrUyXgZ6Z0xEfQ2aE0BoZzy0+mWNhAOA xY3pWxyNmNjBHOX6llFU2/n/mcdpvdqMJjESta4PMB/NdyheoVLEsqY8yIalfpX6r9QK8P XvN+F9e0PtNP9fqFPLJB01iTkwClB5E= X-MC-Unique: 9Zd5n1K_M1GnhEW5-w7yzw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZFXStzDbpHZ3x7owVBtjJeqaH/pfDgxn4UIZ7oQ1Es0=; b=uI1JyXp7fxN6mmdfxOmt3I7ZYkzYY0fcl3b6s/IjFbLG08qGzcwqzs+ogUzz1L1YbK +Ll3+NHpsbW0iyM9wvnCNmQBwnQL3myipAF09/5KNB/MMwU9A1PQPb1OllmhHESGbBLy voUsomI3Nyfi6FcQ4fv3BsQWun7aLAwkjXgfnc/PFnlVBwpZx4b5/lEn3xFb2hxtv8ad C8Z0g4ObuVPNYd4cKHVyctDFeReLNpCbZ0QZ5uFZiekaImTV6SF5NYmbnQTikpr2aPxw cl3f6XyA+n/nEC5lA9LAN4tZbVtZyZiPuZG4ep8zLlIjEyrS+9svAHY7lsKjJ3ctxm7q SBSg== X-Gm-Message-State: AOAM531OaDR9E6dgHb7Q4XhbMFIfEIpn9arMPFvaFBucDS90TTy2f4Jt 9Jw6I4AgdMa+eXIGokuZ7jDzayhqXjbvyfKz3aSlciv08rA/5cjfhHpP2+gs/BuCdlEHDDZWRnw Nq5v1l488dQIb7TjR7z0CvqDWZZft9ZWkEsE2SrTRnXXMD1QcCg2ZYGSEQc2u X-Received: by 2002:a7b:c111:: with SMTP id w17mr17120540wmi.163.1626448529607; Fri, 16 Jul 2021 08:15:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtVBp2xhJAB1jI1FEIXmlOgGEiEtXx5XWgC+xJC48nI0UiFMYhsICPOjcv0otLfd1dkYoK1w== X-Received: by 2002:a7b:c111:: with SMTP id w17mr17120519wmi.163.1626448529414; Fri, 16 Jul 2021 08:15:29 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 11/19] hw/pxb: Add a bypass iommu property Message-ID: <20210716151416.155127-12-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Xingang Wang , Eric Auger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626448864629100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang Add a bypass_iommu property for pci_expander_bridge, the property is used to indicate whether pxb root bus will bypass iommu. By default the bypass_iommu is disabled, and it can be enabled with: qemu -device pxb-pcie,bus_nr=3D0x10,addr=3D0x1,bypass_iommu=3Dtrue Signed-off-by: Xingang Wang Reviewed-by: Eric Auger Message-Id: <1625748919-52456-3-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/pci_expander_bridge.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index aedded1064..7112dc3062 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -57,6 +57,7 @@ struct PXBDev { =20 uint8_t bus_nr; uint16_t numa_node; + bool bypass_iommu; }; =20 static PXBDev *convert_to_pxb(PCIDevice *dev) @@ -255,6 +256,7 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool= pcie, Error **errp) bus->map_irq =3D pxb_map_irq_fn; =20 PCI_HOST_BRIDGE(ds)->bus =3D bus; + PCI_HOST_BRIDGE(ds)->bypass_iommu =3D pxb->bypass_iommu; =20 pxb_register_bus(dev, bus, &local_err); if (local_err) { @@ -301,6 +303,7 @@ static Property pxb_dev_properties[] =3D { /* Note: 0 is not a legal PXB bus number. */ DEFINE_PROP_UINT8("bus_nr", PXBDev, bus_nr, 0), DEFINE_PROP_UINT16("numa_node", PXBDev, numa_node, NUMA_NODE_UNASSIGNE= D), + DEFINE_PROP_BOOL("bypass_iommu", PXBDev, bypass_iommu, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16264490981991016.5532459898996; Fri, 16 Jul 2021 08:24:58 -0700 (PDT) Received: from localhost ([::1]:51334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Phx-0005nL-5l for importer@patchew.org; Fri, 16 Jul 2021 11:24:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYw-0001Ai-A3 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51616) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYt-0004H8-Sp for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:38 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-464-152UynXuNv2Ijy9AYCOcyg-1; Fri, 16 Jul 2021 11:15:33 -0400 Received: by mail-wr1-f69.google.com with SMTP id r18-20020adfce920000b029013bbfb19640so4916566wrn.17 for ; Fri, 16 Jul 2021 08:15:33 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id l16sm12460724wmj.47.2021.07.16.08.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wGJK3zOQMsPUthycRa07iCj/XcAJGJjnk+sZAHLKKJI=; b=F1PqzIti39oITNiBXredNaJY4/xbifcQD6yZbX6zIZavTyQil1nB7yuVljUd3TxqjuLWoa vTWCG2X7wHmwZjf4I1lX4hkuU++5hED2OnjsVCx38eqEe7G5O3hRh7Bv/lgUAzS6dfCuyn f1aeCdOQASMHPELQB7ckUCvBBUJf2UM= X-MC-Unique: 152UynXuNv2Ijy9AYCOcyg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wGJK3zOQMsPUthycRa07iCj/XcAJGJjnk+sZAHLKKJI=; b=GiuTysMvrUCci4vMWKEiIrCK6wDoFmUrhD2eJ4fjEM5RgCEMPw052oBcVPP/H+gxuK X5KcY7eXFhP3pogqrjLvg+kybzDJzqHrOUubb0BQLtG2/BwfPnLprP9KGD4yJSyC60w0 d4HaHal3ziVEZ0GDBsir1kCXMk/gt6H67yDErh9JV3Qd+PaBTOJBdi+N7GB0LiXk9GfX L3tfkO5BgJ1BZpUCEq/o9fQfPidL7FeBfgsYDCNTBpqc2C/7KN1Xrmx/gRaym0azZQHx 6/zKSLFPMBvh9fpOSBbiIDySBFjToQeJYIEWVDagrxr1fI3ST/IGv5zDn28hmt4Genrs +OTw== X-Gm-Message-State: AOAM531eBaY44j8L5nqA2Jy8x3ZUbD9dF/aX8mv97eBMrUDUQ7si4mFa iB6Tdwwtf3FxCQYKZA6rvlGFVEGgGRMZR+uJdUIDu1gTIQdkT3CbufFkshjnq9kFGLFxHR7P0c/ 1k5KnNrlSTW7I3UevpGDUs19UpFdHqGo7OGn6/f2pq9DLFmDYgfY/ZPqdzfdk X-Received: by 2002:a5d:6e07:: with SMTP id h7mr3828705wrz.233.1626448532157; Fri, 16 Jul 2021 08:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLWsiHhGRFWoBsSfob4GPgvl63z36HSPZieeSC5h1pJh/RX3PP0r5VQNPoFBL+LNgSofbPDA== X-Received: by 2002:a5d:6e07:: with SMTP id h7mr3828677wrz.233.1626448531888; Fri, 16 Jul 2021 08:15:31 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 12/19] hw/arm/virt: Add default_bus_bypass_iommu machine option Message-ID: <20210716151416.155127-13-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , qemu-arm@nongnu.org, Xingang Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626449100214100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang Add a default_bus_bypass_iommu machine option to enable/disable bypass_iommu for default root bus. The option is disabled by default and can be enabled with: $QEMU -machine virt,iommu=3Dsmmuv3,default_bus_bypass_iommu=3Dtrue Signed-off-by: Xingang Wang Message-Id: <1625748919-52456-4-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/arm/virt.h | 1 + hw/arm/virt.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 921416f918..9661c46699 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -147,6 +147,7 @@ struct VirtMachineState { OnOffAuto acpi; VirtGICType gic_version; VirtIOMMUType iommu; + bool default_bus_bypass_iommu; VirtMSIControllerType msi_controller; uint16_t virtio_iommu_bdf; struct arm_boot_info bootinfo; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 93ab9d21ea..81eda46b0b 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1367,6 +1367,7 @@ static void create_pcie(VirtMachineState *vms) } =20 pci =3D PCI_HOST_BRIDGE(dev); + pci->bypass_iommu =3D vms->default_bus_bypass_iommu; vms->bus =3D pci->bus; if (vms->bus) { for (i =3D 0; i < nb_nics; i++) { @@ -2322,6 +2323,21 @@ static void virt_set_iommu(Object *obj, const char *= value, Error **errp) } } =20 +static bool virt_get_default_bus_bypass_iommu(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return vms->default_bus_bypass_iommu; +} + +static void virt_set_default_bus_bypass_iommu(Object *obj, bool value, + Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + vms->default_bus_bypass_iommu =3D value; +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -2661,6 +2677,13 @@ static void virt_machine_class_init(ObjectClass *oc,= void *data) "Set the IOMMU type. " "Valid values are none and smmuv= 3"); =20 + object_class_property_add_bool(oc, "default_bus_bypass_iommu", + virt_get_default_bus_bypass_iommu, + virt_set_default_bus_bypass_iommu); + object_class_property_set_description(oc, "default_bus_bypass_iommu", + "Set on/off to enable/disable " + "bypass_iommu for default root b= us"); + object_class_property_add_bool(oc, "ras", virt_get_ras, virt_set_ras); object_class_property_set_description(oc, "ras", @@ -2728,6 +2751,9 @@ static void virt_instance_init(Object *obj) /* Default disallows iommu instantiation */ vms->iommu =3D VIRT_IOMMU_NONE; =20 + /* The default root bus is attached to iommu by default */ + vms->default_bus_bypass_iommu =3D false; + /* Default disallows RAS instantiation */ vms->ras =3D false; =20 --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449075463257.2428335023169; Fri, 16 Jul 2021 08:24:35 -0700 (PDT) Received: from localhost ([::1]:49106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pha-0004J4-7y for importer@patchew.org; Fri, 16 Jul 2021 11:24:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZ2-0001De-D3 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYx-0004Ko-EI for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:42 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-3N6SO1DgMZaWF4WJ5Mut7w-1; Fri, 16 Jul 2021 11:15:37 -0400 Received: by mail-wr1-f69.google.com with SMTP id z6-20020a5d4c860000b029013a10564614so4960523wrs.15 for ; Fri, 16 Jul 2021 08:15:37 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id d29sm12868881wrb.63.2021.07.16.08.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/OZKZnTpXtPjXVstCt8swwDVZoRwveMME1l85hvhMPQ=; b=CAlqbE7fE9wxrcsFCSfPJxPBn5pFoTf6heYtjm1SnDJrP8Cc/gS7duHE0lWZDxNVrEc0Qr 1H8fluWc8FsTyLE4+vSJ4AbUCpILhnua5TwDlzCsSLj2HZL0OnU9GIWnYl7FMHazkeSNfy i+UpZVxYPmlbNdL/OyeIabcFa6jhh4Y= X-MC-Unique: 3N6SO1DgMZaWF4WJ5Mut7w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/OZKZnTpXtPjXVstCt8swwDVZoRwveMME1l85hvhMPQ=; b=M+O0xVYtJXNMn4Qxb1xJ5weEAygCjUzm1zXEwkzo+aQ69lVDc78IYBMlUP1r3M7mU5 hWBmc9iQ5EO1V1K/KbspKlWE8X1lfNE/rOKcCk0rXq074C8RDU0klownFC3XNOEPKNZ0 8GcfvRMoaCciM/6geGOp21GCpKR7uo9dAMgbwHP1hl2+rn6w7Xxe1btTnRJxXjqPe8RZ eNqdbP3M9qzmP8AVb3Q7NiOuvB2V2CJ49ZZhnQa1EtpbXHsgXp0YqsTU7GlxN6lIwz2L TZexSh3ZVzw9F3jg0F1mZvQwW5029X/XJI0SPdOyekjKN5TN4c/lojDy8QnbPqvoHuKR CR/w== X-Gm-Message-State: AOAM531Y0kV/tEOtLjH5d8ZdjrF3z3oT3NSZDAHtpuynzIJqGf3MEdtp KLDHTc9pvskY4yhSbvWAYeE0TkU/WLU0jUgs82uO9edDS8DWZLQdZIvzh1an+busfzzzZKFpGCN vSYvRFGLNvKOTg0QrCfA7RYo34XNeYQ01Py0Xdch4q0vbK+tuaEQZOLIJw85N X-Received: by 2002:a05:600c:1d04:: with SMTP id l4mr3889070wms.130.1626448534689; Fri, 16 Jul 2021 08:15:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiJVxBwGP82p5MPbaKU1qk4aCYqWibfhpP4OBfexYOVNvzDo53yOXBDD0bie8h7YQ9aD7dAQ== X-Received: by 2002:a05:600c:1d04:: with SMTP id l4mr3889044wms.130.1626448534448; Fri, 16 Jul 2021 08:15:34 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 13/19] hw/i386: Add a default_bus_bypass_iommu pc machine option Message-ID: <20210716151416.155127-14-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Xingang Wang , Richard Henderson , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626449076449100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang Add a default_bus_bypass_iommu pc machine option to enable/disable bypass_iommu for default root bus. The option is disabled by default and can be enabled with: $QEMU -machine q35,default_bus_bypass_iommu=3Dtrue Signed-off-by: Xingang Wang Message-Id: <1625748919-52456-5-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 1 + hw/i386/pc.c | 20 ++++++++++++++++++++ hw/pci-host/q35.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 0775f945d7..88dffe7517 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -44,6 +44,7 @@ typedef struct PCMachineState { bool sata_enabled; bool pit_enabled; bool hpet_enabled; + bool default_bus_bypass_iommu; uint64_t max_fw_size; =20 /* NUMA information: */ diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f4c7a78362..c2b9d62a35 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1524,6 +1524,21 @@ static void pc_machine_set_hpet(Object *obj, bool va= lue, Error **errp) pcms->hpet_enabled =3D value; } =20 +static bool pc_machine_get_default_bus_bypass_iommu(Object *obj, Error **e= rrp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + return pcms->default_bus_bypass_iommu; +} + +static void pc_machine_set_default_bus_bypass_iommu(Object *obj, bool valu= e, + Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + pcms->default_bus_bypass_iommu =3D value; +} + static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -1623,6 +1638,7 @@ static void pc_machine_initfn(Object *obj) #ifdef CONFIG_HPET pcms->hpet_enabled =3D true; #endif + pcms->default_bus_bypass_iommu =3D false; =20 pc_system_flash_create(pcms); pcms->pcspk =3D isa_new(TYPE_PC_SPEAKER); @@ -1747,6 +1763,10 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) object_class_property_add_bool(oc, "hpet", pc_machine_get_hpet, pc_machine_set_hpet); =20 + object_class_property_add_bool(oc, "default_bus_bypass_iommu", + pc_machine_get_default_bus_bypass_iommu, + pc_machine_set_default_bus_bypass_iommu); + object_class_property_add(oc, PC_MACHINE_MAX_FW_SIZE, "size", pc_machine_get_max_fw_size, pc_machine_set_max_fw_size, NULL, NULL); diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 0f37cf056a..ab5a47aff5 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -65,6 +65,8 @@ static void q35_host_realize(DeviceState *dev, Error **er= rp) s->mch.address_space_io, 0, TYPE_PCIE_BUS); PC_MACHINE(qdev_get_machine())->bus =3D pci->bus; + pci->bypass_iommu =3D + PC_MACHINE(qdev_get_machine())->default_bus_bypass_iommu; qdev_realize(DEVICE(&s->mch), BUS(pci->bus), &error_fatal); } =20 --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449024351312.4227211178695; Fri, 16 Jul 2021 08:23:44 -0700 (PDT) Received: from localhost ([::1]:44766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pgl-0001Rr-85 for importer@patchew.org; Fri, 16 Jul 2021 11:23:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZ2-0001Di-F0 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PYy-0004ME-Ua for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:44 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-pjN6kKQyM2Savm3eSedsBA-1; Fri, 16 Jul 2021 11:15:39 -0400 Received: by mail-wr1-f71.google.com with SMTP id d9-20020adffbc90000b029011a3b249b10so4906821wrs.3 for ; Fri, 16 Jul 2021 08:15:38 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id b16sm10960152wrs.51.2021.07.16.08.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Cem/scxwfuu8t6UBmBGhZX6mWJ6otnXd6jtrNMLMn2M=; b=HnwO9+3U0h8LiMHbeKLNPfU0GnhfhGyN4WRam0KCG0/6Oh2wiLRz+qX8UhiarwwT8baEhr 9aIlFtFLRkuZzkwC3O+CB3uKHNTl/PYNTgIk1RP9uQ2B9I3eufa+xXyqfXPeknk/TVj6lo g9YsEcKLt7AV6dCNTBGw1QdnV6BVcpE= X-MC-Unique: pjN6kKQyM2Savm3eSedsBA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Cem/scxwfuu8t6UBmBGhZX6mWJ6otnXd6jtrNMLMn2M=; b=jY/sssh1TbSkQRBzALd2LH6XFjy9GQyK2GtarVXVylcHBPzaQ4xX54Pyka0iB8ZaqD PSbDaM3fd8EeRi39ykNFTnJObB/leomAXmf7TXBT/unNL5urMBm0Rnchq7WXHIAbRcPk +hmciRYai8HbY+fSRBYbXMIesOC7I6uS5WE4aQQcNWH0V+PfiUC1CzhLK5m5lP2bWVMI nLmYs/fzeU++aUY+jDSzQeD5n7EgHkk1wAd3FlBZThHsCBM49rLTDsPaCjzGOoUNrZm7 JFaG3kFJm0bTdNLcCRFe9LJUUZhpIeOrblQXaJDxTTbWrohUagh0tOU1h5z0iXhrxwHX W8sg== X-Gm-Message-State: AOAM532yCbwsXr3tCS/2JodD3hJMzjTpqERHmmK8T0/HT9RzAty0Oq3H p0w4TQBOXOrVeiht6YDRw9z6du2DTAu9jCm7GU3uw3he3qG3wVHUDAsTulzg201QzyxdeUJIeED NdUjP/G1cfqpkBVJEKvIDG9veyoH6DSuuN4quREZxtHjpKwxKpVH3gep2pNyX X-Received: by 2002:a05:6000:108:: with SMTP id o8mr13349833wrx.154.1626448537637; Fri, 16 Jul 2021 08:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1OXg3lLNSv2uzkWcr10JMYz5qrhRpeHPAlJyFQFh7OqZX2iTTrbGVugOlLdinSzdtFWeZKg== X-Received: by 2002:a05:6000:108:: with SMTP id o8mr13349805wrx.154.1626448537427; Fri, 16 Jul 2021 08:15:37 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 14/19] hw/pci: Add pci_bus_range() to get PCI bus number range Message-ID: <20210716151416.155127-15-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Xingang Wang , Eric Auger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626449026145100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang This helps to get the min and max bus number of a PCI bus hierarchy. Signed-off-by: Xingang Wang Reviewed-by: Eric Auger Message-Id: <1625748919-52456-6-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 1 + hw/pci/pci.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index f4d51b672b..d0f4266e37 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -450,6 +450,7 @@ static inline PCIBus *pci_get_bus(const PCIDevice *dev) return PCI_BUS(qdev_get_parent_bus(DEVICE(dev))); } int pci_bus_num(PCIBus *s); +void pci_bus_range(PCIBus *bus, int *min_bus, int *max_bus); static inline int pci_dev_bus_num(const PCIDevice *dev) { return pci_bus_num(pci_get_bus(dev)); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 27d588e268..23d2ae2ab2 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -537,6 +537,22 @@ int pci_bus_num(PCIBus *s) return PCI_BUS_GET_CLASS(s)->bus_num(s); } =20 +/* Returns the min and max bus numbers of a PCI bus hierarchy */ +void pci_bus_range(PCIBus *bus, int *min_bus, int *max_bus) +{ + int i; + *min_bus =3D *max_bus =3D pci_bus_num(bus); + + for (i =3D 0; i < ARRAY_SIZE(bus->devices); ++i) { + PCIDevice *dev =3D bus->devices[i]; + + if (dev && PCI_DEVICE_GET_CLASS(dev)->is_bridge) { + *min_bus =3D MIN(*min_bus, dev->config[PCI_SECONDARY_BUS]); + *max_bus =3D MAX(*max_bus, dev->config[PCI_SUBORDINATE_BUS]); + } + } +} + int pci_bus_numa_node(PCIBus *bus) { return PCI_BUS_GET_CLASS(bus)->numa_node(bus); --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449266353852.3473797011762; Fri, 16 Jul 2021 08:27:46 -0700 (PDT) Received: from localhost ([::1]:59854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pkf-0003GN-81 for importer@patchew.org; Fri, 16 Jul 2021 11:27:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZ4-0001Ev-8t for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZ2-0004O7-6a for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:46 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38-U58vQ1n2NP-6kYW_KFUifA-1; Fri, 16 Jul 2021 11:15:41 -0400 Received: by mail-wm1-f71.google.com with SMTP id o21-20020a05600c4fd5b029023448cbd285so2634036wmq.2 for ; Fri, 16 Jul 2021 08:15:41 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id c125sm13446500wme.36.2021.07.16.08.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2tkVF2ulgVK1I83asV+DkCniiWWlnhyo+M2eGWekklE=; b=Q7eNoJB9AUcAeSmoV+ExuspHp8ibOCnpOm+bU6KGLiZzmecQgPtO/482XRTVC4c+jIVzIx F9k6gW9723cNWq9oWXr3Nru9fRLpDOi0d8mclteMy6lGrGaaAf7EoWHmAZSozIAzJUXVyX PS+iMWW4cjPUsRk5Ae1Skm0hDAvrzwU= X-MC-Unique: U58vQ1n2NP-6kYW_KFUifA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2tkVF2ulgVK1I83asV+DkCniiWWlnhyo+M2eGWekklE=; b=alQq7ayaZtN1DL+TDCsAa9Bg+3jGEvoCgfliRuXo4SY3B31g0dana3V8Uhl78uKpGZ 4dJtwpvDEt/y/Qbvexx6+fyMNdj7AS9kQDD5+RtwqeK0INuU7TkL2XDPp++bE+77E9Fo E+Akf06SlutpHcVnXD8xUro7gMEJPRJUGiWXFGHpv0kxvYFiC+3RNNnBFyqd3TYAHjyI mvzrt6Hdz/0CKGKafXdnzE0IKiqyQ0X8+rnONFrMdfSxSK9+nH8eg4nMrf/9ThwJZqhX NX5LLapdFYfuQ8Ls2EQNFqUmmZH+lwrc/OnnDm7Pyc1zX82TQi5c1wrXaMgr2oYl0GAN 5f2A== X-Gm-Message-State: AOAM531OX7OpStnJV1wSYjGmQCiM6k+GjTarBTxtplxMJYTBwrZjPrJN fBXnVy2bSe/UdbJVkfIs6Yas3Lj+iiyrIp6mrDmNDWmujg/jUintYw2wTkOxn+Tx/+wtrucwXZ5 TcAOc+e94LFju6gbDdJtdIl7szn1p3Ueawr3hrkeDy2prQ4sFxKcA8i+Bn1Uj X-Received: by 2002:a7b:c8d2:: with SMTP id f18mr10958738wml.135.1626448540288; Fri, 16 Jul 2021 08:15:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKI4wQmI8k4ESiuyTYpDLDsMaRf9q4/9U92cVttrIuFjDnTUk1/q5qO7exFmB30FNNf0NW5g== X-Received: by 2002:a7b:c8d2:: with SMTP id f18mr10958712wml.135.1626448540071; Fri, 16 Jul 2021 08:15:40 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 15/19] hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3 Message-ID: <20210716151416.155127-16-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Shannon Zhao , Xingang Wang , qemu-arm@nongnu.org, Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626449268543100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang When we build IORT table with SMMUv3 and bypass iommu feature enabled, we can no longer setup one map from RC to SMMUv3 covering the whole RIDs. We need to walk the PCI bus and check whether the root bus will bypass iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu. When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS covering the whole RIDs, and only modify the map from RC to SMMUv3. We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu disabled, and build idmap from RC to ITS directly for the rest of the whole RID space. For example we run qemu with command line: qemu/build/aarch64-softmmu/qemu-system-aarch64 \ -kernel arch/arm64/boot/Image \ -enable-kvm \ -cpu host \ -m 8G \ -smp 8,sockets=3D2,cores=3D4,threads=3D1 \ -machine virt,kernel_irqchip=3Don,gic-version=3D3,iommu=3Dsmmuv3,default_b= us_bypass_iommu=3Dtrue \ -drive file=3D./QEMU_EFI-pflash.raw,if=3Dpflash,format=3Draw,unit=3D0,read= only=3Don \ -device pxb-pcie,bus_nr=3D0x10,id=3Dpci.10,bus=3Dpcie.0,addr=3D0x3.0x1 \ -device pxb-pcie,bus_nr=3D0x20,id=3Dpci.20,bus=3Dpcie.0,addr=3D0x3.0x2,byp= ass_iommu=3Dtrue \ -device pcie-root-port,port=3D0x20,chassis=3D1,id=3Dpci.1,bus=3Dpcie.0,add= r=3D0x2 \ -device pcie-root-port,port=3D0x20,chassis=3D11,id=3Dpci.11,bus=3Dpci.10,a= ddr=3D0x1 \ -device pcie-root-port,port=3D0x20,chassis=3D21,id=3Dpci.21,bus=3Dpci.20,a= ddr=3D0x1 \ -device virtio-scsi-pci,id=3Dscsi0,bus=3Dpci.1,addr=3D0x1 \ -device virtio-scsi-pci,id=3Dscsi1,bus=3Dpci.11,addr=3D0x1 \ -device virtio-scsi-pci,id=3Dscsi2,bus=3Dpci.21,addr=3D0x1 \ -initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \ -nographic \ -append "rdinit=3Dinit console=3DttyAMA0 earlycon=3Dpl011,0x9000000 nokasl= r" \ And we get guest configuration: -+-[0000:20]---01.0-[21]-- +-[0000:10]---01.0-[11]-- \-[0000:00]-+-00.0 Device 1b36:0008 +-01.0 Device 1af4:1000 \-02.0-[01]-- With bypass_iommu enabled, the attached devices will bypass iommu. /sys/class/iommu/smmu3.0x0000000009050000/ |-- device -> ../../../arm-smmu-v3.0.auto |-- devices | `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0 Signed-off-by: Xingang Wang Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/arm/virt-acpi-build.c | 114 +++++++++++++++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 11 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index f1024843dd..037cc1fd82 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -44,6 +44,7 @@ #include "hw/acpi/tpm.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" #include "hw/pci-host/gpex.h" #include "hw/arm/virt.h" #include "hw/mem/nvdimm.h" @@ -239,23 +240,89 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachine= State *vms) } #endif =20 +/* Build the iort ID mapping to SMMUv3 for a given PCI host bridge */ +static int +iort_host_bridges(Object *obj, void *opaque) +{ + GArray *idmap_blob =3D opaque; + + if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { + PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; + + if (bus && !pci_bus_bypass_iommu(bus)) { + int min_bus, max_bus; + + pci_bus_range(bus, &min_bus, &max_bus); + + AcpiIortIdMapping idmap =3D { + .input_base =3D min_bus << 8, + .id_count =3D (max_bus - min_bus + 1) << 8, + }; + g_array_append_val(idmap_blob, idmap); + } + } + + return 0; +} + +static int iort_idmap_compare(gconstpointer a, gconstpointer b) +{ + AcpiIortIdMapping *idmap_a =3D (AcpiIortIdMapping *)a; + AcpiIortIdMapping *idmap_b =3D (AcpiIortIdMapping *)b; + + return idmap_a->input_base - idmap_b->input_base; +} + static void build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - int nb_nodes, iort_start =3D table_data->len; + int i, nb_nodes, rc_mapping_count, iort_start =3D table_data->len; AcpiIortIdMapping *idmap; AcpiIortItsGroup *its; AcpiIortTable *iort; AcpiIortSmmu3 *smmu; size_t node_size, iort_node_offset, iort_length, smmu_offset =3D 0; AcpiIortRC *rc; + GArray *smmu_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMapp= ing)); + GArray *its_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMappi= ng)); =20 iort =3D acpi_data_push(table_data, sizeof(*iort)); =20 if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { + AcpiIortIdMapping next_range =3D {0}; + + object_child_foreach_recursive(object_get_root(), + iort_host_bridges, smmu_idmaps); + + /* Sort the smmu idmap by input_base */ + g_array_sort(smmu_idmaps, iort_idmap_compare); + + /* + * Split the whole RIDs by mapping from RC to SMMU, + * build the ID mapping from RC to ITS directly. + */ + for (i =3D 0; i < smmu_idmaps->len; i++) { + idmap =3D &g_array_index(smmu_idmaps, AcpiIortIdMapping, i); + + if (next_range.input_base < idmap->input_base) { + next_range.id_count =3D idmap->input_base - next_range.inp= ut_base; + g_array_append_val(its_idmaps, next_range); + } + + next_range.input_base =3D idmap->input_base + idmap->id_count; + } + + /* Append the last RC -> ITS ID mapping */ + if (next_range.input_base < 0xFFFF) { + next_range.id_count =3D 0xFFFF - next_range.input_base; + g_array_append_val(its_idmaps, next_range); + } + nb_nodes =3D 3; /* RC, ITS, SMMUv3 */ + rc_mapping_count =3D smmu_idmaps->len + its_idmaps->len; } else { nb_nodes =3D 2; /* RC, ITS */ + rc_mapping_count =3D 1; } =20 iort_length =3D sizeof(*iort); @@ -307,13 +374,13 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) } =20 /* Root Complex Node */ - node_size =3D sizeof(*rc) + sizeof(*idmap); + node_size =3D sizeof(*rc) + sizeof(*idmap) * rc_mapping_count; iort_length +=3D node_size; rc =3D acpi_data_push(table_data, node_size); =20 rc->type =3D ACPI_IORT_NODE_PCI_ROOT_COMPLEX; rc->length =3D cpu_to_le16(node_size); - rc->mapping_count =3D cpu_to_le32(1); + rc->mapping_count =3D cpu_to_le32(rc_mapping_count); rc->mapping_offset =3D cpu_to_le32(sizeof(*rc)); =20 /* fully coherent device */ @@ -321,20 +388,45 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) rc->memory_properties.memory_flags =3D 0x3; /* CCA =3D CPM =3D DCAS = =3D 1 */ rc->pci_segment_number =3D 0; /* MCFG pci_segment */ =20 - /* Identity RID mapping covering the whole input RID range */ - idmap =3D &rc->id_mapping_array[0]; - idmap->input_base =3D 0; - idmap->id_count =3D cpu_to_le32(0xFFFF); - idmap->output_base =3D 0; - if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { - /* output IORT node is the smmuv3 node */ - idmap->output_reference =3D cpu_to_le32(smmu_offset); + AcpiIortIdMapping *range; + + /* translated RIDs connect to SMMUv3 node: RC -> SMMUv3 -> ITS */ + for (i =3D 0; i < smmu_idmaps->len; i++) { + idmap =3D &rc->id_mapping_array[i]; + range =3D &g_array_index(smmu_idmaps, AcpiIortIdMapping, i); + + idmap->input_base =3D cpu_to_le32(range->input_base); + idmap->id_count =3D cpu_to_le32(range->id_count); + idmap->output_base =3D cpu_to_le32(range->input_base); + /* output IORT node is the smmuv3 node */ + idmap->output_reference =3D cpu_to_le32(smmu_offset); + } + + /* bypassed RIDs connect to ITS group node directly: RC -> ITS */ + for (i =3D 0; i < its_idmaps->len; i++) { + idmap =3D &rc->id_mapping_array[smmu_idmaps->len + i]; + range =3D &g_array_index(its_idmaps, AcpiIortIdMapping, i); + + idmap->input_base =3D cpu_to_le32(range->input_base); + idmap->id_count =3D cpu_to_le32(range->id_count); + idmap->output_base =3D cpu_to_le32(range->input_base); + /* output IORT node is the ITS group node (the first node) */ + idmap->output_reference =3D cpu_to_le32(iort_node_offset); + } } else { + /* Identity RID mapping covering the whole input RID range */ + idmap =3D &rc->id_mapping_array[0]; + idmap->input_base =3D cpu_to_le32(0); + idmap->id_count =3D cpu_to_le32(0xFFFF); + idmap->output_base =3D cpu_to_le32(0); /* output IORT node is the ITS group node (the first node) */ idmap->output_reference =3D cpu_to_le32(iort_node_offset); } =20 + g_array_free(smmu_idmaps, true); + g_array_free(its_idmaps, true); + /* * Update the pointer address in case table_data->data moves during ab= ove * acpi_data_push operations. --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449221774216.86381025432843; Fri, 16 Jul 2021 08:27:01 -0700 (PDT) Received: from localhost ([::1]:57606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pjw-0001kU-IJ for importer@patchew.org; Fri, 16 Jul 2021 11:27:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZP-0001z4-Tr for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:16:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZO-0004a8-0o for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:16:07 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303--DbNkNj7MOOLIkPmUPmiDg-1; Fri, 16 Jul 2021 11:15:44 -0400 Received: by mail-wr1-f70.google.com with SMTP id k3-20020a5d52430000b0290138092aea94so4949045wrc.20 for ; Fri, 16 Jul 2021 08:15:43 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id y3sm10473166wrh.16.2021.07.16.08.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5PzNQJlTGNrpijxK0VyVgr7xwJWYbOTHaTkK7HI7uYg=; b=gf02XxUNkHD2jyYEgKQvucWmGRQPTu5DhAdvhNIFempUyDPGNskYCniL0n8gki3xhu5SSr YPCqHGOW25Tl74aGkam/Iz+fXNJpsycGD88ZubOsa6zINsDjs4rBtpqGsK7GHS3Qscmci8 YA72ZE4xhm5WnHViRZefNnikH+IEBDA= X-MC-Unique: -DbNkNj7MOOLIkPmUPmiDg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=5PzNQJlTGNrpijxK0VyVgr7xwJWYbOTHaTkK7HI7uYg=; b=AN8+P/0wz0WsCysIPmfXW1h0ke4svrvdo8jAzHO59GQBw3aEwDpp2lirys/rqR6EgX +FacueMenbaJnkNONNnPwYw1iFbMGcKB9AgeDk/oBd5Ydk2XOPwf9WKseODk+wHcHnfS GCRiCEZeen7Dwpklgiiu2Eh/8+B33JlIc43uEu+hYECJHTnF/QK4lQXPWf3vC/W1kWew nVPNF+xxMmTH1akOUtMTmWoc8fRP3YVtQ++720HxizGcJzLmeUaJhz8dB0mokw9FQ+b2 /T0lmICFCcAYNvN8y7tIF3eVpQGTPHp8KHUJRJoK+4EkV3FKDO2haAKqVGxjXbQRh/Uo uFmw== X-Gm-Message-State: AOAM531mJ+HKCoiKIjnLiu2AGYizyamjnWDNu/WwGAqJXMrcF5a1DnQ3 OZ5v43oF7YDRxeDifnt5S7tnNJqqr3ZFtyqAMyYBr4pTHN1QES71+PNGs8Wa9pbEhxeMTidz5Qu xRsG4jI14ZusB+1fr0MtyxTog76+AFzBuvs0mlIuYgEQCQmcfbR4eF/Qea9dm X-Received: by 2002:adf:e40d:: with SMTP id g13mr12862403wrm.12.1626448542532; Fri, 16 Jul 2021 08:15:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRWU/XtkW8e4JXb2lklyfhmpE2I3hd5hALfVUOZEMCo1xrekvkQ+mAq+/L/jv9rIqi0eD9fQ== X-Received: by 2002:adf:e40d:: with SMTP id g13mr12862366wrm.12.1626448542300; Fri, 16 Jul 2021 08:15:42 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 16/19] hw/i386/acpi-build: Add DMAR support to bypass iommu Message-ID: <20210716151416.155127-17-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Xingang Wang , Richard Henderson , Igor Mammedov , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626449222765100001 From: Xingang Wang In DMAR table, the drhd is set to cover all PCI devices when intel_iommu is on. To support bypass iommu feature, we need to walk the PCI bus with bypass_iommu disabled and add explicit scope data in DMAR drhd structure. /mnt/sdb/wxg/qemu-next/qemu/build/x86_64-softmmu/qemu-system-x86_64 \ -machine q35,accel=3Dkvm,default_bus_bypass_iommu=3Dtrue \ -cpu host \ -m 16G \ -smp 36,sockets=3D2,cores=3D18,threads=3D1 \ -device pxb-pcie,bus_nr=3D0x10,id=3Dpci.10,bus=3Dpcie.0,addr=3D0x3 \ -device pxb-pcie,bus_nr=3D0x20,id=3Dpci.20,bus=3Dpcie.0,addr=3D0x4,bypass_= iommu=3Dtrue \ -device pcie-root-port,port=3D0x1,chassis=3D1,id=3Dpci.11,bus=3Dpci.10,add= r=3D0x0 \ -device pcie-root-port,port=3D0x2,chassis=3D2,id=3Dpci.21,bus=3Dpci.20,add= r=3D0x0 \ -device virtio-scsi-pci,id=3Dscsi0,bus=3Dpci.11,addr=3D0x0 \ -device virtio-scsi-pci,id=3Dscsi1,bus=3Dpci.21,addr=3D0x0 \ -drive file=3D/mnt/sdb/wxg/fedora-48g.qcow2,format=3Dqcow2,if=3Dnone,id=3D= drive-scsi0-0-0-0,cache=3Dnone,aio=3Dnative \ -device scsi-hd,bus=3Dscsi1.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi0-0-0-0,id=3Dscsi0-0-0-0,bootindex=3D1 \ -device intel-iommu \ -nographic \ And we get the guest configuration: ~ lspci -vt -+-[0000:20]---00.0-[21]----00.0 Red Hat, Inc. Virtio SCSI +-[0000:10]---00.0-[11]----00.0 Red Hat, Inc. Virtio SCSI \-[0000:00]-+-00.0 Intel Corporation 82G33/G31/P35/P31 Express DRAM Contr= oller +-01.0 Device 1234:1111 +-02.0 Intel Corporation 82574L Gigabit Network Connection +-03.0 Red Hat, Inc. QEMU PCIe Expander bridge +-04.0 Red Hat, Inc. QEMU PCIe Expander bridge +-1f.0 Intel Corporation 82801IB (ICH9) LPC Interface Control= ler +-1f.2 Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port S= ATA Controller [AHCI mode] \-1f.3 Intel Corporation 82801I (ICH9 Family) SMBus Controller With bypass_iommu enabled on root bus, the attached devices will bypass iom= mu: /sys/class/iommu/dmar0 =E2=94=9C=E2=94=80=E2=94=80 devices =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 0000:10:00.0 -> ../../../= ../pci0000:10/0000:10:00.0 =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 0000:11:00.0 -> ../../../= ../pci0000:10/0000:10:00.0/0000:11:00.0 Signed-off-by: Xingang Wang Message-Id: <1625748919-52456-8-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 68 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index bc966a4110..7efc6285ac 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2022,6 +2022,56 @@ build_srat(GArray *table_data, BIOSLinker *linker, M= achineState *machine) x86ms->oem_table_id); } =20 +/* + * Insert DMAR scope for PCI bridges and endpoint devcie + */ +static void +insert_scope(PCIBus *bus, PCIDevice *dev, void *opaque) +{ + GArray *scope_blob =3D opaque; + AcpiDmarDeviceScope *scope =3D NULL; + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { + /* Dmar Scope Type: 0x02 for PCI Bridge */ + build_append_int_noprefix(scope_blob, 0x02, 1); + } else { + /* Dmar Scope Type: 0x01 for PCI Endpoint Device */ + build_append_int_noprefix(scope_blob, 0x01, 1); + } + + /* length */ + build_append_int_noprefix(scope_blob, + sizeof(*scope) + sizeof(scope->path[0]), 1); + /* reserved */ + build_append_int_noprefix(scope_blob, 0, 2); + /* enumeration_id */ + build_append_int_noprefix(scope_blob, 0, 1); + /* bus */ + build_append_int_noprefix(scope_blob, pci_bus_num(bus), 1); + /* device */ + build_append_int_noprefix(scope_blob, PCI_SLOT(dev->devfn), 1); + /* function */ + build_append_int_noprefix(scope_blob, PCI_FUNC(dev->devfn), 1); +} + +/* For a given PCI host bridge, walk and insert DMAR scope */ +static int +dmar_host_bridges(Object *obj, void *opaque) +{ + GArray *scope_blob =3D opaque; + + if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { + PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; + + if (bus && !pci_bus_bypass_iommu(bus)) { + pci_for_each_device(bus, pci_bus_num(bus), insert_scope, + scope_blob); + } + } + + return 0; +} + /* * VT-d spec 8.1 DMA Remapping Reporting Structure * (version Oct. 2014 or later) @@ -2041,6 +2091,15 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, /* Root complex IOAPIC use one path[0] only */ size_t ioapic_scope_size =3D sizeof(*scope) + sizeof(scope->path[0]); IntelIOMMUState *intel_iommu =3D INTEL_IOMMU_DEVICE(iommu); + GArray *scope_blob =3D g_array_new(false, true, 1); + + /* + * A PCI bus walk, for each PCI host bridge. + * Insert scope for each PCI bridge and endpoint device which + * is attached to a bus with iommu enabled. + */ + object_child_foreach_recursive(object_get_root(), + dmar_host_bridges, scope_blob); =20 assert(iommu); if (x86_iommu_ir_supported(iommu)) { @@ -2054,8 +2113,9 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker= , const char *oem_id, /* DMAR Remapping Hardware Unit Definition structure */ drhd =3D acpi_data_push(table_data, sizeof(*drhd) + ioapic_scope_size); drhd->type =3D cpu_to_le16(ACPI_DMAR_TYPE_HARDWARE_UNIT); - drhd->length =3D cpu_to_le16(sizeof(*drhd) + ioapic_scope_size); - drhd->flags =3D ACPI_DMAR_INCLUDE_PCI_ALL; + drhd->length =3D + cpu_to_le16(sizeof(*drhd) + ioapic_scope_size + scope_blob->len); + drhd->flags =3D 0; /* Don't include all pci device */ drhd->pci_segment =3D cpu_to_le16(0); drhd->address =3D cpu_to_le64(Q35_HOST_BRIDGE_IOMMU_ADDR); =20 @@ -2069,6 +2129,10 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, scope->path[0].device =3D PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC); scope->path[0].function =3D PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC); =20 + /* Add scope found above */ + g_array_append_vals(table_data, scope_blob->data, scope_blob->len); + g_array_free(scope_blob, true); + if (iommu->dt_supported) { atsr =3D acpi_data_push(table_data, sizeof(*atsr)); atsr->type =3D cpu_to_le16(ACPI_DMAR_TYPE_ATSR); --=20 MST From nobody Fri May 10 09:55:46 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449171122537.601642773051; Fri, 16 Jul 2021 08:26:11 -0700 (PDT) Received: from localhost ([::1]:56508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pj7-00010P-Ue for importer@patchew.org; Fri, 16 Jul 2021 11:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZ7-0001Qq-QV for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZ6-0004QU-0e for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:49 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-fItV-tuiNLSAKCsl_dyCHg-1; Fri, 16 Jul 2021 11:15:46 -0400 Received: by mail-wr1-f72.google.com with SMTP id m9-20020a5d4a090000b029013e2b4a9d1eso4967770wrq.4 for ; Fri, 16 Jul 2021 08:15:45 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id g3sm10366553wru.95.2021.07.16.08.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=flEK484QxMT1aHuKxIzbr2uWeLGle3LeEcxZhYEt/9E=; b=EsftECBdCHGfl4TXkQfyP1GukIBa3uJk0lgj72atwblKNHlsRWHiBcmFCcRJYpFp6EGtEJ wx4sFbz99R0BjbinAQtjLp3egSKKKmHVuTqnZqCqwwxLjL7XYCD++CpbWYOAfkFxNKnkCx XDTYCTLey5twP9uVjf6UB0HVc9/ycIE= X-MC-Unique: fItV-tuiNLSAKCsl_dyCHg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=flEK484QxMT1aHuKxIzbr2uWeLGle3LeEcxZhYEt/9E=; b=YHyRdK8jKF9ciAUFgmqWlBONADENGKo2ntFMWk0wHPEQxVhsZy5XzWZbssnLHi9SW1 xTbT2/IS6cCc04ERSreSGOc4Alygc9LyE8zp9PdxwZw21sfIsvSMZc7k6O+P+YqyBHDw 1XOx2UvvU2W82wEeWB7+F2wamgIPOSf0GNwtVIXOy057XNRBCxq+1pbf3REEWzh6nCbw xJZCNQqpAFRvAKwtbWtHX1PUuOJNlPq6o7LSRcf00xUdyw670F+GP6hP48pmK3NY4z5r an/U8ezTeJaepjOoPbg9WbRLPHdgXXCDlp4PhNHHvb4z/mxrTbFGctbIkWAdFquqbFZV 8qbw== X-Gm-Message-State: AOAM531kFvkVKtVdsPm1vJ9lvStjxWV3M/AMhshmx0NbEeYEMg5csilr +HwwPbRGe5jT7XaawYiVnu7oDCFTyKu2pRjq/TjWOpYA6CSIx6VyxQrcarCbvpy4hpyoHvbL0tW srzbc7U3jrvoeeGmXPv8fVjv5u1zWfT/edy4CeuQZfoMWxcHaxKMG/SAbLJyk X-Received: by 2002:adf:fcc9:: with SMTP id f9mr12809202wrs.133.1626448544814; Fri, 16 Jul 2021 08:15:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbCeorGZcO3ryRcD4F2KQWVPNi97oaXfgtWP9zuE+sAvONWYfb2Rj650dhm7cNdvE1H1v6Jg== X-Received: by 2002:adf:fcc9:: with SMTP id f9mr12809171wrs.133.1626448544652; Fri, 16 Jul 2021 08:15:44 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 17/19] hw/i386/acpi-build: Add IVRS support to bypass iommu Message-ID: <20210716151416.155127-18-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Xingang Wang , Richard Henderson , Igor Mammedov , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626449172558100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang Check bypass_iommu to exclude the devices which will bypass iommu. Signed-off-by: Xingang Wang Message-Id: <1625748919-52456-9-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 7efc6285ac..17836149fe 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2263,7 +2263,7 @@ ivrs_host_bridges(Object *obj, void *opaque) if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; =20 - if (bus) { + if (bus && !pci_bus_bypass_iommu(bus)) { pci_for_each_device(bus, pci_bus_num(bus), insert_ivhd, ivhd_b= lob); } } --=20 MST From nobody Fri May 10 09:55:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1626449218; cv=none; d=zohomail.com; s=zohoarc; b=Y11JKK/eZMRYpfKibeG+FAiOLPMQUDMf33zyG1oFo8tvMLY0/JblpSDOAyPgXGDkpiG5Woqlz7tKrKlCWM96OvcX4wYXesdy6VT6Z//GyZrQ8bRACGlh4O2M35iuG/5+XS0Z/lYO3qz3c0/PR8qKdaH9yXFVOIiXRjdMAVAsgog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626449218; h=Content-Type: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=5HVhx8nlAexWU/TA8sFPnLNT9sR3fwWdWFVm7BbK6mM=; b=ByJGXkCm7s4PwQOKeau0+ZNAYsqD7Us9i7OzGpmSEOGILNInbScqW/vxOoNDZ74rY3tUoyhqXxtYpMH2D0O4tLjjmejyrSlzWWFuWKWy56J1mQMA7+LzOrNPxWsYH6RaNzI8gqm4bDMjSJ+J9r6RZ5W6g2uxAxvbC5UWQzneOOs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449218576394.8747806712755; Fri, 16 Jul 2021 08:26:58 -0700 (PDT) Received: from localhost ([::1]:57488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Pjt-0001fL-IA for importer@patchew.org; Fri, 16 Jul 2021 11:26:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZA-0001ZP-Eh for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZ8-0004SS-Ha for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:15:52 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-551-D2xeBroNPRW1e1Q3Qw77Tw-1; Fri, 16 Jul 2021 11:15:48 -0400 Received: by mail-wm1-f69.google.com with SMTP id d16-20020a1c73100000b02901f2d21e46efso3284427wmb.6 for ; Fri, 16 Jul 2021 08:15:48 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id n18sm9845485wrt.89.2021.07.16.08.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5HVhx8nlAexWU/TA8sFPnLNT9sR3fwWdWFVm7BbK6mM=; b=UwjgZOS+FQ37gPYj70lq8jCMRhuTqnDstdfx+Lvn35virBW/CtC68U2iyARXxli7iM3GZt 9ryX6wDqduxvQU1rluz1OAkax5T2qNW8PaTdq1LAqJFxeDEz6RzzWHxvoTq4BongpoqhZM 0P51iwyBluLlFU+cOwtEQ/vIdYdoXqE= X-MC-Unique: D2xeBroNPRW1e1Q3Qw77Tw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5HVhx8nlAexWU/TA8sFPnLNT9sR3fwWdWFVm7BbK6mM=; b=S547dH0UZbS51wOaf0wJvaL7FwaDIyOisfVKkglzAvxJ7XpBsqn/2j7pL/PxfdZKyG ts0lwxw4iF2Dea4W7najdn7kTeLNO/8FhAYLzei3vqVqXo8cnnoycj3xJVO+gEGtAysr ABhUb3wQS9xF9DA3qg70Bb3Vy6TgAJwf8axXwFQDJUT/c7DyXbwFzm2M/80qwmfZbV2q 2PMj/3rI0wLZQAI7MeDJOAva7fNT3PVxZw0ElYKLGjRj1sHV7WD1mdl+EoBUfTyB/KoY I3j3+NZa4ZKT5E61xInc3hzOfrTEdNiUjnwvpsySp/y4RfTT1vZEW1yOCEnzYEwpTn5O gYJw== X-Gm-Message-State: AOAM530UOFgZZef3s988i7EkE8sM29u+yExPKDHpXzZuotrYdJI3jihq IH7piolK9zerUxA3KRAeXjoTlBZxumpY+MPRCV1TbywKI/HkwNZM6NTjJNTwfDHo7ghtwhQdFMb 1+h67WZgDor6P6EtK560ccqXQ5kdtdUERfOSvgazFF+hi96Uf/prdnMPclUPO X-Received: by 2002:adf:f710:: with SMTP id r16mr13104282wrp.124.1626448547416; Fri, 16 Jul 2021 08:15:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMX7c7WoLnQzr+oO/s7SDBtgjPM6btACXFdoSWy6U7JEbcam/BEOpedVKbJIU7DsACxO0aeQ== X-Received: by 2002:adf:f710:: with SMTP id r16mr13104251wrp.124.1626448547166; Fri, 16 Jul 2021 08:15:47 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 18/19] docs: Add documentation for iommu bypass Message-ID: <20210716151416.155127-19-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Xingang Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626449220180100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang Signed-off-by: Xingang Wang Message-Id: <1625748919-52456-10-git-send-email-wangxingang5@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/bypass-iommu.txt | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 docs/bypass-iommu.txt diff --git a/docs/bypass-iommu.txt b/docs/bypass-iommu.txt new file mode 100644 index 0000000000..e6677bddd3 --- /dev/null +++ b/docs/bypass-iommu.txt @@ -0,0 +1,89 @@ +BYPASS IOMMU PROPERTY +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Description +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Traditionally, there is a global switch to enable/disable vIOMMU. All +devices in the system can only support go through vIOMMU or not, which +is not flexible. We introduce this bypass iommu property to support +coexist of devices go through vIOMMU and devices not. This is useful to +passthrough devices with no-iommu mode and devices go through vIOMMU in +the same virtual machine. + +PCI host bridges have a bypass_iommu property. This property is used to +determine whether the devices attached on the PCI host bridge will bypass +virtual iommu. The bypass_iommu property is valid only when there is a +virtual iommu in the system, it is implemented to allow some devices to +bypass vIOMMU. When bypass_iommu property is not set for a host bridge, +the attached devices will go through vIOMMU by default. + +Usage +=3D=3D=3D=3D=3D +The bypass iommu feature support PXB host bridge and default main host +bridge, we add a bypass_iommu property for PXB and default_bus_bypass_iommu +for machine. Note that default_bus_bypass_iommu is available only when +the 'q35' machine type on x86 architecture and the 'virt' machine type +on AArch64. Other machine types do not support bypass iommu for default +root bus. + +1. The following is the bypass iommu options: + (1) PCI expander bridge + qemu -device pxb-pcie,bus_nr=3D0x10,addr=3D0x1,bypass_iommu=3Dtrue + (2) Arm default host bridge + qemu -machine virt,iommu=3Dsmmuv3,default_bus_bypass_iommu=3Dtrue + (3) X86 default root bus bypass iommu: + qemu -machine q35,default_bus_bypass_iommu=3Dtrue + +2. Here is the detailed qemu command line for 'virt' machine with PXB on +AArch64: + +qemu-system-aarch64 \ + -machine virt,kernel_irqchip=3Don,iommu=3Dsmmuv3,default_bus_bypass_iommu= =3Dtrue \ + -device pxb-pcie,bus_nr=3D0x10,id=3Dpci.10,bus=3Dpcie.0,addr=3D0x3.0x1 \ + -device pxb-pcie,bus_nr=3D0x20,id=3Dpci.20,bus=3Dpcie.0,addr=3D0x3.0x2,by= pass_iommu=3Dtrue \ + +And we got: + - a default host bridge which bypass SMMUv3 + - a pxb host bridge which go through SMMUv3 + - a pxb host bridge which bypass SMMUv3 + +3. Here is the detailed qemu command line for 'q35' machine with PXB on +x86 architecture: + +qemu-system-x86_64 \ + -machine q35,accel=3Dkvm,default_bus_bypass_iommu=3Dtrue \ + -device pxb-pcie,bus_nr=3D0x10,id=3Dpci.10,bus=3Dpcie.0,addr=3D0x3 \ + -device pxb-pcie,bus_nr=3D0x20,id=3Dpci.20,bus=3Dpcie.0,addr=3D0x4,bypass= _iommu=3Dtrue \ + -device intel-iommu \ + +And we got: + - a default host bridge which bypass iommu + - a pxb host bridge which go through iommu + - a pxb host bridge which bypass iommu + +Limitations +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +There might be potential security risk when devices bypass iommu, because +devices might send malicious dma request to virtual machine if there is no +iommu isolation. So it would be necessary to only bypass iommu for trusted +device. + +Implementation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The bypass iommu feature includes: + - Address space + Add bypass iommu property check of PCI Host and do not get iommu address + space for devices bypass iommu. + - Arm SMMUv3 support + We traverse all PCI root bus and get bus number ranges, then build expl= icit + RID mapping for devices which do not bypass iommu. + - X86 IOMMU support + To support Intel iommu, we traverse all PCI host bridge and get informa= tion + of devices which do not bypass iommu, then fill the DMAR drhd struct wi= th + explicit device scope info. To support AMD iommu, add check of bypass i= ommu + when traverse the PCI hsot bridge. + - Machine and PXB options + We add bypass iommu options in machine option for default root bus, and= add + option for PXB also. Note that the default value of bypass iommu is fal= se, + so that the devices will by default go through iommu if there exist one. + --=20 MST From nobody Fri May 10 09:55:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1626449348; cv=none; d=zohomail.com; s=zohoarc; b=jo8VcetvZUw0k7RQ0mgt5Wtkb3rqp+ua+bbzXxIsMtLgKCQNkiXYoqvkBqFAsxxtQWU9oKgbRk2Yqr9Kxdo7RyS4Cd9SlYZWogPl4X+hqgLVoyGAKK2zRBKlCW41P0gkMRXw7zRlqjKlI3tEbM9/IacdL4pvXmAu/thFwDmEdEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626449348; h=Content-Type: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=+Y7ACOxj8SZNzmvjevV0tlJBqxfRYd9WxWuOxlZmTHg=; b=aG6Cmtbfl9C+TROG5By0vO5zuGkeAaEW1YpBsFlmJGwsqazDkR3dGw9ESxQ0KXMStpEfip6b8VylLxIiIV9jvbbEdPFsAdqrKBR5t6hZxQcftjp48Pf1pVPdMXXHhPwBxcx7Haa6bGV3UcG54Ykn2tlNEH7cb1DLmNDgDbFZzjw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626449348378222.51438308482284; Fri, 16 Jul 2021 08:29:08 -0700 (PDT) Received: from localhost ([::1]:37916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Plx-0007Op-Ce for importer@patchew.org; Fri, 16 Jul 2021 11:29:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZK-0001h9-6p for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:16:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4PZB-0004UD-KF for qemu-devel@nongnu.org; Fri, 16 Jul 2021 11:16:00 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-7sQOTJq6MFOrX40rm9ErUQ-1; Fri, 16 Jul 2021 11:15:51 -0400 Received: by mail-wm1-f70.google.com with SMTP id p6-20020a05600c3586b029020b46124c2eso3618375wmq.1 for ; Fri, 16 Jul 2021 08:15:51 -0700 (PDT) Received: from redhat.com ([2a10:8004:6ff2:0:a1b1:b3d8:4c4e:4825]) by smtp.gmail.com with ESMTPSA id j10sm10396255wrt.35.2021.07.16.08.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:15:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626448553; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+Y7ACOxj8SZNzmvjevV0tlJBqxfRYd9WxWuOxlZmTHg=; b=DftVsf5QNRLxfd+Dtkefo9fMKshwiBbfraMBIbdciayub6oSuyLrGa9X+U32EutCSwiacX lWBCw6X9vdJ2daioOiVtC+4RB+mIJkJ/FZD+IwIGh3s6i61C4+ZWQQSQXlrdDUpZXmzJqM r5MNY1/4IbQBRcFwH1WEb2HloGJqn8k= X-MC-Unique: 7sQOTJq6MFOrX40rm9ErUQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+Y7ACOxj8SZNzmvjevV0tlJBqxfRYd9WxWuOxlZmTHg=; b=rsK3x4tLtZ6a4yXoSkXr/O78n8imnNSczjRNkj2fVrgL+S97CpfbfeIihIYDMRJXp+ arwqZpHBmdkyXa+2WY6UdyD2YuRLc7SKcB9Clu2CmtUP3jCp0XhUwKOQ4AkuEyZqvS8H IVy/7+fPFBzcspubb8kZToFO8PGphIxgjkZJjkloaxO3lTnYCUy2qPFuHOne593pP3hC FCPz4MUaF/9H3D4gZjT+eum404Gyt4cPZ/YImTFsyOml5mMuMO+DRtdEhvmy1w7lMwsP zfMyygfuBlOgundiwGFGUBSUPIu91mYrQw7ZbyEHAaQ0Kd6FRLq3Vy0jkxdqLnXKQEp6 PdEw== X-Gm-Message-State: AOAM5321VuMkW/0VX1zx+T+RWIkldtvvu3b9SNMk9jyULb0sKoy/+4Vp e9NQGskyWu+kFtWXhfpaFkh95Q7zdWQsOAYJflN+mXBZlK82btMAuqN9W4/OhxTYw9dkavMCtGQ yRGjcC9extmHLYmZNf6C4gUKkoxxIrcvPcyQ15NgGjdu4U/6z2kqTaYJr1UgS X-Received: by 2002:a5d:4e43:: with SMTP id r3mr13025507wrt.132.1626448549662; Fri, 16 Jul 2021 08:15:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwkxSD8uDCRSIrpfvvpNSYRL05IdaoMVYIuP9W8EIMqB3iI9Z0CKZCMqsye3l9AsbWXX2Pxg== X-Received: by 2002:a5d:4e43:: with SMTP id r3mr13025476wrt.132.1626448549381; Fri, 16 Jul 2021 08:15:49 -0700 (PDT) Date: Fri, 16 Jul 2021 11:15:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 19/19] vhost-vsock: SOCK_SEQPACKET feature bit support Message-ID: <20210716151416.155127-20-mst@redhat.com> References: <20210716151416.155127-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210716151416.155127-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Arseny Krasnov , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626449348990100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arseny Krasnov This adds processing of VIRTIO_VSOCK_F_SEQPACKET features bit. Guest negotiates it with vhost, thus both will know that SOCK_SEQPACKET supported by peer. Signed-off-by: Arseny Krasnov Message-Id: <20210622144747.2949134-1-arseny.krasnov@kaspersky.com> Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 777cafe70d..1b1a5c70ed 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -21,6 +21,11 @@ #include "hw/virtio/vhost-vsock.h" #include "monitor/monitor.h" =20 +const int feature_bits[] =3D { + VIRTIO_VSOCK_F_SEQPACKET, + VHOST_INVALID_FEATURE_BIT +}; + static void vhost_vsock_get_config(VirtIODevice *vdev, uint8_t *config) { VHostVSock *vsock =3D VHOST_VSOCK(vdev); @@ -108,8 +113,11 @@ static uint64_t vhost_vsock_get_features(VirtIODevice = *vdev, uint64_t requested_features, Error **errp) { - /* No feature bits used yet */ - return requested_features; + VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); + + virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET); + return vhost_get_features(&vvc->vhost_dev, feature_bits, + requested_features); } =20 static const VMStateDescription vmstate_virtio_vhost_vsock =3D { --=20 MST