From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501623571862585.1896966132565; Tue, 1 Aug 2017 14:39:31 -0700 (PDT) Received: from localhost ([::1]:44557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcet0-0002H2-DZ for importer@patchew.org; Tue, 01 Aug 2017 17:39:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerB-0000xo-Lw for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcer9-0004ah-Lf for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35970) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcer9-0004a4-Fe for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:35 -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 5DF06F5365; Tue, 1 Aug 2017 21:37:34 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id A724D18152; Tue, 1 Aug 2017 21:37:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5DF06F5365 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=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:33 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-2-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-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.26]); Tue, 01 Aug 2017 21:37:34 +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 01/10] tests: switch pxe and vm gen id tests to use kvm 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: Laurent Vivier , Peter Maydell , Thomas Huth , Ben Warren , 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" Speed up tests on host systems with kvm support. Cc: Paolo Bonzini Cc: Thomas Huth Cc: Laurent Vivier Signed-off-by: Michael S. Tsirkin Acked-by: Paolo Bonzini --- tests/pxe-test.c | 2 +- tests/vmgenid-test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 34282d3..cf6e225 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -25,7 +25,7 @@ static void test_pxe_one(const char *params, bool ipv6) { char *args; =20 - args =3D g_strdup_printf("-machine accel=3Dtcg -nodefaults -boot order= =3Dn " + args =3D g_strdup_printf("-machine accel=3Dkvm:tcg -nodefaults -boot o= rder=3Dn " "-netdev user,id=3D" NETNAME ",tftp=3D./,bootfi= le=3D%s," "ipv4=3D%s,ipv6=3D%s %s", disk, ipv6 ? "off" : = "on", ipv6 ? "on" : "off", params); diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index a49de92..3d5c1c3 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -132,7 +132,7 @@ static char disk[] =3D "tests/vmgenid-test-disk-XXXXXX"; =20 static char *guid_cmd_strdup(const char *guid) { - return g_strdup_printf("-machine accel=3Dtcg " + return g_strdup_printf("-machine accel=3Dkvm:tcg " "-device vmgenid,id=3Dtestvgid,guid=3D%s " "-drive id=3Dhd0,if=3Dnone,file=3D%s,format=3Dr= aw " "-device ide-hd,drive=3Dhd0 ", --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501623708630937.1730008339362; Tue, 1 Aug 2017 14:41:48 -0700 (PDT) Received: from localhost ([::1]:44574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcevC-0004LW-QZ for importer@patchew.org; Tue, 01 Aug 2017 17:41:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerD-0000z5-Mi for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerC-0004cV-Q4 for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60094) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerC-0004bu-Je for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:38 -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 8F043123E1A; Tue, 1 Aug 2017 21:37:37 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D87D760BE9; Tue, 1 Aug 2017 21:37:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F043123E1A 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=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:34 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-3-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-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, 01 Aug 2017 21:37:37 +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 02/10] vhost: fix a memory leak 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 , Peng Hao , =?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: Peng Hao vhost exists a call for g_file_get_contents, but not call g_free. Signed-off-by: Peng Hao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/vhost-backend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index cb055e8..7f09efa 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -52,11 +52,13 @@ static int vhost_kernel_memslots_limit(struct vhost_dev= *dev) &s, NULL, NULL)) { uint64_t val =3D g_ascii_strtoull(s, NULL, 10); if (!((val =3D=3D G_MAXUINT64 || !val) && errno)) { + g_free(s); return val; } error_report("ignoring invalid max_mem_regions value in vhost modu= le:" " %s", s); } + g_free(s); return limit; } =20 --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501623835392946.6317772987716; Tue, 1 Aug 2017 14:43:55 -0700 (PDT) Received: from localhost ([::1]:44584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcexF-00062g-Te for importer@patchew.org; Tue, 01 Aug 2017 17:43:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerF-00010k-GV for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerE-0004dn-GC for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3203) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerE-0004dC-6t for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DDDEF539A; Tue, 1 Aug 2017 21:37:39 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id 875DC63772; Tue, 1 Aug 2017 21:37:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1DDDEF539A 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=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:38 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-4-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 01 Aug 2017 21:37:39 +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 03/10] vhost-user: fix legacy cross-endian configurations 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: Mike Cui , Peter Maydell , Felipe Franciosi 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: Felipe Franciosi Currently, vhost-user does not implement any means for notifying the backend about guest endianess. This commit introduces a new message called VHOST_USER_SET_VRING_ENDIAN which is analogous to the ioctl() called VHOST_SET_VRING_ENDIAN used for kernel vhost backends. Such message is necessary for backends supporting legacy (pre-1.0) virtio devices running in big-endian guests. Signed-off-by: Felipe Franciosi Signed-off-by: Mike Cui --- docs/interop/vhost-user.txt | 16 ++++++++++++++++ hw/virtio/vhost-user.c | 23 +++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt index 481ab56..954771d 100644 --- a/docs/interop/vhost-user.txt +++ b/docs/interop/vhost-user.txt @@ -326,6 +326,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3 #define VHOST_USER_PROTOCOL_F_MTU 4 #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5 +#define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 =20 Master message types -------------------- @@ -580,6 +581,21 @@ Master message types This request should be send only when VIRTIO_F_IOMMU_PLATFORM feature has been successfully negotiated. =20 + * VHOST_USER_SET_VRING_ENDIAN + + Id: 23 + Equivalent ioctl: VHOST_SET_VRING_ENDIAN + Master payload: vring state description + + Set the endianess of a VQ for legacy devices. Little-endian is indic= ated + with state.num set to 0 and big-endian is indicated with state.num s= et + to 1. Other values are invalid. + This request should be sent only when VHOST_USER_PROTOCOL_F_CROSS_EN= DIAN + has been negotiated. + Backends that negotiated this feature should handle both endianesses + and expect this message once (per VQ) during device configuration + (ie. before the master starts the VQ). + Slave message types ------------------- =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 2203011..093675e 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -33,6 +33,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_REPLY_ACK =3D 3, VHOST_USER_PROTOCOL_F_NET_MTU =3D 4, VHOST_USER_PROTOCOL_F_SLAVE_REQ =3D 5, + VHOST_USER_PROTOCOL_F_CROSS_ENDIAN =3D 6, =20 VHOST_USER_PROTOCOL_F_MAX }; @@ -63,6 +64,7 @@ typedef enum VhostUserRequest { VHOST_USER_NET_SET_MTU =3D 20, VHOST_USER_SET_SLAVE_REQ_FD =3D 21, VHOST_USER_IOTLB_MSG =3D 22, + VHOST_USER_SET_VRING_ENDIAN =3D 23, VHOST_USER_MAX } VhostUserRequest; =20 @@ -367,8 +369,25 @@ static int vhost_user_set_vring_addr(struct vhost_dev = *dev, static int vhost_user_set_vring_endian(struct vhost_dev *dev, struct vhost_vring_state *ring) { - error_report("vhost-user trying to send unhandled ioctl"); - return -1; + bool cross_endian =3D virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_CROSS_END= IAN); + VhostUserMsg msg =3D { + .request =3D VHOST_USER_SET_VRING_ENDIAN, + .flags =3D VHOST_USER_VERSION, + .payload.state =3D *ring, + .size =3D sizeof(msg.payload.state), + }; + + if (!cross_endian) { + error_report("vhost-user trying to send unhandled ioctl"); + return -1; + } + + if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + return -1; + } + + return 0; } =20 static int vhost_set_vring(struct vhost_dev *dev, --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501623708258172.46930790452302; Tue, 1 Aug 2017 14:41:48 -0700 (PDT) Received: from localhost ([::1]:44573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcevC-0004LU-Ts for importer@patchew.org; Tue, 01 Aug 2017 17:41:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerM-00016x-Cz for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerJ-0004ht-9y for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerJ-0004gM-2U for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:45 -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 09748C0616AF; Tue, 1 Aug 2017 21:37:44 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id 90ED860F90; Tue, 1 Aug 2017 21:37:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 09748C0616AF 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=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:39 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-5-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-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.31]); Tue, 01 Aug 2017 21:37:44 +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 04/10] intel_iommu: fix iova for pt 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 IOMMUTLBEntry.iova is returned incorrectly on one PT path (though mostly we cannot really trigger this path, even if we do, we are mostly disgarding this value, so it didn't break anything). Fix it by converting the VTD_PAGE_MASK into the correct definition VTD_PAGE_MASK_4K, then remove VTD_PAGE_MASK. Fixes: b93130 ("intel_iommu: cleanup vtd_{do_}iommu_translate()") Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 1 - hw/i386/intel_iommu.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index f50ecd8..0e73a65 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -384,7 +384,6 @@ typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo; /* Pagesize of VTD paging structures, including root and context tables */ #define VTD_PAGE_SHIFT 12 #define VTD_PAGE_SIZE (1ULL << VTD_PAGE_SHIFT) -#define VTD_PAGE_MASK (VTD_PAGE_SIZE - 1) =20 #define VTD_PAGE_SHIFT_4K 12 #define VTD_PAGE_MASK_4K (~((1ULL << VTD_PAGE_SHIFT_4K) - 1)) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e398746..e0b0498 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1139,9 +1139,9 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *v= td_as, PCIBus *bus, * Also, let's ignore IOTLB caching as well for PT devices. */ if (vtd_ce_get_type(&ce) =3D=3D VTD_CONTEXT_TT_PASS_THROUGH) { - entry->iova =3D addr & VTD_PAGE_MASK; + entry->iova =3D addr & VTD_PAGE_MASK_4K; entry->translated_addr =3D entry->iova; - entry->addr_mask =3D VTD_PAGE_MASK; + entry->addr_mask =3D ~VTD_PAGE_MASK_4K; entry->perm =3D IOMMU_RW; trace_vtd_translate_pt(source_id, entry->iova); =20 --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501623579164490.899467799787; Tue, 1 Aug 2017 14:39:39 -0700 (PDT) Received: from localhost ([::1]:44558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcet7-0002Oo-DQ for importer@patchew.org; Tue, 01 Aug 2017 17:39:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerN-00017C-HW for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerM-0004k0-HF for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52418) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerM-0004jP-8a for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:48 -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 35E3CA9012; Tue, 1 Aug 2017 21:37:47 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id 7E96C60462; Tue, 1 Aug 2017 21:37:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 35E3CA9012 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=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:44 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-6-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-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.28]); Tue, 01 Aug 2017 21:37:47 +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 05/10] intel_iommu: use access_flags for iotlb 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 It was cached by read/write separately. Let's merge them. Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/intel_iommu.h | 3 +-- hw/i386/intel_iommu.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 08d8a26..ac15e6b 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -103,8 +103,7 @@ struct VTDIOTLBEntry { uint16_t domain_id; uint64_t slpte; uint64_t mask; - bool read_flags; - bool write_flags; + uint8_t access_flags; }; =20 /* VT-d Source-ID Qualifier types */ diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e0b0498..a7bf87a 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -237,8 +237,7 @@ out: =20 static void vtd_update_iotlb(IntelIOMMUState *s, uint16_t source_id, uint16_t domain_id, hwaddr addr, uint64_t slp= te, - bool read_flags, bool write_flags, - uint32_t level) + uint8_t access_flags, uint32_t level) { VTDIOTLBEntry *entry =3D g_malloc(sizeof(*entry)); uint64_t *key =3D g_malloc(sizeof(*key)); @@ -253,8 +252,7 @@ static void vtd_update_iotlb(IntelIOMMUState *s, uint16= _t source_id, entry->gfn =3D gfn; entry->domain_id =3D domain_id; entry->slpte =3D slpte; - entry->read_flags =3D read_flags; - entry->write_flags =3D write_flags; + entry->access_flags =3D access_flags; entry->mask =3D vtd_slpt_level_page_mask(level); *key =3D vtd_get_iotlb_key(gfn, source_id, level); g_hash_table_replace(s->iotlb, key, entry); @@ -1087,6 +1085,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *v= td_as, PCIBus *bus, bool is_fpd_set =3D false; bool reads =3D true; bool writes =3D true; + uint8_t access_flags; VTDIOTLBEntry *iotlb_entry; =20 /* @@ -1101,8 +1100,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *v= td_as, PCIBus *bus, trace_vtd_iotlb_page_hit(source_id, addr, iotlb_entry->slpte, iotlb_entry->domain_id); slpte =3D iotlb_entry->slpte; - reads =3D iotlb_entry->read_flags; - writes =3D iotlb_entry->write_flags; + access_flags =3D iotlb_entry->access_flags; page_mask =3D iotlb_entry->mask; goto out; } @@ -1172,13 +1170,14 @@ static bool vtd_do_iommu_translate(VTDAddressSpace = *vtd_as, PCIBus *bus, } =20 page_mask =3D vtd_slpt_level_page_mask(level); + access_flags =3D IOMMU_ACCESS_FLAG(reads, writes); vtd_update_iotlb(s, source_id, VTD_CONTEXT_ENTRY_DID(ce.hi), addr, slp= te, - reads, writes, level); + access_flags, level); out: entry->iova =3D addr & page_mask; entry->translated_addr =3D vtd_get_slpte_addr(slpte) & page_mask; entry->addr_mask =3D ~page_mask; - entry->perm =3D IOMMU_ACCESS_FLAG(reads, writes); + entry->perm =3D access_flags; return true; =20 error: --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 150162383257677.02392088339582; Tue, 1 Aug 2017 14:43:52 -0700 (PDT) Received: from localhost ([::1]:44583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcexD-00061P-4g for importer@patchew.org; Tue, 01 Aug 2017 17:43:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerR-00019x-Ro for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerQ-0004mF-Vl for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerQ-0004lr-ML for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87A1AC07643C; Tue, 1 Aug 2017 21:37:51 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id BCA2663772; Tue, 1 Aug 2017 21:37:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 87A1AC07643C 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=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:47 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-7-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 01 Aug 2017 21:37:51 +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 06/10] accel: cleanup error output 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: Laurent Vivier , Peter Maydell , Thomas Huth , Yang Zhong , Peter Xu , Anand J , 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: Laurent Vivier Only emit "XXX accelerator not found", if there are not further accelerators listed. eg accel=3Dkvm:tcg doesn't print a "KVM accelerator not found" warning when it falls back to tcg, but a accel=3Dkvm prints a warning, since no fallback is given. Suggested-by: Daniel P. Berrange Suggested-by: Paolo Bonzini Signed-off-by: Laurent Vivier Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Eric Blake Tested-by: Thomas Huth --- accel/accel.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index fa85844..8ae40e1 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -33,6 +33,7 @@ #include "sysemu/qtest.h" #include "hw/xen/xen.h" #include "qom/object.h" +#include "qemu/error-report.h" =20 static const TypeInfo accel_type =3D { .name =3D TYPE_ACCEL, @@ -69,19 +70,20 @@ static int accel_init_machine(AccelClass *acc, MachineS= tate *ms) =20 void configure_accelerator(MachineState *ms) { - const char *p; + const char *accel, *p; char buf[10]; int ret; bool accel_initialised =3D false; bool init_failed =3D false; AccelClass *acc =3D NULL; =20 - p =3D qemu_opt_get(qemu_get_machine_opts(), "accel"); - if (p =3D=3D NULL) { + accel =3D qemu_opt_get(qemu_get_machine_opts(), "accel"); + if (accel =3D=3D NULL) { /* Use the default "accelerator", tcg */ - p =3D "tcg"; + accel =3D "tcg"; } =20 + p =3D accel; while (!accel_initialised && *p !=3D '\0') { if (*p =3D=3D ':') { p++; @@ -89,7 +91,6 @@ void configure_accelerator(MachineState *ms) p =3D get_opt_name(buf, sizeof(buf), p, ':'); acc =3D accel_find(buf); if (!acc) { - fprintf(stderr, "\"%s\" accelerator not found.\n", buf); continue; } if (acc->available && !acc->available()) { @@ -100,9 +101,8 @@ void configure_accelerator(MachineState *ms) ret =3D accel_init_machine(acc, ms); if (ret < 0) { init_failed =3D true; - fprintf(stderr, "failed to initialize %s: %s\n", - acc->name, - strerror(-ret)); + error_report("failed to initialize %s: %s", + acc->name, strerror(-ret)); } else { accel_initialised =3D true; } @@ -110,13 +110,13 @@ void configure_accelerator(MachineState *ms) =20 if (!accel_initialised) { if (!init_failed) { - fprintf(stderr, "No accelerator found!\n"); + error_report("-machine accel=3D%s: No accelerator found", acce= l); } exit(1); } =20 if (init_failed) { - fprintf(stderr, "Back to %s accelerator.\n", acc->name); + error_report("Back to %s accelerator", acc->name); } } =20 --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 15016237159941002.6368063627032; Tue, 1 Aug 2017 14:41:55 -0700 (PDT) Received: from localhost ([::1]:44575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcevJ-0004RF-0s for importer@patchew.org; Tue, 01 Aug 2017 17:41:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerV-0001D4-3Y for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerU-0004nG-3c for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37542) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerT-0004mt-TX for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:56 -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 D9BFD31CE44; Tue, 1 Aug 2017 21:37:54 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id 0DA455D6AA; Tue, 1 Aug 2017 21:37:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D9BFD31CE44 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:51 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-8-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-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.29]); Tue, 01 Aug 2017 21:37:55 +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 07/10] tests/bios-tables-test: Compiler warning fix 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: Marcel Apfelbaum , Peter Maydell , "Dr. David Alan Gilbert" , Igor Mammedov 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: "Dr. David Alan Gilbert" gcc 7.1.1 in fedora 26 moans about the: tables =3D g_new0(uint32_t, tables_nr) because it can't convince itself that tables_nr is positive. This is fallout from g_assert_cmpint no longer necessarily being no-return; replace it with a plain g_assert. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- tests/bios-tables-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 63da978..564da45 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -108,7 +108,7 @@ static void test_acpi_rsdt_table(test_data *data) /* compute the table entries in rsdt */ tables_nr =3D (rsdt_table->length - sizeof(AcpiRsdtDescriptorRev1)) / sizeof(uint32_t); - g_assert_cmpint(tables_nr, >, 0); + g_assert(tables_nr > 0); =20 /* get the addresses of the tables pointed by rsdt */ tables =3D g_new0(uint32_t, tables_nr); --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501623942313294.9631324090569; Tue, 1 Aug 2017 14:45:42 -0700 (PDT) Received: from localhost ([::1]:44594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dceyy-0007hM-3P for importer@patchew.org; Tue, 01 Aug 2017 17:45:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerY-0001Gf-Kd for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerX-0004or-GQ for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerX-0004oO-AF for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:37:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0740AC08C51B; Tue, 1 Aug 2017 21:37:58 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E3576682F; Tue, 1 Aug 2017 21:37:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0740AC08C51B 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=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:54 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-9-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 01 Aug 2017 21:37:58 +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 08/10] vhost-user: fix watcher need be removed when vhost-user hotplug 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 , Jason Wang , Yunjian Wang , =?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: Yunjian Wang "nc" is freed after hotplug vhost-user, but the watcher is not removed. The QEMU crash when the watcher access the "nc" when socket disconnects. Program received signal SIGSEGV, Segmentation fault. #0 object_get_class (obj=3Dobj@entry=3D0x2) at qom/object.c:750 #1 0x00007f9bb4180da1 in qemu_chr_fe_disconnect (be=3D)= at chardev/char-fe.c:372 #2 0x00007f9bb40d1100 in net_vhost_user_watch (chan=3D,= cond=3D, opaque=3D) at net/vhost-user.c:188 #3 0x00007f9baf97f99a in g_main_context_dispatch () from /usr/lib64/li= bglib-2.0.so.0 #4 0x00007f9bb41d7ebc in glib_pollfds_poll () at util/main-loop.c:213 #5 os_host_main_loop_wait (timeout=3D) at util/main-loo= p.c:261 #6 main_loop_wait (nonblocking=3Dnonblocking@entry=3D0) at util/main-l= oop.c:515 #7 0x00007f9bb3e266a7 in main_loop () at vl.c:1917 #8 main (argc=3D, argv=3D, envp=3D) at vl.c:4786 Signed-off-by: Yunjian Wang Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/vhost-user.c b/net/vhost-user.c index 36f32a2..c23927c 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -151,6 +151,10 @@ static void vhost_user_cleanup(NetClientState *nc) s->vhost_net =3D NULL; } if (nc->queue_index =3D=3D 0) { + if (s->watch) { + g_source_remove(s->watch); + s->watch =3D 0; + } qemu_chr_fe_deinit(&s->chr, true); } =20 --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501624043953938.9383011356917; Tue, 1 Aug 2017 14:47:23 -0700 (PDT) Received: from localhost ([::1]:44601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcf0c-0000NQ-Gi for importer@patchew.org; Tue, 01 Aug 2017 17:47:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerZ-0001Hn-WF for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcerZ-0004px-5Z for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37774) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcerY-0004pH-TP for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:01 -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 D7E882F8488; Tue, 1 Aug 2017 21:37:59 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id 84C09619AB; Tue, 1 Aug 2017 21:37:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D7E882F8488 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:58 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-10-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-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.29]); Tue, 01 Aug 2017 21:38:00 +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 09/10] pc: make 'pc.rom' readonly when machine has PCI enabled 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 , Peng Hao , Eduardo Habkost , Igor Mammedov , Paolo Bonzini , 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 looking at bios ROM mapping in QEMU it seems that only isapc (i.e. not PCI enabled machine) requires ROM being mapped as RW in other cases BIOS is mapped as RO. Do the same for option ROM 'pc.rom' when machine has PCI enabled. As useful side-effect pc.rom MemoryRegion stops being put in vhost memory map (filtered out by vhost_section()), which reduces number of entries by 1. Coincidentally it fixes migration failure reported in "[PATCH V2] vhost: fix a migration failed because of vhost region merge" where following destination CLI with /sys/module/vhost/parameters/max_mem_r= egions =3D 8 export DIMMSCOUNT=3D6 QEMU -enable-kvm \ -netdev type=3Dtap,id=3Dguest0,vhost=3Don,script=3Dno,vhostforce \ -device virtio-net-pci,netdev=3Dguest0 \ -m 256,slots=3D256,maxmem=3D2G \ `i=3D0; while [ $i -lt $DIMMSCOUNT ]; do echo \ "-object memory-backend-ram,id=3Dm$i,size=3D128M \ -device pc-dimm,id=3Dd$i,memdev=3Dm$i"; i=3D$(($i + 1)); \ done` will fail to startup with error: "-device pc-dimm,id=3Dd5,memdev=3Dm5: a used vhost backend has no free mem= ory slots left" while it's possible to add the 6th DIMM during hotplug on source. Issue is caused by the fact that number of entries in vhost map is bigger on 1 entry, when -device is processed, than after guest boots up, and that offending entry belongs to 'pc.rom', it's not like vhost intends to do IO in ROM range so making it RO hides region from vhost and makes number of entries in vhost memory map at -device/machine_done time match number of entries after guest boots. Signed-off-by: Igor Mammedov Reported-by: Peng Hao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 22e1603..5943539 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1443,6 +1443,9 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr =3D g_malloc(sizeof(*option_rom_mr)); memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE, &error_fatal); + if (pcmc->pci_enabled) { + memory_region_set_readonly(option_rom_mr, true); + } memory_region_add_subregion_overlap(rom_memory, PC_ROM_MIN_VGA, option_rom_mr, --=20 MST From nobody Mon Apr 29 13:17:23 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.zohomail.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 1501623939777624.465089452127; Tue, 1 Aug 2017 14:45:39 -0700 (PDT) Received: from localhost ([::1]:44593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dceyv-0007fw-DR for importer@patchew.org; Tue, 01 Aug 2017 17:45:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcerb-0001J6-FL for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcera-0004qg-ML for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35002) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcera-0004qD-Co for qemu-devel@nongnu.org; Tue, 01 Aug 2017 17:38:02 -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 53107C0E9167; Tue, 1 Aug 2017 21:38:01 +0000 (UTC) Received: from redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with SMTP id 5B2F960BE9; Tue, 1 Aug 2017 21:38:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 53107C0E9167 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mst@redhat.com Date: Wed, 2 Aug 2017 00:37:59 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1501623438-31419-11-git-send-email-mst@redhat.com> References: <1501623438-31419-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1501623438-31419-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.32]); Tue, 01 Aug 2017 21:38:01 +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 10/10] pc: acpi: force FADT rev1 for 440fx based machine types 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 , John Arbuckle , Igor Mammedov , Paolo Bonzini , 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 w2k used to boot on QEMU until revision of FADT has been bumped to rev3 (commit 77af8a2b hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to impro= ve guest OS support.) Keep PC machine at rev1 to remain compatible and Q35 at rev3 where w2k isn't supported anyway so OSX could run as well. Signed-off-by: Igor Mammedov Tested-by: John Arbuckle Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 6b7bade..b9c245c 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -90,6 +90,7 @@ typedef struct AcpiMcfgInfo { } AcpiMcfgInfo; =20 typedef struct AcpiPmInfo { + bool force_rev1_fadt; bool s3_disabled; bool s4_disabled; bool pcihp_bridge_en; @@ -129,10 +130,13 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) Object *obj =3D NULL; QObject *o; =20 + pm->force_rev1_fadt =3D false; pm->cpu_hp_io_base =3D 0; pm->pcihp_io_base =3D 0; pm->pcihp_io_len =3D 0; if (piix) { + /* w2k requires FADT(rev1) or it won't boot, keep PC compatible */ + pm->force_rev1_fadt =3D true; obj =3D piix; pm->cpu_hp_io_base =3D PIIX4_CPU_HOTPLUG_IO_BASE; pm->pcihp_io_base =3D @@ -304,6 +308,9 @@ static void fadt_setup(AcpiFadtDescriptorRev3 *fadt, Ac= piPmInfo *pm) fadt->flags |=3D cpu_to_le32(1 << ACPI_FADT_F_FORCE_APIC_CLUSTER_M= ODEL); } fadt->century =3D RTC_CENTURY; + if (pm->force_rev1_fadt) { + return; + } =20 fadt->flags |=3D cpu_to_le32(1 << ACPI_FADT_F_RESET_REG_SUP); fadt->reset_value =3D 0xf; @@ -342,6 +349,8 @@ build_fadt(GArray *table_data, BIOSLinker *linker, Acpi= PmInfo *pm, unsigned fw_ctrl_offset =3D (char *)&fadt->firmware_ctrl - table_data-= >data; unsigned dsdt_entry_offset =3D (char *)&fadt->dsdt - table_data->data; unsigned xdsdt_entry_offset =3D (char *)&fadt->x_dsdt - table_data->da= ta; + int fadt_size =3D sizeof(*fadt); + int rev =3D 3; =20 /* FACS address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, @@ -353,12 +362,17 @@ build_fadt(GArray *table_data, BIOSLinker *linker, Ac= piPmInfo *pm, bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, dsdt_entry_offset, sizeof(fadt->dsdt), ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset); - bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->x_dsdt), - ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset); + if (pm->force_rev1_fadt) { + rev =3D 1; + fadt_size =3D offsetof(typeof(*fadt), reset_register); + } else { + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->x_dsdt= ), + ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset); + } =20 build_header(linker, table_data, - (void *)fadt, "FACP", sizeof(*fadt), 3, oem_id, oem_table= _id); + (void *)fadt, "FACP", fadt_size, rev, oem_id, oem_table_i= d); } =20 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, --=20 MST