From nobody Sun Apr 28 15:48:11 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 1516379938427942.1727539634657; Fri, 19 Jan 2018 08:38:58 -0800 (PST) Received: from localhost ([::1]:58914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZgu-0000X9-BT for importer@patchew.org; Fri, 19 Jan 2018 11:38:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZcG-0005MH-OW for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZcC-0006QH-Nj for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51626) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZcC-0006Px-Fh for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:04 -0500 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 A63BB5B2FE; Fri, 19 Jan 2018 16:34:03 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A6F4600C2; Fri, 19 Jan 2018 16:33:53 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:27 -0200 Message-Id: <20180119163345.10649-2-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Fri, 19 Jan 2018 16:34:03 +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 v2 01/19] memfd: split qemu_memfd_alloc() 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 , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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 Add a function to only create a memfd, without mmap. The function is used in the following memory backend. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20171023141815.17709-2-marcandre.lureau@redhat.com> Signed-off-by: Eduardo Habkost --- include/qemu/memfd.h | 1 + util/memfd.c | 61 +++++++++++++++++++++++++++++++-----------------= ---- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h index 745a8c501e..41c24d807c 100644 --- a/include/qemu/memfd.h +++ b/include/qemu/memfd.h @@ -16,6 +16,7 @@ #define F_SEAL_WRITE 0x0008 /* prevent writes */ #endif =20 +int qemu_memfd_create(const char *name, size_t size, unsigned int seals); void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, int *fd); void qemu_memfd_free(void *ptr, size_t size, int fd); diff --git a/util/memfd.c b/util/memfd.c index 412e94a405..3a82505f8d 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -53,6 +53,38 @@ static int memfd_create(const char *name, unsigned int f= lags) #define MFD_ALLOW_SEALING 0x0002U #endif =20 +int qemu_memfd_create(const char *name, size_t size, unsigned int seals) +{ + int mfd =3D -1; + +#ifdef CONFIG_LINUX + unsigned int flags =3D MFD_CLOEXEC; + + if (seals) { + flags |=3D MFD_ALLOW_SEALING; + } + + mfd =3D memfd_create(name, flags); + if (mfd < 0) { + return -1; + } + + if (ftruncate(mfd, size) =3D=3D -1) { + perror("ftruncate"); + close(mfd); + return -1; + } + + if (seals && fcntl(mfd, F_ADD_SEALS, seals) =3D=3D -1) { + perror("fcntl"); + close(mfd); + return -1; + } +#endif + + return mfd; +} + /* * This is a best-effort helper for shared memory allocation, with * optional sealing. The helper will do his best to allocate using @@ -63,35 +95,14 @@ void *qemu_memfd_alloc(const char *name, size_t size, u= nsigned int seals, int *fd) { void *ptr; - int mfd =3D -1; - - *fd =3D -1; - -#ifdef CONFIG_LINUX - if (seals) { - mfd =3D memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC); - } + int mfd =3D qemu_memfd_create(name, size, seals); =20 + /* some systems have memfd without sealing */ if (mfd =3D=3D -1) { - /* some systems have memfd without sealing */ - mfd =3D memfd_create(name, MFD_CLOEXEC); - seals =3D 0; + mfd =3D qemu_memfd_create(name, size, 0); } -#endif - - if (mfd !=3D -1) { - if (ftruncate(mfd, size) =3D=3D -1) { - perror("ftruncate"); - close(mfd); - return NULL; - } =20 - if (seals && fcntl(mfd, F_ADD_SEALS, seals) =3D=3D -1) { - perror("fcntl"); - close(mfd); - return NULL; - } - } else { + if (mfd =3D=3D -1) { const char *tmpdir =3D g_get_tmp_dir(); gchar *fname; =20 --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 151637978620475.56830884241106; Fri, 19 Jan 2018 08:36:26 -0800 (PST) Received: from localhost ([::1]:58863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZeT-0006kd-Fy for importer@patchew.org; Fri, 19 Jan 2018 11:36:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZcQ-0005S0-U3 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZcM-0006V2-VZ for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59986) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZcM-0006Um-PY for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:14 -0500 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 E32AEC0587C0; Fri, 19 Jan 2018 16:34:13 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 008E060C8A; Fri, 19 Jan 2018 16:34:04 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:28 -0200 Message-Id: <20180119163345.10649-3-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Fri, 19 Jan 2018 16:34:13 +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 v2 02/19] memfd: remove needless include 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 , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20171023141815.17709-3-marcandre.lureau@redhat.com> Signed-off-by: Eduardo Habkost --- util/memfd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/util/memfd.c b/util/memfd.c index 3a82505f8d..dce61f9d21 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -27,8 +27,6 @@ =20 #include "qemu/osdep.h" =20 -#include - #include "qemu/memfd.h" =20 #if defined CONFIG_LINUX && !defined CONFIG_MEMFD --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516379955676146.57625158225187; Fri, 19 Jan 2018 08:39:15 -0800 (PST) Received: from localhost ([::1]:58915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZhC-0000nO-UA for importer@patchew.org; Fri, 19 Jan 2018 11:39:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZcW-0005Yg-R8 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZcV-0006Yu-Pv for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35240) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZcV-0006YP-HM for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:23 -0500 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 AD9F762E81; Fri, 19 Jan 2018 16:34:22 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4719160852; Fri, 19 Jan 2018 16:34:15 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:29 -0200 Message-Id: <20180119163345.10649-4-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.39]); Fri, 19 Jan 2018 16:34:22 +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 v2 03/19] qemu-options: document missing memory-backend-file options 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 , Stefan Hajnoczi 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi This patch adds undocumented memory-backend-file options to the documentation. Signed-off-by: Stefan Hajnoczi Message-Id: <20171128161529.3025-2-stefanha@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- qemu-options.hx | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 678181c599..fe8c04f644 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3972,18 +3972,24 @@ property must be set. These objects are placed in = the =20 @table @option =20 -@item -object memory-backend-file,id=3D@var{id},size=3D@var{size},mem-path= =3D@var{dir},share=3D@var{on|off},discard-data=3D@var{on|off} +@item -object memory-backend-file,id=3D@var{id},size=3D@var{size},mem-path= =3D@var{dir},share=3D@var{on|off},discard-data=3D@var{on|off},merge=3D@var{= on|off},dump=3D@var{on|off},prealloc=3D@var{on|off},host-nodes=3D@var{host-= nodes},policy=3D@var{default|preferred|bind|interleave} =20 Creates a memory file backend object, which can be used to back -the guest RAM with huge pages. The @option{id} parameter is a -unique ID that will be used to reference this memory region -when configuring the @option{-numa} argument. The @option{size} -option provides the size of the memory region, and accepts -common suffixes, eg @option{500M}. The @option{mem-path} provides -the path to either a shared memory or huge page filesystem mount. +the guest RAM with huge pages. + +The @option{id} parameter is a unique ID that will be used to reference th= is +memory region when configuring the @option{-numa} argument. + +The @option{size} option provides the size of the memory region, and accep= ts +common suffixes, eg @option{500M}. + +The @option{mem-path} provides the path to either a shared memory or huge = page +filesystem mount. + The @option{share} boolean option determines whether the memory region is marked as private to QEMU, or shared. The latter allows a co-operating external process to access the QEMU memory region. + Setting the @option{discard-data} boolean option to @var{on} indicates that file contents can be destroyed when QEMU exits, to avoid unnecessarily flushing data to the backing file. Note @@ -3991,6 +3997,34 @@ that @option{discard-data} is only an optimization, = and QEMU might not discard file contents if it aborts unexpectedly or is terminated using SIGKILL. =20 +The @option{merge} boolean option enables memory merge, also known as +MADV_MERGEABLE, so that Kernel Samepage Merging will consider the pages for +memory deduplication. + +Setting the @option{dump} boolean option to @var{off} excludes the memory = from +core dumps. This feature is also known as MADV_DONTDUMP. + +The @option{prealloc} boolean option enables memory preallocation. + +The @option{host-nodes} option binds the memory range to a list of NUMA ho= st +nodes. + +The @option{policy} option sets the NUMA policy to one of the following va= lues: + +@table @option +@item @var{default} +default host policy + +@item @var{preferred} +prefer the given host node list for allocation + +@item @var{bind} +restrict memory allocation to the given host node list + +@item @var{interleave} +interleave memory allocations across the given host node list +@end table + @item -object rng-random,id=3D@var{id},filename=3D@var{/dev/random} =20 Creates a random number generator backend which obtains entropy from --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516379809149323.75819870785847; Fri, 19 Jan 2018 08:36:49 -0800 (PST) Received: from localhost ([::1]:58864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZeq-00076o-BS for importer@patchew.org; Fri, 19 Jan 2018 11:36:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZcg-0005hk-ON for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZcf-0006c4-Rm for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52124) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZcf-0006bu-Lo for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:33 -0500 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 B98926AAE7; Fri, 19 Jan 2018 16:34:32 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 163C4600D3; Fri, 19 Jan 2018 16:34:23 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:30 -0200 Message-Id: <20180119163345.10649-5-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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]); Fri, 19 Jan 2018 16:34:32 +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 v2 04/19] qemu-options: document memory-backend-ram 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 , Stefan Hajnoczi 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The documentation should mention -object memory-backend-ram. Suggested-by: Yumei Huang Signed-off-by: Stefan Hajnoczi Message-Id: <20171128161529.3025-3-stefanha@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- qemu-options.hx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index fe8c04f644..5b0ee43b18 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4025,6 +4025,13 @@ restrict memory allocation to the given host node li= st interleave memory allocations across the given host node list @end table =20 +@item -object memory-backend-ram,id=3D@var{id},merge=3D@var{on|off},dump= =3D@var{on|off},prealloc=3D@var{on|off},size=3D@var{size},host-nodes=3D@var= {host-nodes},policy=3D@var{default|preferred|bind|interleave} + +Creates a memory backend object, which can be used to back the guest RAM. +Memory backend objects offer more control than the @option{-m} option that= is +traditionally used to define guest RAM. Please refer to +@option{memory-backend-file} for a description of the options. + @item -object rng-random,id=3D@var{id},filename=3D@var{/dev/random} =20 Creates a random number generator backend which obtains entropy from --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 151638001043165.62496033392279; Fri, 19 Jan 2018 08:40:10 -0800 (PST) Received: from localhost ([::1]:58917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZi5-0001b8-HD for importer@patchew.org; Fri, 19 Jan 2018 11:40:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZcl-0005ki-2B for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZck-0006dn-B2 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45598) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZck-0006dN-5i for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:38 -0500 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 4CECCC03BD6E; Fri, 19 Jan 2018 16:34:37 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15DD060C8D; Fri, 19 Jan 2018 16:34:33 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:31 -0200 Message-Id: <20180119163345.10649-6-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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]); Fri, 19 Jan 2018 16:34:37 +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 v2 05/19] numa: fix missing '-numa cpu' in '-help' 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: Marcel Apfelbaum , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov commit 419fcdec3c (numa: add '-numa cpu,...' option for property based node= mapping) added '-numa cpu' option but forgot to update appropriate section for '--he= lp'. Add '-numa cpu' description to '-help' output Reported-by: Markus Armbruster Signed-off-by: Igor Mammedov Message-Id: <1511880838-56509-1-git-send-email-imammedo@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Eduardo Habkost --- qemu-options.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index 5b0ee43b18..b3e03c5464 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -169,7 +169,9 @@ ETEXI DEF("numa", HAS_ARG, QEMU_OPTION_numa, "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\n" "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\= n" - "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n", QEMU_ARC= H_ALL) + "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" + "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n", + QEMU_ARCH_ALL) STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}] @itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}] --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380126892420.3689104510338; Fri, 19 Jan 2018 08:42:06 -0800 (PST) Received: from localhost ([::1]:58973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZjy-0003Mn-3X for importer@patchew.org; Fri, 19 Jan 2018 11:42:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZd0-0005xl-LN for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZcy-0006na-Vb for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52370) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZcr-0006gs-QM; Fri, 19 Jan 2018 11:34:46 -0500 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 1E18685A04; Fri, 19 Jan 2018 16:34:44 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC90A60C8D; Fri, 19 Jan 2018 16:34:38 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:32 -0200 Message-Id: <20180119163345.10649-7-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Fri, 19 Jan 2018 16:34:45 +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 v2 06/19] machine: Replace has_dynamic_sysbus with list of allowed devices 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: Stefano Stabellini , "Michael S. Tsirkin" , Alexander Graf , Anthony Perard , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Marcel Apfelbaum , xen-devel@lists.xenproject.org, David Gibson 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" The existing has_dynamic_sysbus flag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others. To keep exactly the same behavior as before, the existing has_dynamic_sysbus=3Dtrue assignments are replaced with a TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches will replace the TYPE_SYS_BUS_DEVICE entries with more specific lists of devices. Cc: Peter Maydell Cc: Marcel Apfelbaum Cc: "Michael S. Tsirkin" Cc: Alexander Graf Cc: David Gibson Cc: Stefano Stabellini Cc: Anthony Perard Cc: qemu-arm@nongnu.org Cc: qemu-ppc@nongnu.org Cc: xen-devel@lists.xenproject.org Signed-off-by: Eduardo Habkost Message-Id: <20171125151610.20547-2-ehabkost@redhat.com> Reviewed-by: Greg Kurz Reviewed-by: David Gibson Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 5 ++++- hw/arm/virt.c | 3 ++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 3 ++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 3 ++- hw/xen/xen_backend.c | 7 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 156b16f7a6..041bc08971 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error **errp); =20 +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type); + + /** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU @@ -179,7 +182,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - has_dynamic_sysbus:1, pci_allow_0_address:1, legacy_fw_cfg_order:1; int is_default; @@ -197,6 +199,7 @@ struct MachineClass { bool ignore_memory_transaction_failures; int numa_mem_align_shift; const char **valid_cpu_types; + strList *allowed_dynamic_sysbus_devices; bool auto_enable_numa_with_memhp; void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 543f9bd6cc..7549895fd2 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) * configuration of the particular instance. */ mc->max_cpus =3D 255; - mc->has_dynamic_sysbus =3D true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); mc->block_default_type =3D IF_VIRTIO; mc->no_cdrom =3D 1; mc->pci_allow_0_address =3D true; diff --git a/hw/core/machine.c b/hw/core/machine.c index c857f3f934..0320a8efa1 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -334,29 +334,44 @@ static bool machine_get_enforce_config_section(Object= *obj, Error **errp) return ms->enforce_config_section; } =20 -static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque) +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type) { - error_report("Option '-device %s' cannot be handled by this machine", - object_class_get_name(object_get_class(OBJECT(sbdev)))); - exit(1); + strList *item =3D g_new0(strList, 1); + + item->value =3D g_strdup(type); + item->next =3D mc->allowed_dynamic_sysbus_devices; + mc->allowed_dynamic_sysbus_devices =3D item; } =20 -static void machine_init_notify(Notifier *notifier, void *data) +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) { - Object *machine =3D qdev_get_machine(); - ObjectClass *oc =3D object_get_class(machine); - MachineClass *mc =3D MACHINE_CLASS(oc); + MachineState *machine =3D opaque; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + bool allowed =3D false; + strList *wl; =20 - if (mc->has_dynamic_sysbus) { - /* Our machine can handle dynamic sysbus devices, we're all good */ - return; + for (wl =3D mc->allowed_dynamic_sysbus_devices; + !allowed && wl; + wl =3D wl->next) { + allowed |=3D !!object_dynamic_cast(OBJECT(sbdev), wl->value); } =20 + if (!allowed) { + error_report("Option '-device %s' cannot be handled by this machin= e", + object_class_get_name(object_get_class(OBJECT(sbdev))= )); + exit(1); + } +} + +static void machine_init_notify(Notifier *notifier, void *data) +{ + MachineState *machine =3D MACHINE(qdev_get_machine()); + /* - * Loop through all dynamically created devices and check whether there - * are sysbus devices among them. If there are, error out. + * Loop through all dynamically created sysbus devices and check if th= ey are + * all allowed. If a device is not allowed, error out. */ - foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); + foreach_dynamic_sysbus_device(validate_sysbus_device, machine); } =20 HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 5c6c608fcb..0505730a99 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts =3D "firmware=3Dbios-256k.bin"; m->default_display =3D "std"; m->no_floppy =3D 1; - m->has_dynamic_sysbus =3D true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); m->max_cpus =3D 288; } =20 diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index e59e80fb9e..438118c29b 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -15,6 +15,7 @@ #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" #include "kvm_ppc.h" @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc =3D "generic paravirt e500 platform"; mc->init =3D e500plat_init; mc->max_cpus =3D 32; - mc->has_dynamic_sysbus =3D true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("e500v2_v30"); } =20 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 499ab647d8..5847175fd9 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3843,7 +3843,8 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) mc->default_boot_order =3D ""; mc->default_ram_size =3D 512 * M_BYTE; mc->kvm_type =3D spapr_kvm_type; - mc->has_dynamic_sysbus =3D true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); mc->pci_allow_0_address =3D true; mc->get_hotplug_handler =3D spapr_get_hotplug_handler; hc->pre_plug =3D spapr_machine_device_pre_plug; diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 0f849a26d2..82380ea9ee 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void) ObjectClass *oc =3D object_get_class(machine); MachineClass *mc =3D MACHINE_CLASS(oc); =20 - mc->has_dynamic_sysbus =3D true; + /* + * Emulate old mc->has_dynamic_sysbus=3Dtrue assignment + * + *TODO: add only Xen devices to the list + */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); } =20 int xen_be_register(const char *type, struct XenDevOps *ops) --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380296840639.327421354178; Fri, 19 Jan 2018 08:44:56 -0800 (PST) Received: from localhost ([::1]:59006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZmd-0005rX-Fb for importer@patchew.org; Fri, 19 Jan 2018 11:44:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZd0-0005xj-JQ for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZcz-0006oA-RQ for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:34:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52502) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZcx-0006lB-98; Fri, 19 Jan 2018 11:34:51 -0500 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 769155B2F8; Fri, 19 Jan 2018 16:34:50 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 773FF60A9D; Fri, 19 Jan 2018 16:34:45 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:33 -0200 Message-Id: <20180119163345.10649-8-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.26]); Fri, 19 Jan 2018 16:34:50 +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 v2 07/19] hw/arm/virt: Allow only supported dynamic sysbus devices 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 , qemu-arm@nongnu.org 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Replace the TYPE_SYS_BUS_DEVICE entry in the allowed sysbus device list with the two device types that are really supported by the virt machine: vfio-amd-xgbe and vfio-calxeda-xgmac. Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Eduardo Habkost Message-Id: <20171125151610.20547-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/arm/virt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7549895fd2..4a6fdcc4f5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -34,6 +34,8 @@ #include "hw/arm/arm.h" #include "hw/arm/primecell.h" #include "hw/arm/virt.h" +#include "hw/vfio/vfio-calxeda-xgmac.h" +#include "hw/vfio/vfio-amd-xgbe.h" #include "hw/devices.h" #include "net/net.h" #include "sysemu/block-backend.h" @@ -1591,8 +1593,8 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) * configuration of the particular instance. */ mc->max_cpus =3D 255; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_CALXEDA_XGMAC); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_AMD_XGBE); mc->block_default_type =3D IF_VIRTIO; mc->no_cdrom =3D 1; mc->pci_allow_0_address =3D true; --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380877807512.1990043873656; Fri, 19 Jan 2018 08:54:37 -0800 (PST) Received: from localhost ([::1]:59095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZw0-00061t-LT for importer@patchew.org; Fri, 19 Jan 2018 11:54:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZd6-000643-Jw for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZd3-0006pd-33 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZd2-0006p8-T8; Fri, 19 Jan 2018 11:34:57 -0500 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 0EBC2B2C4; Fri, 19 Jan 2018 16:34:56 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5FB95D6B7; Fri, 19 Jan 2018 16:34:51 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:34 -0200 Message-Id: <20180119163345.10649-9-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.26]); Fri, 19 Jan 2018 16:34:56 +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 v2 08/19] ppc: e500: Allow only supported dynamic sysbus devices 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 , qemu-ppc@nongnu.org, Alexander Graf , David Gibson 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" platform_bus_create_devtree() already rejects all dynamic sysbus devices except TYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type. Cc: Alexander Graf Cc: David Gibson Cc: qemu-ppc@nongnu.org Signed-off-by: Eduardo Habkost Message-Id: <20171125151610.20547-4-ehabkost@redhat.com> Acked-by: David Gibson Reviewed-by: Greg Kurz Signed-off-by: Eduardo Habkost --- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 438118c29b..81d03e1038 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc =3D "generic paravirt e500 platform"; mc->init =3D e500plat_init; mc->max_cpus =3D 32; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("e500v2_v30"); } =20 --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516379998036580.0623598445293; Fri, 19 Jan 2018 08:39:58 -0800 (PST) Received: from localhost ([::1]:58916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZht-0001Pr-79 for importer@patchew.org; Fri, 19 Jan 2018 11:39:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZdF-0006Ca-UT for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZdB-0006tX-UV for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZdB-0006t8-Ny; Fri, 19 Jan 2018 11:35:05 -0500 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 DAEF612E51E; Fri, 19 Jan 2018 16:35:04 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5248560C8A; Fri, 19 Jan 2018 16:34:57 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:35 -0200 Message-Id: <20180119163345.10649-10-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.38]); Fri, 19 Jan 2018 16:35:04 +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 v2 09/19] spapr: Allow only supported dynamic sysbus devices 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 , qemu-ppc@nongnu.org, Alexander Graf , David Gibson 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" TYPE_SPAPR_PCI_HOST_BRIDGE is the only dynamic sysbus device not rejected by ppc_spapr_reset(), so it can be the only entry on the allowed list. Cc: David Gibson Cc: Alexander Graf Cc: qemu-ppc@nongnu.org Signed-off-by: Eduardo Habkost Message-Id: <20171125151610.20547-5-ehabkost@redhat.com> Acked-by: David Gibson Reviewed-by: Greg Kurz Signed-off-by: Eduardo Habkost --- hw/ppc/spapr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5847175fd9..278f9de1e7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3843,8 +3843,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) mc->default_boot_order =3D ""; mc->default_ram_size =3D 512 * M_BYTE; mc->kvm_type =3D spapr_kvm_type; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE); mc->pci_allow_0_address =3D true; mc->get_hotplug_handler =3D spapr_get_hotplug_handler; hc->pre_plug =3D spapr_machine_device_pre_plug; --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380206205532.6703836765139; Fri, 19 Jan 2018 08:43:26 -0800 (PST) Received: from localhost ([::1]:58984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZlF-0004VQ-C9 for importer@patchew.org; Fri, 19 Jan 2018 11:43:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZdJ-0006JB-Eu for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZdI-00070t-AW for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZdI-0006zv-3C for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:12 -0500 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 36AF4C099440; Fri, 19 Jan 2018 16:35:11 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3785B60C8A; Fri, 19 Jan 2018 16:35:06 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:36 -0200 Message-Id: <20180119163345.10649-11-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Fri, 19 Jan 2018 16:35:11 +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 v2 10/19] xen: Add only xen-sysdev to dynamic sysbus device list 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 , Anthony Perard , Stefano Stabellini , Juergen Gross , xen-devel@lists.xenproject.org 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" There's no need to make the machine allow every possible sysbus device. We can now just add xen-sysdev to the allowed list. Cc: Stefano Stabellini Cc: Anthony Perard Cc: xen-devel@lists.xenproject.org Cc: Juergen Gross Signed-off-by: Eduardo Habkost Message-Id: <20171125151610.20547-6-ehabkost@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Acked-by: Anthony PERARD Signed-off-by: Eduardo Habkost --- hw/xen/xen_backend.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 82380ea9ee..7445b506ac 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void) ObjectClass *oc =3D object_get_class(machine); MachineClass *mc =3D MACHINE_CLASS(oc); =20 - /* - * Emulate old mc->has_dynamic_sysbus=3Dtrue assignment - * - *TODO: add only Xen devices to the list - */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV); } =20 int xen_be_register(const char *type, struct XenDevOps *ops) --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516381069820383.6936496989433; Fri, 19 Jan 2018 08:57:49 -0800 (PST) Received: from localhost ([::1]:59170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZzA-0000e3-I4 for importer@patchew.org; Fri, 19 Jan 2018 11:57:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZdm-0006hn-GE for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZdi-0007EI-Gw for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZdi-0007Di-B8 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:38 -0500 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 70867356F4; Fri, 19 Jan 2018 16:35:37 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BCA05C885; Fri, 19 Jan 2018 16:35:12 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:37 -0200 Message-Id: <20180119163345.10649-12-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.30]); Fri, 19 Jan 2018 16:35:37 +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 v2 11/19] q35: Allow only supported dynamic sysbus devices 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 , Marcel Apfelbaum , "Michael S. Tsirkin" 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The only user-creatable sysbus devices in qemu-system-x86_64 are amd-iommu, intel-iommu, and xen-backend. xen-backend is handled by xen_set_dynamic_sysbus(), so we only need to add amd-iommu and intel-iommu. Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20171125151610.20547-7-ehabkost@redhat.com> Reviewed-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost --- hw/i386/pc_q35.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 0505730a99..ed3a0b8ff7 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -42,6 +42,8 @@ #include "exec/address-spaces.h" #include "hw/i386/pc.h" #include "hw/i386/ich9.h" +#include "hw/i386/amd_iommu.h" +#include "hw/i386/intel_iommu.h" #include "hw/smbios/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" @@ -299,8 +301,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts =3D "firmware=3Dbios-256k.bin"; m->default_display =3D "std"; m->no_floppy =3D 1; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE); + machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); m->max_cpus =3D 288; } =20 --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 15163803017691015.1246856528376; Fri, 19 Jan 2018 08:45:01 -0800 (PST) Received: from localhost ([::1]:59008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZmm-0005xY-Ty for importer@patchew.org; Fri, 19 Jan 2018 11:45:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZe1-0006sg-DA for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZdx-0007M4-AN for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZdx-0007Lk-4w for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:35:53 -0500 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 2CFF48B10F; Fri, 19 Jan 2018 16:35:52 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id B51B05D6B2; Fri, 19 Jan 2018 16:35:38 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:38 -0200 Message-Id: <20180119163345.10649-13-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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]); Fri, 19 Jan 2018 16:35:52 +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 v2 12/19] qdev_monitor: Simplify error handling in qdev_device_add() 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 , Thomas Huth 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Instead of doing the clean-ups on errors multiple times, introduce a jump label at the end of the function that can be used by all error paths that need this cleanup. Suggested-by: Igor Mammedov Signed-off-by: Thomas Huth Message-Id: <1509617407-21191-2-git-send-email-thuth@redhat.com> Reviewed-by: Cornelia Huck Signed-off-by: Eduardo Habkost --- qdev-monitor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index b4abb4b5ea..2abb80d7e4 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -619,22 +619,22 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **= errp) =20 /* set properties */ if (qemu_opt_foreach(opts, set_property, dev, &err)) { - error_propagate(errp, err); - object_unparent(OBJECT(dev)); - object_unref(OBJECT(dev)); - return NULL; + goto err_del_dev; } =20 dev->opts =3D opts; object_property_set_bool(OBJECT(dev), true, "realized", &err); if (err !=3D NULL) { - error_propagate(errp, err); dev->opts =3D NULL; - object_unparent(OBJECT(dev)); - object_unref(OBJECT(dev)); - return NULL; + goto err_del_dev; } return dev; + +err_del_dev: + error_propagate(errp, err); + object_unparent(OBJECT(dev)); + object_unref(OBJECT(dev)); + return NULL; } =20 =20 --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380586386977.33655466615; Fri, 19 Jan 2018 08:49:46 -0800 (PST) Received: from localhost ([::1]:59052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZrN-0001e6-K6 for importer@patchew.org; Fri, 19 Jan 2018 11:49:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZeB-00072V-NU for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZe7-0007Pt-Ls for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22671) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZe7-0007PY-DI for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:03 -0500 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 8BB8815447; Fri, 19 Jan 2018 16:36:02 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 662E65D729; Fri, 19 Jan 2018 16:35:53 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:39 -0200 Message-Id: <20180119163345.10649-14-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.29]); Fri, 19 Jan 2018 16:36:02 +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 v2 13/19] qdev: Check for the availability of a hotplug controller before adding a device 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 , Thomas Huth 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The qdev_unplug() function contains a g_assert(hotplug_ctrl) statement, so QEMU crashes when the user tries to device_add + device_del a device that does not have a corresponding hotplug controller. This could be provoked for a couple of devices in the past (see commit 4c93950659487c7ad or 84ebd3e8c7d4fe955 for example), and can currently for example also be triggered like this: $ s390x-softmmu/qemu-system-s390x -M none -nographic QEMU 2.10.50 monitor - type 'help' for more information (qemu) device_add qemu-s390x-cpu,id=3Dx (qemu) device_del x ** ERROR:qemu/qdev-monitor.c:872:qdev_unplug: assertion failed: (hotplug_ctrl) Aborted (core dumped) So devices clearly need a hotplug controller when they should be usable with device_add. The code in qdev_device_add() already checks whether the bus has a proper hotplug controller, but for devices that do not have a corresponding bus, there is no appropriate check available yet. In that case we should check whether the machine itself provides a suitable hotplug controller and refuse to plug the device if none is available. Reviewed-by: Igor Mammedov Signed-off-by: Thomas Huth Message-Id: <1509617407-21191-3-git-send-email-thuth@redhat.com> Reviewed-by: Cornelia Huck Signed-off-by: Eduardo Habkost --- include/hw/qdev-core.h | 1 + hw/core/qdev.c | 28 ++++++++++++++++++++-------- qdev-monitor.c | 5 +++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 0a71bf83f0..51473eee7b 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -286,6 +286,7 @@ DeviceState *qdev_try_create(BusState *bus, const char = *name); void qdev_init_nofail(DeviceState *dev); void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, int required_for_version); +HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev); HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); void qdev_unplug(DeviceState *dev, Error **errp); void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 11112951a5..f739753e3a 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -253,19 +253,31 @@ void qdev_set_legacy_instance_id(DeviceState *dev, in= t alias_id, dev->alias_required_for_version =3D required_for_version; } =20 +HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) +{ + MachineState *machine; + MachineClass *mc; + Object *m_obj =3D qdev_get_machine(); + + if (object_dynamic_cast(m_obj, TYPE_MACHINE)) { + machine =3D MACHINE(m_obj); + mc =3D MACHINE_GET_CLASS(machine); + if (mc->get_hotplug_handler) { + return mc->get_hotplug_handler(machine, dev); + } + } + + return NULL; +} + HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D NULL; + HotplugHandler *hotplug_ctrl; =20 if (dev->parent_bus && dev->parent_bus->hotplug_handler) { hotplug_ctrl =3D dev->parent_bus->hotplug_handler; - } else if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) { - MachineState *machine =3D MACHINE(qdev_get_machine()); - MachineClass *mc =3D MACHINE_GET_CLASS(machine); - - if (mc->get_hotplug_handler) { - hotplug_ctrl =3D mc->get_hotplug_handler(machine, dev); - } + } else { + hotplug_ctrl =3D qdev_get_machine_hotplug_handler(dev); } return hotplug_ctrl; } diff --git a/qdev-monitor.c b/qdev-monitor.c index 2abb80d7e4..c436616446 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -613,6 +613,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **e= rrp) =20 if (bus) { qdev_set_parent_bus(dev, bus); + } else if (qdev_hotplug && !qdev_get_machine_hotplug_handler(dev)) { + /* No bus, no machine hotplug handler --> device is not hotpluggab= le */ + error_setg(&err, "Device '%s' can not be hotplugged on this machin= e", + driver); + goto err_del_dev; } =20 qdev_set_id(dev, qemu_opts_id(opts)); --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380500780842.7579418532382; Fri, 19 Jan 2018 08:48:20 -0800 (PST) Received: from localhost ([::1]:59050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZq0-0000Lj-35 for importer@patchew.org; Fri, 19 Jan 2018 11:48:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZej-0007TQ-1e for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZef-0007hq-1K for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZee-0007hB-PG for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:36 -0500 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 E9CFF4F63F; Fri, 19 Jan 2018 16:36:35 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 631F360C8D; Fri, 19 Jan 2018 16:36:04 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:40 -0200 Message-Id: <20180119163345.10649-15-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.25]); Fri, 19 Jan 2018 16:36:35 +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 v2 14/19] scripts: Remove fixed entries from the device-crash-test 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 , Thomas Huth 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth These are crashes / errors which have been fixed already in the past months. We can remove these from the device-crash-test script now. Signed-off-by: Thomas Huth Message-Id: <1513613438-11017-1-git-send-email-thuth@redhat.com> Signed-off-by: Eduardo Habkost --- scripts/device-crash-test | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 827d8ec2af..7417177ebb 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -207,11 +207,9 @@ ERROR_WHITELIST =3D [ # Known crashes will generate error messages, but won't be fatal. # Those entries must be removed once we fix the crashes. {'exitcode':-6, 'log':r"Device 'serial0' is in use", 'loglevel':loggin= g.ERROR}, - {'exitcode':-6, 'log':r"spapr_rtas_register: Assertion .*rtas_table\[t= oken\]\.name.* failed", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"qemu_net_client_setup: Assertion `!peer->peer'= failed", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r'RAMBlock "[\w.-]+" already registered', 'logle= vel':logging.ERROR}, {'exitcode':-6, 'log':r"find_ram_offset: Assertion `size !=3D 0' faile= d.", 'loglevel':logging.ERROR}, - {'exitcode':-6, 'log':r"puv3_load_kernel: Assertion `kernel_filename != =3D NULL' failed", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"add_cpreg_to_hashtable: code should not be rea= ched", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"qemu_alloc_display: Assertion `surface->image = !=3D NULL' failed", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"Unexpected error in error_set_from_qdev_prop_e= rror", 'loglevel':logging.ERROR}, @@ -219,16 +217,10 @@ ERROR_WHITELIST =3D [ {'exitcode':-6, 'log':r"Object .* is not an instance of type generic-p= c-machine", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"Object .* is not an instance of type e500-ccsr= ", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"vmstate_register_with_alias_id: Assertion `!se= ->compat \|\| se->instance_id =3D=3D 0' failed", 'loglevel':logging.ERROR}, - {'exitcode':-11, 'device':'stm32f205-soc', 'loglevel':logging.ERROR, '= expected':True}, - {'exitcode':-11, 'device':'xlnx,zynqmp', 'loglevel':logging.ERROR, 'ex= pected':True}, - {'exitcode':-11, 'device':'mips-cps', 'loglevel':logging.ERROR, 'expec= ted':True}, {'exitcode':-11, 'device':'gus', 'loglevel':logging.ERROR, 'expected':= True}, - {'exitcode':-11, 'device':'a9mpcore_priv', 'loglevel':logging.ERROR, '= expected':True}, - {'exitcode':-11, 'device':'a15mpcore_priv', 'loglevel':logging.ERROR, = 'expected':True}, {'exitcode':-11, 'device':'isa-serial', 'loglevel':logging.ERROR, 'exp= ected':True}, {'exitcode':-11, 'device':'sb16', 'loglevel':logging.ERROR, 'expected'= :True}, {'exitcode':-11, 'device':'cs4231a', 'loglevel':logging.ERROR, 'expect= ed':True}, - {'exitcode':-11, 'device':'arm-gicv3', 'loglevel':logging.ERROR, 'expe= cted':True}, {'exitcode':-11, 'machine':'isapc', 'device':'.*-iommu', 'loglevel':lo= gging.ERROR, 'expected':True}, =20 # everything else (including SIGABRT and SIGSEGV) will be a fatal erro= r: --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516380206997512.9659442494466; Fri, 19 Jan 2018 08:43:26 -0800 (PST) Received: from localhost ([::1]:58983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZlB-0004RE-6C for importer@patchew.org; Fri, 19 Jan 2018 11:43:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZep-0007a0-KF for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZen-0007lU-RM for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZen-0007l7-IH for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:45 -0500 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 99976A49E2; Fri, 19 Jan 2018 16:36:44 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C813614D0; Fri, 19 Jan 2018 16:36:37 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:41 -0200 Message-Id: <20180119163345.10649-16-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.25]); Fri, 19 Jan 2018 16:36: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 v2 15/19] hostmem-file: add "align" option 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 , Haozhong Zhang 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Haozhong Zhang When mmap(2) the backend files, QEMU uses the host page size (getpagesize(2)) by default as the alignment of mapping address. However, some backends may require alignments different than the page size. For example, mmap a device DAX (e.g., /dev/dax0.0) on Linux kernel 4.13 to an address, which is 4K-aligned but not 2M-aligned, fails with a kernel message like [617494.969768] dax dax0.0: qemu-system-x86: dax_mmap: fail, unaligned vma = (0x7fa37c579000 - 0x7fa43c579000, 0x1fffff) Because there is no common approach to get such alignment requirement, we add the 'align' option to 'memory-backend-file', so that users or management utils, which have enough knowledge about the backend, can specify a proper alignment via this option. Signed-off-by: Haozhong Zhang Message-Id: <20171211072806.2812-2-haozhong.zhang@intel.com> Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi [ehabkost: fixed typo, fixed error_setg() format string] Signed-off-by: Eduardo Habkost --- docs/nvdimm.txt | 16 ++++++++++++++++ include/exec/memory.h | 3 +++ backends/hostmem-file.c | 41 ++++++++++++++++++++++++++++++++++++++++- exec.c | 8 +++++++- memory.c | 2 ++ numa.c | 2 +- qemu-options.hx | 9 ++++++++- 7 files changed, 77 insertions(+), 4 deletions(-) diff --git a/docs/nvdimm.txt b/docs/nvdimm.txt index 2d9f8c0e8c..21249dd062 100644 --- a/docs/nvdimm.txt +++ b/docs/nvdimm.txt @@ -122,3 +122,19 @@ Note: M >=3D size of RAM devices + size of statically plugged vNVDIMM devices + size of hotplugged vNVDIMM devices + +Alignment +--------- + +QEMU uses mmap(2) to maps vNVDIMM backends and aligns the mapping +address to the page size (getpagesize(2)) by default. However, some +types of backends may require an alignment different than the page +size. In that case, QEMU v2.12.0 and later provide 'align' option to +memory-backend-file to allow users to specify the proper alignment. + +For example, device dax require the 2 MB alignment, so we can use +following QEMU command line options to use it (/dev/dax0.0) as the +backend of vNVDIMM: + + -object memory-backend-file,id=3Dmem1,share=3Don,mem-path=3D/dev/dax0.0,s= ize=3D4G,align=3D2M + -device nvdimm,id=3Dnvdimm1,memdev=3Dmem1 diff --git a/include/exec/memory.h b/include/exec/memory.h index a4cabdf44c..07c5d6d597 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -465,6 +465,8 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, * @name: Region name, becomes part of RAMBlock name used in migration str= eam * must be unique within any device * @size: size of the region. + * @align: alignment of the region base address; if 0, the default alignme= nt + * (getpagesize()) will be used. * @share: %true if memory must be mmaped with the MAP_SHARED flag * @path: the path in which to allocate the RAM. * @errp: pointer to Error*, to store an error if it happens. @@ -476,6 +478,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr, struct Object *owner, const char *name, uint64_t size, + uint64_t align, bool share, const char *path, Error **errp); diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index e44c319915..e319ec1ad8 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -34,6 +34,7 @@ struct HostMemoryBackendFile { bool share; bool discard_data; char *mem_path; + uint64_t align; }; =20 static void @@ -58,7 +59,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) path =3D object_get_canonical_path(OBJECT(backend)); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), path, - backend->size, fb->share, + backend->size, fb->align, fb->share, fb->mem_path, errp); g_free(path); } @@ -115,6 +116,40 @@ static void file_memory_backend_set_discard_data(Objec= t *o, bool value, MEMORY_BACKEND_FILE(o)->discard_data =3D value; } =20 +static void file_memory_backend_get_align(Object *o, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + HostMemoryBackendFile *fb =3D MEMORY_BACKEND_FILE(o); + uint64_t val =3D fb->align; + + visit_type_size(v, name, &val, errp); +} + +static void file_memory_backend_set_align(Object *o, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + HostMemoryBackend *backend =3D MEMORY_BACKEND(o); + HostMemoryBackendFile *fb =3D MEMORY_BACKEND_FILE(o); + Error *local_err =3D NULL; + uint64_t val; + + if (host_memory_backend_mr_inited(backend)) { + error_setg(&local_err, "cannot change property value"); + goto out; + } + + visit_type_size(v, name, &val, &local_err); + if (local_err) { + goto out; + } + fb->align =3D val; + + out: + error_propagate(errp, local_err); +} + static void file_backend_unparent(Object *obj) { HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); @@ -145,6 +180,10 @@ file_backend_class_init(ObjectClass *oc, void *data) object_class_property_add_str(oc, "mem-path", get_mem_path, set_mem_path, &error_abort); + object_class_property_add(oc, "align", "int", + file_memory_backend_get_align, + file_memory_backend_set_align, + NULL, NULL, &error_abort); } =20 static void file_backend_instance_finalize(Object *o) diff --git a/exec.c b/exec.c index d28fc0cd3d..629a508385 100644 --- a/exec.c +++ b/exec.c @@ -1612,7 +1612,13 @@ static void *file_ram_alloc(RAMBlock *block, void *area; =20 block->page_size =3D qemu_fd_getpagesize(fd); - block->mr->align =3D block->page_size; + if (block->mr->align % block->page_size) { + error_setg(errp, "alignment 0x%" PRIx64 + " must be multiples of page size 0x%zx", + block->mr->align, block->page_size); + return NULL; + } + block->mr->align =3D MAX(block->page_size, block->mr->align); #if defined(__s390x__) if (kvm_enabled()) { block->mr->align =3D MAX(block->mr->align, QEMU_VMALLOC_ALIGN); diff --git a/memory.c b/memory.c index 4b41fb837b..449a1429b9 100644 --- a/memory.c +++ b/memory.c @@ -1570,6 +1570,7 @@ void memory_region_init_ram_from_file(MemoryRegion *m= r, struct Object *owner, const char *name, uint64_t size, + uint64_t align, bool share, const char *path, Error **errp) @@ -1578,6 +1579,7 @@ void memory_region_init_ram_from_file(MemoryRegion *m= r, mr->ram =3D true; mr->terminates =3D true; mr->destructor =3D memory_region_destructor_ram; + mr->align =3D align; mr->ram_block =3D qemu_ram_alloc_from_file(size, mr, share, path, errp= ); mr->dirty_log_mask =3D tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; } diff --git a/numa.c b/numa.c index 7b9c33ad12..83675a03f3 100644 --- a/numa.c +++ b/numa.c @@ -456,7 +456,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion= *mr, Object *owner, if (mem_path) { #ifdef __linux__ Error *err =3D NULL; - memory_region_init_ram_from_file(mr, owner, name, ram_size, false, + memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, fal= se, mem_path, &err); if (err) { error_report_err(err); diff --git a/qemu-options.hx b/qemu-options.hx index b3e03c5464..5ff741a4af 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3974,7 +3974,7 @@ property must be set. These objects are placed in the =20 @table @option =20 -@item -object memory-backend-file,id=3D@var{id},size=3D@var{size},mem-path= =3D@var{dir},share=3D@var{on|off},discard-data=3D@var{on|off},merge=3D@var{= on|off},dump=3D@var{on|off},prealloc=3D@var{on|off},host-nodes=3D@var{host-= nodes},policy=3D@var{default|preferred|bind|interleave} +@item -object memory-backend-file,id=3D@var{id},size=3D@var{size},mem-path= =3D@var{dir},share=3D@var{on|off},discard-data=3D@var{on|off},merge=3D@var{= on|off},dump=3D@var{on|off},prealloc=3D@var{on|off},host-nodes=3D@var{host-= nodes},policy=3D@var{default|preferred|bind|interleave},align=3D@var{align} =20 Creates a memory file backend object, which can be used to back the guest RAM with huge pages. @@ -4027,6 +4027,13 @@ restrict memory allocation to the given host node li= st interleave memory allocations across the given host node list @end table =20 +The @option{align} option specifies the base address alignment when +QEMU mmap(2) @option{mem-path}, and accepts common suffixes, eg +@option{2M}. Some backend store specified by @option{mem-path} +requires an alignment different than the default one used by QEMU, eg +the device DAX /dev/dax0.0 requires 2M alignment rather than 4K. In +such cases, users can specify the required alignment via this option. + @item -object memory-backend-ram,id=3D@var{id},merge=3D@var{on|off},dump= =3D@var{on|off},prealloc=3D@var{on|off},size=3D@var{size},host-nodes=3D@var= {host-nodes},policy=3D@var{default|preferred|bind|interleave} =20 Creates a memory backend object, which can be used to back the guest RAM. --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380708636701.4885969874617; Fri, 19 Jan 2018 08:51:48 -0800 (PST) Received: from localhost ([::1]:59082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZtC-0003Qt-QL for importer@patchew.org; Fri, 19 Jan 2018 11:51:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZev-0007ht-Lx for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZeu-0007v9-VT for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZeu-0007uz-QB for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:52 -0500 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 F225EDF14; Fri, 19 Jan 2018 16:36:51 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD33460CAE; Fri, 19 Jan 2018 16:36:45 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:42 -0200 Message-Id: <20180119163345.10649-17-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.30]); Fri, 19 Jan 2018 16:36:52 +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 v2 16/19] nvdimm: add a macro for property "label-size" 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 , Haozhong Zhang 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Haozhong Zhang Signed-off-by: Haozhong Zhang Reviewed-by: Stefan Hajnoczi Message-Id: <20171211072806.2812-3-haozhong.zhang@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Eduardo Habkost --- include/hw/mem/nvdimm.h | 3 +++ hw/mem/nvdimm.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index 03e1ff9558..28e68ddf59 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -47,6 +47,9 @@ #define NVDIMM_CLASS(oc) OBJECT_CLASS_CHECK(NVDIMMClass, (oc), TYPE_NVDIMM) #define NVDIMM_GET_CLASS(obj) OBJECT_GET_CLASS(NVDIMMClass, (obj), \ TYPE_NVDIMM) + +#define NVDIMM_LABLE_SIZE_PROP "label-size" + struct NVDIMMDevice { /* private */ PCDIMMDevice parent_obj; diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 952fce5ec8..618c3d677b 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -66,7 +66,7 @@ out: =20 static void nvdimm_init(Object *obj) { - object_property_add(obj, "label-size", "int", + object_property_add(obj, NVDIMM_LABLE_SIZE_PROP, "int", nvdimm_get_label_size, nvdimm_set_label_size, NULL, NULL, NULL); } --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516381857336566.9078883754061; Fri, 19 Jan 2018 09:10:57 -0800 (PST) Received: from localhost ([::1]:60308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecaBs-0004SN-7W for importer@patchew.org; Fri, 19 Jan 2018 12:10:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZez-0007lL-4p for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:37:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZex-0007wJ-Uj for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45104) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZex-0007w1-Lu for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:36:55 -0500 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 B189F8B112; Fri, 19 Jan 2018 16:36:54 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4174660626; Fri, 19 Jan 2018 16:36:53 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:43 -0200 Message-Id: <20180119163345.10649-18-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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]); Fri, 19 Jan 2018 16:36: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 v2 17/19] nvdimm: add 'unarmed' option 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 , Haozhong Zhang 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Haozhong Zhang Currently the only vNVDIMM backend can guarantee the guest write persistence is device DAX on Linux, because no host-side kernel cache is involved in the guest access to it. The approach to detect whether the backend is device DAX needs to access sysfs, which may not work with SELinux. Instead, we add the 'unarmed' option to device 'nvdimm', so that users or management utils, which have enough knowledge about the backend, can control the unarmed flag in guest ACPI NFIT via this option. The guest Linux NVDIMM driver, for example, will mark the corresponding vNVDIMM device read-only if the unarmed flag in guest NFIT is set. The default value of 'unarmed' option is 'off' in order to keep the backwards compatibility. Signed-off-by: Haozhong Zhang Message-Id: <20171211072806.2812-4-haozhong.zhang@intel.com> Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Eduardo Habkost --- docs/nvdimm.txt | 15 +++++++++++++++ include/hw/mem/nvdimm.h | 9 +++++++++ hw/acpi/nvdimm.c | 7 +++++++ hw/mem/nvdimm.c | 26 ++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/docs/nvdimm.txt b/docs/nvdimm.txt index 21249dd062..e903d8bb09 100644 --- a/docs/nvdimm.txt +++ b/docs/nvdimm.txt @@ -138,3 +138,18 @@ backend of vNVDIMM: =20 -object memory-backend-file,id=3Dmem1,share=3Don,mem-path=3D/dev/dax0.0,s= ize=3D4G,align=3D2M -device nvdimm,id=3Dnvdimm1,memdev=3Dmem1 + +Guest Data Persistence +---------------------- + +Though QEMU supports multiple types of vNVDIMM backends on Linux, +currently the only one that can guarantee the guest write persistence +is the device DAX on the real NVDIMM device (e.g., /dev/dax0.0), to +which all guest access do not involve any host-side kernel cache. + +When using other types of backends, it's suggested to set 'unarmed' +option of '-device nvdimm' to 'on', which sets the unarmed flag of the +guest NVDIMM region mapping structure. This unarmed flag indicates +guest software that this vNVDIMM device contains a region that cannot +accept persistent writes. In result, for example, the guest Linux +NVDIMM driver, marks such vNVDIMM device as read-only. diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index 28e68ddf59..7fd87c4e1c 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -49,6 +49,7 @@ TYPE_NVDIMM) =20 #define NVDIMM_LABLE_SIZE_PROP "label-size" +#define NVDIMM_UNARMED_PROP "unarmed" =20 struct NVDIMMDevice { /* private */ @@ -74,6 +75,14 @@ struct NVDIMMDevice { * guest via ACPI NFIT and _FIT method if NVDIMM hotplug is supported. */ MemoryRegion nvdimm_mr; + + /* + * The 'on' value results in the unarmed flag set in ACPI NFIT, + * which can be used to notify guest implicitly that the host + * backend (e.g., files on HDD, /dev/pmemX, etc.) cannot guarantee + * the guest write persistence. + */ + bool unarmed; }; typedef struct NVDIMMDevice NVDIMMDevice; =20 diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 6ceea196e7..59d6e4254c 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -138,6 +138,8 @@ struct NvdimmNfitMemDev { } QEMU_PACKED; typedef struct NvdimmNfitMemDev NvdimmNfitMemDev; =20 +#define ACPI_NFIT_MEM_NOT_ARMED (1 << 3) + /* * NVDIMM Control Region Structure * @@ -284,6 +286,7 @@ static void nvdimm_build_structure_memdev(GArray *structures, DeviceState *dev) { NvdimmNfitMemDev *nfit_memdev; + NVDIMMDevice *nvdimm =3D NVDIMM(OBJECT(dev)); uint64_t size =3D object_property_get_uint(OBJECT(dev), PC_DIMM_SIZE_P= ROP, NULL); int slot =3D object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, @@ -312,6 +315,10 @@ nvdimm_build_structure_memdev(GArray *structures, Devi= ceState *dev) =20 /* Only one interleave for PMEM. */ nfit_memdev->interleave_ways =3D cpu_to_le16(1); + + if (nvdimm->unarmed) { + nfit_memdev->flags |=3D cpu_to_le16(ACPI_NFIT_MEM_NOT_ARMED); + } } =20 /* diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 618c3d677b..61e677f92f 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qapi/visitor.h" +#include "qapi-visit.h" #include "hw/mem/nvdimm.h" =20 static void nvdimm_get_label_size(Object *obj, Visitor *v, const char *nam= e, @@ -64,11 +65,36 @@ out: error_propagate(errp, local_err); } =20 +static bool nvdimm_get_unarmed(Object *obj, Error **errp) +{ + NVDIMMDevice *nvdimm =3D NVDIMM(obj); + + return nvdimm->unarmed; +} + +static void nvdimm_set_unarmed(Object *obj, bool value, Error **errp) +{ + NVDIMMDevice *nvdimm =3D NVDIMM(obj); + Error *local_err =3D NULL; + + if (memory_region_size(&nvdimm->nvdimm_mr)) { + error_setg(&local_err, "cannot change property value"); + goto out; + } + + nvdimm->unarmed =3D value; + + out: + error_propagate(errp, local_err); +} + static void nvdimm_init(Object *obj) { object_property_add(obj, NVDIMM_LABLE_SIZE_PROP, "int", nvdimm_get_label_size, nvdimm_set_label_size, NULL, NULL, NULL); + object_property_add_bool(obj, NVDIMM_UNARMED_PROP, + nvdimm_get_unarmed, nvdimm_set_unarmed, NULL); } =20 static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 1516380384483672.7191083702974; Fri, 19 Jan 2018 08:46:24 -0800 (PST) Received: from localhost ([::1]:59014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZo5-00078W-Gu for importer@patchew.org; Fri, 19 Jan 2018 11:46:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZf4-0007oM-P7 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:37:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZf3-0007zo-6L for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:37:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZf2-0007zN-TO for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:37:01 -0500 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 12C70780F7; Fri, 19 Jan 2018 16:37:00 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15A2E60188; Fri, 19 Jan 2018 16:36:55 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:44 -0200 Message-Id: <20180119163345.10649-19-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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.27]); Fri, 19 Jan 2018 16:37: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 v2 18/19] possible_cpus: add CPUArchId::type field 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 , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Remove dependency of possible_cpus on 1st CPU instance, which decouples configuration data from CPU instances that are created using that data. Also later it would be used for enabling early cpu to numa node configuration at runtime qmp_query_hotpluggable_cpus() should provide a list of available cpu slots at early stage, before machine_init() is called and the 1st cpu is created, so that mgmt might be able to call it and use output to set numa mapping. Use MachineClass::possible_cpu_arch_ids() callback to set cpu type info, along with the rest of possible cpu properties, to let machine define which cpu type* will be used. * for SPAPR it will be a spapr core type and for ARM/s390x/x86 a respective descendant of CPUClass. Move parse_numa_opts() in vl.c after cpu_model is parsed into cpu_type so that possible_cpu_arch_ids() would know which cpu_type to use during layout initialization. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Message-Id: <1515597770-268979-1-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 2 ++ hw/arm/virt.c | 3 ++- hw/core/machine.c | 12 ++++++------ hw/i386/pc.c | 4 +++- hw/ppc/spapr.c | 13 ++++++++----- hw/s390x/s390-virtio-ccw.c | 1 + vl.c | 3 +-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 041bc08971..efb0a9edfd 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -83,6 +83,7 @@ void machine_class_allow_dynamic_sysbus_dev(MachineClass = *mc, const char *type); * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU * @cpu - pointer to corresponding CPU object if it's present on NULL othe= rwise + * @type - QOM class name of possible @cpu object * @props - CPU object properties, initialized by board * #vcpus_count - number of threads provided by @cpu object */ @@ -91,6 +92,7 @@ typedef struct { int64_t vcpus_count; CpuInstanceProperties props; Object *cpu; + const char *type; } CPUArchId; =20 /** diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4a6fdcc4f5..a4537af400 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1359,7 +1359,7 @@ static void machvirt_init(MachineState *machine) break; } =20 - cpuobj =3D object_new(machine->cpu_type); + cpuobj =3D object_new(possible_cpus->cpus[n].type); object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id, "mp-affinity", NULL); =20 @@ -1575,6 +1575,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_id= s(MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (n =3D 0; n < ms->possible_cpus->len; n++) { + ms->possible_cpus->cpus[n].type =3D ms->cpu_type; ms->possible_cpus->cpus[n].arch_id =3D virt_cpu_mp_affinity(vms, n); ms->possible_cpus->cpus[n].props.has_thread_id =3D true; diff --git a/hw/core/machine.c b/hw/core/machine.c index 0320a8efa1..cdc1163dc6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -377,18 +377,18 @@ static void machine_init_notify(Notifier *notifier, v= oid *data) HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) { int i; - Object *cpu; HotpluggableCPUList *head =3D NULL; - const char *cpu_type; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + /* force board to initialize possible_cpus if it hasn't been done yet = */ + mc->possible_cpu_arch_ids(machine); =20 - cpu =3D machine->possible_cpus->cpus[0].cpu; - assert(cpu); /* Boot cpu is always present */ - cpu_type =3D object_get_typename(cpu); for (i =3D 0; i < machine->possible_cpus->len; i++) { + Object *cpu; HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); =20 - cpu_item->type =3D g_strdup(cpu_type); + cpu_item->type =3D g_strdup(machine->possible_cpus->cpus[i].type); cpu_item->vcpus_count =3D machine->possible_cpus->cpus[i].vcpus_co= unt; cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, sizeof(*cpu_item->props)); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 55686bf5d8..ccc50baa85 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1148,7 +1148,8 @@ void pc_cpus_init(PCMachineState *pcms) pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(max_cpus - 1) + 1; possible_cpus =3D mc->possible_cpu_arch_ids(ms); for (i =3D 0; i < smp_cpus; i++) { - pc_new_cpu(ms->cpu_type, possible_cpus->cpus[i].arch_id, &error_fa= tal); + pc_new_cpu(possible_cpus->cpus[i].type, possible_cpus->cpus[i].arc= h_id, + &error_fatal); } } =20 @@ -2307,6 +2308,7 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) for (i =3D 0; i < ms->possible_cpus->len; i++) { X86CPUTopoInfo topo; =20 + ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 278f9de1e7..a781dd22e7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2226,11 +2226,6 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) int boot_cores_nr =3D smp_cpus / smp_threads; int i; =20 - if (!type) { - error_report("Unable to find sPAPR CPU Core definition"); - exit(1); - } - possible_cpus =3D mc->possible_cpu_arch_ids(machine); if (mc->has_hotpluggable_cpus) { if (smp_cpus % smp_threads) { @@ -3545,6 +3540,7 @@ static int64_t spapr_get_default_cpu_node_id(const Ma= chineState *ms, int idx) static const CPUArchIdList *spapr_possible_cpu_arch_ids(MachineState *mach= ine) { int i; + const char *core_type; int spapr_max_cores =3D max_cpus / smp_threads; MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 @@ -3556,12 +3552,19 @@ static const CPUArchIdList *spapr_possible_cpu_arch= _ids(MachineState *machine) return machine->possible_cpus; } =20 + core_type =3D spapr_get_cpu_core_type(machine->cpu_type); + if (!core_type) { + error_report("Unable to find sPAPR CPU Core definition"); + exit(1); + } + machine->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + sizeof(CPUArchId) * spapr_max_cores); machine->possible_cpus->len =3D spapr_max_cores; for (i =3D 0; i < machine->possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 + machine->possible_cpus->cpus[i].type =3D core_type; machine->possible_cpus->cpus[i].vcpus_count =3D smp_threads; machine->possible_cpus->cpus[i].arch_id =3D core_id; machine->possible_cpus->cpus[i].props.has_core_id =3D true; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 35df7e19c5..3807dcb097 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -414,6 +414,7 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(= MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (i =3D 0; i < ms->possible_cpus->len; i++) { + ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; ms->possible_cpus->cpus[i].arch_id =3D i; ms->possible_cpus->cpus[i].props.has_core_id =3D true; diff --git a/vl.c b/vl.c index 2586f25952..e725ecbc08 100644 --- a/vl.c +++ b/vl.c @@ -4611,8 +4611,6 @@ int main(int argc, char **argv, char **envp) current_machine->boot_order =3D boot_order; current_machine->cpu_model =3D cpu_model; =20 - parse_numa_opts(current_machine); - /* parse features once if machine provides default cpu_type */ if (machine_class->default_cpu_type) { current_machine->cpu_type =3D machine_class->default_cpu_type; @@ -4621,6 +4619,7 @@ int main(int argc, char **argv, char **envp) cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_m= odel); } } + parse_numa_opts(current_machine); =20 machine_run_board_init(current_machine); =20 --=20 2.14.3 From nobody Sun Apr 28 15:48:11 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 15163808828431019.8378893523105; Fri, 19 Jan 2018 08:54:42 -0800 (PST) Received: from localhost ([::1]:59112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZwA-0006FV-3d for importer@patchew.org; Fri, 19 Jan 2018 11:54:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZf8-0007rl-Oa for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:37:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecZf8-00081j-2c for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:37:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42116) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecZf7-00081D-Sh for qemu-devel@nongnu.org; Fri, 19 Jan 2018 11:37:05 -0500 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 0FA6021BB0; Fri, 19 Jan 2018 16:37:05 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C39060A9D; Fri, 19 Jan 2018 16:37:01 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 14:33:45 -0200 Message-Id: <20180119163345.10649-20-ehabkost@redhat.com> In-Reply-To: <20180119163345.10649-1-ehabkost@redhat.com> References: <20180119163345.10649-1-ehabkost@redhat.com> 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]); Fri, 19 Jan 2018 16:37:05 +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 v2 19/19] fw_cfg: fix memory corruption when all fw_cfg slots are used 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 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Marcel Apfelbaum When all the fw_cfg slots are used, a write is made outside the bounds of the fw_cfg files array as part of the sort algorithm. Fix it by avoiding an unnecessary array element move. Fix also an assert while at it. Signed-off-by: Marcel Apfelbaum Message-Id: <20180108215007.46471-1-marcel@redhat.com> Reviewed-by: Laszlo Ersek Signed-off-by: Eduardo Habkost --- hw/nvram/fw_cfg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 753ac0e4ea..4313484b21 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -784,7 +784,7 @@ void fw_cfg_add_file_callback(FWCfgState *s, const cha= r *filename, * index and "i - 1" is the one being copied from, thus the * unusual start and end in the for statement. */ - for (i =3D count + 1; i > index; i--) { + for (i =3D count; i > index; i--) { s->files->f[i] =3D s->files->f[i - 1]; s->files->f[i].select =3D cpu_to_be16(FW_CFG_FILE_FIRST + i); s->entries[0][FW_CFG_FILE_FIRST + i] =3D @@ -833,7 +833,6 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *fil= ename, assert(s->files); =20 index =3D be32_to_cpu(s->files->count); - assert(index < fw_cfg_file_slots(s)); =20 for (i =3D 0; i < index; i++) { if (strcmp(filename, s->files->f[i].name) =3D=3D 0) { @@ -843,6 +842,9 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *fil= ename, return ptr; } } + + assert(index < fw_cfg_file_slots(s)); + /* add new one */ fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, data, len, tru= e); return NULL; --=20 2.14.3