From patchwork Fri Jan 13 16:10:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 43414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp362516wrt; Fri, 13 Jan 2023 08:27:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXutx9BSPiWInPXi3BQYpToNsfcFW7nA2WA0U96/9+hKdCGgJvXKq9vG/xbCL7svJTfxVYea X-Received: by 2002:a17:90b:1d0a:b0:226:e466:9e9b with SMTP id on10-20020a17090b1d0a00b00226e4669e9bmr27032312pjb.4.1673627258138; Fri, 13 Jan 2023 08:27:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673627258; cv=none; d=google.com; s=arc-20160816; b=g6zmmN2hYU8CS3bOyyDwodAEkI3Exi2/7G4cwT74HBg0L2Ai4N1fOcIj8F6UNHfbfR e3osE3KVn0iwtNrjy9P3FffZJWB1jgiD6olkuh3EHKrG4lyQhNAoS+yOZhh+Kp2r+61H QK8k0yLLEZtnvFPPLa57LH8+PzjqAw1mBBW+RvjvyZAjh2aCx36Jn+iWqJSHx6z8tCVk WCnqF18dJydKJJRfHuHou3B7KfKDJz1GUaEGMJsZqeMU8Kz8yL+LSwXdBwzWyAamIBrV qrsxqSzxikw0gugzBCl4Il57TiWCmYWcV06KVHTeWL6sKdcBLUDAGFV4q2GEIpe857ju WiwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ln93bccdgNzFEICgGiX/7Ramezk+x3HjkrqS2NuE3WU=; b=iKIp4RA0ohhiiBTqF6Ac2Xx/f8pGodB5gO21I05+huBqsR2JdoCpWTRaX6DM3TRyVs pxMhuDtEuGLF5Oxq5/oh4PU7pzwydcUK9azxmnoQ+TeCCIKzPYPxzQWeTi4Pvu7yplae fytE/EAop3RS/vvJzEtDdYu7w1pejcJxn/gKrD305+6QSmR4iisK2/59HVLsi+Ems/q5 Zbi5YV9z6kcPrKlxgYdAVrfLMfHOo710WpZQjKn973OEF8o/KQWs2EALzhILObGfU6nG /QwXVi43qamr9EeYfcFMyC1xJ/tyPclGm3IpjqnvV6EhZey2NjT6j5/GHx6vX7V36pHf i3sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=k9rr3l4i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li12-20020a17090b48cc00b00210d1aeabc1si13603455pjb.188.2023.01.13.08.27.25; Fri, 13 Jan 2023 08:27:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=k9rr3l4i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbjAMQR4 (ORCPT + 99 others); Fri, 13 Jan 2023 11:17:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbjAMQRS (ORCPT ); Fri, 13 Jan 2023 11:17:18 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD8F96139; Fri, 13 Jan 2023 08:10:35 -0800 (PST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30DFgS2k029121; Fri, 13 Jan 2023 16:10:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=ln93bccdgNzFEICgGiX/7Ramezk+x3HjkrqS2NuE3WU=; b=k9rr3l4icRSIXPa+1MPmP1osmVr37wrOBCyoa8FBOrgBFwEnwpuKmNqzv6t9YMjUr7je 3wY85f4rqV/WPsQf+CBv1ZMGwEo0h4Eb9XyAffaenVdxWpBvqo+Jx4uUHcTChjlO4ss4 SCMoehemR6ax/T/zjdbDSVxDksAd5+nMRAAhfmSE022P+mDIrzEUPJNtZoUSOhvTFjDs q1y1EmvL9bO3JzfdVk/XQ+41wIojTgxMqwrRikLJ2KQoUsKmbRD2QP0Ea7TW+OFrTfrt OVM2S5JytvueTR+8J+BCrfFrr0Ej3Azl2JywZnpXEdweP7MiQxPhJ/8wU7hVgnoY8N5U CA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n3a60gp9f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Jan 2023 16:10:33 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30DFl63j024687; Fri, 13 Jan 2023 16:10:32 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n3a60gp8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Jan 2023 16:10:32 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30DEh0Lj014476; Fri, 13 Jan 2023 16:10:31 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([9.208.130.98]) by ppma01dal.us.ibm.com (PPS) with ESMTPS id 3n1kv5mmus-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Jan 2023 16:10:31 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30DGAT1K9175726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Jan 2023 16:10:29 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FFCA58054; Fri, 13 Jan 2023 16:10:28 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 146C358045; Fri, 13 Jan 2023 16:10:27 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.77.137.189]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 13 Jan 2023 16:10:26 +0000 (GMT) From: Eddie James To: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jgg@ziepe.ca, jarkko@kernel.org, peterhuewe@gmx.de, Eddie James Subject: [PATCH v2 2/2] tpm: Add reserved memory event log Date: Fri, 13 Jan 2023 10:10:17 -0600 Message-Id: <20230113161017.1079299-3-eajames@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230113161017.1079299-1-eajames@linux.ibm.com> References: <20230113161017.1079299-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 9p6qPd3AXBWLpQhChDZQnHeCN1hJKZr2 X-Proofpoint-GUID: 6nsl0VfiKurJL0GwwHUe7wccLZp6ptzj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-13_07,2023-01-13_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301130107 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754925370850260529?= X-GMAIL-MSGID: =?utf-8?q?1754925376009879117?= Some platforms may desire to pass the event log up to linux in the form of a reserved memory region. Add support for this in the TPM core to find the reserved memory region and map it. Signed-off-by: Eddie James --- drivers/char/tpm/eventlog/of.c | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/eventlog/of.c b/drivers/char/tpm/eventlog/of.c index 741ab2204b11..c815cadf00a4 100644 --- a/drivers/char/tpm/eventlog/of.c +++ b/drivers/char/tpm/eventlog/of.c @@ -12,12 +12,48 @@ #include #include +#include +#include #include +#include +#include #include #include "../tpm.h" #include "common.h" +static int tpm_read_log_memory_region(struct tpm_chip *chip) +{ + struct device_node *node; + struct resource res; + int rc; + + node = of_parse_phandle(chip->dev.parent->of_node, "memory-region", 0); + if (!node) { + dev_info(&chip->dev, "no phandle\n"); + return -ENODEV; + } + + rc = of_address_to_resource(node, 0, &res); + of_node_put(node); + if (rc) { + dev_info(&chip->dev, "no mem\n"); + return rc; + } + + chip->log.bios_event_log = devm_memremap(&chip->dev, res.start, resource_size(&res), + MEMREMAP_WB); + if (!chip->log.bios_event_log) { + dev_info(&chip->dev, "err memremap\n"); + return -ENOMEM; + } + + chip->log.bios_event_log_end = chip->log.bios_event_log + resource_size(&res); + + return chip->flags & TPM_CHIP_FLAG_TPM2 ? EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 : + EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2; +} + int tpm_read_log_of(struct tpm_chip *chip) { struct device_node *np; @@ -39,7 +75,7 @@ int tpm_read_log_of(struct tpm_chip *chip) sizep = of_get_property(np, "linux,sml-size", NULL); basep = of_get_property(np, "linux,sml-base", NULL); if (sizep == NULL && basep == NULL) - return -ENODEV; + return tpm_read_log_memory_region(chip); if (sizep == NULL || basep == NULL) return -EIO;