From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: zhao1.liu@intel.com
Subject: Re: [PATCH 4/4] target/i386: move accel_cpu_instance_init to .instance_init
Date: Fri, 11 Jul 2025 10:26:44 +0800 [thread overview]
Message-ID: <3c4f798e-1519-459f-b142-07ca39cf738e@intel.com> (raw)
In-Reply-To: <20250711000603.438312-5-pbonzini@redhat.com>
On 7/11/2025 8:06 AM, Paolo Bonzini wrote:
> With the reordering of instance_post_init callbacks that is new in 10.1
> accel_cpu_instance_init must execute in .instance_init as is already
> the case for RISC-V. Otherwise, for example, setting the vendor
> property is broken when using KVM or Hypervisor.framework, because
> KVM sets it *after* the user's value is set by DeviceState's
> intance_post_init callback.
>
> Reported-by: Xiaoyao Li <xiaoyao.li@intel.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
BTW, the user's value of "pmu" and "invtsc" are still broken for TDX
case. tdx_cpu_instance_init() will always overwrite "pmu" and "invtsc"
even if users explicitly request a different value via "-cpu" option.
Will we leave it as intentional? or fix it as well?
> ---
> target/i386/cpu.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 46d59229200..5f95bb97b82 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -6207,8 +6207,8 @@ static void max_x86_cpu_initfn(Object *obj)
> CPUX86State *env = &cpu->env;
>
> /*
> - * these defaults are used for TCG, other accelerators overwrite these
> - * values
> + * these defaults are used for TCG, other accelerators have overwritten
> + * these values
> */
> if (!env->cpuid_vendor1) {
> object_property_set_str(OBJECT(cpu), "vendor", CPUID_VENDOR_AMD,
> @@ -9043,8 +9043,6 @@ static void x86_cpu_post_initfn(Object *obj)
> }
> }
>
> - accel_cpu_instance_init(CPU(obj));
> -
> #ifndef CONFIG_USER_ONLY
> if (current_machine && current_machine->cgs) {
> x86_confidential_guest_cpu_instance_init(
> @@ -9119,6 +9117,8 @@ static void x86_cpu_initfn(Object *obj)
> if (xcc->model) {
> x86_cpu_load_model(cpu, xcc->model);
> }
> +
> + accel_cpu_instance_init(CPU(obj));
> }
>
> static int64_t x86_cpu_get_arch_id(CPUState *cs)
next prev parent reply other threads:[~2025-07-11 2:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 0:05 [PATCH 0/4] target/i386: fix position of accel_cpu_instance_init Paolo Bonzini
2025-07-11 0:06 ` [PATCH 1/4] target/i386: move max_features to class Paolo Bonzini
2025-07-11 1:52 ` Xiaoyao Li
2025-07-11 3:43 ` Zhao Liu
2025-07-11 0:06 ` [PATCH 2/4] target/i386: nvmm, whpx: add accel/CPU class that sets host vendor Paolo Bonzini
2025-07-11 2:12 ` Xiaoyao Li
2025-07-11 2:17 ` Xiaoyao Li
2025-07-11 6:35 ` Paolo Bonzini
2025-07-11 6:40 ` Xiaoyao Li
2025-07-11 7:46 ` Paolo Bonzini
2025-07-11 5:36 ` Zhao Liu
2025-07-11 0:06 ` [PATCH 3/4] target/i386: allow reordering max_x86_cpu_initfn vs accel CPU init Paolo Bonzini
2025-07-11 2:20 ` Xiaoyao Li
2025-07-11 6:08 ` Zhao Liu
2025-07-11 0:06 ` [PATCH 4/4] target/i386: move accel_cpu_instance_init to .instance_init Paolo Bonzini
2025-07-11 2:26 ` Xiaoyao Li [this message]
2025-07-11 6:37 ` Paolo Bonzini
2025-07-11 6:32 ` Zhao Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c4f798e-1519-459f-b142-07ca39cf738e@intel.com \
--to=xiaoyao.li@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).