From patchwork Tue Oct 25 07:15:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 686355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t34F52Y3bz9t2n for ; Tue, 25 Oct 2016 18:15:53 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3t34F51nnBzDvn6 for ; Tue, 25 Oct 2016 18:15:53 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-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 lists.ozlabs.org (Postfix) with ESMTPS id 3t34DP6zn2zDvkb for ; Tue, 25 Oct 2016 18:15:17 +1100 (AEDT) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9P7ERk1052247 for ; Tue, 25 Oct 2016 03:15:15 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 269v7wqg50-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 25 Oct 2016 03:15:14 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Oct 2016 01:15:13 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 25 Oct 2016 01:15:12 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 6E27719D8042 for ; Tue, 25 Oct 2016 01:14:36 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9P7FBqY16318952; Tue, 25 Oct 2016 00:15:11 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C7D57804D; Tue, 25 Oct 2016 01:15:11 -0600 (MDT) Received: from birb.localdomain (unknown [9.83.7.67]) by b03ledav004.gho.boulder.ibm.com (Postfix) with SMTP id 53B3778038; Tue, 25 Oct 2016 01:15:10 -0600 (MDT) Received: from ka1.ozlabs.ibm.com (localhost.localdomain [127.0.0.1]) by birb.localdomain (Postfix) with ESMTP id 22372229DB4E; Tue, 25 Oct 2016 18:15:05 +1100 (AEDT) From: Stewart Smith To: skiboot@lists.ozlabs.org Date: Tue, 25 Oct 2016 18:15:01 +1100 X-Mailer: git-send-email 2.1.4 In-Reply-To: <1477379702-2376-1-git-send-email-stewart@linux.vnet.ibm.com> References: <1477379702-2376-1-git-send-email-stewart@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16102507-0012-0000-0000-000010F7B734 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005974; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000188; SDB=6.00772422; UDB=6.00370753; IPR=6.00549241; BA=6.00004831; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013098; XFM=3.00000011; UTC=2016-10-25 07:15:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16102507-0013-0000-0000-0000469733AA Message-Id: <1477379702-2376-4-git-send-email-stewart@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-25_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-1609300000 definitions=main-1610250121 Subject: [Skiboot] [PATCH 3/4] libstb/container: add function for getting sw payload size 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" From: Claudio Carvalho Add a function to get the software payload size from a STB container. (originally from patch from Claudio, but I pulled out just this bit here) Extracted-from-a-patch-by: Claudio Carvalho Signed-off-by: Stewart Smith --- libstb/container.c | 10 ++++++++++ libstb/container.h | 1 + 2 files changed, 11 insertions(+) diff --git a/libstb/container.c b/libstb/container.c index 19df55640509..a720fbbf1e8b 100644 --- a/libstb/container.c +++ b/libstb/container.c @@ -38,6 +38,16 @@ uint32_t stb_payload_magic(const void *buf, size_t size) return be32_to_cpu(*(uint32_t*)(p+SECURE_BOOT_HEADERS_SIZE)); } +uint64_t stb_sw_payload_size(const void *buf, size_t size) +{ + struct parsed_stb_container c; + if (!stb_is_container(buf, size)) + return 0; + if (parse_stb_container(buf, size, &c) != 0) + return 0; + return be64_to_cpu(c.sh->payload_size); +} + int parse_stb_container(const void* data, size_t len, struct parsed_stb_container *c) { const size_t prefix_data_min_size = 3 * (EC_COORDBYTES * 2); diff --git a/libstb/container.h b/libstb/container.h index f65615a1db45..f8965d40f52b 100644 --- a/libstb/container.h +++ b/libstb/container.h @@ -143,6 +143,7 @@ bool stb_is_container(const void* buf, size_t size); /* Get the pointer for the sw-payload-hash field of the container header */ const uint8_t* stb_sw_payload_hash(const void* buf, size_t size); +uint64_t stb_sw_payload_size(const void *buf, size_t size); int parse_stb_container(const void* data, size_t len, struct parsed_stb_container *c);