Hi,
I’ve been trying to run UC20 images in secured grade, using QEMU. I got secure boot to work, then looked at adding a TPM device. To create the swtpm socket device I created a docker container with swtpm, which seemed to basically work.
I then start the qemu process with all the various parameters required, and it seems to go fairly well, it runs through initial setup, encrypts the disks etc. I’m using the following command to start the process:
qemu-system-x86_64 -smp 1 -m 2048 \
-machine q35,smm=on,accel=kvm \
-serial file:serial.log \
-net nic,model=virtio -net user,hostfwd=tcp::8022-:22 \
-global driver=cfi.pflash01,property=secure,value=on, \
-drive if=pflash,format=raw,unit=0,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.secboot.fd \
-drive if=pflash,format=raw,unit=1,readonly=on,file=/usr/share/OVMF/OVMF_VARS_4M.ms.fd \
-drive file=${IMG},cache=none,format=raw,id=disk1,if=none \
-object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0 \
-chardev socket,id=chrtpm,path="${HOME}/tmp/tpm/swtpm-sock" \
-tpmdev emulator,id=tpm0,chardev=chrtpm \
-device tpm-tis,tpmdev=tpm0 \
-device virtio-blk-pci,drive=disk1,bootindex=1 \
-device virtio-vga,virgl=on,disable-legacy=off,disable-modern=on
But when it then reboots, it fails to decrypt the data volume. I get the following error:
[ 92.042410] the-tool[194]: error: cannot activate encrypted device "/dev/disk/by-partuuid/b992f75e-ac04-3d4a-b9cc-06bf1063a30b": cannot activate with TPM sealed key (cannot unseal key: invalid key data file: cannot complete authorization policy assertions: cannot complete OR assertions: current session digest not found in policy data) and activation with recovery key failed (cannot obtain recovery key: /usr/sbin/systemd-ask-password failed: exit status 1)[FAILED] Failed to start the-tool.service.
In case the problem is the swtpm implementation I’m using, after some googling I tried the snap I found swtpm-mvo
, and upgrading my stock ubuntu focal version of qemu from 4.x to 6.x , always the same result.
I notice that entropy seems to be very slow to generate, that’s why I added the rng-random
qemu params above, but it didn’t seem to help that much. But I kind of doubt that is the cause of the issue.
Does anyone have any idea what may be causing this ? Or, how can I did into the issue a bit more ?
Cheers, Just