diff -uprN xen-unstable.hg.orig/xen/include/public/io/domain_controller.h xen-unstable.hg/xen/include/public/io/domain_controller.h --- xen-unstable.hg.orig/xen/include/public/io/domain_controller.h 2005-08-15 23:32:29.000000000 -0400 +++ xen-unstable.hg/xen/include/public/io/domain_controller.h 2005-08-16 17:06:13.000000000 -0400 @@ -63,6 +63,8 @@ typedef struct control_if { #define CMSG_USBIF_FE 9 /* USB controller frontend */ #define CMSG_VCPU_HOTPLUG 10 /* Hotplug VCPU messages */ #define CMSG_DEBUG 11 /* PDB backend */ +#define CMSG_TPMIF_BE 12 /* TPM-device backend */ +#define CMSG_TPMIF_FE 13 /* TPM-device frontend */ /****************************************************************************** * CONSOLE DEFINITIONS @@ -784,4 +786,204 @@ typedef struct pdb_Connection { u32 evtchn; /* status: UP */ } pdb_connection_t, *pdb_connection_p; + +/****************************************************************************** + * TPM-INTERFACE FRONTEND DEFINITIONS + */ + +/* Messages from domain controller to guest. */ +#define CMSG_TPMIF_FE_INTERFACE_STATUS 0 +#define CMSG_TPMIF_FE_STARTUP 1 + +/* Messages from guest to domain controller. */ +#define CMSG_TPMIF_FE_DRIVER_STATUS 32 +#define CMSG_TPMIF_FE_INTERFACE_CONNECT 33 +#define CMSG_TPMIF_FE_INTERFACE_DISCONNECT 34 +#define CMSG_TPMIF_FE_INTERFACE_QUERY 35 + +/* + * CMSG_TPMIF_FE_INTERFACE_STATUS: + * Notify a guest about a status change on one of its TPM interfaces. + * If the interface is CLOSED or DOWN then the interface is disconnected: + * 1. The shared-memory frame is available for reuse. + * 2. Any unacknowledged messages pending on the interface were dropped. + */ +#define TPMIF_INTERFACE_STATUS_CLOSED 0 /* Interface doesn't exist. */ +#define TPMIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */ +#define TPMIF_INTERFACE_STATUS_CONNECTED 2 /* Exists and is connected. */ +#define TPMIF_INTERFACE_STATUS_CHANGED 3 /* A device has been added or removed. */ +typedef struct { + u32 handle; /* 0 */ + u32 status; /* 4 */ + u16 evtchn; /* 8: status == TPMIF_INTERFACE_STATUS_CONNECTED */ + domid_t domid; /* 16: status != TPMIF_INTERFACE_STATUS_DESTROYED */ +} tpmif_fe_interface_status_t; /* 18 bytes */ + +/* + * CMSG_TPMIF_FE_DRIVER_STATUS: + * Notify the domain controller that the front-end driver is DOWN or UP. + * When the driver goes DOWN then the controller will send no more + * status-change notifications. + * If the driver goes DOWN while interfaces are still UP, the domain + * will automatically take the interfaces DOWN. + * + * NB. The controller should not send an INTERFACE_STATUS message + * for interfaces that are active when it receives an UP notification. We + * expect that the frontend driver will query those interfaces itself. + */ +#define TPMIF_DRIVER_STATUS_DOWN 0 +#define TPMIF_DRIVER_STATUS_UP 1 +typedef struct { + /* IN */ + u32 status; /* 0: TPMIF_DRIVER_STATUS_??? */ + /* OUT */ + /* Driver should query interfaces [0..max_handle]. */ + u32 max_handle; /* 4 */ +} tpmif_fe_driver_status_t; /* 8 bytes */ + +/* + * CMSG_TPMIF_FE_INTERFACE_CONNECT: + * If successful, the domain controller will acknowledge with a + * STATUS_CONNECTED message. + */ +typedef struct { + u32 handle; /* 0 */ + u32 __pad; /* 4 */ + memory_t shmem_frame; /* 8 */ + u32 shmem_ref; /* 16 */ +} tpmif_fe_interface_connect_t; /* 20 bytes */ + +/* + * CMSG_TPMIF_FE_INTERFACE_DISCONNECT: + * If successful, the domain controller will acknowledge with a + * STATUS_DISCONNECTED message. + */ +typedef struct { + u32 handle; /* 0 */ +} tpmif_fe_interface_disconnect_t; /* 4 bytes */ + +/* + * CMSG_TPMIF_FE_INTERFACE_QUERY: + */ +typedef struct { + /* IN */ + u32 handle; /* 0 */ + /* OUT */ + u32 status; /* 4 */ + u16 evtchn; /* 8: status == TPMIF_INTERFACE_STATUS_CONNECTED */ + domid_t domid; /* 16: status != TPMIF_INTERFACE_STATUS_DESTROYED */ +} tpmif_fe_interface_query_t; /* 18 bytes */ + +/****************************************************************************** + * TPM-INTERFACE BACKEND DEFINITIONS + */ + +/* Messages from domain controller. */ +#define CMSG_TPMIF_BE_CREATE 0 /* Create a new tpm-device interface. */ +#define CMSG_TPMIF_BE_DESTROY 1 /* Destroy a tpm-device interface. */ +#define CMSG_TPMIF_BE_CONNECT 2 /* Connect i/f to remote driver. */ +#define CMSG_TPMIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */ + +/* Messages to domain controller. */ +#define CMSG_TPMIF_BE_DRIVER_STATUS 32 + +/* + * Message request/response definitions for tpm-device messages. + */ + +/* Non-specific 'okay' return. */ +#define TPMIF_BE_STATUS_OKAY 0 +/* Non-specific 'error' return. */ +#define TPMIF_BE_STATUS_ERROR 1 +/* The following are specific error returns. */ +#define TPMIF_BE_STATUS_INTERFACE_EXISTS 2 +#define TPMIF_BE_STATUS_INTERFACE_NOT_FOUND 3 +#define TPMIF_BE_STATUS_INTERFACE_CONNECTED 4 +#define TPMIF_BE_STATUS_OUT_OF_MEMORY 5 +#define TPMIF_BE_STATUS_MAPPING_ERROR 6 + +/* This macro can be used to create an array of descriptive error strings. */ +#define TPMIF_BE_STATUS_ERRORS { \ + "Okay", \ + "Non-specific error", \ + "Interface already exists", \ + "Interface not found", \ + "Interface is still connected", \ + "Out of memory", \ + "Could not map domain memory" } + +/* + * CMSG_TPMIF_BE_CREATE: + * When the driver sends a successful response then the interface is fully + * created. + * + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Domain attached to new interface. */ + u16 __pad0; /* 2 */ + u32 tpmif_handle; /* 4: Domain-specific interface handle. */ + u32 tpm_instance; /* 8: Instance of the TPM to talk to. */ + /* OUT */ + u32 status; /* 12 */ +} tpmif_be_create_t; /* 16 bytes */ + +/* + * CMSG_TPMIF_BE_DESTROY: + * When the driver sends a successful response then the interface is fully + * torn down. The controller will send a DESTROYED notification to the + * front-end driver. + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Identify interface to be destroyed. */ + u16 __pad; + u32 tpmif_handle; /* 4: */ + /* OUT */ + u32 status; /* 8 */ +} tpmif_be_destroy_t; /* 12 bytes */ + +/* + * CMSG_TPMIF_BE_CONNECT: + * When the driver sends a successful response then the interface is fully + * connected. The controller will send a CONNECTED notification to the + * front-end driver. + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Domain attached to new interface. */ + u16 evtchn; /* 2: Event channel for notifications. */ + u32 tpmif_handle; /* 4: Domain-specific interface handle. */ + memory_t shmem_frame; /* 8: Page cont. tx shared comms window. */ + u32 shmem_ref; /* 16: Grant reference for shmem_frame. */ + /* OUT */ + u32 status; /* 20 */ +} tpmif_be_connect_t; /* 24 bytes */ + +/* + * CMSG_TPMIF_BE_DISCONNECT: + * When the driver sends a successful response then the interface is fully + * disconnected. The controller will send a DOWN notification to the + * front-end driver. + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Domain attached to new interface. */ + u16 __pad; + u32 tpmif_handle; /* 4: Domain-specific interface handle. */ + /* OUT */ + u32 status; /* 8 */ +} tpmif_be_disconnect_t; /* 12 bytes */ + +/* + * CMSG_TPMIF_BE_DRIVER_STATUS: + * Notify the domain controller that the back-end driver is DOWN or UP. + * If the driver goes DOWN while interfaces are still UP, the domain + * will automatically send DOWN notifications. + */ +typedef struct { + u32 status; /* 0: TPMIF_DRIVER_STATUS_??? */ +} tpmif_be_driver_status_t; /* 4 bytes */ + + #endif /* __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__ */ diff -uprN xen-unstable.hg.orig/xen/include/public/io/tpmif.h xen-unstable.hg/xen/include/public/io/tpmif.h --- xen-unstable.hg.orig/xen/include/public/io/tpmif.h 1969-12-31 19:00:00.000000000 -0500 +++ xen-unstable.hg/xen/include/public/io/tpmif.h 2005-08-16 17:06:13.000000000 -0400 @@ -0,0 +1,45 @@ +/****************************************************************************** + * tpmif.h + * + * TPM I/O interface for Xen guest OSes. + * + * Copyright (c) 2005, IBM Corporation + * + * Author: Stefan Berger, stefanb@us.ibm.com + * Grant table support: Mahadevan Gomathisankaran + * + * This code has been derived from tools/libxc/xen/io/netif.h + * + * Copyright (c) 2003-2004, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_IO_TPMIF_H__ +#define __XEN_PUBLIC_IO_TPMIF_H__ + +typedef struct { + memory_t addr; /* 0: Machine address of packet. */ +#ifdef CONFIG_XEN_TPMDEV_GRANT + int ref; /* grant table access reference : @DEV */ + // gnttab_op_t aop; /* grant table operation */ +#endif + u16 id; /* 8: Echoed in response message. */ + u16 size:15; /* 10: Packet size in bytes. */ + u16 mapped:1; +} tpmif_tx_request_t; /* 12 bytes - 16 bytes with grant table support */ + +/* + * The TPMIF_TX_RING_SIZE defines the number of pages the + * front-end and backend can exchange (= size of array). + */ +typedef u32 TPMIF_RING_IDX; + +#define TPMIF_TX_RING_SIZE 16 + +/* This structure must fit in a memory page. */ +typedef struct { + union { /* 12 */ + tpmif_tx_request_t req; + } ring[TPMIF_TX_RING_SIZE]; +} tpmif_tx_interface_t; + +#endif diff -uprN xen-unstable.hg.orig/xen/include/public/xen.h xen-unstable.hg/xen/include/public/xen.h --- xen-unstable.hg.orig/xen/include/public/xen.h 2005-08-08 22:17:16.000000000 -0400 +++ xen-unstable.hg/xen/include/public/xen.h 2005-08-16 17:06:13.000000000 -0400 @@ -458,6 +458,7 @@ typedef struct start_info { #define SIF_BLK_BE_DOMAIN (1<<4) /* Is this a block backend domain? */ #define SIF_NET_BE_DOMAIN (1<<5) /* Is this a net backend domain? */ #define SIF_USB_BE_DOMAIN (1<<6) /* Is this a usb backend domain? */ +#define SIF_TPM_BE_DOMAIN (1<<7) /* Is this a TPM backend domain? */ /* For use in guest OSes. */ extern shared_info_t *HYPERVISOR_shared_info;