vtpm Mini-Os domain: hotplug fixes
PATCH 5/7 vtpm Mini-Os domain: hotplug fixes
This patch adds the actual vtpm-stubdom domain itself to the stubdom directory makefile heirarchy. To build vtpm-stubdom and all of its dependent libraries simply do:
cd stubdom; make vtpm-stubdom
libgmp was ported to mini-os as it is needed by the tpm_emulator. To build it:
$ cd stubdom; make cross-gmp
polarssl was ported to mini-os because the vtpm needs an AES implementation to encrypt its persistent state for storage on disk. To build it:
$ cd stubdom; make cross-polarssl
Finally the berlios tpm_emulator version 0.6.1 was ported to mini-os as it is the core engine of the vtpm. To build it separately do:
$ cd stubdom; make cross-tpmemu
Documentation on the architecture and how to use the domain is in stubdom/vtpm/README
stubdom/gmp.patch new file +72 -0
@@ -0,0 +1,72 @@ +--- configure.orig 2009-12-10 11:33:08.000000000 -0500 ++++ configure 2009-12-10 11:31:25.000000000 -0500 +@@ -25999,60 +25999,7 @@ + fi + echo "$as_me:$LINENO: checking for quad_t" >&5 + echo $ECHO_N "checking for quad_t... $ECHO_C" >&6 +-if test "${ac_cv_type_quad_t+set}" = set; then +- echo $ECHO_N "(cached) $ECHO_C" >&6 +-else +- cat >conftest.$ac_ext <<_ACEOF +-/* confdefs.h. */ +-_ACEOF +-cat confdefs.h >>conftest.$ac_ext +-cat >>conftest.$ac_ext <<_ACEOF +-/* end confdefs.h. */ +-$ac_includes_default +-int +-main () +-{ +-if ((quad_t *) 0) +- return 0; +-if (sizeof (quad_t)) +- return 0; +- ; +- return 0; +-} +-_ACEOF +-rm -f conftest.$ac_objext +-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 +- (eval $ac_compile) 2>conftest.er1 +- ac_status=$? +- grep -v '^ *+' conftest.er1 >conftest.err +- rm -f conftest.er1 +- cat conftest.err >&5 +- echo "$as_me:$LINENO: \$? = $ac_status" >&5 +- (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" +- || test ! -s conftest.err' +- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 +- (eval $ac_try) 2>&5 +- ac_status=$? +- echo "$as_me:$LINENO: \$? = $ac_status" >&5 +- (exit $ac_status); }; } && +- { ac_try='test -s conftest.$ac_objext' +- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 +- (eval $ac_try) 2>&5 +- ac_status=$? +- echo "$as_me:$LINENO: \$? = $ac_status" >&5 +- (exit $ac_status); }; }; then +- ac_cv_type_quad_t=yes +-else +- echo "$as_me: failed program was:" >&5 +-sed 's/^/| /' conftest.$ac_ext >&5 +- + ac_cv_type_quad_t=no +-fi +-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +-fi +-echo "$as_me:$LINENO: result: $ac_cv_type_quad_t" >&5 +-echo "${ECHO_T}$ac_cv_type_quad_t" >&6 + if test $ac_cv_type_quad_t = yes; then + + cat >>confdefs.h <<_ACEOF +@@ -27770,7 +27717,7 @@ + + + +-for ac_func in alarm attr_get clock clock_gettime cputime getpagesize getrusage gettimeofday getsysinfo localeconv memset mmap mprotect nl_langinfo obstack_vprintf popen processor_info pstat_getprocessor raise read_real_time sigaction sigaltstack sigstack syssgi strchr strerror strnlen strtol strtoul sysconf sysctl sysctlbyname times ++for ac_func in alarm attr_get clock clock_gettime cputime getpagesize getrusage gettimeofday getsysinfo localeconv memset mmap mprotect nl_langinfo popen processor_info pstat_getprocessor raise read_real_time sigaction sigaltstack sigstack syssgi strchr strerror strnlen strtol strtoul sysconf sysctl sysctlbyname times + do + as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` + echo "$as_me:$LINENO: checking for $ac_func" >&5
stubdom/polarssl.patch new file +12 -0
@@ -0,0 +1,12 @@ +diff -Naur polarssl-0.12.1.orig/include/polarssl/config.h polarssl-0.12.1/include/polarssl/config.h +--- polarssl-0.12.1.orig/include/polarssl/config.h 2010-04-15 16:33:20.000000000 -0400 ++++ polarssl-0.12.1/include/polarssl/config.h 2010-04-15 16:34:08.000000000 -0400 +@@ -221,7 +221,7 @@ + * + * This module provides TCP/IP networking routines. + */ +-#define POLARSSL_NET_C ++//#define POLARSSL_NET_C + + /* + * Module: library/padlock.c
stubdom/tpmemu-0.6.1.patch new file +36 -0
@@ -0,0 +1,36 @@ +diff -Naur tpm_emulator-0.6.1/tpm/tpm_data.c tpm_emulator-x86_32/tpm/tpm_data.c +--- tpm_emulator-0.6.1/tpm/tpm_data.c 2009-10-09 05:07:22.000000000 -0400 ++++ tpm_emulator-x86_32/tpm/tpm_data.c 2010-02-15 12:53:47.000000000 -0500 +@@ -246,8 +246,7 @@ + || tpm_unmarshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanent.data) + || tpm_unmarshal_TPM_STCLEAR_FLAGS(&ptr, &len, &tpmData.stclear.flags) + || tpm_unmarshal_TPM_STCLEAR_DATA(&ptr, &len, &tpmData.stclear.data) +- || tpm_unmarshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data) +- || len > 0) { ++ || tpm_unmarshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data)) { + tpm_free(buf); + return -1; + } +diff -Naur tpm_emulator-0.6.1/tpmd/Makefile tpm_emulator-x86_32/tpmd/Makefile +--- tpm_emulator-0.6.1/tpmd/Makefile 2009-10-09 05:07:22.000000000 -0400 ++++ tpm_emulator-x86_32/tpmd/Makefile 2010-02-15 12:52:07.000000000 -0500 +@@ -39,3 +39,5 @@ + + .PHONY: all clean install + ++.PHONY: objs ++objs: $(OBJS) +diff -Naur tpm_emulator-0.6.1/tpmd/tpm_emulator_config.h tpm_emulator-x86_32/tpmd/tpm_emulator_config.h +--- tpm_emulator-0.6.1/tpmd/tpm_emulator_config.h 2009-10-09 05:07:22.000000000 -0400 ++++ tpm_emulator-x86_32/tpmd/tpm_emulator_config.h 2010-02-15 12:52:07.000000000 -0500 +@@ -29,8 +29,8 @@ + + /* TPM emulator configuration */ + +-#undef TPM_STRONG_PERSISTENCE +-#undef TPM_GENERATE_EK ++#define TPM_STRONG_PERSISTENCE ++#define TPM_GENERATE_EK + #undef TPM_GENERATE_SEED_DAA + #undef TPM_MEMORY_ALIGNMENT_MANDATORY + #undef TPM_USE_INTERNAL_PRNG
stubdom/vtpm/Makefile new file +26 -0
@@ -0,0 +1,26 @@ +TPMEMU_DIR=../tpm_emulator-$(XEN_TARGET_ARCH)/tpmd +TPMEMU_OBJS=$(wildcard $(TPMEMU_DIR)/*.o) +XEN_ROOT=../.. +MNGR_ROOT=$(XEN_ROOT)/tools/vtpm_manager + +PSSL_DIR=../polarssl-$(XEN_TARGET_ARCH)/library +PSSL_OBJS=aes.o padlock.o + +TARGET=vtpm.a +OBJS=vtpm.o vtpm_cmd.o vtpmblk.o + +CPPFLAGS+=-I$(MNGR_ROOT)/manager + +$(TARGET): $(OBJS) + ar -cr $@ $^ $(TPMEMU_OBJS) $(foreach obj,$(PSSL_OBJS),$(PSSL_DIR)/$(obj)) + +clean: clean-compat + -rm $(TARGET) $(OBJS) + +compat: + make -C compat + +clean-compat: + make -C compat clean + +.PHONY: compat clean-compat clean
stubdom/vtpm/README new file +133 -0
133 lines not on this page · raw message
stubdom/vtpm/compat/Makefile new file +26 -0
@@ -0,0 +1,26 @@ + +TARGET=asm/byteorder.h + +$(TARGET): endian_test + mkdir -p `dirname $(TARGET)` + echo "#ifndef BYTEORDER_TPM_COMPAT_H" > $(TARGET) + echo "#define BYTEORDER_TPM_COMPAT_H" >> $(TARGET) + echo "" >> $(TARGET) + cat swab.h >> $(TARGET) + echo "" >> $(TARGET) + if ./endian_test; then \ + echo "Little Endian Host Cpu detected"; \ + cat little_endian.h >> $(TARGET); \ + else \ + echo "Big Endian Host Cpu detected"; \ + cat big_endian.h >> $(TARGET); \ + fi + echo "#endif /* BYTEORDER_TPM_COMPAT_H */" >> $(TARGET) + + +endian_test: endian_test.c + $(CC) $(CFLAGS) -o $@ $< + +clean: + -rm $(TARGET) + -rm endian_test
stubdom/vtpm/compat/big_endian.h new file +14 -0
@@ -0,0 +1,14 @@ + +#define __cpu_to_le64 (x) (__swab64((x))) +#define __le64_to_cpu (x) (__swab64((uint64_t)(x))) +#define __cpu_to_le32 (x) (__swab32((x))) +#define __le32_to_cpu (x) (__swab32((uint32_t)(x))) +#define __cpu_to_le16 (x) (__swab16((x))) +#define __le16_to_cpu (x) (__swab16((uint16_t)(x))) +#define __cpu_to_be64 (x) ((uint64_t)(x)) +#define __be64_to_cpu (x) ((uint64_t)(x)) +#define __cpu_to_be32 (x) ((uint32_t)(x)) +#define __be32_to_cpu (x) ((uint32_t)(x)) +#define __cpu_to_be16 (x) ((uint16_t)(x)) +#define __be16_to_cpu (x) ((uint16_t)(x)) +
stubdom/vtpm/compat/endian_test.c new file +15 -0
@@ -0,0 +1,15 @@ +#include <stdio.h> +int main (void ) +{ +union { +char c; +int i; + } u; + u.i =0 ; + u.c =1 ; + +if (u.i ==1 ) +return 0 ;/* Little Endian */ +else +return 1 ;/* Big Endian */ +}
stubdom/vtpm/compat/little_endian.h new file +14 -0
@@ -0,0 +1,14 @@ + +#define __cpu_to_le64 (x) ((uint64_t)(x)) +#define __le64_to_cpu (x) ((uint64_t)(x)) +#define __cpu_to_le32 (x) ((uint32_t)(x)) +#define __le32_to_cpu (x) ((uint32_t)(x)) +#define __cpu_to_le16 (x) ((uint16_t)(x)) +#define __le16_to_cpu (x) ((uint16_t)(x)) +#define __cpu_to_be64 (x) (__swab64((x))) +#define __be64_to_cpu (x) (__swab64((uint64_t)(x))) +#define __cpu_to_be32 (x) (__swab32((x))) +#define __be32_to_cpu (x) (__swab32((uint32_t)(x))) +#define __cpu_to_be16 (x) (__swab16((x))) +#define __be16_to_cpu (x) (__swab16((uint16_t)(x))) +
stubdom/vtpm/compat/swab.h new file +26 -0
@@ -0,0 +1,26 @@ +#include <stdint.h> + +/* +* casts are necessary for constants, because we never know how for sure +* how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way. +*/ +#define __swab16 (x) ((uint16_t)( \ + (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \ + (((uint16_t)(x) & (uint16_t)0xff00U) >> 8))) + +#define __swab32 (x) ((uint32_t)( \ + (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))) + +#define __swab64 (x) ((uint64_t)( \ + (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \ + (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ + (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ + (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ + (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ + (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ + (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ + (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56))) +
stubdom/vtpm/examples/myguest.cfg new file +5 -0
@@ -0,0 +1,5 @@ +bootloader = pygrub +memory = 192 +name = 'myguest' +disk = ['file:/tmp/myguest.img,hda1,w'] +vtpm = ['backend=myvtpm']
stubdom/vtpm/examples/myvtpm.cfg new file +8 -0
@@ -0,0 +1,8 @@ +kernel = '/boot/vtpm-stubdom.gz' +memory = '8' +name = 'vtpm' +on_shutdown = 'destroy' +on_crash = 'destroy' +disk = ['file:/tmp/myvtpm.img,hda,w'] +extra = 'loglevel=info pvm clear' +vtpm = ['backend=0,uuid=4209a551-9b79-4feb-ad4d-b4ff1c1bc355']
stubdom/vtpm/vtpm.c new file +325 -0
325 lines not on this page · raw message
stubdom/vtpm/vtpm.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef VTPM_H +#define VTPM_H + +/* For testing */ +#define VERS_CMD "\x00\xC1\x00\x00\x00\x16\x00\x00\x00\x65\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x01\x03" +#define VERS_CMD_LEN 22 + +/* Global commandline options */ +struct Opt_args { +enum Mode { +MODE_INVALID , +MODE_PVM , +MODE_HVM + } mode; +enum StartUp { +ST_CLEAR =1 , +ST_SAVE =2 , +ST_DEACTIVATED =3 + } startup; +enum EntropySource { +ENT_TPM , +ENT_RAND + } entropysrc; +int loglevel; +}; +extern struct Opt_args opt_args; + +#endif +
stubdom/vtpm/vtpm_cmd.c new file +182 -0
182 lines not on this page · raw message
stubdom/vtpm/vtpm_cmd.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef MANAGER_H +#define MANAGER_H + +#include <tpmfront.h> +#include "tpm_emulator_config.h" +#include "tpm/tpm_emulator.h" +#include "tpm/tpm_structures.h" + +/* Request random bytes from hardware tpm, returns 0 on success */ +TPM_RESULT VTPM_GetRandom (struct tpmfront_dev * tpmfront_dev,BYTE * bytes,UINT32 numbytes); +/* Send NVM data to manager for secure storage */ +TPM_RESULT VTPM_SaveNVM (struct tpmfront_dev * tpmfront_dev,BYTE *data,size_t data_length); +/* Retreive NVM data from manager */ +TPM_RESULT VTPM_LoadNVM (struct tpmfront_dev * tpmfront_dev,BYTE **data,size_t *data_length); +/* Retreive the size of the NVM data */ +TPM_RESULT VTPM_GetNVMSize (struct tpmfront_dev * tpmfront_dev,UINT32 * size); +/* Retreive 256 bit AES encryption key from manager */ +TPM_RESULT VTPM_LoadKey (struct tpmfront_dev * tpmfront_dev,uint8_t ** data,size_t * data_length); +/* Manager securely saves our 256 bit AES encryption key */ +TPM_RESULT VTPM_SaveKey (struct tpmfront_dev * tpmfront_dev,uint8_t * data,size_t data_length); + +#endif
stubdom/vtpm/vtpmblk.c new file +343 -0
343 lines not on this page · raw message
stubdom/vtpm/vtpmblk.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef NVM_H +#define NVM_H +#include <mini-os/types.h> +#include <tpmfront.h> + +int init_vtpmblk (struct tpmfront_dev * tpmfront_dev); +void shutdown_vtpmblk (void ); + +/* Encrypts and writes data to blk device */ +int write_vtpmblk (struct tpmfront_dev * tpmfront_dev,uint8_t *data,size_t data_length); +/* Reads, Decrypts, and returns data from blk device */ +int read_vtpmblk (struct tpmfront_dev * tpmfront_dev,uint8_t **data,size_t *data_length); + +#endif
extras/mini-os/Makefile +15 -5
@@ -78,12 +78,22 @@ OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS)) +ifeq ($(vtpm),y) + APP_LDLIBS += -lgmp + LDLIBS += -lc + OBJS := $(filter-out $(OBJ_DIR)/fs-front.o, $(OBJS)) + OBJS := $(filter-out $(OBJ_DIR)/daytime.o, $(OBJS)) + OBJS := $(filter-out $(OBJ_DIR)/pcifront.o, $(OBJS)) + OBJS := $(filter-out $(OBJ_DIR)/netfront.o, $(OBJS)) + OBJS := $(filter-out $(OBJ_DIR)/fbfront.o, $(OBJS)) +endif + ifeq ($(libc),y) -APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(XEN_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive -APP_LDLIBS += -lpci -APP_LDLIBS += -lz -APP_LDLIBS += -lm -LDLIBS += -lc + APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(XEN_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive + APP_LDLIBS += -lpci + APP_LDLIBS += -lz + APP_LDLIBS += -lm + LDLIBS += -lc endif ifneq ($(APP_OBJS)-$(lwip),-y)
extras/mini-os/minios.mk +4 -0
@@ -26,6 +26,10 @@ DEF_CFLAGS += -O3 endif +ifeq ($(vtpm),y) +DEF_CPPFLAGS += -DNO_LIBXC -DNO_FSFRONT -DNO_PCIFRONT -DNO_NETFRONT -DNO_FBFRONT +endif + # Make the headers define our internal stuff DEF_CFLAGS += -D__INSIDE_MINIOS__
stubdom/Makefile +101 -1
162 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel