From patchwork Thu May 17 04:26:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 915064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40mdmY1LRsz9s1d for ; Thu, 17 May 2018 14:36:29 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="pcR+etrO"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="cA4xB6DZ"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40mdmX6cb8zF1RV for ; Thu, 17 May 2018 14:36:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="pcR+etrO"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="cA4xB6DZ"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mendozajonas.com (client-ip=66.111.4.25; helo=out1-smtp.messagingengine.com; envelope-from=sam@mendozajonas.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="pcR+etrO"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="cA4xB6DZ"; dkim-atps=neutral X-Greylist: delayed 523 seconds by postgrey-1.36 at bilbo; Thu, 17 May 2018 14:35:59 AEST Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40mdlz0Z22zF1PT for ; Thu, 17 May 2018 14:35:58 +1000 (AEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id D36E5221C9; Thu, 17 May 2018 00:27:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 17 May 2018 00:27:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=kRL/3uwKkr6EC4tOj NjKDu31OmvjZR/GgpPIutbte00=; b=pcR+etrOey7JNI1NMl8xuHQQ64Vn3Iebx NaKxtivOsvnLoDFDU1F+FA3uTuxtNBfZ1G3j6n2qiZE8IaMZCdiN0n1p5VnUhLdS Zc9jmQz2LK6QT7ddq0hKAIeF/B3abWENFrfgd/cMOA8hPkASFbKwinPvWrxICi+w 2if3+7e3NnIddQVrIqXPMr07TSGL7bOpcYiIP2s5IBDxqpVhJLyVy9ESZAEuh7lz hhYUkGUIEeTsOMuzOANGaGhAbSyU4CrzLE/rGXK4X6Z+Z5FsCP2uQlxyDd69dOtz LjB553smvb96pbIhrFHlY9d9DDGg0S1mNhgrqoV/JM8UfYyRbzcBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=kRL/3uwKkr6EC4tOj NjKDu31OmvjZR/GgpPIutbte00=; b=cA4xB6DZAmJzC1ukwPyfYBgu3iWguP5i+ 4c2Y68lHmopbonv+5FkUdvH2R9px3ME7q8zZirHVPLwjYRffdH8UzmrQJ+WFaIeQ //kzNDR/+4PUtC+IvdW81SJC6PeOGZQ/CVtwzdo4rX9oesLoWv7Gz/hv5KtWqGeE POYgGdIoLhrVZuOpmCJUIMiJPeNJENOFQyHVfxTrnKMjLxPxwSm6lss0rykTWVq1 dxKueueVxFpM/a2N7Y2NI8cwA/PiWvDNmFWlAsjFNey2sDG4pKagkrOwRrGND9DZ Ho25Pd3E/QSIH0ApQrkDPhxSDNmq46ZrrGyaLc545iRHc1n+hlfSg== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 60AF910260; Thu, 17 May 2018 00:27:07 -0400 (EDT) From: Samuel Mendoza-Jonas To: skiboot@lists.ozlabs.org Date: Thu, 17 May 2018 14:26:59 +1000 Message-Id: <20180517042659.31143-1-sam@mendozajonas.com> X-Mailer: git-send-email 2.17.0 Subject: [Skiboot] [PATCH] Recognise signed VERSION partition X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" A few things need to change to support a signed VERSION partition: - A signed VERSION partition will be 4K + SECURE_BOOT_HEADERS_SIZE (4K). - The VERSION partition needs to be loaded after secure/trusted boot is set up, and therefore after nvram_init(). - Added to the trustedboot resources array. Signed-off-by: Samuel Mendoza-Jonas Reviewed-by: Vasant Hegde --- Aside from the partition size changes this is an alternative take to this earlier patch, trying to move less things around: http://patchwork.ozlabs.org/patch/897865/ Take your pick! core/flash.c | 4 +++- core/init.c | 9 +++++++++ libstb/trustedboot.c | 1 + platforms/astbmc/common.c | 6 ------ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/flash.c b/core/flash.c index 4031e7b3..161b5c90 100644 --- a/core/flash.c +++ b/core/flash.c @@ -51,7 +51,7 @@ static u32 nvram_offset, nvram_size; /* ibm,firmware-versions support */ static char *version_buf; -static size_t version_buf_size = 0x1000; +static size_t version_buf_size = 0x2000; bool flash_reserve(void) { @@ -235,6 +235,8 @@ void flash_dt_add_fw_version(void) fw_version = dt_new(dt_root, "ibm,firmware-versions"); assert(fw_version); + if (stb_is_container(version_buf, version_buf_size)) + numbytes += SECURE_BOOT_HEADERS_SIZE; for ( ; (numbytes < version_buf_size) && version_buf[numbytes]; numbytes++) { if (version_buf[numbytes] == '\n') { version_data[i] = '\0'; diff --git a/core/init.c b/core/init.c index 3b887a24..a02304e6 100644 --- a/core/init.c +++ b/core/init.c @@ -1067,6 +1067,15 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) secureboot_init(); trustedboot_init(); + /* + * BMC platforms load version information from flash after + * secure/trustedboot init. + */ + if (platform.bmc) { + flash_fw_version_preload(); + flash_dt_add_fw_version(); + } + /* preload the IMC catalog dtb */ imc_catalog_preload(); diff --git a/libstb/trustedboot.c b/libstb/trustedboot.c index 151e4e16..35b26240 100644 --- a/libstb/trustedboot.c +++ b/libstb/trustedboot.c @@ -46,6 +46,7 @@ static struct { { RESOURCE_ID_IMA_CATALOG, PCR_2 }, { RESOURCE_ID_KERNEL, PCR_4 }, { RESOURCE_ID_CAPP, PCR_2 }, + { RESOURCE_ID_VERSION, PCR_3 }, }; /* diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c index 243ad946..3c59f82a 100644 --- a/platforms/astbmc/common.c +++ b/platforms/astbmc/common.c @@ -134,9 +134,6 @@ void astbmc_init(void) astbmc_fru_init(); ipmi_sensor_init(); - /* Preload PNOR VERSION section */ - flash_fw_version_preload(); - /* As soon as IPMI is up, inform BMC we are in "S0" */ ipmi_set_power_state(IPMI_PWR_SYS_S0_WORKING, IPMI_PWR_NOCHANGE); @@ -147,9 +144,6 @@ void astbmc_init(void) /* Setup UART console for use by Linux via OPAL API */ set_opal_console(&uart_opal_con); - - /* Add ibm,firmware-versions node */ - flash_dt_add_fw_version(); } int64_t astbmc_ipmi_power_down(uint64_t request)