From: Claudio Fontana <cfontana@suse.de> To: "Peter Maydell" <peter.maydell@linaro.org>, "Paolo Bonzini" <pbonzini@redhat.com>, "Eduardo Habkost" <ehabkost@redhat.com>, "Siddharth Chandrasekaran" <sidcha@amazon.de>, "Philippe Mathieu-Daudé" <philmd@redhat.com> Cc: Claudio Fontana <cfontana@suse.de>, "Michael S . Tsirkin" <mst@redhat.com>, kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <r.bolshakov@yadro.com>, qemu-devel@nongnu.org Subject: [PATCH 1/2] i386: reorder call to cpu_exec_realizefn in x86_cpu_realizefn Date: Sat, 29 May 2021 11:13:12 +0200 [thread overview] Message-ID: <20210529091313.16708-2-cfontana@suse.de> (raw) In-Reply-To: <20210529091313.16708-1-cfontana@suse.de> we need to expand features first, before we attempt to check them in the accel realizefn code called by cpu_exec_realizefn(). At the same time we need checks for code_urev and host_cpuid_required, and modifications to cpu->mwait to happen after the initial setting of them inside the accel realizefn code. Partial Fix. Fixes: 48afe6e4eabf ("i386: split cpu accelerators from cpu.c, using AccelCPUClass") Signed-off-by: Claudio Fontana <cfontana@suse.de> --- target/i386/cpu.c | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9e211ac2ce..6bcb7dbc2c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6133,34 +6133,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) Error *local_err = NULL; static bool ht_warned; - /* Process Hyper-V enlightenments */ - x86_cpu_hyperv_realize(cpu); - - cpu_exec_realizefn(cs, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); - return; - } - - if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { - g_autofree char *name = x86_cpu_class_get_model_name(xcc); - error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name); - goto out; - } - - if (cpu->ucode_rev == 0) { - /* The default is the same as KVM's. */ - if (IS_AMD_CPU(env)) { - cpu->ucode_rev = 0x01000065; - } else { - cpu->ucode_rev = 0x100000000ULL; - } - } - - /* mwait extended info: needed for Core compatibility */ - /* We always wake on interrupt even if host does not have the capability */ - cpu->mwait.ecx |= CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; - if (cpu->apic_id == UNASSIGNED_APIC_ID) { error_setg(errp, "apic-id property was not initialized properly"); return; @@ -6190,6 +6162,34 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) & CPUID_EXT2_AMD_ALIASES); } + /* Process Hyper-V enlightenments */ + x86_cpu_hyperv_realize(cpu); + + cpu_exec_realizefn(cs, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } + + if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { + g_autofree char *name = x86_cpu_class_get_model_name(xcc); + error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name); + goto out; + } + + if (cpu->ucode_rev == 0) { + /* The default is the same as KVM's. */ + if (IS_AMD_CPU(env)) { + cpu->ucode_rev = 0x01000065; + } else { + cpu->ucode_rev = 0x100000000ULL; + } + } + + /* mwait extended info: needed for Core compatibility */ + /* We always wake on interrupt even if host does not have the capability */ + cpu->mwait.ecx |= CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; + /* For 64bit systems think about the number of physical bits to present. * ideally this should be the same as the host; anything other than matching * the host can cause incorrect guest behaviour. -- 2.26.2
WARNING: multiple messages have this Message-ID (diff)
From: Claudio Fontana <cfontana@suse.de> To: "Peter Maydell" <peter.maydell@linaro.org>, "Paolo Bonzini" <pbonzini@redhat.com>, "Eduardo Habkost" <ehabkost@redhat.com>, "Siddharth Chandrasekaran" <sidcha@amazon.de>, "Philippe Mathieu-Daudé" <philmd@redhat.com> Cc: kvm@vger.kernel.org, "Michael S . Tsirkin" <mst@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <r.bolshakov@yadro.com>, Claudio Fontana <cfontana@suse.de> Subject: [PATCH 1/2] i386: reorder call to cpu_exec_realizefn in x86_cpu_realizefn Date: Sat, 29 May 2021 11:13:12 +0200 [thread overview] Message-ID: <20210529091313.16708-2-cfontana@suse.de> (raw) In-Reply-To: <20210529091313.16708-1-cfontana@suse.de> we need to expand features first, before we attempt to check them in the accel realizefn code called by cpu_exec_realizefn(). At the same time we need checks for code_urev and host_cpuid_required, and modifications to cpu->mwait to happen after the initial setting of them inside the accel realizefn code. Partial Fix. Fixes: 48afe6e4eabf ("i386: split cpu accelerators from cpu.c, using AccelCPUClass") Signed-off-by: Claudio Fontana <cfontana@suse.de> --- target/i386/cpu.c | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9e211ac2ce..6bcb7dbc2c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6133,34 +6133,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) Error *local_err = NULL; static bool ht_warned; - /* Process Hyper-V enlightenments */ - x86_cpu_hyperv_realize(cpu); - - cpu_exec_realizefn(cs, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); - return; - } - - if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { - g_autofree char *name = x86_cpu_class_get_model_name(xcc); - error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name); - goto out; - } - - if (cpu->ucode_rev == 0) { - /* The default is the same as KVM's. */ - if (IS_AMD_CPU(env)) { - cpu->ucode_rev = 0x01000065; - } else { - cpu->ucode_rev = 0x100000000ULL; - } - } - - /* mwait extended info: needed for Core compatibility */ - /* We always wake on interrupt even if host does not have the capability */ - cpu->mwait.ecx |= CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; - if (cpu->apic_id == UNASSIGNED_APIC_ID) { error_setg(errp, "apic-id property was not initialized properly"); return; @@ -6190,6 +6162,34 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) & CPUID_EXT2_AMD_ALIASES); } + /* Process Hyper-V enlightenments */ + x86_cpu_hyperv_realize(cpu); + + cpu_exec_realizefn(cs, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } + + if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { + g_autofree char *name = x86_cpu_class_get_model_name(xcc); + error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name); + goto out; + } + + if (cpu->ucode_rev == 0) { + /* The default is the same as KVM's. */ + if (IS_AMD_CPU(env)) { + cpu->ucode_rev = 0x01000065; + } else { + cpu->ucode_rev = 0x100000000ULL; + } + } + + /* mwait extended info: needed for Core compatibility */ + /* We always wake on interrupt even if host does not have the capability */ + cpu->mwait.ecx |= CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; + /* For 64bit systems think about the number of physical bits to present. * ideally this should be the same as the host; anything other than matching * the host can cause incorrect guest behaviour. -- 2.26.2
next prev parent reply other threads:[~2021-05-29 9:13 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-29 9:13 [PATCH 0/2] Fixes for broken commit 48afe6e4eabf, Windows fails to boot Claudio Fontana 2021-05-29 9:13 ` Claudio Fontana 2021-05-29 9:13 ` Claudio Fontana [this message] 2021-05-29 9:13 ` [PATCH 1/2] i386: reorder call to cpu_exec_realizefn in x86_cpu_realizefn Claudio Fontana 2021-06-01 18:48 ` Eduardo Habkost 2021-06-01 18:48 ` Eduardo Habkost 2021-06-03 8:13 ` Claudio Fontana 2021-06-03 8:13 ` Claudio Fontana 2021-06-03 18:16 ` Eduardo Habkost 2021-06-03 18:16 ` Eduardo Habkost 2021-06-03 8:45 ` Vitaly Kuznetsov 2021-06-03 8:45 ` Vitaly Kuznetsov 2021-05-29 9:13 ` [PATCH 2/2] i386: run accel_cpu_instance_init as instance_post_init Claudio Fontana 2021-05-29 9:13 ` Claudio Fontana 2021-06-01 18:59 ` Eduardo Habkost 2021-06-01 18:59 ` Eduardo Habkost 2021-06-03 7:38 ` Claudio Fontana 2021-06-03 7:38 ` Claudio Fontana
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=20210529091313.16708-2-cfontana@suse.de \ --to=cfontana@suse.de \ --cc=dirty@apple.com \ --cc=ehabkost@redhat.com \ --cc=kvm@vger.kernel.org \ --cc=mst@redhat.com \ --cc=mtosatti@redhat.com \ --cc=pbonzini@redhat.com \ --cc=peter.maydell@linaro.org \ --cc=philmd@redhat.com \ --cc=qemu-devel@nongnu.org \ --cc=r.bolshakov@yadro.com \ --cc=richard.henderson@linaro.org \ --cc=sidcha@amazon.de \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.