On 02/16/2013 06:19 AM, Andreas Färber wrote:
@@ -1 +1,2 @@
common-obj-y = tpm.o
+common-obj-$(CONFIG_TPM) += tpm_tis.o
Some softmmus might not even support ISA, so this needs to be
conditional on more than just the host's $(CONFIG_TPM), it should be a
combination of the host's CONFIG_TPM=y and CONFIG_TPM_TIS=y in
default-configs/{i386,x86_64}-softmmu.config or similar.
I am having some tough problems here getting the above suggestion
implemented and building for example for i386 and x86_64 while not
building TPM for other targets. as Andreas suggested, ISA may not be
available or TPM may not be typically available. The problems I am
facing are related to CONFIG_TPM and CONFIG_TPM_PASSTHROUGH being used
in vl.c and qemu-options.hx and for example vl.c #include'ing
config-host.h, which then gives it access to those #defines.
from qemu-options.hx
#ifdef CONFIG_TPM
+# ifdef CONFIG_TPM_PASSTHROUGH
DEFHEADING(TPM device options:)
DEF("tpmdev", HAS_ARG, QEMU_OPTION_tpmdev, \
- "-tpmdev [<type>],id=str[,option][,option][,...]\n",
+ "-tpmdev passthrough,id=id[,path=path]\n"
+ " use path to provide path to a character device; default is
/dev/tpm0\n",
QEMU_ARCH_ALL)
STEXI
I believe the above makes sense. It only shows the -tpmdev passthrough option
as being available if in fact the passthrough device has been compiled in.
CONFIG_TPM and CONFIG_TPM_PASSTHROUGH are created through ./configure
--enable-tpm and --enable-tpm-passthrough respectively and end up in
config-host.h. Config-host.h is not a problem to include in qemu-options.hx and
also not in vl.c:
The following is from vl.c where we restrict the -tpmdev option to only be
available if the TPM passthrough was compiled in. The restriction with the
#define's is necessary due to similar restrictions in qemu-options.hx.
#ifdef CONFIG_TPM
+# ifdef CONFIG_TPM_PASSTHROUGH
case QEMU_OPTION_tpmdev:
if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
exit(1);
}
break;
+# endif
#endif
I have tried to make CONFIG_TPM and CONFIG_TPM_PASSTHROUGH target-specific
#defines by having them written for example into i386-softmmu/config-target.h.
Once I do that I get problems #includ'ing the config-target.h from vl.c for
example. Vl.c does not see the necessary -include path to config-target.h via
gcc as for example exec.c sees it. So it's not compileable this way and I would
have to have vl.c built as part of obj-y rather than common-obj-y.
Even though soundhw may not be considered a good model to follow, the following
patch allows me to build for different architectures and simply disable the
usage of the TPM by reducing the choices the user has:
---
Makefile.objs | 1 +
configure | 8 ++++++++
tpm/Makefile.objs | 2 +-
3 files changed, 10 insertions(+), 1 deletion(-)
Index: qemu-git.pt/configure
===================================================================
--- qemu-git.pt.orig/configure
+++ qemu-git.pt/configure
@@ -4279,6 +4279,14 @@ if test "$tpm" = "yes"; then
fi
fi
+if test "$target_softmmu" = "yes" ; then
+ case "$TARGET_BASE_ARCH" in
+ i386|x86_64)
+ cflags="-DHAS_TPM_CHOICE $cflags"
+ ;;
+ esac
+fi
+
if test "$ARCH" = "tci"; then
linker_script=""
else
Index: qemu-git.pt/tpm/Makefile.objs
===================================================================
--- qemu-git.pt.orig/tpm/Makefile.objs
+++ qemu-git.pt/tpm/Makefile.objs
@@ -1,3 +1,3 @@
-common-obj-y = tpm.o
+obj-y = tpm.o
common-obj-$(CONFIG_TPM) += tpm_tis.o tpm_backend.o
common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o
Index: qemu-git.pt/Makefile.objs
===================================================================
--- qemu-git.pt.orig/Makefile.objs
+++ qemu-git.pt/Makefile.objs
@@ -75,6 +75,7 @@ common-obj-y += dma-helpers.o
common-obj-y += qtest.o
common-obj-y += vl.o
common-obj-y += tpm/
+obj-y += tpm/
common-obj-$(CONFIG_SLIRP) += slirp/
tpm/tpm.o has to be built as part of obj-y to 'see' -DHAS_TPM_CHOICE.
This is similar to arch_init.o being built as part of obj-y to see
-DHAS_AUDIO_CHOICE.
I have now been wrestling with this challenge for a couple of hours.
Please let me know how to go about it. I tried several paths but some
end up with above mentioned compilation problems.
Thanks and regards,
Stefan