]> code.ossystems Code Review - openembedded-core.git/commit
qemu: support virtual TPM
authorPatrick Ohly <patrick.ohly@intel.com>
Fri, 20 Jan 2017 07:51:07 +0000 (08:51 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 23 Feb 2017 23:11:22 +0000 (15:11 -0800)
commit1264d26fa251ac11a9069f3e602dec6be9d8b9ba
treed0e6c309c63c758822ab2200ecf4f28f9180e4fd
parent65cfc8aca3ff7e39453977a0215a350d13cb85ef
qemu: support virtual TPM

This enables the use of swtpm (from meta-security) as a virtual TPM in
qemu. These patches extend the existing support in qemu for TPM
passthrough so that a swtpm daemon can be accessed via CUSE (character
device in user space).

To use this:
 - add the meta-security layer including the swtpm enhancements for qemu
 - bitbake swtpm-native
 - create a TPM instance and initialize it with:

   $ mkdir -p my-machine/myvtpm0
   $ tmp-glibc/sysroots/x86_64-linux/usr/bin/swtpm_setup_oe.sh --tpm-state my-machine/myvtpm0 --createek
   Starting vTPM manufacturing as root:root @ Fri 20 Jan 2017 08:56:18 AM CET
   TPM is listening on TCP port 52167.
   Successfully created EK.
   Successfully authored TPM state.
   Ending vTPM manufacturing @ Fri 20 Jan 2017 08:56:19 AM CET

 - run swtpm *before each runqemu invocation* (it shuts down after use) and
   do it as root (required to set up the /dev/vtpm0 CUSE device):

   $ sudo sh -c 'PATH=`pwd`/tmp-glibc/sysroots/x86_64-linux/usr/bin/:`pwd`/tmp-glibc/sysroots/x86_64-linux/usr/sbin/:$PATH; export TPM_PATH=`pwd`/my-machine/myvtpm0; swtpm_cuse -n vtpm0' && sudo chmod a+rw /dev/vtpm0

 - run qemu:

   $ runqemu 'qemuparams=-tpmdev cuse-tpm,id=tpm0,path=/dev/vtpm0 -device tpm-tis,tpmdev=tpm0' ...

The guest kernel has to have TPM support enabled, which can be done with:

KERNEL_FEATURES_append = " features/tpm/tpm.scc"

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
meta/recipes-devtools/qemu/qemu/0001-Provide-support-for-the-CUSE-TPM.patch [new file with mode: 0644]
meta/recipes-devtools/qemu/qemu/0002-Introduce-condition-to-notify-waiters-of-completed-c.patch [new file with mode: 0644]
meta/recipes-devtools/qemu/qemu/0003-Introduce-condition-in-TPM-backend-for-notification.patch [new file with mode: 0644]
meta/recipes-devtools/qemu/qemu/0004-Add-support-for-VM-suspend-resume-for-TPM-TIS.patch [new file with mode: 0644]
meta/recipes-devtools/qemu/qemu_2.8.0.bb