stefanberger/swtpm

Can't boot qemu-system-riscv64 with swtpm

czz19981215 opened this issue · 2 comments

Dear Sir:

I would like to mount the tpm device to my riscv64 qemu virtual machine.
The command are:
swtpm socket --tpmstate dir=/tmp/mytpm1 --tpm2 \ --ctrl type=unixio,path=/tmp/mytpm1/swtpm-sock \ --log level=20 -d

qemu-system-riscv64 -nographic -machine virt -m 4G -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0 -append "console=ttyS0 rw root=/dev/vda1" -device virtio-blk-device,drive=hd0 -drive file=rootfs.img,format=raw,id=hd0 -device virtio-net-device,netdev=usernet -netdev user,id=usernet,hostfwd=tcp::22222-:22 \ -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0

And the response is:
qemu-system-riscv64: -tpmdev emulator,id=tpm0,chardev=chrtpm: Parameter 'type' expects a TPM backend type No TPM backend types are available
For for some version, the response is:
Failed to connect to '/tmp/mytpm1/swtpm-sock' : Connection refused

I've tested the qemu-system-x86 which can boot successfully but riscv64.

Desktop

  • OS: Ubuntu 20.04 in Vmware Workstation
  • Linux Version 5.13.0-37-generic

Versions of relevant components

  • swtpm: 0.7.0
  • QEMU: version 6.2.50 (v6.1.0-rc1-3124-g8d29feca83)
  • PS: I've tested various version of swtpm and qemu but the problem still.

Appreciate for your noticing and considering.

The problem is that there's no TPM support for riscv64 in qemu:

$ qemu-system-riscv64 -tpmdev help
No TPM backend types are available
$ qemu-system-x86_64 -tpmdev help
Supported TPM types (choose only one):
 passthrough   Passthrough TPM backend driver
    emulator   TPM emulator backend driver

To get this right it would likely require figuring out which TPM device (TIS or CRB) is suitable for RISC-V and on what bus. Then likely TPM ACPI tables need to be created on QEMU, followed by extensions to firmware (EDK2?) and then possibly Linux. I am not familiar with this architecture to know whether for example Linux TPM drivers are already working as-is and it's just a matter of enabling the hardware emulation in QEMU.

Dear Sir,

Thanks for your replying.

The difficulty of solving this problem is beyond my ability, and I am considering opening an issue to QEMU. I'll close this issue, thanks again.