From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, amarnath.valluri@intel.com
Subject: Re: [Qemu-devel] [PATCH 2/5] tpm: pull tpm_util_send() out of tpm_util_test()
Date: Wed, 8 Nov 2017 17:22:05 +0100 [thread overview]
Message-ID: <20171108162205.GD13150@boraha> (raw)
In-Reply-To: <1510016336-4086-3-git-send-email-stefanb@linux.vnet.ibm.com>
Hi Stefan,
On Mon, Nov 06, 2017 at 07:58:53PM -0500, Stefan Berger wrote:
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
> hw/tpm/tpm_util.c | 33 ++++++++++++++++++++++++++-------
> 1 file changed, 26 insertions(+), 7 deletions(-)
>
> diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c
> index daf1faa..396e793 100644
> --- a/hw/tpm/tpm_util.c
> +++ b/hw/tpm/tpm_util.c
> @@ -53,10 +53,11 @@ bool tpm_util_is_selftest(const uint8_t *in, uint32_t in_len)
> * A basic test of a TPM device. We expect a well formatted response header
> * (error response is fine) within one second.
> */
> -static int tpm_util_test(int fd,
> - unsigned char *request,
> - size_t requestlen,
> - uint16_t *return_tag)
> +static int tpm_util_tx(int fd,
The function is not just tx, but write & read. Call it
tpm_util_request() instead?
> + unsigned char *request,
> + size_t requestlen,
> + unsigned char *response,
> + size_t responselen)
> {
> struct tpm_resp_hdr *resp;
> fd_set readfds;
> @@ -65,7 +66,6 @@ static int tpm_util_test(int fd,
> .tv_sec = 1,
> .tv_usec = 0,
> };
> - unsigned char buf[1024];
>
> n = write(fd, request, requestlen);
> if (n < 0) {
> @@ -84,17 +84,36 @@ static int tpm_util_test(int fd,
> return -errno;
> }
>
> - n = read(fd, &buf, sizeof(buf));
> + n = read(fd, response, responselen);
> if (n < sizeof(struct tpm_resp_hdr)) {
> return -EFAULT;
> }
>
> - resp = (struct tpm_resp_hdr *)buf;
> + resp = (struct tpm_resp_hdr *)response;
> /* check the header */
> if (be32_to_cpu(resp->len) != n) {
> return -EMSGSIZE;
> }
>
> + return 0;
> +}
> +
> +static int tpm_util_test(int fd,
> + unsigned char *request,
> + size_t requestlen,
> + uint16_t *return_tag)
> +{
> + struct tpm_resp_hdr *resp;
> + unsigned char buf[1024];
> + ssize_t ret;
> +
> + ret = tpm_util_tx(fd, request, requestlen,
> + buf, sizeof(buf));
> + if (ret < 0) {
> + return ret;
> + }
> +
> + resp = (struct tpm_resp_hdr *)buf;
> *return_tag = be16_to_cpu(resp->tag);
>
> return 0;
> --
> 2.5.5
>
>
Looks fine otherwise,
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
next prev parent reply other threads:[~2017-11-08 16:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 0:58 [Qemu-devel] [PATCH 0/5] tpm: Match frontend and backend buffer sizes (not 2.11) Stefan Berger
2017-11-07 0:58 ` [Qemu-devel] [PATCH 1/5] tpm: Move getting TPM buffer size to backends Stefan Berger
2017-11-08 16:21 ` Marc-André Lureau
2017-11-08 18:19 ` Stefan Berger
2017-11-07 0:58 ` [Qemu-devel] [PATCH 2/5] tpm: pull tpm_util_send() out of tpm_util_test() Stefan Berger
2017-11-08 16:22 ` Marc-André Lureau [this message]
2017-11-07 0:58 ` [Qemu-devel] [PATCH 3/5] tpm: tpm_passthrough: Read the buffer size from the host device Stefan Berger
2017-11-07 12:28 ` Stefan Berger
2017-11-08 16:18 ` Marc-André Lureau
2017-11-07 0:58 ` [Qemu-devel] [PATCH 4/5] tpm: tpm_emulator: get and set buffer size of device Stefan Berger
2017-11-08 16:22 ` Marc-André Lureau
2017-11-08 17:50 ` Stefan Berger
2017-11-07 0:58 ` [Qemu-devel] [PATCH 5/5] tpm: tpm_passthrough: Fail startup if FE buffer size < BE buffer size Stefan Berger
2017-11-08 16:22 ` Marc-André Lureau
2017-11-08 18:20 ` Stefan Berger
2017-11-08 16:20 ` [Qemu-devel] [PATCH 0/5] tpm: Match frontend and backend buffer sizes (not 2.11) Marc-André Lureau
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=20171108162205.GD13150@boraha \
--to=marcandre.lureau@redhat.com \
--cc=amarnath.valluri@intel.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.vnet.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.