qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [REPOST v2] [PATCH] tpm: adapt sysfs cancel path for new TPM driver
@ 2016-03-21 14:39 Stefan Berger
  2016-03-28 20:05 ` Stefan Berger
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Berger @ 2016-03-21 14:39 UTC (permalink / raw)
  To: mst, qemu-devel, peter.maydell; +Cc: Stefan Berger, Stefan Berger, crobinso

This patch addresses BZ 1281413.

Adapt the sysfs TPM command cancel path for the TPM driver that
does not use a miscdevice anymore since Linux 4.0. Support old
and new paths.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 hw/tpm/tpm_passthrough.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index e98efb7..e1edb38 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -377,6 +377,8 @@ static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb)
     int fd = -1;
     char *dev;
     char path[PATH_MAX];
+    const char *prefix[] = {"misc/", "tpm/"};
+    int i;
 
     if (tb->cancel_path) {
         fd = qemu_open(tb->cancel_path, O_WRONLY);
@@ -390,16 +392,21 @@ static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb)
     dev = strrchr(tpm_pt->tpm_dev, '/');
     if (dev) {
         dev++;
-        if (snprintf(path, sizeof(path), "/sys/class/misc/%s/device/cancel",
-                     dev) < sizeof(path)) {
-            fd = qemu_open(path, O_WRONLY);
-            if (fd >= 0) {
-                tb->cancel_path = g_strdup(path);
-            } else {
-                error_report("tpm_passthrough: Could not open TPM cancel "
-                             "path %s : %s", path, strerror(errno));
+        for (i = 0; i < ARRAY_SIZE(prefix); i++) {
+            if (snprintf(path, sizeof(path),
+                         "/sys/class/%s%s/device/cancel",
+                         prefix[i], dev) < sizeof(path)) {
+                fd = qemu_open(path, O_WRONLY);
+                if (fd >= 0) {
+                    tb->cancel_path = g_strdup(path);
+                    break;
+                }
             }
         }
+        if (fd < 0) {
+            error_report("tpm_passthrough: Could not open TPM cancel "
+                         "path %s : %s", path, strerror(errno));
+        }
     } else {
        error_report("tpm_passthrough: Bad TPM device path %s",
                     tpm_pt->tpm_dev);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [REPOST v2] [PATCH] tpm: adapt sysfs cancel path for new TPM driver
  2016-03-21 14:39 [Qemu-devel] [REPOST v2] [PATCH] tpm: adapt sysfs cancel path for new TPM driver Stefan Berger
@ 2016-03-28 20:05 ` Stefan Berger
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Berger @ 2016-03-28 20:05 UTC (permalink / raw)
  To: Stefan Berger, mst, qemu-devel, peter.maydell; +Cc: crobinso

Peter, Michael,

   I have 3 TPM related patches on the mailing list that are fixing 
buges. They are either being overlooked or ignored. How can we make 
progress with them?

Regards,
    Stefan



On 03/21/2016 10:39 AM, Stefan Berger wrote:
> This patch addresses BZ 1281413.
>
> Adapt the sysfs TPM command cancel path for the TPM driver that
> does not use a miscdevice anymore since Linux 4.0. Support old
> and new paths.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>   hw/tpm/tpm_passthrough.c | 23 +++++++++++++++--------
>   1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
> index e98efb7..e1edb38 100644
> --- a/hw/tpm/tpm_passthrough.c
> +++ b/hw/tpm/tpm_passthrough.c
> @@ -377,6 +377,8 @@ static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb)
>       int fd = -1;
>       char *dev;
>       char path[PATH_MAX];
> +    const char *prefix[] = {"misc/", "tpm/"};
> +    int i;
>
>       if (tb->cancel_path) {
>           fd = qemu_open(tb->cancel_path, O_WRONLY);
> @@ -390,16 +392,21 @@ static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb)
>       dev = strrchr(tpm_pt->tpm_dev, '/');
>       if (dev) {
>           dev++;
> -        if (snprintf(path, sizeof(path), "/sys/class/misc/%s/device/cancel",
> -                     dev) < sizeof(path)) {
> -            fd = qemu_open(path, O_WRONLY);
> -            if (fd >= 0) {
> -                tb->cancel_path = g_strdup(path);
> -            } else {
> -                error_report("tpm_passthrough: Could not open TPM cancel "
> -                             "path %s : %s", path, strerror(errno));
> +        for (i = 0; i < ARRAY_SIZE(prefix); i++) {
> +            if (snprintf(path, sizeof(path),
> +                         "/sys/class/%s%s/device/cancel",
> +                         prefix[i], dev) < sizeof(path)) {
> +                fd = qemu_open(path, O_WRONLY);
> +                if (fd >= 0) {
> +                    tb->cancel_path = g_strdup(path);
> +                    break;
> +                }
>               }
>           }
> +        if (fd < 0) {
> +            error_report("tpm_passthrough: Could not open TPM cancel "
> +                         "path %s : %s", path, strerror(errno));
> +        }
>       } else {
>          error_report("tpm_passthrough: Bad TPM device path %s",
>                       tpm_pt->tpm_dev);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-28 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-21 14:39 [Qemu-devel] [REPOST v2] [PATCH] tpm: adapt sysfs cancel path for new TPM driver Stefan Berger
2016-03-28 20:05 ` Stefan Berger

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).