qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG
@ 2025-05-14  3:16 Xiaoyao Li
  2025-05-14  3:16 ` [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported Xiaoyao Li
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Xiaoyao Li @ 2025-05-14  3:16 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Zhao Liu, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
	qemu-devel, Xiaoyao Li

Starting from QEMU v10.0.0, QEMU hits warnings when vcpus >= 2 with TCG

 qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
 qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.80000001H:ECX.cmp-legacy [bit 1]

For HVF, it should have the same warning of CPUID.01H:EDX.ht [bit 28].

This series tries to fix them.

Xiaoyao Li (2):
  i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported
  i386/hvf: Make CPUID_HT supported

 target/i386/cpu.c           | 8 +++++---
 target/i386/hvf/x86_cpuid.c | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported
  2025-05-14  3:16 [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG Xiaoyao Li
@ 2025-05-14  3:16 ` Xiaoyao Li
  2025-05-15  7:53   ` Zhao Liu
  2025-05-14  3:16 ` [PATCH 2/2] i386/hvf: Make CPUID_HT supported Xiaoyao Li
  2025-05-22 11:27 ` [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG Michael Tokarev
  2 siblings, 1 reply; 7+ messages in thread
From: Xiaoyao Li @ 2025-05-14  3:16 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Zhao Liu, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
	qemu-devel, Xiaoyao Li

Since commit c6bd2dd63420 ("i386/cpu: Set up CPUID_HT in
x86_cpu_expand_features() instead of cpu_x86_cpuid()") and
commit 99a637a86f55 ("i386/cpu: Set and track CPUID_EXT3_CMP_LEG in
env->features[FEAT_8000_0001_ECX]"), it gets warnings when booting the
VM with vcpus >= 2 and with tcg:

  qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
  qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.80000001H:ECX.cmp-legacy [bit 1]

This is because, after the two commits, CPUID_HT and CPUID_EXT3_CMP_LEG
are set in env->features[] when vcpus >=2 (in x86_cpu_expand_features())
later in x86_cpu_filter_features() it will check against the TCG supported
bits. However, current TCG doesn't mark the two bits as supported, hence
the warnings.

Fix it by adding the two bits to the supported bits of TCG since multiple
vcpus are supported by TCG.

Fixes: c6bd2dd63420 ("i386/cpu: Set up CPUID_HT in x86_cpu_expand_features() instead of cpu_x86_cpuid()")
Fixes: 99a637a86f55 ("i386/cpu: Set and track CPUID_EXT3_CMP_LEG in env->features[FEAT_8000_0001_ECX]")
Reported-by: Ewan Hai <ewanhai-oc@zhaoxin.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 target/i386/cpu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 1ca6307c72ef..c5a1fe1e8afe 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -776,11 +776,12 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
           CPUID_PAE | CPUID_MCE | CPUID_CX8 | CPUID_APIC | CPUID_SEP | \
           CPUID_MTRR | CPUID_PGE | CPUID_MCA | CPUID_CMOV | CPUID_PAT | \
           CPUID_PSE36 | CPUID_CLFLUSH | CPUID_ACPI | CPUID_MMX | \
-          CPUID_FXSR | CPUID_SSE | CPUID_SSE2 | CPUID_SS | CPUID_DE)
+          CPUID_FXSR | CPUID_SSE | CPUID_SSE2 | CPUID_SS | CPUID_DE | \
+          CPUID_HT)
           /* partly implemented:
           CPUID_MTRR, CPUID_MCA, CPUID_CLFLUSH (needed for Win64) */
           /* missing:
-          CPUID_VME, CPUID_DTS, CPUID_SS, CPUID_HT, CPUID_TM, CPUID_PBE */
+          CPUID_VME, CPUID_DTS, CPUID_SS, CPUID_TM, CPUID_PBE */
 
 /*
  * Kernel-only features that can be shown to usermode programs even if
@@ -848,7 +849,8 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
 
 #define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \
           CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A | \
-          CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_KERNEL_FEATURES)
+          CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_KERNEL_FEATURES | \
+          CPUID_EXT3_CMP_LEG)
 
 #define TCG_EXT4_FEATURES 0
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] i386/hvf: Make CPUID_HT supported
  2025-05-14  3:16 [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG Xiaoyao Li
  2025-05-14  3:16 ` [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported Xiaoyao Li
@ 2025-05-14  3:16 ` Xiaoyao Li
  2025-05-15  8:17   ` Zhao Liu
  2025-05-22 11:27 ` [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG Michael Tokarev
  2 siblings, 1 reply; 7+ messages in thread
From: Xiaoyao Li @ 2025-05-14  3:16 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Zhao Liu, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
	qemu-devel, Xiaoyao Li

Since Commit c6bd2dd63420 ("i386/cpu: Set up CPUID_HT in
x86_cpu_expand_features() instead of cpu_x86_cpuid()"), CPUID_HT will be
set in env->features[] in x86_cpu_expand_features() when vcpus >= 2.

Later in x86_cpu_filter_features() it will check against the HVF
supported bits. It will trigger the warning like

    qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]

Add CPUID_HT to HVF supported CPUID bits to fix it.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
Note, the issue is totally by my analysis (which should be the same as
the TCG warnings) because I don't have HVF environment to verify it.

If would be helpful if anyone can help reproduce it and test the patch
in HVF environment.
---
 target/i386/hvf/x86_cpuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/hvf/x86_cpuid.c b/target/i386/hvf/x86_cpuid.c
index fa131b18c6d1..0798a0cbafb9 100644
--- a/target/i386/hvf/x86_cpuid.c
+++ b/target/i386/hvf/x86_cpuid.c
@@ -73,7 +73,7 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
              CPUID_MSR | CPUID_PAE | CPUID_MCE | CPUID_CX8 | CPUID_APIC |
              CPUID_SEP | CPUID_MTRR | CPUID_PGE | CPUID_MCA | CPUID_CMOV |
              CPUID_PAT | CPUID_PSE36 | CPUID_CLFLUSH | CPUID_MMX |
-             CPUID_FXSR | CPUID_SSE | CPUID_SSE2 | CPUID_SS;
+             CPUID_FXSR | CPUID_SSE | CPUID_SSE2 | CPUID_SS | CPUID_HT;
         ecx &= CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSSE3 |
              CPUID_EXT_FMA | CPUID_EXT_CX16 | CPUID_EXT_PCID |
              CPUID_EXT_SSE41 | CPUID_EXT_SSE42 | CPUID_EXT_MOVBE |
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported
  2025-05-14  3:16 ` [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported Xiaoyao Li
@ 2025-05-15  7:53   ` Zhao Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Zhao Liu @ 2025-05-15  7:53 UTC (permalink / raw)
  To: Xiaoyao Li
  Cc: Paolo Bonzini, Cameron Esfahani, Roman Bolshakov,
	Phil Dennis-Jordan, qemu-devel

On Tue, May 13, 2025 at 11:16:51PM -0400, Xiaoyao Li wrote:
> Date: Tue, 13 May 2025 23:16:51 -0400
> From: Xiaoyao Li <xiaoyao.li@intel.com>
> Subject: [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG
>  supported
> X-Mailer: git-send-email 2.43.0
> 
> Since commit c6bd2dd63420 ("i386/cpu: Set up CPUID_HT in
> x86_cpu_expand_features() instead of cpu_x86_cpuid()") and
> commit 99a637a86f55 ("i386/cpu: Set and track CPUID_EXT3_CMP_LEG in
> env->features[FEAT_8000_0001_ECX]"), it gets warnings when booting the
> VM with vcpus >= 2 and with tcg:
> 
>   qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
>   qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.80000001H:ECX.cmp-legacy [bit 1]
> 
> This is because, after the two commits, CPUID_HT and CPUID_EXT3_CMP_LEG
> are set in env->features[] when vcpus >=2 (in x86_cpu_expand_features())
> later in x86_cpu_filter_features() it will check against the TCG supported
> bits. However, current TCG doesn't mark the two bits as supported, hence
> the warnings.
> 
> Fix it by adding the two bits to the supported bits of TCG since multiple
> vcpus are supported by TCG.
> 
> Fixes: c6bd2dd63420 ("i386/cpu: Set up CPUID_HT in x86_cpu_expand_features() instead of cpu_x86_cpuid()")
> Fixes: 99a637a86f55 ("i386/cpu: Set and track CPUID_EXT3_CMP_LEG in env->features[FEAT_8000_0001_ECX]")
> Reported-by: Ewan Hai <ewanhai-oc@zhaoxin.com>

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2894

Then QEMU gitlab can track this fix.

> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>  target/i386/cpu.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Both HT and CMPLegacy depend on CPU topology (mutiple threads per
package), therefore, there's no need for extra work in TCG.

So,

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] i386/hvf: Make CPUID_HT supported
  2025-05-14  3:16 ` [PATCH 2/2] i386/hvf: Make CPUID_HT supported Xiaoyao Li
@ 2025-05-15  8:17   ` Zhao Liu
  2025-05-16  3:17     ` Zhao Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Zhao Liu @ 2025-05-15  8:17 UTC (permalink / raw)
  To: Xiaoyao Li
  Cc: Paolo Bonzini, Cameron Esfahani, Roman Bolshakov,
	Phil Dennis-Jordan, qemu-devel

On Tue, May 13, 2025 at 11:16:52PM -0400, Xiaoyao Li wrote:
> Date: Tue, 13 May 2025 23:16:52 -0400
> From: Xiaoyao Li <xiaoyao.li@intel.com>
> Subject: [PATCH 2/2] i386/hvf: Make CPUID_HT supported
> X-Mailer: git-send-email 2.43.0
> 
> Since Commit c6bd2dd63420 ("i386/cpu: Set up CPUID_HT in
> x86_cpu_expand_features() instead of cpu_x86_cpuid()"), CPUID_HT will be
> set in env->features[] in x86_cpu_expand_features() when vcpus >= 2.
> 
> Later in x86_cpu_filter_features() it will check against the HVF
> supported bits. It will trigger the warning like
> 
>     qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
> 
> Add CPUID_HT to HVF supported CPUID bits to fix it.
> 
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
> Note, the issue is totally by my analysis (which should be the same as
> the TCG warnings) because I don't have HVF environment to verify it.
> 
> If would be helpful if anyone can help reproduce it and test the patch
> in HVF environment.

Ah, I found someone has reported a bug on HVF. In his log, there's the
ht warning:

https://gitlab.com/qemu-project/qemu/-/issues/2938

But I don't know if this fix can help on his bug...let's wait for his
feedback.

> ---
>  target/i386/hvf/x86_cpuid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Anyway, this fix is fine for me, so,

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] i386/hvf: Make CPUID_HT supported
  2025-05-15  8:17   ` Zhao Liu
@ 2025-05-16  3:17     ` Zhao Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Zhao Liu @ 2025-05-16  3:17 UTC (permalink / raw)
  To: Xiaoyao Li
  Cc: Paolo Bonzini, Cameron Esfahani, Roman Bolshakov,
	Phil Dennis-Jordan, qemu-devel

On Thu, May 15, 2025 at 04:17:28PM +0800, Zhao Liu wrote:
> Date: Thu, 15 May 2025 16:17:28 +0800
> From: Zhao Liu <zhao1.liu@intel.com>
> Subject: Re: [PATCH 2/2] i386/hvf: Make CPUID_HT supported
> 
> On Tue, May 13, 2025 at 11:16:52PM -0400, Xiaoyao Li wrote:
> > Date: Tue, 13 May 2025 23:16:52 -0400
> > From: Xiaoyao Li <xiaoyao.li@intel.com>
> > Subject: [PATCH 2/2] i386/hvf: Make CPUID_HT supported
> > X-Mailer: git-send-email 2.43.0
> > 
> > Since Commit c6bd2dd63420 ("i386/cpu: Set up CPUID_HT in
> > x86_cpu_expand_features() instead of cpu_x86_cpuid()"), CPUID_HT will be
> > set in env->features[] in x86_cpu_expand_features() when vcpus >= 2.
> > 
> > Later in x86_cpu_filter_features() it will check against the HVF
> > supported bits. It will trigger the warning like
> > 
> >     qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
> > 
> > Add CPUID_HT to HVF supported CPUID bits to fix it.
> > 
> > Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> > ---
> > Note, the issue is totally by my analysis (which should be the same as
> > the TCG warnings) because I don't have HVF environment to verify it.
> > 
> > If would be helpful if anyone can help reproduce it and test the patch
> > in HVF environment.
> 
> Ah, I found someone has reported a bug on HVF. In his log, there's the
> ht warning:
> 
> https://gitlab.com/qemu-project/qemu/-/issues/2938
> 
> But I don't know if this fix can help on his bug...let's wait for his
> feedback.

Amitai has confirmed this fix can resolve #2938. So I think it's
necessary to add the tag:

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2938

and CC this series to qemu-stable@nongnu.org.

Thanks,
Zhao

> > ---
> >  target/i386/hvf/x86_cpuid.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Anyway, this fix is fine for me, so,
> 
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG
  2025-05-14  3:16 [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG Xiaoyao Li
  2025-05-14  3:16 ` [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported Xiaoyao Li
  2025-05-14  3:16 ` [PATCH 2/2] i386/hvf: Make CPUID_HT supported Xiaoyao Li
@ 2025-05-22 11:27 ` Michael Tokarev
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2025-05-22 11:27 UTC (permalink / raw)
  To: Xiaoyao Li, Paolo Bonzini
  Cc: Zhao Liu, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
	qemu-devel

On 14.05.2025 06:16, Xiaoyao Li wrote:
> Starting from QEMU v10.0.0, QEMU hits warnings when vcpus >= 2 with TCG
> 
>   qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
>   qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.80000001H:ECX.cmp-legacy [bit 1]
> 
> For HVF, it should have the same warning of CPUID.01H:EDX.ht [bit 28].
> 
> This series tries to fix them.
> 
> Xiaoyao Li (2):
>    i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported
>    i386/hvf: Make CPUID_HT supported

This seems to be a qemu-stable material (10.0).
Applied to staging-10.0, please let me know if I shouldn't.

Thanks,

/mjt


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-05-22 11:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-14  3:16 [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG Xiaoyao Li
2025-05-14  3:16 ` [PATCH 1/2] i386/tcg: Make CPUID_HT and CPUID_EXT3_CMP_LEG supported Xiaoyao Li
2025-05-15  7:53   ` Zhao Liu
2025-05-14  3:16 ` [PATCH 2/2] i386/hvf: Make CPUID_HT supported Xiaoyao Li
2025-05-15  8:17   ` Zhao Liu
2025-05-16  3:17     ` Zhao Liu
2025-05-22 11:27 ` [PATCH 0/2] Fixes for TCG/HVF warning of CPUID_HT and CPUID_EXT3_CMP_LEG Michael Tokarev

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).