Skip to content

Commit c038c98

Browse files
committed
Fix #471: Improve x86_64 emulation on arm64 platform
This change will use qemu64 cpu for better emulation and add some extra parameters like tcg accel and force multi threading where multiple host threads will be used for vcpus according to qemu documentation. Added few more extra parameters which are used by UTM for better emulation of x86_64 Signed-off-by: Gayan Perera <[email protected]>
1 parent f290fa5 commit c038c98

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/qemu/qemu.go

+14-2
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)