Skip to content

Commit ad1142c

Browse files
authored
Merge pull request #494 from gayanper/patch-1
Fix #471: Improve x86_64 emulation on arm64 platform
2 parents 03b4ac1 + c038c98 commit ad1142c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/qemu/qemu.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,24 @@ func Cmdline(cfg Config) (string, []string, error) {
208208
}
209209
switch *y.Arch {
210210
case limayaml.X8664:
211-
cpu := "Haswell-v4"
211+
cpu := "qemu64"
212212
if isNativeArch(*y.Arch) {
213213
cpu = "host"
214214
}
215215
args = appendArgsIfNoConflict(args, "-cpu", cpu)
216-
args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel)
216+
if isNativeArch(*y.Arch) {
217+
args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel)
218+
} else {
219+
// use q35 machine with vmware io port disabled.
220+
args = appendArgsIfNoConflict(args, "-machine", "q35,vmport=off")
221+
// use tcg accelerator with multi threading with 512MB translation block size
222+
// https://qemu-project.gitlab.io/qemu/devel/multi-thread-tcg.html?highlight=tcg
223+
// https://qemu-project.gitlab.io/qemu/system/invocation.html?highlight=tcg%20opts
224+
// this will make sure each vCPU will be backed by 1 host user thread.
225+
args = appendArgsIfNoConflict(args, "-accel", "tcg,thread=multi,tb-size=512")
226+
// This will disable CPU S3 state.
227+
args = append(args, "-global", "ICH9-LPC.disable_s3=1")
228+
}
217229
case limayaml.AARCH64:
218230
cpu := "cortex-a72"
219231
if isNativeArch(*y.Arch) {

0 commit comments

Comments
 (0)