ia64/xen-unstable

view tools/vtpm/tpm_emulator.patch @ 7238:971e7c7411b3

Raise an exception if an error appears on the pipes to our children, and make
sure that the child's pipes are closed even under that exception. Move the
handling of POLLHUP to the end of the loop, so that we guarantee to read any
remaining data from the child if POLLHUP and POLLIN appear at the same time.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 10:13:11 2005 +0100 (2005-10-06)
parents 06d84bf87159
children 201d48272a57
line source
1 diff -uprN orig/tpm_emulator-0.2-x86_64/AUTHORS tpm_emulator/AUTHORS
2 --- orig/tpm_emulator-0.2-x86_64/AUTHORS 2005-08-15 00:58:57.000000000 -0700
3 +++ tpm_emulator/AUTHORS 2005-09-14 20:27:22.000000000 -0700
4 @@ -1 +1,2 @@
5 Mario Strasser <mast@gmx.net>
6 +INTEL Corp <>
7 diff -uprN orig/tpm_emulator-0.2-x86_64/ChangeLog tpm_emulator/ChangeLog
8 --- orig/tpm_emulator-0.2-x86_64/ChangeLog 2005-08-15 00:58:57.000000000 -0700
9 +++ tpm_emulator/ChangeLog 2005-09-14 20:27:22.000000000 -0700
10 @@ -1,3 +1,7 @@
11 +2005-08-16: INTEL Corp
12 + * Set default permissions to PCRs
13 + * Changed device to /dev/tpm0
14 +
15 2005-08-15 Mario Strasser <mast@gmx.net>
16 * all: some typos corrected
17 * tpm_integrity.c: bug in TPM_Extend fixed
18 diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.h tpm_emulator/linux_module.h
19 --- orig/tpm_emulator-0.2-x86_64/linux_module.h 2005-09-15 19:21:14.844078720 -0700
20 +++ tpm_emulator/linux_module.h 2005-09-14 20:27:22.000000000 -0700
21 @@ -1,5 +1,6 @@
22 /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
23 * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
24 + * Copyright (C) 2005 INTEL Corp.
25 *
26 * This module is free software; you can redistribute it and/or modify
27 * it under the terms of the GNU General Public License as published
28 @@ -35,7 +36,7 @@
29 #include "tpm_version.h"
31 #define TPM_DEVICE_MINOR 224
32 -#define TPM_DEVICE_NAME "tpm"
33 +#define TPM_DEVICE_NAME "tpm0"
34 #define TPM_MODULE_NAME "tpm_emulator"
36 /* debug and log output functions */
37 diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile tpm_emulator/Makefile
38 --- orig/tpm_emulator-0.2-x86_64/Makefile 2005-09-15 19:21:14.845078568 -0700
39 +++ tpm_emulator/Makefile 2005-09-14 20:27:22.000000000 -0700
40 @@ -1,16 +1,20 @@
41 # Software-Based Trusted Platform Module (TPM) Emulator for Linux
42 # Copyright (C) 2004 Mario Strasser <mast@gmx.net>
43 +# Copyright (C) 2005 INTEL Corp.
44 #
45 # $Id: Makefile 10 2005-04-26 20:59:50Z mast $
47 +XEN_ROOT := ../../..
48 +EUID := $(shell id -u)
49 +
50 # kernel settings
51 KERNEL_RELEASE := $(shell uname -r)
52 -KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build
53 +KERNEL_BUILD := $(XEN_ROOT)/linux-2.6.12-xen0
54 MOD_SUBDIR := misc
55 COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/)
57 # module settings
58 -MODULE_NAME := tpm_emulator
59 +BIN := tpm_emulator
60 VERSION_MAJOR := 0
61 VERSION_MINOR := 2
62 VERSION_BUILD := $(shell date +"%s")
63 @@ -34,11 +38,9 @@ DIRS := . crypto tpm
64 SRCS := $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.c))
65 OBJS := $(patsubst %.c, %.o, $(SRCS))
66 SRCS += $(foreach dir, $(DIRS), $(wildcard $(src)/$(dir)/*.h))
67 -DISTSRC := ./README ./AUTHORS ./ChangeLog ./Makefile $(SRCS)
68 -DISTDIR := tpm_emulator-$(VERSION_MAJOR).$(VERSION_MINOR)
70 -obj-m := $(MODULE_NAME).o
71 -$(MODULE_NAME)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a
72 +obj-m := $(BIN).o
73 +$(BIN)-objs := $(patsubst $(src)/%.o, %.o, $(OBJS)) crypto/libgmp.a
75 EXTRA_CFLAGS += -I$(src) -I$(src)/crypto -I$(src)/tpm
77 @@ -49,23 +51,17 @@ all: $(src)/crypto/gmp.h $(src)/crypto/l
78 @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules
80 install:
81 - @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules_install
82 - test -d /var/tpm || mkdir /var/tpm
83 - test -c /dev/tpm || mknod /dev/tpm c 10 224
84 - chmod 666 /dev/tpm
85 - depmod -a
86 + @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) INSTALL_MOD_PATH=$(DESTDIR) modules_install
87 + test -d $(DESTDIR)/var/tpm || mkdir $(DESTDIR)/var/tpm
88 + test -d $(DESTDIR)/dev || mkdir $(DESTDIR)/dev
89 + test -c $(DESTDIR)/dev/tpm0 || [ $(EUID) -ne 0 ] || mknod $(DESTDIR)/dev/tpm0 c 10 224
90 + [ $(EUID) -ne 0 ] || chmod 666 $(DESTDIR)/dev/tpm0
92 clean:
93 @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean
94 rm -f $(src)/crypto/gmp.h $(src)/crypto/libgmp.a
96 -dist: $(DISTSRC)
97 - rm -rf $(DISTDIR)
98 - mkdir $(DISTDIR)
99 - cp --parents $(DISTSRC) $(DISTDIR)/
100 - rm -f $(DISTDIR)/crypto/gmp.h
101 - tar -chzf $(DISTDIR).tar.gz $(DISTDIR)
102 - rm -rf $(DISTDIR)
103 +mrproper: clean
105 $(src)/crypto/libgmp.a:
106 test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB) $(src)/crypto/libgmp.a
107 diff -uprN orig/tpm_emulator-0.2-x86_64/README tpm_emulator/README
108 --- orig/tpm_emulator-0.2-x86_64/README 2005-08-15 00:58:57.000000000 -0700
109 +++ tpm_emulator/README 2005-09-14 20:27:22.000000000 -0700
110 @@ -13,7 +13,8 @@ $Id: README 8 2005-01-25 21:11:45Z jmoli
111 Copyright
112 --------------------------------------------------------------------------
113 Copyright (C) 2004 Mario Strasser <mast@gmx.net> and Swiss Federal
114 -Institute of Technology (ETH) Zurich.
115 + Institute of Technology (ETH) Zurich.
116 +Copyright (C) 2005
118 This program is free software; you can redistribute it and/or modify
119 it under the terms of the GNU General Public License as published by
120 diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c tpm_emulator/tpm/tpm_data.c
121 --- orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c 2005-09-15 19:21:14.847078264 -0700
122 +++ tpm_emulator/tpm/tpm_data.c 2005-09-14 20:27:22.000000000 -0700
123 @@ -1,6 +1,7 @@
124 /* Software-Based Trusted Platform Module (TPM) Emulator for Linux
125 * Copyright (C) 2004 Mario Strasser <mast@gmx.net>,
126 * Swiss Federal Institute of Technology (ETH) Zurich
127 + * Copyright (C) 2005 INTEL Corp
128 *
129 * This module is free software; you can redistribute it and/or modify
130 * it under the terms of the GNU General Public License as published
131 @@ -85,6 +86,11 @@ void tpm_init_data(void)
132 tpmData.permanent.data.version.revMinor = VERSION_MINOR;
133 /* setup PCR attributes */
134 for (i = 0; i < TPM_NUM_PCR; i++) {
135 + int j;
136 + for (j=0; j < TPM_NUM_LOCALITY; j++) {
137 + tpmData.permanent.data.pcrAttrib[i].pcrExtendLocal[j] = TRUE;
138 + }
139 +
140 tpmData.permanent.data.pcrAttrib[i].pcrReset = TRUE;
141 }
142 /* set tick type */