Skip to contentSkip to conversation

Adding /dev/tpm0 to qemu-system-aarch64

Qemu-arm Lakshmi Ramasubramanian 2 participants 7 messages Sep 16, 2019 – Sep 17, 2019

lore
Share & tools
lore
#0 lore raw

Hello,

I am trying to add a TPM device (/dev/tpm0) for qemu-system-aarch64.

I have a TPM simulator implemented as a Trusted Application (TA). The device /dev/tee0 interfaces with the above TA.

Have a TPM driver that interfaces with /dev/tpm0 and talks to /dev/tee0 in the backend.

Am trying to add /dev/tpm0 through qemu-system-aarch64 command line arguments like below:

-device tpm-tis,tpmdev=tpm0

I see the following error:

qemu-system-aarch64: -device tpm-tis,tpmdev=tpm0: 'tpm-tis' is not a valid device model name

What is the right way to add an emulated TPM device on qemu-system-aarch64?

For qemu-system-x86_64 I have seen TPM device emulated through socket application and added as given below:

  -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \
  -tpmdev emulator,id=tpm0,chardev=chrtpm \
  -device tpm-tis,tpmdev=tpm0

https://github.com/qemu/qemu/blob/master/docs/specs/tpm.txt

Thanks,
-lakshmi

#1 lore raw
Quoted 14 lines · Lakshmi Ramasubramanian

Hello,

I am trying to add a TPM device (/dev/tpm0) for qemu-system-aarch64.

I have a TPM simulator implemented as a Trusted Application (TA). The device /dev/tee0 interfaces with the above TA.

Have a TPM driver that interfaces with /dev/tpm0 and talks to /dev/tee0 in the backend.

Am trying to add /dev/tpm0 through qemu-system-aarch64 command line arguments like below:

Quoted 6 lines

-device tpm-tis,tpmdev=tpm0

I see the following error:

qemu-system-aarch64: -device tpm-tis,tpmdev=tpm0: 'tpm-tis' is not a valid device model name

This is because QEMU only supports TPM device emulation on x86. To add it to aarch64 somebody would have to investigate what the hardware interface for TPM ought to be on aarch64 hardware, and then implement an emulation of it and add that to the 'virt' board. (It would probably share a lot of the implementation with the current x86 TPM, obviously.)

thanks
-- PMM

#2 lore raw
Quoted 11 lines · Peter Maydell
Quoted 2 lines · Lakshmi Ramasubramanian

qemu-system-aarch64: -device tpm-tis,tpmdev=tpm0: 'tpm-tis' is not a valid device model name

This is because QEMU only supports TPM device emulation on x86. To add it to aarch64 somebody would have to investigate what the hardware interface for TPM ought to be on aarch64 hardware, and then implement an emulation of it and add that to the 'virt' board. (It would probably share a lot of the implementation with the current x86 TPM, obviously.)

Hmm, actually a quick grep suggests we have some TPM support for PPC as well (via a hypercall interface). The rest of my answer still stands, though.

thanks
-- PMM

#3 lore raw
Quoted 13 lines · Peter Maydell
Quoted 11 lines · Peter Maydell
Quoted 2 lines · Lakshmi Ramasubramanian

qemu-system-aarch64: -device tpm-tis,tpmdev=tpm0: 'tpm-tis' is not a valid device model name

This is because QEMU only supports TPM device emulation on x86. To add it to aarch64 somebody would have to investigate what the hardware interface for TPM ought to be on aarch64 hardware, and then implement an emulation of it and add that to the 'virt' board. (It would probably share a lot of the implementation with the current x86 TPM, obviously.)

Quoted 7 lines

Hmm, actually a quick grep suggests we have some TPM support for PPC as well (via a hypercall interface). The rest of my answer still stands, though.

thanks
-- PMM

Thanks for the info Peter.

-lakshmi

#4 lore raw
In reply to Peter Maydell

On 9/16/19 10:24 AM, Peter Maydell wrote:

Hi Peter,

Quoted 9 lines

This is because QEMU only supports TPM device emulation on x86. To add it to aarch64 somebody would have to investigate what the hardware interface for TPM ought to be on aarch64 hardware, and then implement an emulation of it and add that to the 'virt' board. (It would probably share a lot of the implementation with the current x86 TPM, obviously.)

thanks
-- PMM

The TPM I am emulating is implemented in firmware (fTPM) that runs in the Trust Zone (emulated in QEMU). There is a kernel module that handles this fTPM.

If I add the following entry in the Device Tree that QEMU passes to the boot loader, the fTPM kernel module will load and it should be able to talk to the firmware device.

	tpm@0 {
	    compatible = "myorg,ftpm"
	};

How do I add such a custom entry in the device tree in QEMU?

Is there a way to do that by, say, "-device" command line argument or such in qemu-system-aarch64?

Thanks,
-lakshmi

#5 lore raw
Quoted 8 lines · Lakshmi Ramasubramanian

The TPM I am emulating is implemented in firmware (fTPM) that runs in the Trust Zone (emulated in QEMU). There is a kernel module that handles this fTPM.

If I add the following entry in the Device Tree that QEMU passes to the boot loader, the fTPM kernel module will load and it should be able to talk to the firmware device.

Quoted 5 lines
        tpm@0 {
            compatible = "myorg,ftpm"
        };

How do I add such a custom entry in the device tree in QEMU?

If you're running a UEFI blob within QEMU that runs at EL3 and provides this TPM, then it's the responsibility of that UEFI blob to provide device tree or ACPI tables to the guest which describe devices which the UEFI blob is providing. QEMU shouldn't describe them in the device tree it passes to UEFI, because QEMU doesn't implement them.

thanks
-- PMM

#6 lore raw
Quoted 9 lines · Peter Maydell
Quoted 1 line

How do I add such a custom entry in the device tree in QEMU?

If you're running a UEFI blob within QEMU that runs at EL3 and provides this TPM, then it's the responsibility of that UEFI blob to provide device tree or ACPI tables to the guest which describe devices which the UEFI blob is providing. QEMU shouldn't describe them in the device tree it passes to UEFI, because QEMU doesn't implement them.

Quoted 3 lines

thanks
-- PMM

Got it - Thanks for the information.

-lakshmi