Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 24 additions & 23 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,40 @@ var (
)

func defaultCPUType() CPUType {
// x86_64 + TCG + max was previously unstable until 2021.
// https://bugzilla.redhat.com/show_bug.cgi?id=1999700
// https://bugs.launchpad.net/qemu/+bug/1748296
defaultX8664 := "max"
if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" {
// https://github.com/lima-vm/lima/pull/3487#issuecomment-2846253560
// > #931 intentionally prevented the code from setting it to max when running on Windows,
// > and kept it at qemu64.
//
// TODO: remove this if "max" works with the latest qemu
defaultX8664 = "qemu64"
}
cpuType := map[Arch]string{
AARCH64: "cortex-a76", // available since QEMU 7.1 (Aug 2022)
ARMV7L: "cortex-a7",
// Since https://github.com/lima-vm/lima/pull/494, we use qemu64 cpu for better emulation of x86_64.
X8664: "qemu64",
AARCH64: "max",
ARMV7L: "max",
X8664: defaultX8664,
RISCV64: "max",
S390X: "qemu", // FIXME: what is the right choice for s390x?
S390X: "max",
}
for arch := range cpuType {
if IsNativeArch(arch) && IsAccelOS() {
if HasHostCPU() {
cpuType[arch] = "host"
} else if HasMaxCPU() {
cpuType[arch] = "max"
}
}
if arch == X8664 && runtime.GOOS == "darwin" {
switch cpuType[arch] {
case "host", "max":
// disable AVX-512, since it requires trapping instruction faults in guest
// Enterprise Linux requires either v2 (SSE4) or v3 (AVX2), but not yet v4.
cpuType[arch] += ",-avx512vl"

// Disable pdpe1gb on Intel Mac
// https://github.com/lima-vm/lima/issues/1485
// https://stackoverflow.com/a/72863744/5167443
cpuType[arch] += ",-pdpe1gb"
}
// disable AVX-512, since it requires trapping instruction faults in guest
// Enterprise Linux requires either v2 (SSE4) or v3 (AVX2), but not yet v4.
cpuType[arch] += ",-avx512vl"

// Disable pdpe1gb on Intel Mac
// https://github.com/lima-vm/lima/issues/1485
// https://stackoverflow.com/a/72863744/5167443
cpuType[arch] += ",-pdpe1gb"
}
}
return cpuType
Expand Down Expand Up @@ -1273,11 +1279,6 @@ func HasHostCPU() bool {
return false
}

func HasMaxCPU() bool {
// windows: WHPX: Unexpected VP exit code 4
return HasHostCPU()
}

func IsNativeArch(arch Arch) bool {
nativeX8664 := arch == X8664 && runtime.GOARCH == "amd64"
nativeAARCH64 := arch == AARCH64 && runtime.GOARCH == "arm64"
Expand Down
7 changes: 4 additions & 3 deletions pkg/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
// Machine
switch *y.Arch {
case limayaml.X8664:
if strings.HasPrefix(cpu, "qemu64") && runtime.GOOS != "windows" {
switch accel {
case "tcg":
// use q35 machine with vmware io port disabled.
args = appendArgsIfNoConflict(args, "-machine", "q35,vmport=off")
// use tcg accelerator with multi threading with 512MB translation block size
Expand All @@ -559,10 +560,10 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
// This will disable CPU S3/S4 state.
args = append(args, "-global", "ICH9-LPC.disable_s3=1")
args = append(args, "-global", "ICH9-LPC.disable_s4=1")
} else if runtime.GOOS == "windows" && accel == "whpx" {
case "whpx":
// whpx: injection failed, MSI (0, 0) delivery: 0, dest_mode: 0, trigger mode: 0, vector: 0
args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel+",kernel-irqchip=off")
} else {
default:
args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel)
}
case limayaml.AARCH64:
Expand Down
6 changes: 0 additions & 6 deletions templates/_images/centos-stream-10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ firmware:
# CentOS Stream 10 still requires legacyBIOS
# https://issues.redhat.com/browse/CS-2672
legacyBIOS: true

cpuType:
# When emulating Intel on ARM hosts, Lima uses the "qemu64" CPU by default (https://github.com/lima-vm/lima/pull/494).
# However, CentOS Stream 10 kernel reboots indefinitely due to lack of the support for x86_64-v3 instructions.
# This issue is tracked in <https://github.com/lima-vm/lima/issues/3063>.
x86_64: "Haswell-v4"
8 changes: 4 additions & 4 deletions templates/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ os: null
# Setting of instructions is supported like this: "qemu64,+ssse3".
# 🟢 Builtin default: hard-coded arch map with type (see the output of `limactl info | jq .defaultTemplate.cpuType`)
cpuType:
# aarch64: "cortex-a76" # (or "host" when running on aarch64 host)
# armv7l: "cortex-a7" # (or "host" when running on armv7l host)
# riscv64: "rv64" # (or "host" when running on riscv64 host)
# x86_64: "qemu64" # (or "host,-pdpe1gb" when running on x86_64 host)
# aarch64: "max" # (or "host" when running on aarch64 host)
# armv7l: "max" # (or "host" when running on armv7l host)
# riscv64: "max" # (or "host" when running on riscv64 host)
# x86_64: "max" # (or "host" when running on x86_64 host; additional options are appended on Intel Mac)

rosetta:
# Enable Rosetta inside the VM; needs `vmType: vz`
Expand Down
Loading