@@ -61,34 +61,40 @@ var (
6161)
6262
6363func defaultCPUType () CPUType {
64+ // x86_64 + TCG + max was previously unstable until 2021.
65+ // https://bugzilla.redhat.com/show_bug.cgi?id=1999700
66+ // https://bugs.launchpad.net/qemu/+bug/1748296
67+ defaultX8664 := "max"
68+ if runtime .GOOS == "windows" && runtime .GOARCH == "amd64" {
69+ // https://github.com/lima-vm/lima/pull/3487#issuecomment-2846253560
70+ // > #931 intentionally prevented the code from setting it to max when running on Windows,
71+ // > and kept it at qemu64.
72+ //
73+ // TODO: remove this if "max" works with the latest qemu
74+ defaultX8664 = "qemu64"
75+ }
6476 cpuType := map [Arch ]string {
65- AARCH64 : "cortex-a76" , // available since QEMU 7.1 (Aug 2022)
66- ARMV7L : "cortex-a7" ,
67- // Since https://github.com/lima-vm/lima/pull/494, we use qemu64 cpu for better emulation of x86_64.
68- X8664 : "qemu64" ,
77+ AARCH64 : "max" ,
78+ ARMV7L : "max" ,
79+ X8664 : defaultX8664 ,
6980 RISCV64 : "max" ,
70- S390X : "qemu" , // FIXME: what is the right choice for s390x?
81+ S390X : "max" ,
7182 }
7283 for arch := range cpuType {
7384 if IsNativeArch (arch ) && IsAccelOS () {
7485 if HasHostCPU () {
7586 cpuType [arch ] = "host"
76- } else if HasMaxCPU () {
77- cpuType [arch ] = "max"
7887 }
7988 }
8089 if arch == X8664 && runtime .GOOS == "darwin" {
81- switch cpuType [arch ] {
82- case "host" , "max" :
83- // disable AVX-512, since it requires trapping instruction faults in guest
84- // Enterprise Linux requires either v2 (SSE4) or v3 (AVX2), but not yet v4.
85- cpuType [arch ] += ",-avx512vl"
86-
87- // Disable pdpe1gb on Intel Mac
88- // https://github.com/lima-vm/lima/issues/1485
89- // https://stackoverflow.com/a/72863744/5167443
90- cpuType [arch ] += ",-pdpe1gb"
91- }
90+ // disable AVX-512, since it requires trapping instruction faults in guest
91+ // Enterprise Linux requires either v2 (SSE4) or v3 (AVX2), but not yet v4.
92+ cpuType [arch ] += ",-avx512vl"
93+
94+ // Disable pdpe1gb on Intel Mac
95+ // https://github.com/lima-vm/lima/issues/1485
96+ // https://stackoverflow.com/a/72863744/5167443
97+ cpuType [arch ] += ",-pdpe1gb"
9298 }
9399 }
94100 return cpuType
@@ -1273,11 +1279,6 @@ func HasHostCPU() bool {
12731279 return false
12741280}
12751281
1276- func HasMaxCPU () bool {
1277- // windows: WHPX: Unexpected VP exit code 4
1278- return HasHostCPU ()
1279- }
1280-
12811282func IsNativeArch (arch Arch ) bool {
12821283 nativeX8664 := arch == X8664 && runtime .GOARCH == "amd64"
12831284 nativeAARCH64 := arch == AARCH64 && runtime .GOARCH == "arm64"
0 commit comments