From nobody Sun May 19 07:16:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625032062798201.83833347190057; Tue, 29 Jun 2021 22:47:42 -0700 (PDT) Received: from localhost ([::1]:39048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyT4X-0004bF-7Y for importer@patchew.org; Wed, 30 Jun 2021 01:47:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyT3W-0002dU-GX for qemu-devel@nongnu.org; Wed, 30 Jun 2021 01:46:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyT3R-0002Xq-Si for qemu-devel@nongnu.org; Wed, 30 Jun 2021 01:46:38 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15U5Y9lp166835; Wed, 30 Jun 2021 01:46:30 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 39ghdp9upd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 01:46:30 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 15U5YdQV167986; Wed, 30 Jun 2021 01:46:30 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 39ghdp9up2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 01:46:29 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15U5bVb3014913; Wed, 30 Jun 2021 05:46:28 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04wdc.us.ibm.com with ESMTP id 39duvce1ff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 05:46:28 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15U5kRTY13107474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Jun 2021 05:46:27 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91723C605F; Wed, 30 Jun 2021 05:46:27 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFF8AC6067; Wed, 30 Jun 2021 05:46:26 +0000 (GMT) Received: from localhost.localdomain (unknown [9.2.130.16]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 30 Jun 2021 05:46:26 +0000 (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-type : content-transfer-encoding; s=pp1; bh=dDePpOUCA5CWVEMR0ePccoGLr+2Da6MG95bk3tyC2Fs=; b=qo03uga3gBFRqKyaacRmn5mgh6ei35dzPz/mpnBNdL1slf01/4tCDxHu3NkmrQ0i3Hso yt2epCaGgmyng06qPRaZqkXp54TkSr6qP5iMmXVXG7Z4xKXyC8fj8lg9KAwow1baudYL 1j1MbFPRT3xf6o4+yywzftoikFiV3WwEeeSoXk2yUM/vSD34tpwiI3EkixkzOZMmbOw8 MG8xR9yfGacxfnCzXgi4T9WW2xAsMWr04ju7hPjbqe8ysaEA6odfQdFmSyutYKZrXaI2 OUK6d/TB4W3EmTQyFdqTmuS0ZV+7xd0MAiID7CGHMFVOoxlYRf66WMVc9w/osRPnN9XY 4w== From: Dov Murik To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] hw/i386/pc: pc_system_ovmf_table_find: Assert that flash was parsed Date: Wed, 30 Jun 2021 05:46:24 +0000 Message-Id: <20210630054625.3424178-2-dovmurik@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210630054625.3424178-1-dovmurik@linux.ibm.com> References: <20210630054625.3424178-1-dovmurik@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qMqSgWD12GhqTlfSEOMbkvKy2qSEVeCi X-Proofpoint-GUID: UtOXn3LTq6Da6wJFvde3hapmhwyLMUFF X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-30_01:2021-06-29, 2021-06-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106300034 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=dovmurik@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Eduardo Habkost , "Michael S. Tsirkin" , Richard Henderson , Dov Murik , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add assertion in pc_system_ovmf_table_find that verifies that the flash was indeed previously parsed (looking for the OVMF table) by pc_system_parse_ovmf_flash. Now pc_system_ovmf_table_find distinguishes between "no one called pc_system_parse_ovmf_flash" (which will abort due to assertion failure) and "the flash was parsed but no OVMF table was found, or it is invalid" (which will return false). Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Dov Murik Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Tom Lendacky --- hw/i386/pc_sysfw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 6ce37a2b05..9eac36b830 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -126,6 +126,7 @@ void pc_system_flash_cleanup_unused(PCMachineState *pcm= s) =20 #define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d" =20 +static bool ovmf_flash_parsed =3D false; static uint8_t *ovmf_table; static int ovmf_table_len; =20 @@ -136,10 +137,12 @@ static void pc_system_parse_ovmf_flash(uint8_t *flash= _ptr, size_t flash_size) int tot_len; =20 /* should only be called once */ - if (ovmf_table) { + if (ovmf_flash_parsed) { return; } =20 + ovmf_flash_parsed =3D true; + if (flash_size < TARGET_PAGE_SIZE) { return; } @@ -183,6 +186,8 @@ bool pc_system_ovmf_table_find(const char *entry, uint8= _t **data, int tot_len =3D ovmf_table_len; QemuUUID entry_guid; =20 + assert(ovmf_flash_parsed); + if (qemu_uuid_parse(entry, &entry_guid) < 0) { return false; } --=20 2.25.1 From nobody Sun May 19 07:16:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625032062672396.26355896336736; Tue, 29 Jun 2021 22:47:42 -0700 (PDT) Received: from localhost ([::1]:38964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyT4X-0004Y0-83 for importer@patchew.org; Wed, 30 Jun 2021 01:47:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyT3T-0002d4-N6 for qemu-devel@nongnu.org; Wed, 30 Jun 2021 01:46:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyT3R-0002YU-II for qemu-devel@nongnu.org; Wed, 30 Jun 2021 01:46:35 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15U5Wlk1162868; Wed, 30 Jun 2021 01:46:30 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 39ghu6s82g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 01:46:30 -0400 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 15U5Y4Av166009; Wed, 30 Jun 2021 01:46:30 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 39ghu6s829-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 01:46:30 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15U5cX0O019242; Wed, 30 Jun 2021 05:46:29 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma01wdc.us.ibm.com with ESMTP id 39ejyyqns3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 05:46:29 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15U5kSrw33751300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Jun 2021 05:46:28 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 88F4CC6059; Wed, 30 Jun 2021 05:46:28 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD692C6061; Wed, 30 Jun 2021 05:46:27 +0000 (GMT) Received: from localhost.localdomain (unknown [9.2.130.16]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 30 Jun 2021 05:46:27 +0000 (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-type : content-transfer-encoding; s=pp1; bh=6byZ7BJiyAcUu2bKywj05Fxscef09SQjlZFWMEm9dgE=; b=MSeQW84cuz1bo8GF0elVw3eCWV/I/XbxTvv98OagopFZsfeOwk/OvrITW3+peGgpf8R9 hYsPoFIWYFjUHLytCawo3XEr6Srx+2kXGwKabAUCx3Z7XP97g/mf+PSM02wdkpaME3r1 x8V5zKEZErCydpzwOMf3eHQKxtYGUg6KKSzO/ri2xUEoVToH6zFvEGzHPYm8m/Gp6TQd qTWKuiTnY6b3xDC1iKquuTWjV/Z6YbdRHgHaSTrw+A23Kxg9bomDhVfA8dD4wp8HpBv7 ehM5uOV96ursWVQladgxwHOKb0f/OSE7A3sIPm7rEwspdxB89Rk2KSRfV9Rr9AUmXu3U kg== From: Dov Murik To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] hw/i386/pc: Document pc_system_ovmf_table_find Date: Wed, 30 Jun 2021 05:46:25 +0000 Message-Id: <20210630054625.3424178-3-dovmurik@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210630054625.3424178-1-dovmurik@linux.ibm.com> References: <20210630054625.3424178-1-dovmurik@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: rPdjw0-TsdUtpKbKqQ3Z7BNLUwEUgvDY X-Proofpoint-ORIG-GUID: YO3TxbNef4V559hclwUFR2xxRByS_UaZ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-30_01:2021-06-29, 2021-06-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 malwarescore=0 clxscore=1015 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106300034 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=dovmurik@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Eduardo Habkost , "Michael S. Tsirkin" , Richard Henderson , Dov Murik , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Dov Murik Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc_sysfw.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 9eac36b830..d02f1b2361 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -179,6 +179,17 @@ static void pc_system_parse_ovmf_flash(uint8_t *flash_= ptr, size_t flash_size) ovmf_table +=3D tot_len; } =20 +/** + * pc_system_ovmf_table_find - Find the data associated with an entry in O= VMF's + * reset vector GUIDed table. + * + * @entry: GUID string of the entry to lookup + * @data: Filled with a pointer to the entry's value (if not NULL) + * @data_len: Filled with the length of the entry's value (if not NULL). P= ass + * NULL here if the length of data is known. + * + * Return: true if the entry was found in the OVMF table; false otherwise. + */ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, int *data_len) { --=20 2.25.1