From patchwork Fri Oct 25 02:25:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1183729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="MT+fGoom"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46zp5s116xz9sPk for ; Fri, 25 Oct 2019 13:31:44 +1100 (AEDT) Received: from localhost ([::1]:54604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNpO9-0002Zb-FT for incoming@patchwork.ozlabs.org; Thu, 24 Oct 2019 22:31:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39560) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNpIs-0002JD-Qo for qemu-devel@nongnu.org; Thu, 24 Oct 2019 22:26:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNpIr-0007bV-If for qemu-devel@nongnu.org; Thu, 24 Oct 2019 22:26:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31516 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNpIr-0007bL-FA for qemu-devel@nongnu.org; Thu, 24 Oct 2019 22:26:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571970372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pbB5R4thUE5Gt4DY003mthYNBru3RU5to81ayHIC/6M=; b=MT+fGoomE7YMgONFLfjCE1pnv7ZcWWltd9aOBLJBReDiUDDrxrifMagjeA4pU9A/hOi7eX 12/bQjgxY0Oda59KbabU8PsvbA19yKnVLlq2g4vBwf5eH8ZxTDGNGFliRQ3AebnExPl7xs j7F6g0Qo8BToKxmXwgQ32w+Uh4Bk2Q4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-A0qb6TAJNZ-04Y3SQS7j5A-1; Thu, 24 Oct 2019 22:26:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CB2B800D49; Fri, 25 Oct 2019 02:26:08 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1DA660600; Fri, 25 Oct 2019 02:26:07 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 6/7] i386: Don't use default_cpu_version() inside query-cpu-definitions Date: Thu, 24 Oct 2019 23:25:52 -0300 Message-Id: <20191025022553.25298-7-ehabkost@redhat.com> In-Reply-To: <20191025022553.25298-1-ehabkost@redhat.com> References: <20191025022553.25298-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: A0qb6TAJNZ-04Y3SQS7j5A-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Igor Mammedov , Paolo Bonzini , Jiri Denemark , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We will change query-cpu-definitions to have a new `machine` parameter. Make the machine-specific parts of that code explicit instead of calling default_cpu_version(), so we can change it to use the new parameter later. As the code now has a dependency on MachineClass, wrap it inside a !CONFIG_USER_ONLY ifdef. The function was never used by *-user, anyway. This patch shouldn't introduce any behavior change. Results of query-cpu-definition will be exactly the same. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5dbd379331..67d1eca4ed 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3877,6 +3877,7 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, visit_type_strList(v, "unavailable-features", &result, errp); } +#ifndef CONFIG_USER_ONLY /* Check for missing features that may prevent the CPU class from * running using the current machine and accelerator. */ @@ -3914,6 +3915,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, object_unref(OBJECT(xc)); } +#endif /* Print all cpuid feature names in featureset */ @@ -4039,11 +4041,17 @@ void x86_cpu_list(void) g_list_free(names); } +#ifndef CONFIG_USER_ONLY +typedef struct X86CPUDefinitionArgs { + CpuDefinitionInfoList *cpu_list; + X86CPUVersion default_version; +} X86CPUDefinitionArgs; + static void x86_cpu_definition_entry(gpointer data, gpointer user_data) { ObjectClass *oc = data; X86CPUClass *cc = X86_CPU_CLASS(oc); - CpuDefinitionInfoList **cpu_list = user_data; + X86CPUDefinitionArgs *args = user_data; CpuDefinitionInfoList *entry; CpuDefinitionInfo *info; @@ -4059,25 +4067,30 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) * Old machine types won't report aliases, so that alias translation * doesn't break compatibility with previous QEMU versions. */ - if (default_cpu_version() != CPU_VERSION_LEGACY) { - info->alias_of = x86_cpu_class_get_alias_of(cc, default_cpu_version()); + if (args->default_version != CPU_VERSION_LEGACY) { + info->alias_of = x86_cpu_class_get_alias_of(cc, args->default_version); info->has_alias_of = !!info->alias_of; } entry = g_malloc0(sizeof(*entry)); entry->value = info; - entry->next = *cpu_list; - *cpu_list = entry; + entry->next = args->cpu_list; + args->cpu_list = entry; } CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { - CpuDefinitionInfoList *cpu_list = NULL; - GSList *list = get_sorted_cpu_model_list(); - g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list); + X86CPUDefinitionArgs args = { .cpu_list = NULL }; + GSList *list; + MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); + + args.default_version = default_cpu_version_for_machine(mc); + list = get_sorted_cpu_model_list(); + g_slist_foreach(list, x86_cpu_definition_entry, &args); g_slist_free(list); - return cpu_list; + return args.cpu_list; } +#endif static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only)