qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] i386: Minor fixes for building  CPUIDs
@ 2024-01-25  2:40 Xiaoyao Li
  2024-01-25  2:40 ` [PATCH v3 1/3] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Xiaoyao Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xiaoyao Li @ 2024-01-25  2:40 UTC (permalink / raw)
  To: Paolo Bonzini, Marcelo Tosatti; +Cc: qemu-devel, kvm, xiaoyao.li

The issue that fixed by Patch 1 looks fatal though it doesn't appear on
KVM because KVM always searches with assending order and hit with the
correct cpuid leaf 0.

Patch 2 removes the wrong constraint on CPUID leaf 1f.

Patch 3 fix the build of CPUID leaf 7.

Changes in v3:
- collect Reviewed-by tags;
- rebase to latest master branch
  4a4efae44f19 ("Merge tag 'pull-hex-20240121' of https://github.com/quic/qemu into staging")

v2:
https://lore.kernel.org/qemu-devel/20230613131929.720453-1-xiaoyao.li@intel.com/
Changes in v2:
- Add Patch 3;
- rebase to latest master branch

v1:
https://lore.kernel.org/qemu-devel/20220712021249.3227256-1-xiaoyao.li@intel.com/


Xiaoyao Li (3):
  i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F
  i386/cpuid: Remove subleaf constraint on CPUID leaf 1F
  i386/cpuid: Move leaf 7 to correct group

 target/i386/kvm/kvm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

-- 
2.34.1



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

* [PATCH v3 1/3] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F
  2024-01-25  2:40 [PATCH v3 0/3] i386: Minor fixes for building CPUIDs Xiaoyao Li
@ 2024-01-25  2:40 ` Xiaoyao Li
  2024-01-25  2:40 ` [PATCH v3 2/3] i386/cpuid: Remove subleaf constraint on " Xiaoyao Li
  2024-01-25  2:40 ` [PATCH v3 3/3] i386/cpuid: Move leaf 7 to correct group Xiaoyao Li
  2 siblings, 0 replies; 4+ messages in thread
From: Xiaoyao Li @ 2024-01-25  2:40 UTC (permalink / raw)
  To: Paolo Bonzini, Marcelo Tosatti; +Cc: qemu-devel, kvm, xiaoyao.li

Existing code misses a decrement of cpuid_i when skip leaf 0x1F.
There's a blank CPUID entry(with leaf, subleaf as 0, and all fields
stuffed 0s) left in the CPUID array.

It conflicts with correct CPUID leaf 0.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by:Yang Weijiang <weijiang.yang@intel.com>
---
 target/i386/kvm/kvm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 76a66246eb72..dff9dedbd761 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1914,6 +1914,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
         }
         case 0x1f:
             if (env->nr_dies < 2) {
+                cpuid_i--;
                 break;
             }
             /* fallthrough */
-- 
2.34.1



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

* [PATCH v3 2/3] i386/cpuid: Remove subleaf constraint on CPUID leaf 1F
  2024-01-25  2:40 [PATCH v3 0/3] i386: Minor fixes for building CPUIDs Xiaoyao Li
  2024-01-25  2:40 ` [PATCH v3 1/3] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Xiaoyao Li
@ 2024-01-25  2:40 ` Xiaoyao Li
  2024-01-25  2:40 ` [PATCH v3 3/3] i386/cpuid: Move leaf 7 to correct group Xiaoyao Li
  2 siblings, 0 replies; 4+ messages in thread
From: Xiaoyao Li @ 2024-01-25  2:40 UTC (permalink / raw)
  To: Paolo Bonzini, Marcelo Tosatti; +Cc: qemu-devel, kvm, xiaoyao.li

No such constraint that subleaf index needs to be less than 64.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by:Yang Weijiang <weijiang.yang@intel.com>
---
 target/i386/kvm/kvm.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index dff9dedbd761..9758c83693ec 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1926,10 +1926,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
                     break;
                 }
 
-                if (i == 0x1f && j == 64) {
-                    break;
-                }
-
                 c->function = i;
                 c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
                 c->index = j;
-- 
2.34.1



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

* [PATCH v3 3/3] i386/cpuid: Move leaf 7 to correct group
  2024-01-25  2:40 [PATCH v3 0/3] i386: Minor fixes for building CPUIDs Xiaoyao Li
  2024-01-25  2:40 ` [PATCH v3 1/3] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Xiaoyao Li
  2024-01-25  2:40 ` [PATCH v3 2/3] i386/cpuid: Remove subleaf constraint on " Xiaoyao Li
@ 2024-01-25  2:40 ` Xiaoyao Li
  2 siblings, 0 replies; 4+ messages in thread
From: Xiaoyao Li @ 2024-01-25  2:40 UTC (permalink / raw)
  To: Paolo Bonzini, Marcelo Tosatti; +Cc: qemu-devel, kvm, xiaoyao.li

CPUID leaf 7 was grouped together with SGX leaf 0x12 by commit
b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") by mistake.

SGX leaf 0x12 has its specific logic to check if subleaf (starting from 2)
is valid or not by checking the bit 0:3 of corresponding EAX is 1 or
not.

Leaf 7 follows the logic that EAX of subleaf 0 enumerates the maximum
valid subleaf.

Fixes: b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 target/i386/kvm/kvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 9758c83693ec..42970ab046fa 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1951,7 +1951,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
                 c = &cpuid_data.entries[cpuid_i++];
             }
             break;
-        case 0x7:
         case 0x12:
             for (j = 0; ; j++) {
                 c->function = i;
@@ -1971,6 +1970,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
                 c = &cpuid_data.entries[cpuid_i++];
             }
             break;
+        case 0x7:
         case 0x14:
         case 0x1d:
         case 0x1e: {
-- 
2.34.1



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

end of thread, other threads:[~2024-01-25  2:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25  2:40 [PATCH v3 0/3] i386: Minor fixes for building CPUIDs Xiaoyao Li
2024-01-25  2:40 ` [PATCH v3 1/3] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Xiaoyao Li
2024-01-25  2:40 ` [PATCH v3 2/3] i386/cpuid: Remove subleaf constraint on " Xiaoyao Li
2024-01-25  2:40 ` [PATCH v3 3/3] i386/cpuid: Move leaf 7 to correct group Xiaoyao Li

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