From nobody Sat Nov 15 14:51:50 2025 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1751357176; cv=none; d=zohomail.com; s=zohoarc; b=DOkYmvw16S1tBlBZUDIkME/cEoBhB1TNJB6bbVXJ7loKi8agv/rDSefhb1YBynQZINkpjN5u/Swjmap4/3ZtVOThXWY4n7B7QyazYuL2tLwbBPebI7akZuWbYTLb1nMQbH/5PAIPAMnHC+/hDQDh+TJhL0H0RfsQki9LefhEPnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751357176; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Vl78HM3eYTjAMs+7gZ5L/6YgNLqEHbf2CqbHNqgRK0E=; b=lwqSs1T0ZYQ0TPkMcGcJay/8vpk3rykO7Qp5vNUTkRkXv5r89hdmeIYwYlHR0CO+QA4T5BACpNg0IdPt+2HckyP72awmWuGnlz98y2eyVpE8mOcyWUTLsUTkpnk376vcv3EaXDCBaBx/3z0Myq8n4V22fB/ejkqBCMpTnvNDAN8= 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 1751357176206854.5538996320282; Tue, 1 Jul 2025 01:06:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uWVza-00073R-C3; Tue, 01 Jul 2025 04:05:26 -0400 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 1uWVzW-0006y6-8Q for qemu-devel@nongnu.org; Tue, 01 Jul 2025 04:05:24 -0400 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uWVzO-000778-An for qemu-devel@nongnu.org; Tue, 01 Jul 2025 04:05:21 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2025 01:05:09 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by fmviesa003.fm.intel.com with ESMTP; 01 Jul 2025 01:05:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751357114; x=1782893114; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cduq3IksxQAC1VaVQiBD1YTkVkSCxY9jre/WCsJuYD8=; b=hAxDiOYSj32q7CBOgNxTj8VmsAsENm6ASbQA4YIGi6kdg0MslflOl9va N8dFGphjjjDrbezQncu06VyCdneiFdvDZDqOlbrxKNuMLt1ejljShGz9S utDze6aF1yRfBwL2Luqhr0Eoxoj0xFGf36RLGE5gOaYg2ZugRuMLYZTcr UTBmpyIFFDfDcmhq9DfNjojekO7kv5EtaeVtkJMnSJmzUvNYvQuLYrPEa AsTACBa4bVXtJrqov/d2GbevbGK1GhsOa68QkA6Sibwxdrd+0m4wWleRr jwurQmQSzAXufRBQzu0e/tbV9MXfnmdJ1ozpK7bRWqScSiGVDOTJjETAI w==; X-CSE-ConnectionGUID: uginMejkTuKXj6i5HFzg+A== X-CSE-MsgGUID: R0k2pgxLRbWdcDz98OkYXw== X-IronPort-AV: E=McAfee;i="6800,10657,11480"; a="64207667" X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="64207667" X-CSE-ConnectionGUID: 6zcu2EBoSsGltzjPAzgytw== X-CSE-MsgGUID: bCCNEiCAT/inlNIGP6ywDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="157726517" From: Xiaoyao Li To: Paolo Bonzini Cc: Zhao Liu , Cameron Esfahani , Roman Bolshakov , Phil Dennis-Jordan , Marcelo Tosatti , qemu-devel@nongnu.org, xiaoyao.li@intel.com Subject: [PATCH 1/2] i386/cpu: Rename host_cpu_instance_init() to apply_host_vendor() Date: Tue, 1 Jul 2025 15:57:37 +0800 Message-ID: <20250701075738.3451873-2-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701075738.3451873-1-xiaoyao.li@intel.com> References: <20250701075738.3451873-1-xiaoyao.li@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: pass client-ip=192.198.163.11; envelope-from=xiaoyao.li@intel.com; helo=mgamail.intel.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: 1751357179134116600 Content-Type: text/plain; charset="utf-8" The name of host_cpu_instance_init is really confusing. It misleads people to think it as the .instance_init() callback of "host" x86 cpu type. Rename it to match what it does and move the xcc->model check to callers since it's better to let host-cpu.c concentrate only on the host related functionalities. Signed-off-by: Xiaoyao Li --- target/i386/host-cpu.c | 12 ++++-------- target/i386/host-cpu.h | 2 +- target/i386/hvf/hvf-cpu.c | 5 ++++- target/i386/kvm/kvm-cpu.c | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/target/i386/host-cpu.c b/target/i386/host-cpu.c index 383c42d4ae3d..c86b8227b974 100644 --- a/target/i386/host-cpu.c +++ b/target/i386/host-cpu.c @@ -127,16 +127,12 @@ void host_cpu_vendor_fms(char *vendor, int *family, i= nt *model, int *stepping) } } =20 -void host_cpu_instance_init(X86CPU *cpu) +void apply_host_vendor(X86CPU *cpu) { - X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); + char vendor[CPUID_VENDOR_SZ + 1]; =20 - if (xcc->model) { - char vendor[CPUID_VENDOR_SZ + 1]; - - host_cpu_vendor_fms(vendor, NULL, NULL, NULL); - object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abor= t); - } + host_cpu_vendor_fms(vendor, NULL, NULL, NULL); + object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort); } =20 void host_cpu_max_instance_init(X86CPU *cpu) diff --git a/target/i386/host-cpu.h b/target/i386/host-cpu.h index b97ec01c9bec..779f0f2f4123 100644 --- a/target/i386/host-cpu.h +++ b/target/i386/host-cpu.h @@ -11,7 +11,7 @@ #define HOST_CPU_H =20 uint32_t host_cpu_phys_bits(void); -void host_cpu_instance_init(X86CPU *cpu); +void apply_host_vendor(X86CPU *cpu); void host_cpu_max_instance_init(X86CPU *cpu); bool host_cpu_realizefn(CPUState *cs, Error **errp); =20 diff --git a/target/i386/hvf/hvf-cpu.c b/target/i386/hvf/hvf-cpu.c index dfdda701268e..16647482aba0 100644 --- a/target/i386/hvf/hvf-cpu.c +++ b/target/i386/hvf/hvf-cpu.c @@ -61,8 +61,11 @@ static void hvf_cpu_xsave_init(void) static void hvf_cpu_instance_init(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); + X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); =20 - host_cpu_instance_init(cpu); + if (xcc->model) { + apply_host_vendor(cpu); + } =20 /* Special cases not set in the X86CPUDefinition structs: */ /* TODO: in-kernel irqchip for hvf */ diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 6df92dc6d703..99e4357d5efe 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -202,9 +202,9 @@ static void kvm_cpu_instance_init(CPUState *cs) X86CPU *cpu =3D X86_CPU(cs); X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); =20 - host_cpu_instance_init(cpu); - if (xcc->model) { + apply_host_vendor(cpu); + /* only applies to builtin_x86_defs cpus */ if (!kvm_irqchip_in_kernel()) { x86_cpu_change_kvm_default("x2apic", "off"); --=20 2.43.0