From patchwork Tue Feb 5 13:07:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 10797473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60D6713B4 for ; Tue, 5 Feb 2019 13:12:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FDDF2BC44 for ; Tue, 5 Feb 2019 13:12:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E07F2BCB6; Tue, 5 Feb 2019 13:12:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BCC772BC9A for ; Tue, 5 Feb 2019 13:12:50 +0000 (UTC) Received: from localhost ([127.0.0.1]:60119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr0Wv-0004Sa-VY for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 08:12:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr0V8-0002sS-J3 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 08:10:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gr0S9-0003FI-HK for qemu-devel@nongnu.org; Tue, 05 Feb 2019 08:07:55 -0500 Received: from mail.ispras.ru ([83.149.199.45]:33642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr0S8-00033W-9n for qemu-devel@nongnu.org; Tue, 05 Feb 2019 08:07:53 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id CB460540089; Tue, 5 Feb 2019 16:07:34 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 05 Feb 2019 16:07:35 +0300 Message-ID: <154937205518.29984.9188603364499998604.stgit@pasha-VirtualBox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH] mips: implement qmp query-cpu-definitions command 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: pavel.dovgaluk@ispras.ru, arikalo@wavecomp.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com, dovgaluk@ispras.ru, natalia.fursova@ispras.ru, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch enables QMP-based querying of the available CPU types for MIPS and MIPS64 platforms. Signed-off-by: Pavel Dovgalyuk Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- monitor.c | 2 +- target/mips/helper.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/monitor.c b/monitor.c index c09fa63940..25d3b141ad 100644 --- a/monitor.c +++ b/monitor.c @@ -1165,7 +1165,7 @@ static void qmp_unregister_commands_hack(void) qmp_unregister_command(&qmp_commands, "query-cpu-model-comparison"); #endif #if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \ - && !defined(TARGET_S390X) + && !defined(TARGET_S390X) && !defined(TARGET_MIPS) qmp_unregister_command(&qmp_commands, "query-cpu-definitions"); #endif } diff --git a/target/mips/helper.c b/target/mips/helper.c index 8988452dbd..c84d056c09 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -24,6 +24,7 @@ #include "exec/cpu_ldst.h" #include "exec/log.h" #include "hw/mips/cpudevs.h" +#include "sysemu/arch_init.h" enum { TLBRET_XI = -6, @@ -1472,3 +1473,35 @@ void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, cpu_loop_exit_restore(cs, pc); } + +static void mips_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **cpu_list = user_data; + CpuDefinitionInfoList *entry; + CpuDefinitionInfo *info; + const char *typename; + + typename = object_class_get_name(oc); + info = g_malloc0(sizeof(*info)); + info->name = g_strndup(typename, + strlen(typename) - strlen("-" TYPE_MIPS_CPU)); + info->q_typename = g_strdup(typename); + + entry = g_malloc0(sizeof(*entry)); + entry->value = info; + entry->next = *cpu_list; + *cpu_list = entry; +} + +CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + + list = object_class_get_list(TYPE_MIPS_CPU, false); + g_slist_foreach(list, mips_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +}