Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2196095/?format=api
{ "id": 2196095, "url": "http://patchwork.ozlabs.org/api/patches/2196095/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260212204352.1044699-5-zycai@linux.ibm.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260212204352.1044699-5-zycai@linux.ibm.com>", "list_archive_url": null, "date": "2026-02-12T20:43:25", "name": "[v8,04/30] hw/s390x/ipl: Create certificate store", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "5ab5eb34cf1a763f1e33b4ed51edf6908549f03b", "submitter": { "id": 90643, "url": "http://patchwork.ozlabs.org/api/people/90643/?format=api", "name": "Zhuoying Cai", "email": "zycai@linux.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260212204352.1044699-5-zycai@linux.ibm.com/mbox/", "series": [ { "id": 492021, "url": "http://patchwork.ozlabs.org/api/series/492021/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=492021", "date": "2026-02-12T20:43:36", "name": "Secure IPL Support for SCSI Scheme of virtio-blk/virtio-scsi Devices", "version": 8, "mbox": "http://patchwork.ozlabs.org/series/492021/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2196095/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2196095/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=o/RGluuv;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fBnSR6TXSz1xr1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 13 Feb 2026 07:48:07 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vqdXq-0000da-3F; Thu, 12 Feb 2026 15:44:14 -0500", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <zycai@linux.ibm.com>)\n id 1vqdXo-0000bx-BY; Thu, 12 Feb 2026 15:44:12 -0500", "from mx0a-001b2d01.pphosted.com ([148.163.156.1])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <zycai@linux.ibm.com>)\n id 1vqdXm-0007ON-1Q; Thu, 12 Feb 2026 15:44:12 -0500", "from pps.filterd (m0353729.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 61CD80Il3201530; Thu, 12 Feb 2026 20:44:05 GMT", "from ppma23.wdc07v.mail.ibm.com\n (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696wg4kk-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 12 Feb 2026 20:44:05 +0000 (GMT)", "from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1])\n by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 61CI0dKN012626;\n Thu, 12 Feb 2026 20:44:04 GMT", "from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70])\n by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6h7km13v-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 12 Feb 2026 20:44:04 +0000", "from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com\n [10.39.53.233])\n by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 61CKhgSe28050118\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Thu, 12 Feb 2026 20:43:42 GMT", "from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id E29185804E;\n Thu, 12 Feb 2026 20:44:02 +0000 (GMT)", "from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 2595C58056;\n Thu, 12 Feb 2026 20:44:01 +0000 (GMT)", "from fedora-workstation.ibmuc.com (unknown [9.61.112.15])\n by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP;\n Thu, 12 Feb 2026 20:44:01 +0000 (GMT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n :content-transfer-encoding:date:from:in-reply-to:message-id\n :mime-version:references:subject:to; s=pp1; bh=Lpt8LXZpW10c7Apx6\n BK1eNbikZCtHYu3JGVkXhJ74Ng=; b=o/RGluuvY2Q9TLkUW2lwd54PJmKUlw6rx\n 2xmiwm6R6MZmezsGD5TGZS7K4i/GFqNCDL4ow49IkSa8JnIU78IsapMCfkMYOt5m\n w2hKxgYqvvZNZgcKNnFF9/rBIEYeECm/BtfHQX9CYDs8dwnuYMkPd9qVb9X0hTas\n jd87ANCn1C3t8xOhpXCbpa7IvZ/gj+idzgXr54Am5pONmhulivZk9wonFkT853AW\n IXhEHbEOp4GNhHt7aD2Da2GKnpjgdxhxHTXLSWqNUr9wfn2TnEwNAyKF63Piy1ZT\n E5zgp0/Img4BjNXHUy/HNrHmb0+NZdKy38JeMHquFRVgR7eYMW01A==", "From": "Zhuoying Cai <zycai@linux.ibm.com>", "To": "thuth@redhat.com, berrange@redhat.com, richard.henderson@linaro.org,\n jrossi@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org", "Cc": "david@kernel.org, walling@linux.ibm.com, jjherne@linux.ibm.com,\n pasic@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com,\n mjrosato@linux.ibm.com, iii@linux.ibm.com, eblake@redhat.com,\n armbru@redhat.com, zycai@linux.ibm.com, alifm@linux.ibm.com,\n brueckner@linux.ibm.com", "Subject": "[PATCH v8 04/30] hw/s390x/ipl: Create certificate store", "Date": "Thu, 12 Feb 2026 15:43:25 -0500", "Message-ID": "<20260212204352.1044699-5-zycai@linux.ibm.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260212204352.1044699-1-zycai@linux.ibm.com>", "References": "<20260212204352.1044699-1-zycai@linux.ibm.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-TM-AS-GCONF": "00", "X-Authority-Analysis": "v=2.4 cv=YeCwJgRf c=1 sm=1 tr=0 ts=698e3b95 cx=c_pps\n a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17\n a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22\n a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=6ph8WD7lSjxTzuMCr3kA:9", "X-Proofpoint-GUID": "RrHZWjDI8DMvoGmZ8A05-mtCIAm90Lus", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMjEyMDE1NyBTYWx0ZWRfX7QVu8cJEIHck\n C9OnkZMec/mL+QIJ6Vi9W9QDA1u3w7m/uMGWlxqnclZpg6vYE/uroMN/TxDSVNR4JQ2WbYIcAs5\n 3kfkr5xhQXK4mZrtqsitEojG855WKWIhQo/yefaMGlISPIqKV/sMEpZFn5UUKAneib2mRCvK84J\n oeNk4MrKUSgHCg100GhxiJTQpqQB3kgu/la9v3Vb4WjedBHQEti1t5YVGDdN2FGkBcKeYMuadve\n m/0OMWWxGk+SlxRwnQLce1bCgIrpmy5vzSjYzVZ/cL5qkZxzm7HKc1c+8wv0KPKSr+zPsPcWpzf\n /FqTdFiWHLCslvlcehRfWBi/AYqrqVP2tXESdFGkSnl/FcsWgbccAXnPufzoGl3O0lzu5J8v8ha\n WJE4osxrDUyhdduuahdRhcD/FfgNhJLNkQFIj6zwd4S/jye2a91Z3ZJe1UpPOrDmKdykLExBgEF\n uTxhEjbNJ9CQMlj7Ssw==", "X-Proofpoint-ORIG-GUID": "RrHZWjDI8DMvoGmZ8A05-mtCIAm90Lus", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-02-12_05,2026-02-12_03,2025-10-01_01", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0\n priorityscore=1501 lowpriorityscore=0 clxscore=1015 impostorscore=0\n spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound\n adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000\n definitions=main-2602120157", "Received-SPF": "pass client-ip=148.163.156.1; envelope-from=zycai@linux.ibm.com;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001,\n RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n 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.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Create a certificate store for boot certificates used for secure IPL.\n\nLoad certificates from the `boot-certs` parameter of s390-ccw-virtio\nmachine type option into the cert store.\n\nCurrently, only X.509 certificates in PEM format are supported, as the\nQEMU command line accepts certificates in PEM format only.\n\nSigned-off-by: Zhuoying Cai <zycai@linux.ibm.com>\n---\n docs/specs/s390x-secure-ipl.rst | 16 +++\n hw/s390x/cert-store.c | 221 ++++++++++++++++++++++++++++++++\n hw/s390x/cert-store.h | 41 ++++++\n hw/s390x/ipl.c | 10 ++\n hw/s390x/ipl.h | 3 +\n hw/s390x/meson.build | 1 +\n include/hw/s390x/ipl/qipl.h | 2 +\n 7 files changed, 294 insertions(+)\n create mode 100644 docs/specs/s390x-secure-ipl.rst\n create mode 100644 hw/s390x/cert-store.c\n create mode 100644 hw/s390x/cert-store.h", "diff": "diff --git a/docs/specs/s390x-secure-ipl.rst b/docs/specs/s390x-secure-ipl.rst\nnew file mode 100644\nindex 0000000000..7ddac98a37\n--- /dev/null\n+++ b/docs/specs/s390x-secure-ipl.rst\n@@ -0,0 +1,16 @@\n+.. SPDX-License-Identifier: GPL-2.0-or-later\n+\n+s390 Certificate Store and Functions\n+====================================\n+\n+s390 Certificate Store\n+----------------------\n+\n+A certificate store is implemented for s390-ccw guests to retain within\n+memory all certificates provided by the user via the command-line, which\n+are expected to be stored somewhere on the host's file system. The store\n+will keep track of the number of certificates, their respective size,\n+and a summation of the sizes.\n+\n+Note: A maximum of 64 certificates are allowed to be stored in the certificate\n+store.\ndiff --git a/hw/s390x/cert-store.c b/hw/s390x/cert-store.c\nnew file mode 100644\nindex 0000000000..f642d50795\n--- /dev/null\n+++ b/hw/s390x/cert-store.c\n@@ -0,0 +1,221 @@\n+/*\n+ * S390 certificate store implementation\n+ *\n+ * Copyright 2025 IBM Corp.\n+ * Author(s): Zhuoying Cai <zycai@linux.ibm.com>\n+ *\n+ * SPDX-License-Identifier: GPL-2.0-or-later\n+ */\n+\n+#include \"qemu/osdep.h\"\n+#include \"cert-store.h\"\n+#include \"qapi/error.h\"\n+#include \"qemu/error-report.h\"\n+#include \"qemu/option.h\"\n+#include \"qemu/config-file.h\"\n+#include \"hw/s390x/ebcdic.h\"\n+#include \"hw/s390x/s390-virtio-ccw.h\"\n+#include \"qemu/cutils.h\"\n+#include \"crypto/x509-utils.h\"\n+#include \"qapi/qapi-types-machine-s390x.h\"\n+\n+static BootCertificatesList *s390_get_boot_certs(void)\n+{\n+ return S390_CCW_MACHINE(qdev_get_machine())->boot_certs;\n+}\n+\n+static S390IPLCertificate *init_cert(char *path, Error **errp)\n+{\n+ int rc;\n+ char *buf;\n+ size_t size;\n+ size_t der_len;\n+ char name[CERT_NAME_MAX_LEN];\n+ g_autofree gchar *filename = NULL;\n+ S390IPLCertificate *cert = NULL;\n+ g_autofree uint8_t *cert_der = NULL;\n+ Error *local_err = NULL;\n+\n+ filename = g_path_get_basename(path);\n+\n+ if (!g_file_get_contents(path, &buf, &size, NULL)) {\n+ error_setg(errp, \"Failed to load certificate: %s\", path);\n+ return NULL;\n+ }\n+\n+ rc = qcrypto_x509_convert_cert_der((uint8_t *)buf, size,\n+ &cert_der, &der_len, &local_err);\n+ if (rc != 0) {\n+ error_propagate_prepend(errp, local_err,\n+ \"Failed to initialize certificate: %s: \", path);\n+ g_free(buf);\n+ return NULL;\n+ }\n+\n+ cert = g_new0(S390IPLCertificate, 1);\n+ cert->size = size;\n+ /*\n+ * Store DER length only - reused for size calculation.\n+ * cert_der is discarded because DER certificate data will be used once\n+ * and can be regenerated from cert->raw.\n+ */\n+ cert->der_size = der_len;\n+ /* store raw pointer - ownership transfers to cert */\n+ cert->raw = (uint8_t *)buf;\n+\n+ /*\n+ * Left justified certificate name with padding on the right with blanks.\n+ * Convert certificate name to EBCDIC.\n+ */\n+ strpadcpy(name, CERT_NAME_MAX_LEN, filename, ' ');\n+ ebcdic_put(cert->name, name, CERT_NAME_MAX_LEN);\n+\n+ return cert;\n+}\n+\n+static void update_cert_store(S390IPLCertificateStore *cert_store,\n+ S390IPLCertificate *cert)\n+{\n+ size_t data_buf_size;\n+ size_t keyid_buf_size;\n+ size_t hash_buf_size;\n+ size_t cert_buf_size;\n+\n+ /* length field is word aligned for later DIAG use */\n+ keyid_buf_size = ROUND_UP(CERT_KEY_ID_LEN, 4);\n+ hash_buf_size = ROUND_UP(CERT_HASH_LEN, 4);\n+ cert_buf_size = ROUND_UP(cert->der_size, 4);\n+ data_buf_size = keyid_buf_size + hash_buf_size + cert_buf_size;\n+\n+ if (cert_store->largest_cert_size < data_buf_size) {\n+ cert_store->largest_cert_size = data_buf_size;\n+ }\n+\n+ g_assert(cert_store->count < MAX_CERTIFICATES);\n+\n+ cert_store->certs[cert_store->count] = *cert;\n+ cert_store->total_bytes += data_buf_size;\n+ cert_store->count++;\n+}\n+\n+static GPtrArray *get_cert_paths(Error **errp)\n+{\n+ struct stat st;\n+ BootCertificatesList *path_list = NULL;\n+ BootCertificatesList *list = NULL;\n+ gchar *cert_path;\n+ GDir *dir = NULL;\n+ const gchar *filename;\n+ bool is_empty;\n+ g_autoptr(GError) err = NULL;\n+ g_autoptr(GPtrArray) cert_path_builder = g_ptr_array_new_full(0, g_free);\n+\n+ path_list = s390_get_boot_certs();\n+\n+ for (list = path_list; list; list = list->next) {\n+ cert_path = list->value->path;\n+\n+ if (g_strcmp0(cert_path, \"\") == 0) {\n+ error_setg(errp, \"Empty path in certificate path list is not allowed\");\n+ goto fail;\n+ }\n+\n+ if (stat(cert_path, &st) != 0) {\n+ error_setg(errp, \"Failed to stat path '%s': %s\",\n+ cert_path, g_strerror(errno));\n+ goto fail;\n+ }\n+\n+ if (S_ISREG(st.st_mode)) {\n+ if (!g_str_has_suffix(cert_path, \".pem\")) {\n+ error_setg(errp, \"Certificate file '%s' must have a .pem extension\",\n+ cert_path);\n+ goto fail;\n+ }\n+\n+ g_ptr_array_add(cert_path_builder, g_strdup(cert_path));\n+ } else if (S_ISDIR(st.st_mode)) {\n+ dir = g_dir_open(cert_path, 0, &err);\n+ if (dir == NULL) {\n+ error_setg(errp, \"Failed to open directory '%s': %s\",\n+ cert_path, err->message);\n+\n+ goto fail;\n+ }\n+\n+ is_empty = true;\n+ while ((filename = g_dir_read_name(dir))) {\n+ is_empty = false;\n+\n+ if (g_str_has_suffix(filename, \".pem\")) {\n+ g_ptr_array_add(cert_path_builder,\n+ g_build_filename(cert_path, filename, NULL));\n+ } else {\n+ warn_report(\"skipping '%s': not a .pem file\", filename);\n+ }\n+ }\n+\n+ if (is_empty) {\n+ warn_report(\"'%s' directory is empty\", cert_path);\n+ }\n+\n+ g_dir_close(dir);\n+ } else {\n+ error_setg(errp, \"Path '%s' is neither a file nor a directory\", cert_path);\n+ goto fail;\n+ }\n+ }\n+\n+ qapi_free_BootCertificatesList(path_list);\n+ return g_steal_pointer(&cert_path_builder);\n+\n+fail:\n+ qapi_free_BootCertificatesList(path_list);\n+ return NULL;\n+}\n+\n+void s390_ipl_create_cert_store(S390IPLCertificateStore *cert_store)\n+{\n+ GPtrArray *cert_path_builder;\n+ Error *err = NULL;\n+\n+ /* If cert store is already populated, then no work to do */\n+ if (cert_store->count) {\n+ return;\n+ }\n+\n+ cert_path_builder = get_cert_paths(&err);\n+ if (cert_path_builder == NULL) {\n+ error_report_err(err);\n+ exit(1);\n+ }\n+\n+ if (cert_path_builder->len == 0) {\n+ g_ptr_array_free(cert_path_builder, TRUE);\n+ return;\n+ }\n+\n+ if (cert_path_builder->len > MAX_CERTIFICATES - 1) {\n+ error_report(\"Cert store exceeds maximum of %d certificates\", MAX_CERTIFICATES);\n+ g_ptr_array_free(cert_path_builder, TRUE);\n+ exit(1);\n+ }\n+\n+ cert_store->largest_cert_size = 0;\n+ cert_store->total_bytes = 0;\n+\n+ for (int i = 0; i < cert_path_builder->len; i++) {\n+ g_autofree S390IPLCertificate *cert = init_cert(\n+ (char *) cert_path_builder->pdata[i],\n+ &err);\n+ if (!cert) {\n+ error_report_err(err);\n+ g_ptr_array_free(cert_path_builder, TRUE);\n+ exit(1);\n+ }\n+\n+ update_cert_store(cert_store, cert);\n+ }\n+\n+ g_ptr_array_free(cert_path_builder, TRUE);\n+}\ndiff --git a/hw/s390x/cert-store.h b/hw/s390x/cert-store.h\nnew file mode 100644\nindex 0000000000..50e36e2389\n--- /dev/null\n+++ b/hw/s390x/cert-store.h\n@@ -0,0 +1,41 @@\n+/*\n+ * S390 certificate store\n+ *\n+ * Copyright 2025 IBM Corp.\n+ * Author(s): Zhuoying Cai <zycai@linux.ibm.com>\n+ *\n+ * SPDX-License-Identifier: GPL-2.0-or-later\n+ */\n+\n+#ifndef HW_S390_CERT_STORE_H\n+#define HW_S390_CERT_STORE_H\n+\n+#include \"hw/s390x/ipl/qipl.h\"\n+#include \"crypto/x509-utils.h\"\n+\n+#define CERT_NAME_MAX_LEN 64\n+\n+#define CERT_KEY_ID_LEN QCRYPTO_HASH_DIGEST_LEN_SHA256\n+#define CERT_HASH_LEN QCRYPTO_HASH_DIGEST_LEN_SHA256\n+\n+struct S390IPLCertificate {\n+ uint8_t name[CERT_NAME_MAX_LEN];\n+ size_t size;\n+ size_t der_size;\n+ uint8_t *raw;\n+};\n+typedef struct S390IPLCertificate S390IPLCertificate;\n+\n+struct S390IPLCertificateStore {\n+ uint16_t count;\n+ size_t largest_cert_size;\n+ size_t total_bytes;\n+ S390IPLCertificate certs[MAX_CERTIFICATES];\n+};\n+typedef struct S390IPLCertificateStore S390IPLCertificateStore;\n+QEMU_BUILD_BUG_MSG(sizeof(S390IPLCertificateStore) != 5656,\n+ \"size of S390IPLCertificateStore is wrong\");\n+\n+void s390_ipl_create_cert_store(S390IPLCertificateStore *cert_store);\n+\n+#endif\ndiff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c\nindex d34adb5522..ea108fe370 100644\n--- a/hw/s390x/ipl.c\n+++ b/hw/s390x/ipl.c\n@@ -36,6 +36,7 @@\n #include \"qemu/option.h\"\n #include \"qemu/ctype.h\"\n #include \"standard-headers/linux/virtio_ids.h\"\n+#include \"cert-store.h\"\n \n #define KERN_IMAGE_START 0x010000UL\n #define LINUX_MAGIC_ADDR 0x010008UL\n@@ -425,6 +426,13 @@ void s390_ipl_convert_loadparm(char *ascii_lp, uint8_t *ebcdic_lp)\n }\n }\n \n+S390IPLCertificateStore *s390_ipl_get_certificate_store(void)\n+{\n+ S390IPLState *ipl = get_ipl_device();\n+\n+ return &ipl->cert_store;\n+}\n+\n static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)\n {\n CcwDevice *ccw_dev = NULL;\n@@ -718,6 +726,8 @@ void s390_ipl_prepare_cpu(S390CPU *cpu)\n cpu->env.psw.addr = ipl->start_addr;\n cpu->env.psw.mask = IPL_PSW_MASK;\n \n+ s390_ipl_create_cert_store(&ipl->cert_store);\n+\n if (!ipl->kernel || ipl->iplb_valid) {\n cpu->env.psw.addr = ipl->bios_start_addr;\n if (!ipl->iplb_valid) {\ndiff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h\nindex 85be03de1b..0c773ac8ce 100644\n--- a/hw/s390x/ipl.h\n+++ b/hw/s390x/ipl.h\n@@ -13,6 +13,7 @@\n #ifndef HW_S390_IPL_H\n #define HW_S390_IPL_H\n \n+#include \"cert-store.h\"\n #include \"cpu.h\"\n #include \"exec/target_page.h\"\n #include \"system/address-spaces.h\"\n@@ -35,6 +36,7 @@ int s390_ipl_pv_unpack(struct S390PVResponse *pv_resp);\n void s390_ipl_prepare_cpu(S390CPU *cpu);\n IplParameterBlock *s390_ipl_get_iplb(void);\n IplParameterBlock *s390_ipl_get_iplb_pv(void);\n+S390IPLCertificateStore *s390_ipl_get_certificate_store(void);\n \n enum s390_reset {\n /* default is a reset not triggered by a CPU e.g. issued by QMP */\n@@ -64,6 +66,7 @@ struct S390IPLState {\n IplParameterBlock iplb;\n IplParameterBlock iplb_pv;\n QemuIplParameters qipl;\n+ S390IPLCertificateStore cert_store;\n uint64_t start_addr;\n uint64_t compat_start_addr;\n uint64_t bios_start_addr;\ndiff --git a/hw/s390x/meson.build b/hw/s390x/meson.build\nindex 8866012ddc..80d3d4a74d 100644\n--- a/hw/s390x/meson.build\n+++ b/hw/s390x/meson.build\n@@ -17,6 +17,7 @@ s390x_ss.add(files(\n 'sclpcpu.c',\n 'sclpquiesce.c',\n 'tod.c',\n+ 'cert-store.c',\n ))\n s390x_ss.add(when: 'CONFIG_KVM', if_true: files(\n 'tod-kvm.c',\ndiff --git a/include/hw/s390x/ipl/qipl.h b/include/hw/s390x/ipl/qipl.h\nindex 6824391111..e505f44020 100644\n--- a/include/hw/s390x/ipl/qipl.h\n+++ b/include/hw/s390x/ipl/qipl.h\n@@ -20,6 +20,8 @@\n #define LOADPARM_LEN 8\n #define NO_LOADPARM \"\\0\\0\\0\\0\\0\\0\\0\\0\"\n \n+#define MAX_CERTIFICATES 64\n+\n /*\n * The QEMU IPL Parameters will be stored at absolute address\n * 204 (0xcc) which means it is 32-bit word aligned but not\n", "prefixes": [ "v8", "04/30" ] }