From patchwork Thu Nov 16 16:37:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 744442 Delivered-To: patch@linaro.org Received: by 2002:a5d:5388:0:b0:32d:baff:b0ca with SMTP id d8csp418646wrv; Thu, 16 Nov 2023 08:37:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IER2c0YmjS6BnIcqg07+hMRxsPIBXvS2w47aGJB6xZVVfuVa2qtuIZeyZaRlXZPaQydTn9J X-Received: by 2002:a05:620a:4081:b0:773:f6ea:1f59 with SMTP id f1-20020a05620a408100b00773f6ea1f59mr3479053qko.16.1700152671397; Thu, 16 Nov 2023 08:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700152671; cv=none; d=google.com; s=arc-20160816; b=XnI/eZIFg1UyFI6B9V3T7a4XFgulHV2OmZ+s+RkJ2cScwvnIWdo3p188wmC6mvW37s 948HVNkE9T4GtNlQFWVhciz+tNqIMEB7vE/WGDWmevcuJNwnxa4jQ+pMlj1puWf+eoU2 pn7U7TCd9UnZ7Xrgso22UqxGSxyuwmdJdJMyxHcnc9hNDlnCjXAupTtbKYch3fFYsfZR Z50PsLC2nYTZ9/dolzlWkU9vttEQ6tJKi5zH9axTdtY+07wtVQSaQtrXsnruPckSeCcJ +uatWWLrCaH4QcuDMamlCjIWthM0U4QA+bcQhG0QYN5XHpUsyjFZjl+1KblXMTK5hdqJ vqGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=inXKrafPd5SkQhA/cWzh8/eJIxvZt3CwOO4U8YkDwa0=; fh=N3Y6blR9u35PB7wBUKj/OGyZz3x/G22TZkZCOsyA4SM=; b=UVGmfBWKjKeQYnoMX/Kh5dRTFj9F/QXszfADI+cV9iKPo690r+LOZ5miGMCdmXt4OV QVqVycTUxOld/3HLvsumoFA4JjK0NN2tVaijMiU8luV0HP/eDdDzgPT1V6JwxiWcE9Rw l3wN5N+gV6AgDOLeIxI+gxRWG02xiXrrtHCUcPylnNAxcFjezSUC/Fzut2ZdHNOrDI1D tnGwqe7rGvLuNuYPBnjH5VC82rw4aHcKkH9xgwsiGFDKPjmxaFsZ5v33tjf+gwk5M82V m4Eoej+ucOSi9DkV1YBEC3mbPv2UuwOGOyrubuAi5RtKsEg0RxT+PCXqdtEEnMUHT27R 7G6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hnMmpXxw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id pz17-20020a05620a641100b00778bb397d29si10957522qkn.638.2023.11.16.08.37.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Nov 2023 08:37:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hnMmpXxw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3fN1-0004eU-Dy; Thu, 16 Nov 2023 11:37:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3fMz-0004dx-Dd for qemu-devel@nongnu.org; Thu, 16 Nov 2023 11:37:33 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3fMw-0004fL-M7 for qemu-devel@nongnu.org; Thu, 16 Nov 2023 11:37:32 -0500 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9e4675c7a5fso148705166b.0 for ; Thu, 16 Nov 2023 08:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700152649; x=1700757449; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=inXKrafPd5SkQhA/cWzh8/eJIxvZt3CwOO4U8YkDwa0=; b=hnMmpXxwyveErSB0As1dFy6Otvp0PxUPmyg4d9YZHZ6pFtoAGkVC+ibThfZokeDin3 g2WDMZRt5NFyz0BSAactlkrtYM2T2pVILiZ71q30ncNKUT2C52C1kJMl9JSvGlBd6ctr wXO+lyijySQI44rWgczVvpLF4NiyX3ydeKqzBfSPq/H+Sx7GYFBKv7hUzAsPkMtPeKGA QATc4UMhv43DJeJCd4G5nUNEnLc4M3b5VV1Js8QmsKKoI1e5TewxOElR5XW9xkD+puji FobPZw1tbmjOz/3W+73drIGDtUEO6zOgDD66yQo1NdcxD9IgQsm4u/bDQ8jidXX8BVPp m2Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700152649; x=1700757449; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=inXKrafPd5SkQhA/cWzh8/eJIxvZt3CwOO4U8YkDwa0=; b=TZ2NmL28kmEVnIwYsfKTt1eZg7nL5E46+xq6JpHhuxNCgGiEtpRdzubhrwzqpWUesO yD83EDInMeDYPEzxseYNxdEw+zPC3xnGNnXvNyOcz8gaVzNr+yQ5KdYR6vw0nv36ylJz WabT/GUtDPZ2r/RvTzO73MUtix2wnIL0BjEKzENX9e53576CaudwOHWWmxXX9mcNb7/G byb0zzB+AXcaBflQ5rEpRgBIQ/HjN/FjknuYKdXx3yF5Emo5DnXqgoMZ3K7JrybYt217 mJ3+vgdje3a4E3xFyRcLnLPtW/sRrDHyE0ziYmwUpvW8Dg4GVuzNKBThsZ6tf3BmJIVB VglA== X-Gm-Message-State: AOJu0YzIe/zBuLsghFoeZ1e181ht37NxLSkEgxpxcSXntJO9U5p0qBX9 akD6z8uCYbEfeIrjRB7kBJqYQkJJNYUiVqSzxGI= X-Received: by 2002:a17:906:6bd4:b0:9be:51ce:e91b with SMTP id t20-20020a1709066bd400b009be51cee91bmr13843754ejs.68.1700152648810; Thu, 16 Nov 2023 08:37:28 -0800 (PST) Received: from m1x-phil.lan ([176.187.220.205]) by smtp.gmail.com with ESMTPSA id o10-20020a1709062e8a00b009e676a5b158sm8521799eji.83.2023.11.16.08.37.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Nov 2023 08:37:28 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Gavin Shan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , Paolo Bonzini , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH-for-9.0] hw/core: Add machine_class_default_cpu_type() Date: Thu, 16 Nov 2023 17:37:26 +0100 Message-ID: <20231116163726.28952-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=philmd@linaro.org; helo=mail-ej1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a helper to return a machine default CPU type. If this machine is restricted to a single CPU type, use it as default, obviously. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/boards.h | 6 ++++++ hw/core/machine.c | 8 ++++++++ system/vl.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index da85f86efb..160a10036e 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -24,6 +24,12 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) extern MachineState *current_machine; +/** + * machine_class_default_cpu_type: Return the machine default CPU type. + * @mc: Machine class + */ +const char *machine_class_default_cpu_type(MachineClass *mc); + void machine_add_audiodev_property(MachineClass *mc); void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp); bool machine_usb(MachineState *machine); diff --git a/hw/core/machine.c b/hw/core/machine.c index 0c17398141..baf25c3fc5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1387,6 +1387,14 @@ out: return r; } +const char *machine_class_default_cpu_type(MachineClass *mc) +{ + if (mc->valid_cpu_types && !mc->valid_cpu_types[1]) { + /* Only a single CPU type allowed: use it as default. */ + return mc->valid_cpu_types[0]; + } + return mc->default_cpu_type; +} void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp) { diff --git a/system/vl.c b/system/vl.c index 5af7ced2a1..1c28162b21 100644 --- a/system/vl.c +++ b/system/vl.c @@ -3730,7 +3730,7 @@ void qemu_init(int argc, char **argv) migration_object_init(); /* parse features once if machine provides default cpu_type */ - current_machine->cpu_type = machine_class->default_cpu_type; + current_machine->cpu_type = machine_class_default_cpu_type(machine_class); if (cpu_option) { current_machine->cpu_type = parse_cpu_option(cpu_option); }