qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH V21 6/7] Add support for cancelling of a TPM com


From: Corey Bryant
Subject: Re: [Qemu-devel] [PATCH V21 6/7] Add support for cancelling of a TPM command
Date: Mon, 11 Feb 2013 16:43:57 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2



On 02/11/2013 04:38 PM, Stefan Berger wrote:
On 02/11/2013 01:46 PM, Corey Bryant wrote:

@@ -79,25 +88,36 @@ static uint32_t
tpm_passthrough_get_size_from_buffer(const uint8_t *buf)
      return be32_to_cpu(resp->len);
  }

-static int tpm_passthrough_unix_tx_bufs(int tpm_fd,
+static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt,
                                          const uint8_t *in, uint32_t
in_len,
                                          uint8_t *out, uint32_t
out_len)
  {
      int ret;

-    ret = tpm_passthrough_unix_write(tpm_fd, in, in_len);
+    tpm_pt->tpm_op_canceled = false;
+    tpm_pt->tpm_executing = true;
+
+    ret = tpm_passthrough_unix_write(tpm_pt->tpm_fd, in, in_len);
      if (ret != in_len) {
-        error_report("tpm_passthrough: error while transmitting data "
-                     "to TPM: %s (%i)\n",
-                     strerror(errno), errno);
+        if (!tpm_pt->tpm_op_canceled ||
+            (tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
+            error_report("tpm_passthrough: error while transmitting
data "
+                         "to TPM: %s (%i)\n",
+                         strerror(errno), errno);
+        }
          goto err_exit;
      }

-    ret = tpm_passthrough_unix_read(tpm_fd, out, out_len);
+    tpm_pt->tpm_executing = false;
+
+    ret = tpm_passthrough_unix_read(tpm_pt->tpm_fd, out, out_len);
      if (ret < 0) {
-        error_report("tpm_passthrough: error while reading data from "
-                     "TPM: %s (%i)\n",
-                     strerror(errno), errno);
+        if (!tpm_pt->tpm_op_canceled ||
+            (tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
+            error_report("tpm_passthrough: error while reading data
from "
+                         "TPM: %s (%i)\n",
+                         strerror(errno), errno);
+        }
      } else if (ret < sizeof(struct tpm_resp_hdr) ||
                 tpm_passthrough_get_size_from_buffer(out) != ret) {
          ret = -1;
@@ -110,13 +130,15 @@ err_exit:
          tpm_write_fatal_error_response(out, out_len);
      }

+    tpm_pt->tpm_executing = false;

This can be removed because it is already false.


Above I am setting tpm_executing to true before the write to the device.
If an error occurred, we goto to the exit with the above statement. I am
also setting tpm_executing to false before the reading of the result. So
in case of an error this statement is need.



You're right.  My mistake, I missed the exit label.

--
Regards,
Corey Bryant




reply via email to

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