utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
27.07k stars 1.34k forks source link

The UTM(JIT) cannot be set to '-accel tcg,tb-size=256,split-wx=off', otherwise it will crash? #6632

Closed huanggui closed 2 months ago

huanggui commented 2 months ago

Describe the issue After setting the UTM qemu runtime parameters to '-accel tcg,tb-size=256,split-wx=off', a crash will occur: qemu-i386-softmmu: -accel tcg,tb-size=256,split-wx=off: allocate 268435456 bytes for jit buffer: Invalid argument.

Configuration (required)

Crash log 2024-08-28 10:06:31.834004+0800 UTM[7008:2790562] [QEMULogging(0x280180a40)] Launching: qemu-system-i386 -L /private/var/containers/Bundle/Application/87791EB4-B539-47AF-92C5-F90CA85A14B2/UTM.app/qemu -S -spice unix=on,addr=76D18910-E5B6-4859-8845-3DB263A94ABA.spice,disable-ticketing=on,image-compression=off,playback-compression=off,streaming-video=off,gl=off -chardev spiceport,name=org.qemu.monitor.qmp.0,id=org.qemu.monitor.qmp -mon chardev=org.qemu.monitor.qmp,mode=control -nodefaults -vga none -device rtl8139,mac=C2:12:D2:8C:9C:29,netdev=net0 -netdev user,id=net0 -device qxl-vga -smp cpus=4,sockets=1,cores=4,threads=1 -machine pc,vmport=off,hpet=off -accel tcg,tb-size=256,split-wx=off -global PIIX4_PM.disable_s3=1 -global ICH9-LPC.disable_s3=1 -m 1024 -audiodev spice,id=audio0 -device AC97,audiodev=audio0 -usb -device usb-tablet,bus=usb-bus.0 -device usb-mouse,bus=usb-bus.0 -device usb-kbd,bus=usb-bus.0 -device ich9-usb-ehci1,id=usb-controller-0 -device ich9-usb-uhci1,masterbus=usb-controller-0.0,firstport=0,multifunction=on -device ich9-usb-uhci2,masterbus=usb-controller-0.0,firstport=2,multifunction=on -device ich9-usb-uhci3,masterbus=usb-controller-0.0,firstport=4,multifunction=on -chardev spicevmc,name=usbredir,id=usbredirchardev0 -device usb-redir,chardev=usbredirchardev0,id=usbredirdev0,bus=usb-controller-0.0 -chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=usb-controller-0.0 -chardev spicevmc,name=usbredir,id=usbredirchardev2 -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2,bus=usb-controller-0.0 -device ide-hd,bus=ide.0,drive=drive0,bootindex=0 -drive "if=none,media=disk,id=drive0,file=/private/var/mobile/Containers/Data/Application/10D06309-1895-446D-BEBB-C87871750260/Documents/Android 4.4.utm/Images/android-4.4.qcow2,discard=unmap,detect-zeroes=unmap" -device virtio-serial -device virtserialport,chardev=org.qemu.guest_agent,name=org.qemu.guest_agent.0 -chardev spiceport,name=org.qemu.guest_agent.0,id=org.qemu.guest_agent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -chardev spicevmc,id=vdagent,debug=0,name=vdagent -name "Android 44" -uuid 76D18910-E5B6-4859-8845-3DB263A94ABA -rtc base=localtime -device virtio-rng-pci -cpu max -global i440FX-pcihost.x-pci-hole64-fix=off -global q35-pcihost.x-pci-hole64-fix=off 2024-08-28 10:06:31.849680+0800 UTM[7008:2790562] [QEMULogging(0x280180a40)] Loading qemu-i386-softmmu.framework/qemu-i386-softmmu 2024-08-28 10:06:31.915446+0800 UTM[7008:2790937] [QEMULogging(0x280180a40)] UI Error: Could not connect: Connection refused qemu-i386-softmmu: -accel tcg,tb-size=256,split-wx=off: allocate 268435456 bytes for jit buffer: Invalid argument 2024-08-28 10:06:31.922010+0800 UTM[7008:2790565] [QEMULogging(0x280180a40)] QEMU exited with code -1: (no message) 2024-08-28 10:06:32.922820+0800 UTM[7008:2790570] [QEMULogging(0x280180a40)] Retrying interface connection... 2024-08-28 10:06:32.925803+0800 UTM[7008:2790937] [QEMULogging(0x280180a40)] 2024-08-28 02:06:32,925 WARNING GSpice-main-1:0: could not set sockopt TCP_NODELAY: Operation not supported on socket

osy commented 2 months ago

Post your config.plist as requested in the template

huanggui commented 2 months ago

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

Debug DebugLog Display ConsoleFont Menlo ConsoleFontSize 12 ConsoleTheme Default DisplayDownscaler linear DisplayUpscaler linear Drives ImagePath android-4.4.qcow2 ImageType disk InterfaceType ide Input InputLegacy Networking NetworkCard rtl8139 NetworkEnabled Printing Sharing ClipboardSharing Sound SoundCard ac97 SoundEnabled System AddArgs -cpu max -global i440FX-pcihost.x-pci-hole64-fix=off -global q35-pcihost.x-pci-hole64-fix=off Architecture i386 BootDevice cd CPUCount 1 ForceMulticore JITCacheSize 0 Memory 1024 SystemUUID 76D18910-E5B6-4859-8845-3DB263A94ABA Target pc
huanggui commented 2 months ago

config.plist: config.plist.txt @osy

huanggui commented 2 months ago

hi, osy, Is there any progress on this issue? @osy

osy commented 2 months ago

I don't see how you're getting "split-wx=off". The only code to set that is "on". https://github.com/utmapp/UTM/blob/main/Configuration/UTMQemuConfiguration%2BArguments.swift#L411

Are you sure you're not running modified code?

huanggui commented 2 months ago

I checked the description of the "-accel" parameter in qemu, and it doesn't require "split-wx=on". Additionally, in UTM SE, "split-wx" is not set to "on". So what did the UTM version do that requires "split-wx" to be set to "on"? @osy

osy commented 2 months ago

Did you modify the code?

huanggui commented 2 months ago

I have another question, why does enabling JIT make the system loading speed of UTM much faster compared to the SE version? What has UTM done with JIT, including any optimizations made by the dependent QEMU? @osy

I experienced the following results on the iPhone 14 Pro: UTM takes only 30 seconds to load Android 4.4, while UTM SE takes more than 30 minutes.

huanggui commented 2 months ago

Did you modify the code?

In order to compare, I tried modifying the code:https://github.com/utmapp/UTM/blob/main/Configuration/UTMQemuConfiguration%2BArguments.swift#L411

osy commented 2 months ago

In the future, when reporting issues to any open source project, if you modify the code you must disclose it. That would prevent wasting people's time. In this case, you removed the line of code explicitly added for JIT to work.

huanggui commented 2 months ago

In the future, when reporting issues to any open source project, if you modify the code you must disclose it. That would prevent wasting people's time. In this case, you removed the line of code explicitly added for JIT to work.

I apologize for not clarifying that I modified that line of code earlier, and for wasting your valuable time. Actually, I wanted to understand how JIT achieves acceleration, so I compared the differences with SE, and split-wx is a key point. Then I modified this configuration on the JIT version. Finally, does UTM SE v4.5.3 depend on the qemu branch v7.2.0-utm as well? @osy