From nobody Mon Feb 9 18:18:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676281934; cv=none; d=zohomail.com; s=zohoarc; b=Sip8tfe9+t4cRoDZd4+/jJZxCbhdHbHDPtMk6EqD1FwOe6+78uDSOj7ZAscsysSWTF4+IAXXVClPUzT7f//NmS1uXCy/wygL0VXyEc+RIL+e7mTuoZd9eMog+CZ2PTZs85i+D94RMF0wz+4TsLr++WW47XhxaEb5js52EgNvxZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676281934; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DgNYbgmfooZT+pFhQteWSIXzSgXMxgsCJ+tsaL4cyVk=; b=QPeYy66E2vbz7W3bxhZ5G3DyW/6Kg4Qp64h9MkJBmOLYQ0qUA69/NsPNnjxvK421TqtiFlTEb1tIZHUNYZIrrqa6whldX/v7UBEi35H53Lz46acD2MT7NhrnBtf9SRPbSEy0IOOnsF6ATJW2OFuYTDo/iZxAr/gCwF8t5Xp2KZw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676281934498352.5607487170655; Mon, 13 Feb 2023 01:52:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRVQC-0002qU-2Y; Mon, 13 Feb 2023 04:46:52 -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 1pRVPw-0002F2-75 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:46:37 -0500 Received: from mga12.intel.com ([192.55.52.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRVPk-0002n2-SN for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:46:34 -0500 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:45:45 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by fmsmga007.fm.intel.com with ESMTP; 13 Feb 2023 01:45:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676281584; x=1707817584; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7e0HqmBGarsYKxE3WIICOxyMlzjga2EZEcRvyGGYmpE=; b=a4nKG/G7Xz4F4RhDW8jbikLdyMWG6+yvuYos3Pv+blBtW6P3AnH0Otuv H7GHhbAVvzUiAkEWAySrMB5Z8Cv+2RwkP0oYrJ3lgBXPi7ENYjcPVeNBv OPC69w7Dov0Cw1vScxqfTVVDTgaYLIyBEsxluyphcQ/mWYxIyDfFsUTCm CIe156jlKH+Dvhy2WDbZ8kMIoI+OU9u0Z//NdXmAMfWn7w6cSBd9Ho5yB 99dm/uPKvx6rjgHoNoHysk+LJbB7Iha9pyokH4gNU4V3N/gHvzco9qRGS Fhi2DQU5b90vD+/ScaQJyuBcsqthyYvimMV+36/iy2iuyJfzPuJssYAHd Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="310487143" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="310487143" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="670760647" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="670760647" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Sean Christopherson , Like Xu , Zhao Liu Subject: [RFC 41/52] machine: Introduce core_type() hook Date: Mon, 13 Feb 2023 17:50:24 +0800 Message-Id: <20230213095035.158240-42-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213095035.158240-1-zhao1.liu@linux.intel.com> References: <20230213095035.158240-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=192.55.52.136; envelope-from=zhao1.liu@linux.intel.com; helo=mga12.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676281936667100009 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Since supported core types are architecture specific, we need this hook to allow archs define its own parsing or validation method. As the example, add the x86 core_type() which will be used in "-hybrid" parameter parsing. Signed-off-by: Zhao Liu --- hw/core/machine-topo.c | 14 ++++++++++++++ hw/core/machine.c | 1 + hw/i386/x86.c | 15 +++++++++++++++ include/hw/boards.h | 7 +++++++ 4 files changed, 37 insertions(+) diff --git a/hw/core/machine-topo.c b/hw/core/machine-topo.c index 12c05510c1b5..f9ab08a1252e 100644 --- a/hw/core/machine-topo.c +++ b/hw/core/machine-topo.c @@ -352,3 +352,17 @@ void machine_parse_smp_config(MachineState *ms, return; } } + +/* + * machine_parse_hybrid_core_type: the default hook to parse hybrid core + * type corresponding to the coretype + * string option. + */ +int machine_parse_hybrid_core_type(MachineState *ms, const char *coretype) +{ + if (strcmp(coretype, "") =3D=3D 0 || strcmp(coretype, "none") =3D=3D 0= ) { + return 0; + } + + return -1; +} diff --git a/hw/core/machine.c b/hw/core/machine.c index fad990f49b03..acc32b3be5f6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -926,6 +926,7 @@ static void machine_class_init(ObjectClass *oc, void *d= ata) * On Linux, each node's border has to be 8MB aligned */ mc->numa_mem_align_shift =3D 23; + mc->core_type =3D machine_parse_hybrid_core_type; =20 object_class_property_add_str(oc, "kernel", machine_get_kernel, machine_set_kernel); diff --git a/hw/i386/x86.c b/hw/i386/x86.c index f381fdc43180..f58a90359170 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -1569,6 +1569,20 @@ static void machine_set_sgx_epc(Object *obj, Visitor= *v, const char *name, qapi_free_SgxEPCList(list); } =20 +static int x86_parse_hybrid_core_type(MachineState *ms, const char *corety= pe) +{ + X86HybridCoreType type; + + if (strcmp(coretype, "atom") =3D=3D 0) { + type =3D INTEL_ATOM_TYPE; + } else if (strcmp(coretype, "core") =3D=3D 0) { + type =3D INTEL_CORE_TYPE; + } else { + type =3D INVALID_HYBRID_TYPE; + } + return type; +} + static void x86_machine_initfn(Object *obj) { X86MachineState *x86ms =3D X86_MACHINE(obj); @@ -1596,6 +1610,7 @@ static void x86_machine_class_init(ObjectClass *oc, v= oid *data) x86mc->save_tsc_khz =3D true; x86mc->fwcfg_dma_enabled =3D true; nc->nmi_monitor_handler =3D x86_nmi; + mc->core_type =3D x86_parse_hybrid_core_type; =20 object_class_property_add(oc, X86_MACHINE_SMM, "OnOffAuto", x86_machine_get_smm, x86_machine_set_smm, diff --git a/include/hw/boards.h b/include/hw/boards.h index 9364c90d5f1a..34ec035b5c9f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -36,6 +36,7 @@ void machine_set_cpu_numa_node(MachineState *machine, Error **errp); void machine_parse_smp_config(MachineState *ms, const SMPConfiguration *config, Error **errp= ); +int machine_parse_hybrid_core_type(MachineState *ms, const char *coretype); =20 /** * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devic= es @@ -199,6 +200,11 @@ typedef struct { * Return the type of KVM corresponding to the kvm-type string option or * computed based on other criteria such as the host kernel capabilitie= s. * kvm-type may be NULL if it is not needed. + * @core_type: + * Return the type of hybrid cores corresponding to the coretype string + * option. The default hook only accept "none" or "" since the most gen= eric + * core topology should not specify any specific core type. Each arch c= an + * define its own core_type() hook to override the default one. * @numa_mem_supported: * true if '--numa node.mem' option is supported and false otherwise * @hotplug_allowed: @@ -237,6 +243,7 @@ struct MachineClass { void (*reset)(MachineState *state, ShutdownCause reason); void (*wakeup)(MachineState *state); int (*kvm_type)(MachineState *machine, const char *arg); + int (*core_type)(MachineState *state, const char *type); =20 BlockInterfaceType block_default_type; int units_per_default_bus; --=20 2.34.1