qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Add TPM support


From: Thomas Bleher
Subject: Re: [Qemu-devel] [PATCH] Add TPM support
Date: Wed, 7 Nov 2007 13:05:31 +0100
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

* Fabrice Bellard <address@hidden> [2007-11-06 20:47]:
> Thomas Bleher wrote:
> > * Fabrice Bellard <address@hidden> [2007-11-05 16:40]:
> >> Thomas Bleher wrote:
> > +        result = write(s->tpm_fd, s->send_data, s->send_data_index);
> > +        if (result < s->send_data_index) {
> > +            fprintf(stderr, "WARNING: Failed to write data to tpm!\n");
> > +            return ATML_STATUS_BUSY;
> > +        }
> 
> You should handle EINTR and EAGAIN.
> 
> > +        s->send_data_index = 0;
> > +        s->recv_data_pos = 0;
> > +        s->recv_data_length = 0;
> > +        s->data_to_send = 0;
> > +        s->data_to_recv = 1;
> > +    }
> > +    if (s->data_to_recv) {
> > +        if (poll(&(s->tpm_poll), 1, 0) > 0) {
> 
> poll is not needed as read will block.
> 
> > +            result = read(s->tpm_fd, s->recv_data, 2048);
> > +            if (result < 6) { // a minimal packet is 6 bytes long
> > +                fprintf(stderr, "WARNING: Not enough data from tpm!\n");
> > +                return ATML_STATUS_BUSY;
> > +            }
> 
> same comment as write().
> 
> > +    res = connect(sock, (struct sockaddr*)&addr, sizeof(struct 
> > sockaddr_un));
> > +    if (res < 0)
> > +        return -1;
> 
> same comment for EINTR.
> 
> +/* should be called first, initializes all structures and connects to
> the external emulator */
> +void tpm_configure(const char* tpm_socket)
> +{
> 
> Suppress this function (cf tpm_register).
> 
> > +/* split of from tpm_configure() so the configuration can be called 
> > earlier */
> > +void tpm_register()
> 
> Ansi C requires void in parameters. Allocate the state and return it.
> Suppress the global variable tpm_state. Pass the path to this function
> and suppress the configure function. Add a global variable for the path
> and register the device if it is not NULL.

Thank you for the review!
An updated patch is appended. The patch has been tested using a Linux
client with IMA added.

Thomas

Attachment: tpm-support.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]