Skip to contentSkip to conversation

microvm: do not use the lastest cpu version

PATCH Superseded Ani Sinha 3 participants 3 messages Feb 13, 2025 – Feb 19, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ani Sinha

author
#0 lore raw

PATCH 1/1 microvm: do not use the lastest cpu version

Microvm machines are not versioned and therefore there is no requirement to use the latest cpu model by default. Let microvms use the non-versioned cpu model. Those users who need spefific cpu versions can use explicit commandline to select the cpu version desired.

---
 hw/i386/microvm.c |  2 +-
 target/i386/cpu.c | 15 ---------------
 target/i386/cpu.h |  4 ----
 3 files changed, 1 insertion(+), 20 deletions(-)

Pipeline passes:
https://gitlab.com/anisinha/qemu/-/pipelines/1669159835
See also Igor's comment on
https://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

hw/i386/microvm.c +1 -1
index a8d354aabe..b8be1542ff 100644
@@ -458,7 +458,7 @@ static void microvm_machine_state_init(MachineState *machine)
 
     microvm_memory_init(mms);
 
-    x86_cpus_init(x86ms, CPU_VERSION_LATEST);
+    x86_cpus_init(x86ms, 1);
 
     microvm_devices_init(mms);
 }
target/i386/cpu.c +0 -15
index b5dd60d281..6d251c0025 100644
@@ -5513,18 +5513,6 @@ void x86_cpu_set_default_version(X86CPUVersion version)
     default_cpu_version = version;
 }
 
-static X86CPUVersion x86_cpu_model_last_version(const X86CPUModel *model)
-{
-    int v = 0;
-    const X86CPUVersionDefinition *vdef =
-        x86_cpu_def_get_versions(model->cpudef);
-    while (vdef->version) {
-        v = vdef->version;
-        vdef++;
-    }
-    return v;
-}
-
 /* Return the actual version being used for a specific CPU model */
 static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model)
 {
@@ -5532,9 +5520,6 @@ static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model)
     if (v == CPU_VERSION_AUTO) {
         v = default_cpu_version;
     }
-    if (v == CPU_VERSION_LATEST) {
-        return x86_cpu_model_last_version(model);
-    }
     return v;
 }
 
target/i386/cpu.h +0 -4
index c67b42d34f..71f150a05f 100644
@@ -2701,10 +2701,6 @@ void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip,
                                    TPRAccess access);
 
 /* Special values for X86CPUVersion: */
-
-/* Resolve to latest CPU version */
-#define CPU_VERSION_LATEST -1
-
 /*
  * Resolve to version defined by current machine type.
  * See x86_cpu_set_default_version()
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · On Thu, 13 Feb 2025 15:11:00 +0530 Ani Sinha <[email protected]> wrote:

Microvm machines are not versioned and therefore there is no requirement to use the latest cpu model by default. Let microvms use the non-versioned cpu model. Those users who need spefific cpu versions can use explicit commandline to select the cpu version desired.

Above says why we can do this but,
I'd also add here a reason why we are doing that to begin with.

Quoted 4 lines
Quoted 72 lines
---
 hw/i386/microvm.c |  2 +-
 target/i386/cpu.c | 15 ---------------
 target/i386/cpu.h |  4 ----
 3 files changed, 1 insertion(+), 20 deletions(-)

Pipeline passes:
https://gitlab.com/anisinha/qemu/-/pipelines/1669159835
See also Igor's comment on
https://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

hw/i386/microvm.c +1 -1
index a8d354aabe..b8be1542ff 100644
@@ -458,7 +458,7 @@ static void microvm_machine_state_init(MachineState *machine)
 
     microvm_memory_init(mms);
 
-    x86_cpus_init(x86ms, CPU_VERSION_LATEST);
+    x86_cpus_init(x86ms, 1);
 
     microvm_devices_init(mms);
 }
target/i386/cpu.c +0 -15
index b5dd60d281..6d251c0025 100644
@@ -5513,18 +5513,6 @@ void x86_cpu_set_default_version(X86CPUVersion version)
     default_cpu_version = version;
 }
 
-static X86CPUVersion x86_cpu_model_last_version(const X86CPUModel *model)
-{
-    int v = 0;
-    const X86CPUVersionDefinition *vdef =
-        x86_cpu_def_get_versions(model->cpudef);
-    while (vdef->version) {
-        v = vdef->version;
-        vdef++;
-    }
-    return v;
-}
-
 /* Return the actual version being used for a specific CPU model */
 static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model)
 {
@@ -5532,9 +5520,6 @@ static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model)
     if (v == CPU_VERSION_AUTO) {
         v = default_cpu_version;
     }
-    if (v == CPU_VERSION_LATEST) {
-        return x86_cpu_model_last_version(model);
-    }
     return v;
 }
 
target/i386/cpu.h +0 -4
index c67b42d34f..71f150a05f 100644
@@ -2701,10 +2701,6 @@ void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip,
                                    TPRAccess access);
 
 /* Special values for X86CPUVersion: */
-
-/* Resolve to latest CPU version */
-#define CPU_VERSION_LATEST -1
-
 /*
  * Resolve to version defined by current machine type.
  * See x86_cpu_set_default_version()
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ani Sinha
Quoted 5 lines · Ani Sinha

Microvm machines are not versioned and therefore there is no requirement to use the latest cpu model by default. Let microvms use the non-versioned cpu model. Those users who need spefific cpu versions can use explicit commandline to select the cpu version desired.

Quoted 8 lines
---
 hw/i386/microvm.c |  2 +-
 target/i386/cpu.c | 15 ---------------
 target/i386/cpu.h |  4 ----
 3 files changed, 1 insertion(+), 20 deletions(-)