From patchwork Mon Mar 11 13:20:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 13588754 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8098E22064; Mon, 11 Mar 2024 13:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710163259; cv=none; b=L+qgNpUsdnqKo3QfzFCh+Fv/m4ltvv9jFoB9nONLnmMB9Z+4Nj7gbCuPqMb8ch898APkdVEbGO3C6aBQ6XB8D8hqX4rFRIwUXJtbI5zrn34F03k24Zqsz2lnzZNE72nkhq2eZU1lR89GvEdCyWWX/E2TcMbI7+xz8aBCLWwnYzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710163259; c=relaxed/simple; bh=WzLuQ44dxHHThOYvx0wNWyL9Gwww+wh867usE5iK92o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GJJjBDG8v3XXhlao0y5TVjlo4N6oYqxx9wb0o0QbQsuJRWnUgWs3wkAC/f3obBK1gd6HYPBta15OrE0jf2cr2k5Sia7P3VqYSX+Y685eQSLpB6KX970OFwR4N9NII9KuZdqMee5jVq4Q7un/YROVFtpINuHlnOBsNqWzgLI1xOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=hVMoOPd+; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hVMoOPd+" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42BCViTB013442; Mon, 11 Mar 2024 13:20:47 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=D+ymWYhcKlVtuY88TLHRXmdCukNBtEwkGmsa5Q+jAKA=; b=hVMoOPd+dM1mfWm6CJbLYudAsIUaZQ6/odCjCWGJm31SGej7E7YbpeGoheyDjlyQwezQ rX7tmTxwnZegA2n7Jy3A8JHG16S28K9kzQi71N/Gxx8L77dDHma6nqT0sxVfSSLZpJ1o V41mE+CIbOX2ygv/Oe22GxiA3rSw7G506BJNq+w/SpJujivKgqc8qCMfjakZrqxeM+8d XhEHTZz+FITnV1ErO/MHXluGdbZKCbUfFipjlyhShYD95X4sy5mG++XTHgfTdWaVQUIY 7U1HFZXpW+X+sxGRLOmR8gtW/zwk99qaDfu5ooNDtuTPiCo1vMD9CjeA1ql/T/taSDzq zg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wt1ub18sk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:47 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42BCn1LX030314; Mon, 11 Mar 2024 13:20:47 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wt1ub18sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:46 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42BC3c2e018543; Mon, 11 Mar 2024 13:20:46 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ws4t1r7d6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:46 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42BDKgWY32244076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 13:20:44 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D7A958069; Mon, 11 Mar 2024 13:20:42 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE44758056; Mon, 11 Mar 2024 13:20:41 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 11 Mar 2024 13:20:41 +0000 (GMT) From: Stefan Berger To: mpe@ellerman.id.au, linux-integrity@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, jarkko@kernel.org, rnsastry@linux.ibm.com, peterhuewe@gmx.de, viparash@in.ibm.com, devicetree@vger.kernel.org, jsnitsel@redhat.com, Stefan Berger Subject: [RFC PATCH v2 1/3] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log Date: Mon, 11 Mar 2024 09:20:28 -0400 Message-ID: <20240311132030.1103122-2-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311132030.1103122-1-stefanb@linux.ibm.com> References: <20240311132030.1103122-1-stefanb@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jZMDAgE8buyi2GjnRjHPY5Rmz2M0p_tg X-Proofpoint-ORIG-GUID: 7avnkx9d6VRIUGZeJiIcR0uqKwj0IQKZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-11_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 suspectscore=0 spamscore=0 impostorscore=0 adultscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403110100 linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec. To avoid accessing an invalid address or corrupted buffer, embed the whole TPM log in the device tree property linux,sml-log. This helps to protect the log since it is properly carried across a kexec soft reboot with both of the kexec syscalls. Avoid having the firmware ingest the whole TPM log when calling prom_setprop but only create the linux,sml-log property as a place holder. Insert the actual TPM log during the tree flattening phase. Fixes: 4a727429abec ("PPC64: Add support for instantiating SML from Open Firmware") Suggested-by: Michael Ellerman Signed-off-by: Stefan Berger --- arch/powerpc/kernel/prom_init.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index e67effdba85c..6f7ca72013c2 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -211,6 +211,8 @@ static cell_t __prombss regbuf[1024]; static bool __prombss rtas_has_query_cpu_stopped; +static u64 __prombss sml_base; +static u32 __prombss sml_size; /* * Error results ... some OF calls will return "-1" on error, some @@ -1954,17 +1956,15 @@ static void __init prom_instantiate_sml(void) } prom_printf(" done\n"); - reserve_mem(base, size); - - prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-base", - &base, sizeof(base)); - prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-size", - &size, sizeof(size)); - - prom_debug("sml base = 0x%llx\n", base); + /* Add property now, defer adding log to tree flattening phase */ + prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-log", + NULL, 0); prom_debug("sml size = 0x%x\n", size); prom_debug("prom_instantiate_sml: end...\n"); + + sml_base = base; + sml_size = size; } /* @@ -2645,6 +2645,17 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, } prev_name = sstart + soff; + if (!prom_strcmp("linux,sml-log", pname)) { + /* push property head */ + dt_push_token(OF_DT_PROP, mem_start, mem_end); + dt_push_token(sml_size, mem_start, mem_end); + dt_push_token(soff, mem_start, mem_end); + /* push property content */ + valp = make_room(mem_start, mem_end, sml_size, 1); + memcpy(valp, (void *)sml_base, sml_size); + *mem_start = ALIGN(*mem_start, 4); + continue; + } /* get length */ l = call_prom("getproplen", 2, 1, node, pname); From patchwork Mon Mar 11 13:20:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 13588756 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FED33D3A2; Mon, 11 Mar 2024 13:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710163260; cv=none; b=HIN4sXtQ7tyfyOIpAD8akvT5FaSAGxqtbED0frLRropT6pmZNLLe/1EZgiBWaNxmjxYIA6xVVImEDMGdfNImQUm6RJdEKSe1F6/mpDWmJKCFuM+9HaFWrpSgJALCSz1RuHWcSSBlhSmOlsGK2IOXabPEzNNPtjVWXqcEO5W4xRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710163260; c=relaxed/simple; bh=qM47hDuXXo+x3f8ngjeq/AsiJ2DnslX83WJXGYVbdb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fc7iMLrFj5EoFKL23H8pJlbt61QJ3Cm9ab0KG/ejs41NZeotwiD/a4QdnDY+pfUlPQ/sPjwAsoUL0jCNnKyl8zpxdHcNZD5oFYggSmezwdLipdEvvuHYwzsgDCMJHNcfQwS/42qLkM2nrDGJ2JD5+El+IL2d4URFmaE/xSYXLy4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=NPUF5zwl; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="NPUF5zwl" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42BCu6ti001855; Mon, 11 Mar 2024 13:20:48 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=PDOWkT1/qUN1RbHLq4ddY3Ay1sVFnWbuFxkQ3Hny/jw=; b=NPUF5zwlgkOiCovnJzMsrQx991/40mEZDNRB8ylzZqvO5GpBc8mSAPLulk4ZdCFYRIsJ emmsH4Tby06EUf8rgdGI2VbkkcKdYsxQswkPyyuSP9WfI4EQ1HxUbx6CvpBUOxQeKCnw XWIidxxGIP5dsuYy1Cdoe9CZsaN2Og8qzg/UdC3mAn2nDFy7q4k45CPiX0a5rzTXupYX cc2+hD5RZF3w4zkwHdKP+BEGihPICuYzVAcxDB/UGamQz6XfGrnJbF09Z3XCJCNeE9DW IAEg9bEC+lKqOMxtT///nGC116vhsirQJkYHEiWXi9bjdfEUImLuroiETFUotZuCmujR 9A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wt1yk958t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:47 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42BCudFf004062; Mon, 11 Mar 2024 13:20:47 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wt1yk957w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:47 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42BBqP4a018581; Mon, 11 Mar 2024 13:20:46 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ws4t1r7d7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:46 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42BDKhSC7865002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 13:20:45 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A80C58068; Mon, 11 Mar 2024 13:20:43 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 759C058056; Mon, 11 Mar 2024 13:20:42 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 11 Mar 2024 13:20:42 +0000 (GMT) From: Stefan Berger To: mpe@ellerman.id.au, linux-integrity@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, jarkko@kernel.org, rnsastry@linux.ibm.com, peterhuewe@gmx.de, viparash@in.ibm.com, devicetree@vger.kernel.org, jsnitsel@redhat.com, Stefan Berger , Lukas Wunner , Nayna Jain Subject: [RFC PATCH v2 2/3] dt-bindings: tpm: Add linux,sml-log to ibm,vtpm.yaml Date: Mon, 11 Mar 2024 09:20:29 -0400 Message-ID: <20240311132030.1103122-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311132030.1103122-1-stefanb@linux.ibm.com> References: <20240311132030.1103122-1-stefanb@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 20ubOuGWMGmMN66zt-m4ZQr-JWVw_EUh X-Proofpoint-GUID: yCzjiifoKb6BvxyBu9ESDz0GX__e7vvO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-11_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403110100 Add linux,sml-log, which carries the firmware TPM log in a uint8-array, to the properties. Either this property is required or both linux,sml-base and linux,sml-size are required. Add a test case for verification. Fixes: 82003e0487fb ("Documentation: tpm: add the IBM Virtual TPM device tree binding documentation") Cc: Lukas Wunner Cc: Nayna Jain Signed-off-by: Michael Ellerman Signed-off-by: Stefan Berger --- .../devicetree/bindings/tpm/ibm,vtpm.yaml | 20 +++++++++++++++++-- .../devicetree/bindings/tpm/tpm-common.yaml | 14 ++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml b/Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml index 50a3fd31241c..8885ef3b7638 100644 --- a/Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +++ b/Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml @@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-size allOf: - $ref: tpm-common.yaml# @@ -102,3 +100,21 @@ examples: linux,sml-size = <0xbce10200>; }; }; + - | + soc { + #address-cells = <1>; + #size-cells = <0>; + + tpm@30000003 { + compatible = "IBM,vtpm20"; + device_type = "IBM,vtpm"; + reg = <0x30000003>; + interrupts = <0xa0003 0x0>; + ibm,#dma-address-cells = <0x2>; + ibm,#dma-size-cells = <0x2>; + ibm,my-dma-window = <0x10000003 0x0 0x0 0x0 0x10000000>; + ibm,my-drc-index = <0x30000003>; + ibm,loc-code = "U9080.HEX.134CA08-V7-C3"; + linux,sml-log = <00 00 00 00 03 00 00>; + }; + }; diff --git a/Documentation/devicetree/bindings/tpm/tpm-common.yaml b/Documentation/devicetree/bindings/tpm/tpm-common.yaml index 3c1241b2a43f..f6f0b551268c 100644 --- a/Documentation/devicetree/bindings/tpm/tpm-common.yaml +++ b/Documentation/devicetree/bindings/tpm/tpm-common.yaml @@ -30,6 +30,11 @@ properties: size of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint32 + linux,sml-log: + description: + Content of firmware event log + $ref: /schemas/types.yaml#/definitions/uint8-array + memory-region: description: reserved memory allocated for firmware event log maxItems: 1 @@ -53,15 +58,22 @@ dependentRequired: linux,sml-base: ['linux,sml-size'] linux,sml-size: ['linux,sml-base'] -# must only have either memory-region or linux,sml-base +# must only have either memory-region or linux,sml-base/size or linux,sml-log # as well as either resets or reset-gpios dependentSchemas: memory-region: properties: linux,sml-base: false + linux,sml-log: false linux,sml-base: properties: memory-region: false + linux,sml-log: false + linux,sml-log: + properties: + memory-region: false + linux,sml-base: false + linux,sml-size: false resets: properties: reset-gpios: false From patchwork Mon Mar 11 13:20:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 13588755 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A45AB3CF7E; Mon, 11 Mar 2024 13:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710163259; cv=none; b=kcBTGlmHSyihc2HBSqn/S3REyZ8Nl9y02dssRkhkYgbZAeOywOH8677HJkhDwPyh3kZvHT43XNqjARImiDMBlrLuf48T9fO2yzRrzJ70gQNgRhslUANP0GEWKQK/agiY9lfssRGn3CZQuUW54rOqANHnVs+unBekWFq4or/fLAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710163259; c=relaxed/simple; bh=cgS41CqvwZ+ehlK1tNBeiYgzqPwMBSss5h2R6tKQ3mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TvmVo0O91zeIKwS5BxltFZp7g6kvW9jhwJyxDhgH2ddzMPj872VQNMB8/L657oXzHkrP6JvVubc8gLak6Nmr1B7ED8lSSoFDP3VcFrkQ2goVuQ9nv32wQM5gOH0Q29QNKcXAzLREJ6oba7JmLE76x1Vy0dum2BNcbSz/gmL/RaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qXwQ89WW; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="qXwQ89WW" Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42BCXN1N021451; Mon, 11 Mar 2024 13:20:48 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=9Q+aNdf4aY1ZWQIbQqm5mKOU85sMqxIoieARj6LXs68=; b=qXwQ89WW7X+BQKSDUt55gMXYWEyVAP+ocOlgkO7NQ0Hxbvo2FB+08QpTnRaAASUE9nLV MqmKh0K4DkopA2FwEU60tkcKAFn687p4qlL3m7stFr1Y3x6X2jcp6938NB/IMUuayaZ2 9L6cgXmEdvEaogLbe8c6/kXHO+hvwEtciBVEQdpy7xYAw6br2aG/njxx0Sso7v4tVDZR qDmspBR0pS7sbmpX12IdAc8b5NQ/AnNp/j2gb9eGPjSx/iwIcnEcKoTUxa7LM3I5WNuJ BerFb5UTO3tMAHmiPBg4mPQUUJaTmOH/9smBXTe1fC17RkeuyshOVWUr55RAlrLwvX9o ZQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wt2290yc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:47 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42BCYYDX024875; Mon, 11 Mar 2024 13:20:47 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wt2290yc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:47 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42BCZ5bl018133; Mon, 11 Mar 2024 13:20:46 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ws23t0wdd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 13:20:46 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42BDKhFi31130030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 13:20:46 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D47F65806C; Mon, 11 Mar 2024 13:20:43 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 418DB58056; Mon, 11 Mar 2024 13:20:43 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 11 Mar 2024 13:20:43 +0000 (GMT) From: Stefan Berger To: mpe@ellerman.id.au, linux-integrity@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, jarkko@kernel.org, rnsastry@linux.ibm.com, peterhuewe@gmx.de, viparash@in.ibm.com, devicetree@vger.kernel.org, jsnitsel@redhat.com, Stefan Berger Subject: [RFC PATCH v2 3/3] tpm: of: If available use linux,sml-log to get the log and its size Date: Mon, 11 Mar 2024 09:20:30 -0400 Message-ID: <20240311132030.1103122-4-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311132030.1103122-1-stefanb@linux.ibm.com> References: <20240311132030.1103122-1-stefanb@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vRub7t0aVGig_2UvQXSQrKNVntS_a5Gn X-Proofpoint-ORIG-GUID: GJwB-jDVg_6K6X6mXZ_I0GwqJ864FEmR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-11_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 suspectscore=0 bulkscore=0 mlxlogscore=930 phishscore=0 malwarescore=0 priorityscore=1501 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403110100 If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have become inaccessible or corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms. Keep the handling of linux,sml-base/sml-size for powernv platforms that provide the two properties via skiboot. Fixes: c5df39262dd5 ("drivers/char/tpm: Add securityfs support for event log") Signed-off-by: Stefan Berger --- drivers/char/tpm/eventlog/of.c | 36 +++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/drivers/char/tpm/eventlog/of.c b/drivers/char/tpm/eventlog/of.c index 930fe43d5daf..dbd837d65264 100644 --- a/drivers/char/tpm/eventlog/of.c +++ b/drivers/char/tpm/eventlog/of.c @@ -54,8 +54,8 @@ int tpm_read_log_of(struct tpm_chip *chip) const u32 *sizep; const u64 *basep; struct tpm_bios_log *log; + const void *logp; u32 size; - u64 base; log = &chip->log; if (chip->dev.parent && chip->dev.parent->of_node) @@ -66,37 +66,23 @@ int tpm_read_log_of(struct tpm_chip *chip) if (of_property_read_bool(np, "powered-while-suspended")) chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED; - sizep = of_get_property(np, "linux,sml-size", NULL); - basep = of_get_property(np, "linux,sml-base", NULL); - if (sizep == NULL && basep == NULL) - return tpm_read_log_memory_region(chip); - if (sizep == NULL || basep == NULL) - return -EIO; - - /* - * For both vtpm/tpm, firmware has log addr and log size in big - * endian format. But in case of vtpm, there is a method called - * sml-handover which is run during kernel init even before - * device tree is setup. This sml-handover function takes care - * of endianness and writes to sml-base and sml-size in little - * endian format. For this reason, vtpm doesn't need conversion - * but physical tpm needs the conversion. - */ - if (of_property_match_string(np, "compatible", "IBM,vtpm") < 0 && - of_property_match_string(np, "compatible", "IBM,vtpm20") < 0) { + logp = of_get_property(np, "linux,sml-log", &size); + if (logp == NULL) { + sizep = of_get_property(np, "linux,sml-size", NULL); + basep = of_get_property(np, "linux,sml-base", NULL); + if (sizep == NULL && basep == NULL) + return tpm_read_log_memory_region(chip); + if (sizep == NULL || basep == NULL) + return -EIO; size = be32_to_cpup((__force __be32 *)sizep); - base = be64_to_cpup((__force __be64 *)basep); - } else { - size = *sizep; - base = *basep; + logp = __va(be64_to_cpup((__force __be64 *)basep)); } - if (size == 0) { dev_warn(&chip->dev, "%s: Event log area empty\n", __func__); return -EIO; } - log->bios_event_log = devm_kmemdup(&chip->dev, __va(base), size, GFP_KERNEL); + log->bios_event_log = devm_kmemdup(&chip->dev, logp, size, GFP_KERNEL); if (!log->bios_event_log) return -ENOMEM;