From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org, andreas.niederl@iaik.tugraz.at
Subject: Re: [Qemu-devel] [PATCH V14 2/7] Add TPM (frontend) hardware interface (TPM TIS) to Qemu
Date: Tue, 21 Feb 2012 06:19:26 -0500 [thread overview]
Message-ID: <4F437DBE.90901@linux.vnet.ibm.com> (raw)
In-Reply-To: <20120221031854.GA2502@redhat.com>
On 02/20/2012 10:18 PM, Michael S. Tsirkin wrote:
> On Mon, Feb 20, 2012 at 07:43:05PM -0500, Stefan Berger wrote:
>> On 02/20/2012 05:02 PM, Michael S. Tsirkin wrote:
>>> On Wed, Dec 14, 2011 at 08:43:17AM -0500, Stefan Berger wrote:
>>>> +/*
>>>> + * Send a TPM request.
>>>> + * Call this with the state_lock held so we can sync with the receive
>>>> + * callback.
>>>> + */
>>>> +static void tpm_tis_tpm_send(TPMState *s, uint8_t locty)
>>>> +{
>>>> + TPMTISState *tis =&s->s.tis;
>>>> +
>>>> + tpm_tis_show_buffer(&tis->loc[locty].w_buffer, "tpm_tis: To TPM");
>>>> +
>>>> + s->command_locty = locty;
>>>> + s->cmd_locty =&tis->loc[locty];
>>>> +
>>>> + /* w_offset serves as length indicator for length of data;
>>>> + it's reset when the response comes back */
>>>> + tis->loc[locty].status = TPM_TIS_STATUS_EXECUTION;
>>>> + tis->loc[locty].sts&= ~TPM_TIS_STS_EXPECT;
>>>> +
>>>> + s->to_tpm_execute = true;
>>>> + qemu_cond_signal(&s->to_tpm_cond);
>>>> +}
>>> What happens IIUC is that frondend sets to_tpm_execute
>>> and signals a condition, and backend clears it
>>> and waits on a condition.
>>>
>>> So how about moving all the signalling
>>> and locking out to backend, and have frontend
>>> invoke a callback to signal it?
>>>
>>> The whole threading thing then becomes a work-around
>>> for a backend that does not support select,
>>> instead of spilling out into frontend?
>>>
>> How do I get the lock calls (qemu_mutex_lock(&s->state_lock)) out of
>> the frontend? Do you want me to add callbacks to the backend
>> interface for locking (s->be_driver->ops->state_lock(s)) and one for
>> unlocking (s->be_driver->ops->state_unlock(tpm_be)) of the state
>> that really belongs to the front-end (state is 's') and invoke it as
>> shown in parenthesis and still keep s->state_lock around? Ideally
>> the locks would end up being 'nop's' if select() was available, but
>> in the end all backend will need to support that lock.
>>
>> [The lock protects the common structure so that the thread in the
>> backend can deliver the response to a request while the OS for
>> example polls the hardware interface for its current state.]
>>
>>
>> Stefan
>
> Well, this is just an idea, please do not take this as
> a request or anything like that. Maybe it is a dumb one.
>
> Maybe something like what you describe.
I am starting to wonder what we're trying to achieve? We have a
producer-consumer problem here with different threads. Both threads need
to have some locking constructs along with the signalling (condition).
The backend needs to be written in a certain way to work with the
frontend, locking and signalling is a part of this. So I don't see it
makes much sense to move all that code around, especially since there is
only one backend right now. Maybe something really great can be done
once there is a 2nd backend.
> Alternatively, I imagined that you can pass a copy
> or pointer of the necessary state to the backend,
> which queues the command and wakes the worker.
> In the reverse direction, backend queues a response
> and when OS polls you dequeue it and update state.
>
The OS doesn't necessarily need to poll. It is just one mode of
operation of the OS, the other being interrupt-driven where the backend
raises the interrupt once it has delivered the response to the frontend.
Stefan
> Can this work?
next prev parent reply other threads:[~2012-02-21 11:19 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 13:43 [Qemu-devel] [PATCH V14 0/7] Qemu Trusted Platform Module (TPM) integration Stefan Berger
2011-12-14 13:43 ` [Qemu-devel] [PATCH V14 1/7] Support for TPM command line options Stefan Berger
2011-12-14 13:43 ` [Qemu-devel] [PATCH V14 2/7] Add TPM (frontend) hardware interface (TPM TIS) to Qemu Stefan Berger
2012-02-20 8:51 ` Michael S. Tsirkin
2012-02-20 15:48 ` Stefan Berger
2012-02-20 19:37 ` Michael S. Tsirkin
2012-02-20 19:58 ` Stefan Berger
2012-02-23 20:47 ` Stefan Berger
2012-02-20 22:02 ` Michael S. Tsirkin
2012-02-21 0:43 ` Stefan Berger
2012-02-21 3:18 ` Michael S. Tsirkin
2012-02-21 11:19 ` Stefan Berger [this message]
2012-02-21 12:18 ` Michael S. Tsirkin
2012-02-21 15:05 ` Stefan Berger
2012-02-21 19:58 ` Michael S. Tsirkin
2012-02-21 22:30 ` Stefan Berger
2012-02-21 23:08 ` Michael S. Tsirkin
2012-02-22 0:21 ` Stefan Berger
2012-02-22 4:34 ` Michael S. Tsirkin
2012-02-22 15:03 ` Stefan Berger
2012-02-22 17:55 ` Stefan Berger
2012-03-02 12:02 ` Stefan Berger
2012-03-04 22:59 ` Michael S. Tsirkin
2012-03-05 15:44 ` Stefan Berger
2012-03-05 15:46 ` Stefan Berger
2011-12-14 13:43 ` [Qemu-devel] [PATCH V14 3/7] Add a debug register Stefan Berger
2011-12-14 13:43 ` [Qemu-devel] [PATCH V14 4/7] Build the TPM frontend code Stefan Berger
2011-12-14 13:43 ` [Qemu-devel] [PATCH V14 5/7] Add a TPM Passthrough backend driver implementation Stefan Berger
2012-02-20 19:51 ` Michael S. Tsirkin
2012-02-20 20:25 ` Stefan Berger
2012-02-20 21:15 ` Michael S. Tsirkin
2012-02-21 1:03 ` Stefan Berger
2012-03-21 23:27 ` Anthony Liguori
2012-02-20 20:01 ` Michael S. Tsirkin
2012-02-20 21:12 ` Stefan Berger
2012-02-20 21:30 ` Michael S. Tsirkin
2012-02-21 0:30 ` Stefan Berger
2011-12-14 13:43 ` [Qemu-devel] [PATCH V14 6/7] Introduce --enable-tpm-passthrough configure option Stefan Berger
2011-12-14 13:43 ` [Qemu-devel] [PATCH V14 7/7] Add fd parameter for TPM passthrough driver Stefan Berger
2012-01-12 16:59 ` [Qemu-devel] [PATCH V14 0/7] Qemu Trusted Platform Module (TPM) integration Paul Moore
2012-01-16 19:21 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F437DBE.90901@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=andreas.niederl@iaik.tugraz.at \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).