From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494335850720961.6920380268486; Tue, 9 May 2017 06:17:30 -0700 (PDT) Received: from localhost ([::1]:37214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8511-0003CO-OY for importer@patchew.org; Tue, 09 May 2017 09:17:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zF-00026o-88 for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zD-0003NX-0Z for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zC-0003NP-Qh for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE50880486; Tue, 9 May 2017 13:15:29 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with SMTP id 2B3FF782A5; Tue, 9 May 2017 13:15:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BE50880486 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BE50880486 Date: Tue, 9 May 2017 16:15:28 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-2-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 09 May 2017 13:15:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/8] hw/acpi-defs: replace leading X with x_ in FADT field names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Laszlo Ersek , Ard Biesheuvel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel At the request of Michael, replace the leading capital X in the FADT field name Xfacs and Xdsdt with lower case x + underscore. Cc: Michael S. Tsirkin Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 4cc3630..db48807 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -165,8 +165,8 @@ struct AcpiFadtDescriptorRev5_1 { /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1)= */ uint16_t arm_boot_flags; uint8_t minor_revision; /* FADT Minor Revision (ACPI 5.1) */ - uint64_t Xfacs; /* 64-bit physical address of FACS */ - uint64_t Xdsdt; /* 64-bit physical address of DSDT */ + uint64_t x_facs; /* 64-bit physical address of FACS */ + uint64_t x_dsdt; /* 64-bit physical address of DSDT */ /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ struct AcpiGenericAddress xpm1a_event_block; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ --=20 MST From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494336099183673.7670597897038; Tue, 9 May 2017 06:21:39 -0700 (PDT) Received: from localhost ([::1]:37234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8557-00074X-6J for importer@patchew.org; Tue, 09 May 2017 09:21:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zJ-00028s-3N for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zH-0003OR-OF for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36664) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zE-0003Nf-BN; Tue, 09 May 2017 09:15:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F7D6804E0; Tue, 9 May 2017 13:15:31 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with SMTP id 3739B8821B; Tue, 9 May 2017 13:15:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4F7D6804E0 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4F7D6804E0 Date: Tue, 9 May 2017 16:15:29 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-3-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 09 May 2017 13:15:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/8] hw/arm/virt: generate 64-bit addressable ACPI objects X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , Ard Biesheuvel , qemu-arm@nongnu.org, Shannon Zhao , Igor Mammedov , Laszlo Ersek Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel Our current ACPI table generation code limits the placement of ACPI tables to 32-bit addressable memory, in order to be able to emit the root pointer (RSDP) and root table (RSDT) using table types from the ACPI 1.0 days. Since ARM was not supported by ACPI before version 5.0, it makes sense to lift this restriction. This is not crucial for mach-virt, which is guaranteed to have some memory available below the 4 GB mark, but it is a nice to have for QEMU machines that do not have any 32-bit addressable memory, which is not uncommon for real world 64-bit ARM systems. Since we already emit a version of the RSDP root pointer that has a secondary 64-bit wide address field for the 64-bit root table (XSDT), all we need to do is replace the RSDT generation with the generation of an XSDT table, and use a different slot in the FADT table to refer to the DSDT. Signed-off-by: Ard Biesheuvel Reviewed-by: Andrew Jones Acked-by: Laszlo Ersek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Peter Maydell --- include/hw/acpi/acpi-defs.h | 11 +++++++++++ include/hw/acpi/aml-build.h | 3 +++ hw/acpi/aml-build.c | 27 +++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 +++++++++++++------------- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index db48807..dff6d4f 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -238,6 +238,17 @@ struct AcpiRsdtDescriptorRev1 typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1; =20 /* + * ACPI 2.0 eXtended System Description Table (XSDT) + */ +struct AcpiXsdtDescriptorRev2 +{ + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint64_t table_offset_entry[0]; /* Array of pointers to other */ + /* ACPI tables */ +} QEMU_PACKED; +typedef struct AcpiXsdtDescriptorRev2 AcpiXsdtDescriptorRev2; + +/* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ struct AcpiFacsDescriptorRev1 diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 00c21f1..eb07c2d 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -381,6 +381,9 @@ void acpi_build_tables_cleanup(AcpiBuildTables *tables,= bool mfre); void build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id); +void +build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, + const char *oem_id, const char *oem_table_id); =20 int build_append_named_dword(GArray *array, const char *name_format, ...) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index c6f2032..4ddfb68 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1599,6 +1599,33 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, G= Array *table_offsets, (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id); } =20 +/* Build xsdt table */ +void +build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, + const char *oem_id, const char *oem_table_id) +{ + int i; + unsigned xsdt_entries_offset; + AcpiXsdtDescriptorRev2 *xsdt; + const unsigned table_data_len =3D (sizeof(uint64_t) * table_offsets->l= en); + const unsigned xsdt_entry_size =3D sizeof(xsdt->table_offset_entry[0]); + const size_t xsdt_len =3D sizeof(*xsdt) + table_data_len; + + xsdt =3D acpi_data_push(table_data, xsdt_len); + xsdt_entries_offset =3D (char *)xsdt->table_offset_entry - table_data-= >data; + for (i =3D 0; i < table_offsets->len; ++i) { + uint64_t ref_tbl_offset =3D g_array_index(table_offsets, uint32_t,= i); + uint64_t xsdt_entry_offset =3D xsdt_entries_offset + xsdt_entry_si= ze * i; + + /* xsdt->table_offset_entry to be filled by Guest linker */ + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, xsdt_entry_offset, xsdt_entry_size, + ACPI_BUILD_TABLE_FILE, ref_tbl_offset); + } + build_header(linker, table_data, + (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id); +} + void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags) { diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 0835e59..6e5f339 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -364,12 +364,12 @@ static void acpi_dsdt_add_power_button(Aml *scope) =20 /* RSDP */ static GArray * -build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offse= t) +build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned xsdt_tbl_offse= t) { AcpiRsdpDescriptor *rsdp =3D acpi_data_push(rsdp_table, sizeof *rsdp); - unsigned rsdt_pa_size =3D sizeof(rsdp->rsdt_physical_address); - unsigned rsdt_pa_offset =3D - (char *)&rsdp->rsdt_physical_address - rsdp_table->data; + unsigned xsdt_pa_size =3D sizeof(rsdp->xsdt_physical_address); + unsigned xsdt_pa_offset =3D + (char *)&rsdp->xsdt_physical_address - rsdp_table->data; =20 bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, rsdp_table, 16, true /* fseg memory */); @@ -381,8 +381,8 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsi= gned rsdt_tbl_offset) =20 /* Address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_RSDP_FILE, rsdt_pa_offset, rsdt_pa_size, - ACPI_BUILD_TABLE_FILE, rsdt_tbl_offset); + ACPI_BUILD_RSDP_FILE, xsdt_pa_offset, xsdt_pa_size, + ACPI_BUILD_TABLE_FILE, xsdt_tbl_offset); =20 /* Checksum to be filled by Guest linker */ bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, @@ -659,7 +659,7 @@ static void build_fadt(GArray *table_data, BIOSLinker *= linker, VirtMachineState *vms, unsigned dsdt_tbl_offset) { AcpiFadtDescriptorRev5_1 *fadt =3D acpi_data_push(table_data, sizeof(*= fadt)); - unsigned dsdt_entry_offset =3D (char *)&fadt->dsdt - table_data->data; + unsigned xdsdt_entry_offset =3D (char *)&fadt->x_dsdt - table_data->da= ta; uint16_t bootflags; =20 switch (vms->psci_conduit) { @@ -685,7 +685,7 @@ static void build_fadt(GArray *table_data, BIOSLinker *= linker, =20 /* DSDT address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, dsdt_entry_offset, sizeof(fadt->dsdt), + ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->x_dsdt), ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset); =20 build_header(linker, table_data, @@ -748,7 +748,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTa= bles *tables) { VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); GArray *table_offsets; - unsigned dsdt, rsdt; + unsigned dsdt, xsdt; GArray *tables_blob =3D tables->table_data; =20 table_offsets =3D g_array_new(false, true /* clear */, @@ -788,12 +788,12 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuild= Tables *tables) build_iort(tables_blob, tables->linker); } =20 - /* RSDT is pointed to by RSDP */ - rsdt =3D tables_blob->len; - build_rsdt(tables_blob, tables->linker, table_offsets, NULL, NULL); + /* XSDT is pointed to by RSDP */ + xsdt =3D tables_blob->len; + build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL); =20 /* RSDP is in FSEG memory, so allocate it separately */ - build_rsdp(tables->rsdp, tables->linker, rsdt); + build_rsdp(tables->rsdp, tables->linker, xsdt); =20 /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); --=20 MST From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494336199370204.13320519904119; Tue, 9 May 2017 06:23:19 -0700 (PDT) Received: from localhost ([::1]:37251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d856k-0000Oy-2q for importer@patchew.org; Tue, 09 May 2017 09:23:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zK-0002AX-Vq for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zJ-0003Ok-LF for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zJ-0003OZ-CL; Tue, 09 May 2017 09:15:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5481EC04B953; Tue, 9 May 2017 13:15:36 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF020783A1; Tue, 9 May 2017 13:15:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5481EC04B953 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5481EC04B953 Date: Tue, 9 May 2017 16:15:31 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-4-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 09 May 2017 13:15:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/8] hw/virtio: fix vhost user fails to startup when MQ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Zhiyong Yang , qemu-stable@nongnu.org, Jens Freimann , Maxime Coquelin , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Zhiyong Yang Qemu2.7~2.9 and vhost user for dpdk 17.02 release work together to cause failures of new connection when negotiating to set MQ. (one queue pair works well). Because there exist some bugs in qemu code when introducing VHOST_USER_PROTOCOL_F_REPLY_ACK to qemu. When vhost_user_set_mem_table is invoked to deal with the vhost message VHOST_USER_SET_MEM_TABLE for the second time, qemu indeed doesn't send the messge (The message needs to be sent only once)but still will be waiting for dpdk's reply ack, then, qemu is always freezing, while DPDK is always waiting for next vhost message from qemu. The patch aims to fix the bug, MQ can work well. The same bug is found in function vhost_user_net_set_mtu, it is fixed at the same time. DPDK related patch is as following: http://www.dpdk.org/dev/patchwork/patch/23955/ Signed-off-by: Zhiyong Yang Cc: qemu-stable@nongnu.org Fixes: ca525ce5618b ("vhost-user: Introduce a new protocol feature REPLY_AC= K.") Reviewed-by: Maxime Coquelin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Jens Freimann Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/vhost-user.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 9334a8a..32a95a8 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -163,22 +163,26 @@ fail: } =20 static int process_message_reply(struct vhost_dev *dev, - VhostUserRequest request) + VhostUserMsg msg) { - VhostUserMsg msg; + VhostUserMsg msg_reply; =20 - if (vhost_user_read(dev, &msg) < 0) { + if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) =3D=3D 0) { + return 0; + } + + if (vhost_user_read(dev, &msg_reply) < 0) { return -1; } =20 - if (msg.request !=3D request) { + if (msg_reply.request !=3D msg.request) { error_report("Received unexpected msg type." "Expected %d received %d", - request, msg.request); + msg.request, msg_reply.request); return -1; } =20 - return msg.payload.u64 ? -1 : 0; + return msg_reply.payload.u64 ? -1 : 0; } =20 static bool vhost_user_one_time_request(VhostUserRequest request) @@ -208,6 +212,7 @@ static int vhost_user_write(struct vhost_dev *dev, Vhos= tUserMsg *msg, * request, we just ignore it. */ if (vhost_user_one_time_request(msg->request) && dev->vq_index !=3D 0)= { + msg->flags &=3D ~VHOST_USER_NEED_REPLY_MASK; return 0; } =20 @@ -320,7 +325,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *d= ev, } =20 if (reply_supported) { - return process_message_reply(dev, msg.request); + return process_message_reply(dev, msg); } =20 return 0; @@ -712,7 +717,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev= , uint16_t mtu) =20 /* If reply_ack supported, slave has to ack specified MTU is valid */ if (reply_supported) { - return process_message_reply(dev, msg.request); + return process_message_reply(dev, msg); } =20 return 0; --=20 MST From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494335985335467.9052440185327; Tue, 9 May 2017 06:19:45 -0700 (PDT) Received: from localhost ([::1]:37221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d853H-0005Xh-1L for importer@patchew.org; Tue, 09 May 2017 09:19:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zT-0002Fk-1a for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zO-0003PU-Tg for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zO-0003PG-Km for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F04361E50; Tue, 9 May 2017 13:15:41 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDEE1A2517; Tue, 9 May 2017 13:15:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F04361E50 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8F04361E50 Date: Tue, 9 May 2017 16:15:36 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-5-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 09 May 2017 13:15:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/8] libvhost-user: fix crash when rings aren't ready X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Felipe Franciosi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Calling libvhost-user functions like vu_queue_get_avail_bytes() when the queue doesn't yet have addresses will result in the crashes like the following: Program received signal SIGSEGV, Segmentation fault. 0x000055c414112ce4 in vring_avail_idx (vq=3D0x55c41582fd68, vq=3D0x55c41582= fd68) at /home/dgilbert/git/qemu/contrib/libvhost-user/libvhost-user.c:940 940 vq->shadow_avail_idx =3D vq->vring.avail->idx; (gdb) p vq $1 =3D (VuVirtq *) 0x55c41582fd68 (gdb) p vq->vring $2 =3D {num =3D 0, desc =3D 0x0, avail =3D 0x0, used =3D 0x0, log_guest_add= r =3D 0, flags =3D 0} at /home/dgilbert/git/qemu/contrib/libvhost-user/libvhost-user.c:940 No locals. at /home/dgilbert/git/qemu/contrib/libvhost-user/libvhost-user.c:960 num_heads =3D out_bytes=3Dout_bytes@entry=3D0x7fffd035d7c4, max_in_bytes=3Dmax_in_byt= es@entry=3D0, max_out_bytes=3Dmax_out_bytes@entry=3D0) at /home/dgilbert/git/qemu/con= trib/libvhost-user/libvhost-user.c:1034 Add a pre-condition checks on vring.avail before accessing it. Fix documentation and return type of vu_queue_empty() while at it. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/libvhost-user/libvhost-user.h | 6 +++--- contrib/libvhost-user/libvhost-user.c | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/= libvhost-user.h index 156b50e..af02a31 100644 --- a/contrib/libvhost-user/libvhost-user.h +++ b/contrib/libvhost-user/libvhost-user.h @@ -327,13 +327,13 @@ void vu_queue_set_notification(VuDev *dev, VuVirtq *v= q, int enable); bool vu_queue_enabled(VuDev *dev, VuVirtq *vq); =20 /** - * vu_queue_enabled: + * vu_queue_empty: * @dev: a VuDev context * @vq: a VuVirtq queue * - * Returns: whether the queue is empty. + * Returns: true if the queue is empty or not ready. */ -int vu_queue_empty(VuDev *dev, VuVirtq *vq); +bool vu_queue_empty(VuDev *dev, VuVirtq *vq); =20 /** * vu_queue_notify: diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index af4faad..e1bf964 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -1031,6 +1031,11 @@ vu_queue_get_avail_bytes(VuDev *dev, VuVirtq *vq, un= signed int *in_bytes, idx =3D vq->last_avail_idx; =20 total_bufs =3D in_total =3D out_total =3D 0; + if (unlikely(dev->broken) || + unlikely(!vq->vring.avail)) { + goto done; + } + while ((rc =3D virtqueue_num_heads(dev, vq, idx)) > 0) { unsigned int max, num_bufs, indirect =3D 0; struct vring_desc *desc; @@ -1121,11 +1126,16 @@ vu_queue_avail_bytes(VuDev *dev, VuVirtq *vq, unsig= ned int in_bytes, =20 /* Fetch avail_idx from VQ memory only when we really need to know if * guest has added some buffers. */ -int +bool vu_queue_empty(VuDev *dev, VuVirtq *vq) { + if (unlikely(dev->broken) || + unlikely(!vq->vring.avail)) { + return true; + } + if (vq->shadow_avail_idx !=3D vq->last_avail_idx) { - return 0; + return false; } =20 return vring_avail_idx(vq) =3D=3D vq->last_avail_idx; @@ -1174,7 +1184,8 @@ vring_notify(VuDev *dev, VuVirtq *vq) void vu_queue_notify(VuDev *dev, VuVirtq *vq) { - if (unlikely(dev->broken)) { + if (unlikely(dev->broken) || + unlikely(!vq->vring.avail)) { return; } =20 @@ -1291,7 +1302,8 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) struct vring_desc *desc; int rc; =20 - if (unlikely(dev->broken)) { + if (unlikely(dev->broken) || + unlikely(!vq->vring.avail)) { return NULL; } =20 @@ -1445,7 +1457,8 @@ vu_queue_fill(VuDev *dev, VuVirtq *vq, { struct vring_used_elem uelem; =20 - if (unlikely(dev->broken)) { + if (unlikely(dev->broken) || + unlikely(!vq->vring.avail)) { return; } =20 @@ -1474,7 +1487,8 @@ vu_queue_flush(VuDev *dev, VuVirtq *vq, unsigned int = count) { uint16_t old, new; =20 - if (unlikely(dev->broken)) { + if (unlikely(dev->broken) || + unlikely(!vq->vring.avail)) { return; } =20 --=20 MST From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494335858573638.3714784574917; Tue, 9 May 2017 06:17:38 -0700 (PDT) Received: from localhost ([::1]:37215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d851D-0003T3-3A for importer@patchew.org; Tue, 09 May 2017 09:17:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zR-0002Ey-QE for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zQ-0003Pv-PQ for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zQ-0003Pe-Gu for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A9C680C1B; Tue, 9 May 2017 13:15:43 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with SMTP id 6F55988D9D; Tue, 9 May 2017 13:15:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A9C680C1B Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8A9C680C1B Date: Tue, 9 May 2017 16:15:41 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-6-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 09 May 2017 13:15:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/8] pc/fwcfg: unbreak migration from qemu-2.5 and qemu-2.6 during firmware boot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Igor Mammedov , Paolo Bonzini , Laszlo Ersek , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Since 2.7 commit (b2a575a Add optionrom compatible with fw_cfg DMA version) regressed migration during firmware exection time by abusing fwcfg.dma_enabled property to decide loading dma version of option rom AND by mistake disabling DMA for 2.6 and earlier globally instead of only for option rom. so 2.6 machine type guest is broken when it already runs firmware in DMA mode but migrated to qemu-2.7(pc-2.6) at that time; a) qemu-2.6:pc2.6 (fwcfg.dma=3Don,firmware=3Ddma,oprom=3Dioport) b) qemu-2.7:pc2.6 (fwcfg.dma=3Doff,firmware=3Dioport,oprom=3Dioport) to: a b from a OK FAIL b OK OK So we currently have broken forward migration from qemu-2.6 to qemu-2.[789] that however could be fixed for 2.10 by re-enabling DMA for 2.[56] machine types and allowing dma capable option rom only since 2.7. As result qemu should end up with: c) qemu-2.10:pc2.6 (fwcfg.dma=3Don,firmware=3Ddma,oprom=3Dioport) to: a b c from a OK FAIL OK b OK OK OK c OK FAIL OK where forward migration from qemu-2.6 to qemu-2.10 should work again leaving only qemu-2.[789]:pc-2.6 broken. Reported-by: Eduardo Habkost Analyzed-by: Laszlo Ersek Signed-off-by: Igor Mammedov Reviewed-by: Laszlo Ersek Reviewed-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 7 +++---- hw/i386/pc.c | 9 ++++----- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f278b3a..a57c607 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -151,6 +151,9 @@ struct PCMachineClass { bool save_tsc_khz; /* generate legacy CPU hotplug AML */ bool legacy_cpu_hotplug; + + /* use DMA capable linuxboot option rom */ + bool linuxboot_dma_enabled; }; =20 #define TYPE_PC_MACHINE "generic-pc-machine" @@ -432,10 +435,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_= t *); #define PC_COMPAT_2_6 \ HW_COMPAT_2_6 \ {\ - .driver =3D "fw_cfg_io",\ - .property =3D "dma_enabled",\ - .value =3D "off",\ - },{\ .driver =3D TYPE_X86_CPU,\ .property =3D "cpuid-0xb",\ .value =3D "off",\ diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f3b372a..8063241 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1047,12 +1047,10 @@ static void load_linux(PCMachineState *pcms, fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size); =20 - if (fw_cfg_dma_enabled(fw_cfg)) { + option_rom[nb_option_roms].bootindex =3D 0; + option_rom[nb_option_roms].name =3D "linuxboot.bin"; + if (pcmc->linuxboot_dma_enabled && fw_cfg_dma_enabled(fw_cfg)) { option_rom[nb_option_roms].name =3D "linuxboot_dma.bin"; - option_rom[nb_option_roms].bootindex =3D 0; - } else { - option_rom[nb_option_roms].name =3D "linuxboot.bin"; - option_rom[nb_option_roms].bootindex =3D 0; } nb_option_roms++; } @@ -2321,6 +2319,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) * to be used at the moment, 32K should be enough for a while. */ pcmc->acpi_data_size =3D 0x20000 + 0x8000; pcmc->save_tsc_khz =3D true; + pcmc->linuxboot_dma_enabled =3D true; mc->get_hotplug_handler =3D pc_get_hotpug_handler; mc->cpu_index_to_socket_id =3D pc_cpu_index_to_socket_id; mc->possible_cpu_arch_ids =3D pc_possible_cpu_arch_ids; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 9f102aa..a11190b 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -474,6 +474,7 @@ static void pc_i440fx_2_6_machine_options(MachineClass = *m) PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_i440fx_2_7_machine_options(m); pcmc->legacy_cpu_hotplug =3D true; + pcmc->linuxboot_dma_enabled =3D false; SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); } =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index dd792a8..0a61a20 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -335,6 +335,7 @@ static void pc_q35_2_6_machine_options(MachineClass *m) PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_2_7_machine_options(m); pcmc->legacy_cpu_hotplug =3D true; + pcmc->linuxboot_dma_enabled =3D false; SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); } =20 --=20 MST From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494336108141502.41926998785266; Tue, 9 May 2017 06:21:48 -0700 (PDT) Received: from localhost ([::1]:37237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d855F-0007Av-IL for importer@patchew.org; Tue, 09 May 2017 09:21:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zX-0002Jj-6R for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zU-0003Rm-1L for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50968) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zT-0003QE-Og for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBF333D957; Tue, 9 May 2017 13:15:46 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with SMTP id 05684783A1; Tue, 9 May 2017 13:15:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BBF333D957 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BBF333D957 Date: Tue, 9 May 2017 16:15:43 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-7-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 09 May 2017 13:15:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/8] pc: add 2.10 machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Eduardo Habkost , Peter Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu CC: "Michael S. Tsirkin" CC: Paolo Bonzini CC: Richard Henderson CC: Eduardo Habkost Signed-off-by: Peter Xu Reviewed-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 3 +++ hw/i386/pc_piix.c | 15 ++++++++++++--- hw/i386/pc_q35.c | 13 +++++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index a57c607..6252e93 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -376,6 +376,9 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); int e820_get_num_entries(void); bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); =20 +#define PC_COMPAT_2_9 \ + HW_COMPAT_2_9 \ + #define PC_COMPAT_2_8 \ HW_COMPAT_2_8 \ {\ diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a11190b..8f3d85c 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -437,21 +437,30 @@ static void pc_i440fx_machine_options(MachineClass *m) m->default_display =3D "std"; } =20 -static void pc_i440fx_2_9_machine_options(MachineClass *m) +static void pc_i440fx_2_10_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->alias =3D "pc"; m->is_default =3D 1; } =20 +DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL, + pc_i440fx_2_10_machine_options); + +static void pc_i440fx_2_9_machine_options(MachineClass *m) +{ + pc_i440fx_2_10_machine_options(m); + m->is_default =3D 0; + m->alias =3D NULL; + SET_MACHINE_COMPAT(m, PC_COMPAT_2_9); +} + DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL, pc_i440fx_2_9_machine_options); =20 static void pc_i440fx_2_8_machine_options(MachineClass *m) { pc_i440fx_2_9_machine_options(m); - m->is_default =3D 0; - m->alias =3D NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_8); } =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 0a61a20..cf9a788 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -301,19 +301,28 @@ static void pc_q35_machine_options(MachineClass *m) m->max_cpus =3D 288; } =20 -static void pc_q35_2_9_machine_options(MachineClass *m) +static void pc_q35_2_10_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->alias =3D "q35"; } =20 +DEFINE_Q35_MACHINE(v2_10, "pc-q35-2.10", NULL, + pc_q35_2_10_machine_options); + +static void pc_q35_2_9_machine_options(MachineClass *m) +{ + pc_q35_2_10_machine_options(m); + m->alias =3D NULL; + SET_MACHINE_COMPAT(m, PC_COMPAT_2_9); +} + DEFINE_Q35_MACHINE(v2_9, "pc-q35-2.9", NULL, pc_q35_2_9_machine_options); =20 static void pc_q35_2_8_machine_options(MachineClass *m) { pc_q35_2_9_machine_options(m); - m->alias =3D NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_8); } =20 --=20 MST From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149433587725022.67992908510689; Tue, 9 May 2017 06:17:57 -0700 (PDT) Received: from localhost ([::1]:37216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d851U-0003wM-Ri for importer@patchew.org; Tue, 09 May 2017 09:17:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zb-0002N6-0g for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zV-0003S0-5J for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37200) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zU-0003Rq-SU for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E240C804E5; Tue, 9 May 2017 13:15:47 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with SMTP id 3771F783BC; Tue, 9 May 2017 13:15:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E240C804E5 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E240C804E5 Date: Tue, 9 May 2017 16:15:46 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-8-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 09 May 2017 13:15:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/8] iommu: Don't crash if machine is not PC_MACHINE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Eduardo Habkost , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eduardo Habkost Currently it's possible to crash QEMU using "-device *-iommu" and "-machine none": $ qemu-system-x86_64 -machine none -device amd-iommu qemu/hw/i386/amd_iommu.c:1140:amdvi_realize: Object 0x55627dafbc90 is not= an instance of type generic-pc-machine Aborted (core dumped) $ qemu-system-x86_64 -machine none -device intel-iommu qemu/hw/i386/intel_iommu.c:2972:vtd_realize: Object 0x56292ec0bc90 is not= an instance of type generic-pc-machine Aborted (core dumped) Fix amd-iommu and intel-iommu to ensure the current machine is really a TYPE_PC_MACHINE instance at their realize methods. Resulting error messages: $ qemu-system-x86_64 -machine none -device amd-iommu qemu-system-x86_64: -device amd-iommu: Machine-type 'none' not supported = by amd-iommu $ qemu-system-x86_64 -machine none -device intel-iommu qemu-system-x86_64: -device intel-iommu: Machine-type 'none' not supporte= d by intel-iommu Signed-off-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 15 ++++++++++++++- hw/i386/intel_iommu.c | 14 ++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index f86a40a..516ebae 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -21,6 +21,7 @@ */ #include "qemu/osdep.h" #include "hw/i386/amd_iommu.h" +#include "qapi/error.h" #include "qemu/error-report.h" #include "trace.h" =20 @@ -1137,7 +1138,19 @@ static void amdvi_realize(DeviceState *dev, Error **= err) int ret =3D 0; AMDVIState *s =3D AMD_IOMMU_DEVICE(dev); X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(dev); - PCIBus *bus =3D PC_MACHINE(qdev_get_machine())->bus; + MachineState *ms =3D MACHINE(qdev_get_machine()); + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + PCMachineState *pcms =3D + PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE)); + PCIBus *bus; + + if (!pcms) { + error_setg(err, "Machine-type '%s' not supported by amd-iommu", + mc->name); + return; + } + + bus =3D pcms->bus; s->iotlb =3D g_hash_table_new_full(amdvi_uint64_hash, amdvi_uint64_equal, g_free, g_free); =20 diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 02f047c..a12b176 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2969,11 +2969,21 @@ static bool vtd_decide_config(IntelIOMMUState *s, E= rror **errp) =20 static void vtd_realize(DeviceState *dev, Error **errp) { - PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); - PCIBus *bus =3D pcms->bus; + MachineState *ms =3D MACHINE(qdev_get_machine()); + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + PCMachineState *pcms =3D + PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE)); + PCIBus *bus; IntelIOMMUState *s =3D INTEL_IOMMU_DEVICE(dev); X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(dev); =20 + if (!pcms) { + error_setg(errp, "Machine-type '%s' not supported by intel-iommu", + mc->name); + return; + } + + bus =3D pcms->bus; VTD_DPRINTF(GENERAL, ""); x86_iommu->type =3D TYPE_INTEL; =20 --=20 MST From nobody Mon May 6 06:45:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149433600477375.03689160251997; Tue, 9 May 2017 06:20:04 -0700 (PDT) Received: from localhost ([::1]:37222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d853a-0005ml-D4 for importer@patchew.org; Tue, 09 May 2017 09:20:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d84zc-0002O3-6A for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d84zb-0003Sf-BX for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49088) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d84zb-0003SW-4n for qemu-devel@nongnu.org; Tue, 09 May 2017 09:15:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E4CA80C15; Tue, 9 May 2017 13:15:54 +0000 (UTC) Received: from redhat.com (ovpn-124-82.rdu2.redhat.com [10.10.124.82]) by smtp.corp.redhat.com (Postfix) with SMTP id 6665494C60; Tue, 9 May 2017 13:15:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2E4CA80C15 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2E4CA80C15 Date: Tue, 9 May 2017 16:15:47 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1494330527-24163-9-git-send-email-mst@redhat.com> References: <1494330527-24163-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1494330527-24163-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 09 May 2017 13:15:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/8] ACPI: don't call acpi_pcihp_device_plug_cb on xen X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Bruce Rogers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bruce Rogers Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi pci hotplug code was being executed by mistake. Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set. Signed-off-by: Bruce Rogers Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/piix4.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index a553a7e..c409374 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler *hotpl= ug_dev, dev, errp); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, = errp); + if (!xen_enabled()) { + acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, d= ev, + errp); + } } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (s->cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp); @@ -408,8 +411,10 @@ static void piix4_device_unplug_request_cb(HotplugHand= ler *hotplug_dev, acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, - errp); + if (!xen_enabled()) { + acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug,= dev, + errp); + } } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && !s->cpu_hotplug_legacy) { acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp= ); --=20 MST