From patchwork Fri Mar 10 09:58:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiandi An X-Patchwork-Id: 9615787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EFB3A604DD for ; Fri, 10 Mar 2017 10:14:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE10C28703 for ; Fri, 10 Mar 2017 10:14:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2ED528712; Fri, 10 Mar 2017 10:14:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E0052870D for ; Fri, 10 Mar 2017 10:14:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cmHZV-000179-Fy; Fri, 10 Mar 2017 10:14:53 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cmHZU-000173-Ko for tpmdd-devel@lists.sourceforge.net; Fri, 10 Mar 2017 10:14:52 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of codeaurora.org designates 198.145.29.96 as permitted sender) client-ip=198.145.29.96; envelope-from=anjiandi@codeaurora.org; helo=smtp.codeaurora.org; Received: from smtp.codeaurora.org ([198.145.29.96]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1cmHZT-0002eF-MM for tpmdd-devel@lists.sourceforge.net; Fri, 10 Mar 2017 10:14:52 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 88725607B5; Fri, 10 Mar 2017 09:58:18 +0000 (UTC) Received: from anjiandi-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: anjiandi@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D9A21607B5; Fri, 10 Mar 2017 09:58:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D9A21607B5 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=anjiandi@codeaurora.org From: Jiandi An To: tpmdd-devel@lists.sourceforge.net Date: Fri, 10 Mar 2017 03:58:08 -0600 Message-Id: <1489139889-14376-3-git-send-email-anjiandi@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1489139889-14376-1-git-send-email-anjiandi@codeaurora.org> References: <1489139889-14376-1-git-send-email-anjiandi@codeaurora.org> X-Headers-End: 1cmHZT-0002eF-MM Cc: Jiandi An , rafael.j.wysocki@intel.com, robert.moore@intel.com, lv.zheng@intel.com, lenb@kernel.org Subject: [tpmdd-devel] [PATCH 2/3] tpm: Add start method for ARM Secure Monitor Call X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP Add a TPM Command Response Buffer start method that invokes a secure Monitor Call to request the firmware to execute or cancel a TPM 2.0 command for ARM64. Signed-off-by: Jiandi An --- drivers/char/tpm/tpm.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 4937b56..4341594 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -35,6 +35,9 @@ #include #include #include +#ifdef CONFIG_ARM64 +#include +#endif enum tpm_const { TPM_MINOR = 224, /* officially assigned */ @@ -484,6 +487,32 @@ static inline void tpm_buf_append_u32(struct tpm_buf *buf, const u32 value) tpm_buf_append(buf, (u8 *) &value2, 4); } +#ifdef CONFIG_ARM64 +/* + * This is a TPM Command Response Buffer start method that invokes a + * Secure Monitor Call to requrest the firmware to execute or cancel + * a TPM 2.0 command. + */ +static inline int tpm_crb_smc_start(unsigned long func_id) +{ + struct arm_smccc_res res; + + arm_smccc_smc(func_id, 0, 0, 0, 0, 0, 0, 0, &res); + if (res.a0 != 0) { + WARN(1, "tpm_crb_smc_start() returns res.a0 = 0x%lx\n", res.a0); + return -EIO; + } + + return 0; +} +#else +static inline int tpm_crb_smc_start(unsigned long func_id) +{ + WARN(1, "tpm_crb: incorrect start method\n"); + return -EINVAL; +} +#endif + extern struct class *tpm_class; extern dev_t tpm_devt; extern const struct file_operations tpm_fops;