From patchwork Thu Aug 31 07:24:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Carvalho X-Patchwork-Id: 808094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xjYpb4SFPz9sNr for ; Thu, 31 Aug 2017 17:26:47 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xjYpb3WQgzDqZf for ; Thu, 31 Aug 2017 17:26:47 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org 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 3xjYmq3S1szDqXt for ; Thu, 31 Aug 2017 17:25:15 +1000 (AEST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7V7OfI1076988 for ; Thu, 31 Aug 2017 03:25:14 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cp98rt191-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 31 Aug 2017 03:25:13 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 31 Aug 2017 03:25:12 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 31 Aug 2017 03:25:10 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7V7PAwh25231364 for ; Thu, 31 Aug 2017 07:25:10 GMT Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 06FDF11205E for ; Thu, 31 Aug 2017 03:24:56 -0400 (EDT) X-IMSS-HAND-OFF-DIRECTIVE: 127.0.0.1:10026 Received: from legolas.ibm.com (unknown [9.85.193.48]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id EF0F2112047; Thu, 31 Aug 2017 03:24:46 -0400 (EDT) From: Claudio Carvalho To: skiboot@lists.ozlabs.org Date: Thu, 31 Aug 2017 04:24:36 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504164285-15095-1-git-send-email-cclaudio@linux.vnet.ibm.com> References: <1504164285-15095-1-git-send-email-cclaudio@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083107-2213-0000-0000-000002123A04 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007640; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00910098; UDB=6.00456511; IPR=6.00690378; BA=6.00005562; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016938; XFM=3.00000015; UTC=2017-08-31 07:25:11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083107-2214-0000-0000-000057644C6D Message-Id: <1504164285-15095-6-git-send-email-cclaudio@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-31_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708310114 Subject: [Skiboot] [PATCH v2 05/14] libstb: rename rom_driver_ops struct to container_verification_code X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This just gives a better name to the rom_driver_ops structure. Signed-off-by: Claudio Carvalho --- libstb/drivers/romcode.c | 4 ++-- libstb/drivers/sw_driver.c | 4 ++-- libstb/rom.c | 22 +++++++++++----------- libstb/rom.h | 6 +++--- libstb/stb.c | 22 ++++++++++------------ 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/libstb/drivers/romcode.c b/libstb/drivers/romcode.c index 94bd42c..68f1230 100644 --- a/libstb/drivers/romcode.c +++ b/libstb/drivers/romcode.c @@ -81,7 +81,7 @@ static void romcode_cleanup(void) { hw_key_hash = NULL; } -static struct rom_driver_ops romcode_driver = { +static struct container_verification_code c1vc = { .name = DRIVER_NAME, .verify = romcode_verify, .sha512 = romcode_sha512, @@ -134,5 +134,5 @@ void romcode_probe(const struct dt_node *node) * the ROM code or set the memory region as executable. * skiboot accesses the physical memory directly. Real mode. */ - rom_set_driver(&romcode_driver); + rom_set_driver(&c1vc); } diff --git a/libstb/drivers/sw_driver.c b/libstb/drivers/sw_driver.c index e7f3740..55224a2 100644 --- a/libstb/drivers/sw_driver.c +++ b/libstb/drivers/sw_driver.c @@ -44,7 +44,7 @@ static void stb_software_cleanup(void) return; } -static struct rom_driver_ops sw_driver = { +static struct container_verification_code c1vc = { .name = "software", .verify = stb_software_verify, .sha512 = stb_software_sha512, @@ -72,5 +72,5 @@ void stb_software_probe(const struct dt_node *node) } hw_key_hash = (sha2_hash_t*) dt_prop_get(node, "hw-key-hash"); - rom_set_driver(&sw_driver); + rom_set_driver(&c1vc); } diff --git a/libstb/rom.c b/libstb/rom.c index 5f9abd2..27b65c9 100644 --- a/libstb/rom.c +++ b/libstb/rom.c @@ -19,37 +19,37 @@ #include "drivers/romcode.h" #include "drivers/sw_driver.h" -static struct rom_driver_ops *rom_driver = NULL; +static struct container_verification_code *c1vc = NULL; -struct rom_driver_ops* rom_init(const struct dt_node *node __unused) +struct container_verification_code* rom_init(const struct dt_node *node __unused) { - if (rom_driver) + if (c1vc) goto end; /* ROM drivers supported */ romcode_probe(node); - if (!rom_driver) + if (!c1vc) stb_software_probe(node); - if (!rom_driver) + if (!c1vc) prlog(PR_NOTICE, "ROM: no rom driver found\n"); end: - return rom_driver; + return c1vc; } -void rom_set_driver(struct rom_driver_ops *driver) +void rom_set_driver(struct container_verification_code *driver) { - if (rom_driver) { + if (c1vc) { /** * @fwts-label ROMAlreadyRegistered * @fwts-advice ibm,secureboot already registered. Check if * rom_init called twice or the same driver is probed twice */ prlog(PR_WARNING, "ROM: %s driver already registered\n", - driver->name); + c1vc->name); return; } - rom_driver = driver; - prlog(PR_NOTICE, "ROM: %s driver registered\n", driver->name); + c1vc = driver; + prlog(PR_NOTICE, "ROM: %s driver registered\n", c1vc->name); } diff --git a/libstb/rom.h b/libstb/rom.h index e1a7497..972a19b 100644 --- a/libstb/rom.h +++ b/libstb/rom.h @@ -22,7 +22,7 @@ #include #include "container.h" -struct rom_driver_ops { +struct container_verification_code { const char* name; int (*verify)(void *container); void (*sha512)(const uint8_t *data, size_t len, uint8_t *digest); @@ -33,11 +33,11 @@ struct rom_driver_ops { * Load a compatible driver to access the functions of the * verification code flashed in the secure ROM */ -extern struct rom_driver_ops* rom_init(const struct dt_node *node); +extern struct container_verification_code* rom_init(const struct dt_node *node); /* * Set the rom driver that will be used */ -extern void rom_set_driver(struct rom_driver_ops *driver); +extern void rom_set_driver(struct container_verification_code *driver); #endif /* __ROM_H */ diff --git a/libstb/stb.c b/libstb/stb.c index ed34c6a..eb77038 100644 --- a/libstb/stb.c +++ b/libstb/stb.c @@ -32,7 +32,7 @@ static bool secure_mode = false; static bool trusted_mode = false; -static struct rom_driver_ops *rom_driver = NULL; +static struct container_verification_code *c1vc = NULL; /* * This maps a PCR for each resource we can measure. The PCR number is @@ -124,8 +124,8 @@ void stb_init(void) if (!secure_mode && !trusted_mode) return; - rom_driver = rom_init(ibm_secureboot); - if (secure_mode && !rom_driver) { + c1vc = rom_init(ibm_secureboot); + if (secure_mode && !c1vc) { prlog(PR_EMERG, "STB: compatible romcode driver not found\n"); sb_enforce(); } @@ -167,9 +167,8 @@ int stb_final(void) } tpm_add_status_property(); } - if (rom_driver) { - rom_driver->cleanup(); - rom_driver = NULL; + if (c1vc) { + c1vc = NULL; } tpm_cleanup(); secure_mode = false; @@ -235,9 +234,8 @@ int tb_measure(enum resource_id id, void *buf, size_t len) abort(); } - rom_driver->sha512( - (void*)((uint8_t*)buf + SECURE_BOOT_HEADERS_SIZE), - len - SECURE_BOOT_HEADERS_SIZE, digest); + c1vc->sha512((void*) buf + SECURE_BOOT_HEADERS_SIZE, + len - SECURE_BOOT_HEADERS_SIZE, digest); prlog(PR_INFO, "STB: %s sha512 hash re-calculated\n", name); if (memcmp(digestp, digest, TPM_ALG_SHA256_SIZE) != 0) { @@ -251,7 +249,7 @@ int tb_measure(enum resource_id id, void *buf, size_t len) abort(); } } else { - rom_driver->sha512(buf, len, digest); + c1vc->sha512(buf, len, digest); prlog(PR_INFO, "STB: %s sha512 hash calculated\n", name); } @@ -287,7 +285,7 @@ int sb_verify(enum resource_id id, void *buf, size_t len) "resource_id=%d unknown\n", id); sb_enforce(); } - if (!rom_driver || !rom_driver->verify) { + if (!c1vc || !c1vc->verify) { prlog(PR_EMERG, "STB: secure boot not initialized\n"); sb_enforce(); } @@ -296,7 +294,7 @@ int sb_verify(enum resource_id id, void *buf, size_t len) __func__, id, buf, len); sb_enforce(); } - if (rom_driver->verify(buf)) { + if (c1vc->verify(buf)) { prlog(PR_EMERG, "STB: %s failed: resource %s, " "eyecatcher 0x%016llx\n", __func__, name, *((uint64_t*)buf));