Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp401352lql; Mon, 11 Mar 2024 06:21:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzEh9EvyQJUC+mI542iiyksAQt2WPlZp/30x4ANuUuHTPP+nZWhhz0HiXhv9t43+JvNI8UlzVD2ibeyLcbU8dfnpPDykNreozFsFNWWw== X-Google-Smtp-Source: AGHT+IEXQqAjfA4XRCcptBNpiVEdhTFlV57i7urF+t7RJZuQPXHd+eQmKOXzygeSVZ54Scwzr65V X-Received: by 2002:a05:6808:1309:b0:3c2:3530:db09 with SMTP id y9-20020a056808130900b003c23530db09mr8572709oiv.54.1710163278595; Mon, 11 Mar 2024 06:21:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710163278; cv=pass; d=google.com; s=arc-20160816; b=IMFAshbiLNainIDh8DfwWdVflBjHmIoiaHaVd9Rn/UFtVNSK+ECokGeJbSRV9SxMr1 kFZyt8eH6ZJR/hSfz663a8uXBpXxeTa1Q9b4PrNIe5a652SuBcBvfKcno4h/zOVx2qyw xJhnNcXwGOJi3634OGKs3J9bzHEGQSmJFR4BhqhfRpmTRLF93XD7TCugJXT4fScIyN4s NPeFPzCjnj+wPX6javVWV/82Ndp0J3VBS76eZH2khxOyWi5+SlIi5Ta56eaAC3hhlvNO IbZGhoZFigH1rkwfyqo3HEoiLmnDFwSR7amYmNiwJM4VBOF9wLyrkwd2jOVCIO9ST48f kUxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=D+ymWYhcKlVtuY88TLHRXmdCukNBtEwkGmsa5Q+jAKA=; fh=aYT1QCvCpVt7hLy9TgPRqXM92FdesWzKX0O2yBr0Qvw=; b=KfB26/AlLlpBtL4XVLLtf6OV3SgrAw5RbDzClz81bStlxJA8FIzS7NiYkmVqG/ZqiD Fup6FvcEpYBeT8RtjiutyLnt6rkjcw6bijIui/IfbMqaTHpMuOlUN1gXpJysC6tN1ctt 5F1OK/Hcz1gdFOHZZNTqrzn6o+sEOtQu781xmlPT1cScExzo45rohwbDjFtecumEJDEl bHd1xl69JpwL2E//q4q+f/+aOHatidvOFNc1LAmpVgNqyMWt8SsmFECatJ5e4TQG5n6P qrdbRwysULxywjay5tf5Mh2tLqSwYEoblzZdf5AJkpjLy2nwBqY+YLWWoswTSCHrsgir oDIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hVMoOPd+; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-98861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e14-20020a65648e000000b005dc89de5d21si4684240pgv.776.2024.03.11.06.21.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 06:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hVMoOPd+; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-98861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DBDD5282BDD for ; Mon, 11 Mar 2024 13:21:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 197603F8C3; Mon, 11 Mar 2024 13:21:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hVMoOPd+" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.43.0