From patchwork Wed Nov 18 22:12:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 546226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5F6E0141478 for ; Thu, 19 Nov 2015 09:13:24 +1100 (AEDT) Received: from localhost ([::1]:38600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzAyg-0004H8-EH for incoming@patchwork.ozlabs.org; Wed, 18 Nov 2015 17:13:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzAyO-0003yi-Li for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:13:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzAyL-0005Ss-A9 for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:13:04 -0500 Received: from e17.ny.us.ibm.com ([129.33.205.207]:48957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzAyL-0005Sj-5d for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:13:01 -0500 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Nov 2015 17:12:59 -0500 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Nov 2015 17:12:57 -0500 X-IBM-Helo: d01dlp03.pok.ibm.com X-IBM-MailFrom: stefanb@us.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 52E0DC90046 for ; Wed, 18 Nov 2015 17:01:06 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAIMCuuY53215316 for ; Wed, 18 Nov 2015 22:12:56 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAIMCtAu024143 for ; Wed, 18 Nov 2015 17:12:55 -0500 Received: from sbct-3.watson.ibm.com (sbct-3.watson.ibm.com [9.2.141.158]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tAIMCt5L024128; Wed, 18 Nov 2015 17:12:55 -0500 From: Stefan Berger To: mst@redhat.com, qemu-devel@nongnu.org Date: Wed, 18 Nov 2015 17:12:40 -0500 Message-Id: <1447884760-23667-1-git-send-email-stefanb@us.ibm.com> X-Mailer: git-send-email 2.4.3 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15111822-0041-0000-0000-0000026833DA X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 129.33.205.207 Cc: Stefan Berger , Stefan Berger , crobinso@redhat.com Subject: [Qemu-devel] [REPOST] [PATCH] tpm: adapt sysfs cancel path for new TPM driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 8d8523a..424d7e3 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -353,6 +353,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); @@ -366,16 +368,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);