Hi Jiri, I meet a segment fault for sev-snp testing on this libvirt branch. Here are the details:
Version:
qemu-kvm-9.1.0-4.el10.x86_64
kernel-6.12.0-30.el10.x86_64
host CPU: AMD EPYC 7313 16-Core Processor
Step:
0. Enable AMD SEV-SNP settings in BIOS and kernel. Make sure `sevctl ok` pass.
1. Start a domain with sev-snp, EPYC-Milan-v2 CPU model
domain XML:
<domain type='kvm'>
...
<currentMemory unit='KiB'>5120000</currentMemory>
<memtune>
<hard_limit unit='KiB'>5120000</hard_limit>
</memtune>
<vcpu placement='static'>4</vcpu>
<os>
<type arch='x86_64' machine='pc-q35-rhel10.0.0'>hvm</type>
<loader type='rom' stateless='yes'>/usr/share/edk2/ovmf/OVMF.amdsev.fd</loader>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<smm state='on'/>
</features>
<cpu mode='host-model' check='partial'>
<model fallback='forbid'>EPYC-Milan-v2</model>
<vendor>AMD</vendor>
<maxphysaddr mode='passthrough' limit='43'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='vaes'/>
<feature policy='require' name='vpclmulqdq'/>
<feature policy='require' name='spec-ctrl'/>
<feature policy='require' name='stibp'/>
<feature policy='require' name='arch-capabilities'/>
<feature policy='require' name='ssbd'/>
<feature policy='require' name='cmp_legacy'/>
<feature policy='require' name='overflow-recov'/>
<feature policy='require' name='succor'/>
<feature policy='require' name='invtsc'/>
<feature policy='require' name='stibp-always-on'/>
<feature policy='require' name='virt-ssbd'/>
<feature policy='require' name='amd-psfd'/>
<feature policy='require' name='lbrv'/>
<feature policy='require' name='tsc-scale'/>
<feature policy='require' name='vmcb-clean'/>
<feature policy='require' name='flushbyasid'/>
<feature policy='require' name='pause-filter'/>
<feature policy='require' name='pfthreshold'/>
<feature policy='require' name='v-vmsave-vmload'/>
<feature policy='require' name='vgif'/>
<feature policy='require' name='no-nested-data-bp'/>
<feature policy='require' name='lfence-always-serializing'/>
<feature policy='require' name='null-sel-clr-base'/>
<feature policy='require' name='rdctl-no'/>
<feature policy='require' name='skip-l1dfl-vmentry'/>
<feature policy='require' name='mds-no'/>
<feature policy='require' name='pschange-mc-no'/>
<feature policy='require' name='gds-no'/>
<feature policy='require' name='rfds-no'/>
</cpu>
...
<launchSecurity type='sev-snp' kernelHashes='no'>
<cbitpos>51</cbitpos>
<reducedPhysBits>1</reducedPhysBits>
<policy>0x00030000</policy>
</launchSecurity>
</domain>
# virsh start sev-snp
error: Disconnected from qemu:///system due to end of file
error: Failed to start domain 'sev-snp'
error: End of file while reading data: Input/output error
# coredumpctl -1
TIME PID UID GID SIG COREFILE EXE SIZE
Tue 2024-11-26 21:54:19 EST 5027 0 0 SIGSEGV present /usr/sbin/virtqemud 1M
Backtrace:
#0 0x00007f78a4824dbf in virCPUCompareUnusable (arch=arch@entry=VIR_ARCH_X86_64, host=host@entry=0x7f78840269e0, cpu=cpu@entry=0x7f788402ba80, blockers=0x0, failIncompatible=failIncompatible@entry=true) at ../src/cpu/cpu.c:204
#1 0x00007f78904c10a6 in qemuDomainCheckCPU (arch=VIR_ARCH_X86_64, virtType=VIR_DOMAIN_VIRT_KVM, qemuCaps=0x7f7884039020 [virQEMUCaps], cpu=0x7f788402ba80, compatCPU=VIR_QEMU_CAPS_HOST_CPU_FULL, failIncompatible=<optimized out>) at ../src/qemu/qemu_domain.c:11433
#2 0x00007f7890550200 in qemuProcessUpdateGuestCPU (def=0x7f78581a0880, qemuCaps=0x7f7884039020 [virQEMUCaps], hostarch=VIR_ARCH_X86_64, flags=17) at ../src/qemu/qemu_process.c:6368
#3 qemuProcessPrepareDomain (driver=driver@entry=0x7f78340195e0, vm=vm@entry=0x7f7834352900 [virDomainObj], flags=flags@entry=17) at ../src/qemu/qemu_process.c:6800
#4 0x00007f7890556bb0 in qemuProcessStart (conn=0x7f788c428350, driver=0x7f78340195e0, vm=0x7f7834352900 [virDomainObj], updatedCPU=0x0, asyncJob=VIR_ASYNC_JOB_START, migrateFrom=0x0, migrateFd=-1, migratePath=0x0, snapshot=0x0, vmop=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=17) at ../src/qemu/qemu_process.c:8304
#5 0x00007f789057a3d8 in qemuDomainObjStart.constprop.0 (conn=0x7f788c428350, driver=0x7f78340195e0, vm=0x7f7834352900 [virDomainObj], flags=0, asyncJob=<optimized out>) at ../src/qemu/qemu_driver.c:6336
#6 0x00007f78904d0d91 in qemuDomainCreateWithFlags (dom=0x7f7884053e30, flags=0) at ../src/qemu/qemu_driver.c:6385
#7 0x00007f78a49132b9 in virDomainCreate (domain=domain@entry=0x7f7884053e30) at ../src/libvirt-domain.c:7079
#8 0x0000556939de9df1 in remoteDispatchDomainCreate (server=0x55694c7a1360 [virNetServer], msg=0x55694c7a6090, client=<optimized out>, rerr=0x7f78947fd9f0, args=0x7f788404fe70) at src/remote/remote_daemon_dispatch_stubs.h:5050
#9 remoteDispatchDomainCreateHelper (server=0x55694c7a1360 [virNetServer], client=<optimized out>, msg=0x55694c7a6090, rerr=0x7f78947fd9f0, args=0x7f788404fe70, ret=0x0) at src/remote/remote_daemon_dispatch_stubs.h:5029
#10 0x00007f78a4804f19 in virNetServerProgramDispatchCall (prog=0x55694c79a000 [virNetServerProgram], server=0x55694c7a1360 [virNetServer], client=0x55694c7aaac0 [virNetServerClient], msg=0x55694c7a6090) at ../src/rpc/virnetserverprogram.c:423
#11 virNetServerProgramDispatch (prog=0x55694c79a000 [virNetServerProgram], server=server@entry=0x55694c7a1360 [virNetServer], client=client@entry=0x55694c7aaac0 [virNetServerClient], msg=msg@entry=0x55694c7a6090) at ../src/rpc/virnetserverprogram.c:299
#12 0x00007f78a4805512 in virNetServerProcessMsg (srv=srv@entry=0x55694c7a1360 [virNetServer], client=0x55694c7aaac0 [virNetServerClient], prog=<optimized out>, msg=0x55694c7a6090) at ../src/rpc/virnetserver.c:135
#13 0x00007f78a4805621 in virNetServerHandleJob (jobOpaque=0x55694c798710, opaque=0x55694c7a1360) at ../src/rpc/virnetserver.c:155
#14 0x00007f78a473d225 in virThreadPoolWorker (opaque=<optimized out>) at ../src/util/virthreadpool.c:164
#15 0x00007f78a473c718 in virThreadHelper (data=<optimized out>) at ../src/util/virthread.c:256
#16 0x00007f78a40dfa29 in start_thread (arg=<optimized out>) at pthread_create.c:447
#17 0x00007f78a414f4fc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Attachment: the domain XML, the qemu log, full backtrace