From patchwork Wed Sep 22 03:11:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Richter X-Patchwork-Id: 1531003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=OGXgRKy7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4HDjyc6fbzz9sRK for ; Wed, 22 Sep 2021 13:12:24 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HDjyc5Wzbz2ypL for ; Wed, 22 Sep 2021 13:12:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=OGXgRKy7; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=erichte@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=OGXgRKy7; dkim-atps=neutral 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 lists.ozlabs.org (Postfix) with ESMTPS id 4HDjxs3CJkz2yL9 for ; Wed, 22 Sep 2021 13:11:45 +1000 (AEST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18M1USvf028542 for ; Tue, 21 Sep 2021 23:11:43 -0400 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=Vb5uUGXJTNwBSzeSE2zUj8qxoIvK7Fj/lcVwawD+ixc=; b=OGXgRKy7wwr/1xtKMk8mzX+bNjfcTktoMwK/Bgk9GZOZ5xNCC18Gr+WB3Aco0m0NgCSP /CsuBkSDTIXCceFK/igOa9ZYvJW9FdpC0khVeaMfG/TPtpx71+p2g2JWV4z+HCIjH2Be pgvVz1w97+ZPode/3MvuJqQibxfAvTGdnXWb8fMjDerHUjzJQ4ci+9aAJWx5AxkSbmPN wuV3tQviCuaJ4V9Dlgs7mmtOwyi+a/feW58LGUPLccmxbYlt7aQMl0CVNDVgz2CQ6kWr UUA/TFNQu1R4i6SJzhH8+YBTavD4cX9zW+Z+IDBJjTNzYe6pxyPNizXBu+EjQwhs/9SA Xw== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b7tvv9faw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 21 Sep 2021 23:11:43 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18M37xPB013855 for ; Wed, 22 Sep 2021 03:11:40 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3b7q6phjgw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Sep 2021 03:11:40 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18M3BaNx43319698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Sep 2021 03:11:36 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A879DA4053; Wed, 22 Sep 2021 03:11:36 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ECCDDA404D; Wed, 22 Sep 2021 03:11:35 +0000 (GMT) Received: from ceres.ibmuc.com (unknown [9.65.202.213]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 22 Sep 2021 03:11:35 +0000 (GMT) From: Eric Richter To: skiboot@lists.ozlabs.org Date: Tue, 21 Sep 2021 22:11:26 -0500 Message-Id: <20210922031129.4188386-6-erichte@linux.ibm.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210922031129.4188386-1-erichte@linux.ibm.com> References: <20210922031129.4188386-1-erichte@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4Ur9wXXGl6H8ZWQoWHu-mB_1lBFrgqPp X-Proofpoint-GUID: 4Ur9wXXGl6H8ZWQoWHu-mB_1lBFrgqPp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-22_01,2021-09-20_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 mlxlogscore=903 clxscore=1015 mlxscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109200000 definitions=main-2109220015 Subject: [Skiboot] [RFC 5/8] secvar: add build-time mechanism to inject default variable data X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nayna@linux.ibm.com Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" To allow the implementation of a backend that uses static, built-in variables, this patch adds the ability to compile in a blob of data, accessible by symbol named similarly to the file in which the data was loaded from. To operate: place a file in the libstb/secvar/defaultvars directory named `secvar_default_NAME.var`, where NAME is the case-sensitive name of the variable the static-variable enabled backend will expect it to be. For example, to build in a db into the forthcoming edk2-compat-static driver, copy the db.esl file into the aforementioned directory as `secvar_default_db.var`. This will be compiled in, and exposed in the secvar_default_vars.h header, which will look something like: uint8_t secvar_default_db[] = { ... }; \#define SECVAR_DEFAULT_DB The #define may be used by backends to determine if a default variable was provided for a specific variable it may expect. RFC NOTE: This is a rather janky first implementation, and ideally should be improved in some form. I am open to suggestions on how to improve this. Ideally at minimum, the backend should be able to "discover" which variables have been built in. Furthermore, there should likely be some kind of trigger to detect whether or not default keys have been built in at all, but that is something that will come up in a later patch. Signed-off-by: Eric Richter --- Makefile.main | 1 + libstb/secvar/Makefile.inc | 3 ++- libstb/secvar/defaultvars/Makefile.inc | 31 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 libstb/secvar/defaultvars/Makefile.inc diff --git a/Makefile.main b/Makefile.main index c8a63e8b..d0b5d4eb 100644 --- a/Makefile.main +++ b/Makefile.main @@ -409,6 +409,7 @@ clean: $(RM) include/asm-offsets.h version.c .version $(RM) skiboot.info external/gard/gard.info external/pflash/pflash.info $(RM) extract-gcov $(TARGET).lid.stb $(TARGET).lid.xz.stb + $(RM) libstb/secvar/defaultvars/*.{c,d,o,h} distclean: clean $(RM) *~ $(SUBDIRS:%=%/*~) include/*~ diff --git a/libstb/secvar/Makefile.inc b/libstb/secvar/Makefile.inc index 57c7cfb5..1d6f4c81 100644 --- a/libstb/secvar/Makefile.inc +++ b/libstb/secvar/Makefile.inc @@ -8,5 +8,6 @@ SECVAR = libstb/secvar/built-in.a include $(SRC)/libstb/secvar/storage/Makefile.inc include $(SRC)/libstb/secvar/backend/Makefile.inc +include $(SRC)/libstb/secvar/defaultvars/Makefile.inc -$(SECVAR): $(SECVAR_OBJS:%=libstb/secvar/%) $(SECVAR_STORAGE) $(SECVAR_BACKEND) +$(SECVAR): $(SECVAR_OBJS:%=libstb/secvar/%) $(SECVAR_DEFAULTVARS) $(SECVAR_STORAGE) $(SECVAR_BACKEND) diff --git a/libstb/secvar/defaultvars/Makefile.inc b/libstb/secvar/defaultvars/Makefile.inc new file mode 100644 index 00000000..f831413d --- /dev/null +++ b/libstb/secvar/defaultvars/Makefile.inc @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# -*-Makefile-*- + +SECVAR_DEFAULTVARS_DIR = libstb/secvar/defaultvars + +SUBDIRS += $(SECVAR_DEFAULTVARS_DIR) + +SECVAR_DEFAULTVARS_FILES = $(wildcard $(SECVAR_DEFAULTVARS_DIR)/secvar_default_*.var) +SECVAR_DEFAULTVARS_C_FILES = $(patsubst %.var,%.c,$(notdir $(SECVAR_DEFAULTVARS_FILES))) +SECVAR_DEFAULTVARS_OBJS = $(patsubst %.c,%.o,$(SECVAR_DEFAULTVARS_C_FILES)) + +$(SECVAR_DEFAULTVARS_DIR)/secvar_default_vars.h: $(SECVAR_DEFAULTVARS_FILES) + echo -n "" > $@ + for var in $(subst .var,,$(notdir $^)) ; do \ + echo "#ifndef _SECVAR_DEFAULTVARS_H_" >> $@ ; \ + echo "#define _SECVAR_DEFAULTVARS_H_" >> $@ ; \ + echo "extern unsigned char *$$var;" >> $@ ; \ + echo -n "#define " >> $@ ; \ + echo $$var | tr [:lower:] [:upper:] >> $@ ; \ + echo "#endif" >> $@ ; \ + done; + +secvar_default_%.c: secvar_default_%.var $(SECVAR_DEFAULTVARS_DIR)/secvar_default_vars.h + echo $^ + echo "unsigned char $(subst .var,,$(notdir $<))[] = {" > $@ + cat $^ | xxd -e -i >> $@ + echo "};" >> $@ + +SECVAR_DEFAULTVARS = $(SECVAR_DEFAULTVARS_DIR)/built-in.a + +$(SECVAR_DEFAULTVARS): $(SECVAR_DEFAULTVARS_OBJS:%=$(SECVAR_DEFAULTVARS_DIR)/%)