[PATCH] target/i386/cpu: Use the KVM reported value for the number of ASIDs

Like Xu posted 1 patch 2 years, 9 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210715103945.95004-1-likexu@tencent.com
target/i386/cpu.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
[PATCH] target/i386/cpu: Use the KVM reported value for the number of ASIDs
Posted by Like Xu 2 years, 9 months ago
From: Like Xu <likexu@tencent.com>

If KVM is enabled, use the supported number of address space identifiers
(ASIDs) by the CPUID Fn8000_000A_EBX instead of hard-coding it to 0x10.

Signed-off-by: Like Xu <likexu@tencent.com>
---
 target/i386/cpu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 48b55ebd0a..959c4425a4 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -5523,7 +5523,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
     case 0x8000000A:
         if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) {
             *eax = 0x00000001; /* SVM Revision */
-            *ebx = 0x00000010; /* nr of ASIDs */
+            /* nr of ASIDs */
+            if (kvm_enabled()) {
+                *ebx = kvm_arch_get_supported_cpuid(cs->kvm_state,
+                                                    0x8000000A, 0, R_EBX);
+            } else {
+                *ebx = 0x00000010;
+            }
             *ecx = 0;
             *edx = env->features[FEAT_SVM]; /* optional features */
         } else {
-- 
2.32.0