Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2233177/?format=api
{ "id": 2233177, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2233177/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505201905.997996-14-zycai@linux.ibm.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.2/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": "<20260505201905.997996-14-zycai@linux.ibm.com>", "list_archive_url": null, "date": "2026-05-05T20:18:45", "name": "[v11,13/32] s390x/diag: Implement DIAG 508 subcode 1 for signature verification", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "c24b787ac42d182ea1d5546f0a2d5665709dc4a0", "submitter": { "id": 90643, "url": "http://patchwork.ozlabs.org/api/1.2/people/90643/?format=api", "name": "Zhuoying Cai", "email": "zycai@linux.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505201905.997996-14-zycai@linux.ibm.com/mbox/", "series": [ { "id": 502896, "url": "http://patchwork.ozlabs.org/api/1.2/series/502896/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502896", "date": "2026-05-05T20:18:37", "name": "Secure IPL Support for SCSI Scheme of virtio-blk/virtio-scsi Devices", "version": 11, "mbox": "http://patchwork.ozlabs.org/series/502896/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2233177/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2233177/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=nQQDueBA;\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=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.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 4g98yW6hByz1yJx\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 06:20:19 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wKMF4-0007l2-6n; Tue, 05 May 2026 16:19:42 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.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 1wKMF2-0007hE-0j; Tue, 05 May 2026 16:19:40 -0400", "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 1wKMEz-0000FS-Ug; Tue, 05 May 2026 16:19:39 -0400", "from pps.filterd (m0360083.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 645J1Znq3330886; Tue, 5 May 2026 20:19:34 GMT", "from ppma12.dal12v.mail.ibm.com\n (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9v7dnnm-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Tue, 05 May 2026 20:19:33 +0000 (GMT)", "from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1])\n by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id\n 645K9ah8031779;\n Tue, 5 May 2026 20:19:33 GMT", "from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9])\n by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwukqbftd-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Tue, 05 May 2026 20:19:33 +0000 (GMT)", "from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com\n [10.39.53.229])\n by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 645KJVbP24838828\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Tue, 5 May 2026 20:19:32 GMT", "from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id B29F25805B;\n Tue, 5 May 2026 20:19:31 +0000 (GMT)", "from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 215BF5805E;\n Tue, 5 May 2026 20:19:30 +0000 (GMT)", "from fedora-workstation.pok.ibm.com (unknown [9.12.79.241])\n by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP;\n Tue, 5 May 2026 20:19:30 +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=vEjX0uqKl3hz8mPPc\n TDZNOTid7nDNNw6UHC3uqxRGFo=; b=nQQDueBAhdeNhmYYiFHLMM3Dc+307BEWv\n TwlCVqQT3MSveZKb+jQ/AaAKi1mLosLaf7BVJbOUXp3r2PKv5/JIR5O8OtW9V/py\n FTrSZPwBLkQ4ANcK6fMmKFe3W9GebcLsg7oLN+Kbz8hv8T3olGs34ALCmn7nZPRV\n 9Q6ALkbN7LQMDwbjsWRmWn5m2DkQmbAJNr7LfrAjZIB145HN8pBm/Uazt51M1FfA\n lNxl5G10pbjnvLJp0cdMcfCoe4T3M1ptRf0dr6Rr0MDEwYYmHSJM5vbtFDP4ZlA/\n fkR55mAJO6mwBc1c+IvI96tx9xyAb+zYReJjVK59S6xledYwPL+Ag==", "From": "Zhuoying Cai <zycai@linux.ibm.com>", "To": "qemu-s390x@nongnu.org, qemu-devel@nongnu.org", "Cc": "jrossi@linux.ibm.com, cohuck@redhat.com, berrange@redhat.com,\n richard.henderson@linaro.org, david@kernel.org, walling@linux.ibm.com,\n jjherne@linux.ibm.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com,\n farman@linux.ibm.com, mjrosato@linux.ibm.com, iii@linux.ibm.com,\n eblake@redhat.com, armbru@redhat.com, zycai@linux.ibm.com,\n alifm@linux.ibm.com, brueckner@linux.ibm.com,\n pierrick.bouvier@oss.qualcomm.com, jdaley@linux.ibm.com", "Subject": "[PATCH v11 13/32] s390x/diag: Implement DIAG 508 subcode 1 for\n signature verification", "Date": "Tue, 5 May 2026 16:18:45 -0400", "Message-ID": "<20260505201905.997996-14-zycai@linux.ibm.com>", "X-Mailer": "git-send-email 2.54.0", "In-Reply-To": "<20260505201905.997996-1-zycai@linux.ibm.com>", "References": "<20260505201905.997996-1-zycai@linux.ibm.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-TM-AS-GCONF": "00", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNTA1MDE5NSBTYWx0ZWRfX4vUBEn9zp59o\n IDNWINq6r49t3A1LWD/RFsHWnMREH3p7tdYQ79lk5u2+L5ORMp+lUvezdhNcztU3x5T7inD8ljI\n ps/VP1EwajRFQVDjjEgMPbkFbG3N1oNoLirDTPmYQoabS9YAZXV6ntMnEcF+zY3lSixdZ2O3DRr\n Oi1sfDhEh1vQ+dabHYBw7ftTlDyDobCbqK9A8hoh5AjwBVRF0+IVs1GgYoGsrwpWvEfNRL88xO1\n 8rAyidVnEkAPlzyoQpjE496HCPsuY450tqoPcgi1m0ApCaMwg3FaV33yKrmlpbDcKMRO9ioKbsK\n oeYYDOgPXBlFuI3oVP09q9CfikUdQAUFdlEBPEfICKuaB1Wq4UgLrgBnW86GwIgIYF7VbjSWRd+\n de57uzeB7xuJvWpA7RNc4pe4+Wstf0orL9xTv8UPtDQlWIB83WzJKExmm83pmNedgmhQsryXI1v\n J0PmomVRmRbUqjjFI5Q==", "X-Proofpoint-GUID": "yDGFDFLe-IvdYVFUJCaHvj2JrgYj2QC3", "X-Proofpoint-ORIG-GUID": "yDGFDFLe-IvdYVFUJCaHvj2JrgYj2QC3", "X-Authority-Analysis": "v=2.4 cv=eu/vCIpX c=1 sm=1 tr=0 ts=69fa50d5 cx=c_pps\n a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17\n a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8\n a=K66z3tz1c1WH2lCF3KIA:9", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-05-05_02,2026-04-30_02,2025-10-01_01", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n priorityscore=1501 phishscore=0 lowpriorityscore=0 clxscore=1011 adultscore=0\n suspectscore=0 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050195", "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": "-26", "X-Spam_score": "-2.7", "X-Spam_bar": "--", "X-Spam_report": "(-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\n RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001,\n 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": "From: Collin Walling <walling@linux.ibm.com>\n\nDIAG 508 subcode 1 performs signature-verification on signed components.\nA signed component may be a Linux kernel image, or any other signed\nbinary. **Verification of initrd is not supported.**\n\nThe instruction call expects two item-pairs: an address of a device\ncomponent, an address of the analogous signature file (in PKCS#7 DER format),\nand their respective lengths. All of this data should be encapsulated\nwithin a Diag508SigVerifBlock.\n\nThe DIAG handler will read from the provided addresses\nto retrieve the necessary data, parse the signature file, then\nperform the signature-verification. Because there is no way to\ncorrelate a specific certificate to a component, each certificate\nin the store is tried until either verification succeeds, or all\ncerts have been exhausted.\n\nA return code of 1 indicates success, and the index and length of the\ncorresponding certificate will be set in the Diag508SigVerifBlock.\nThe following values indicate failure:\n\n\t0x0102: no certificates are available in the store\n\t0x0202: component data is invalid\n\t0x0302: PKCS#7 format signature is invalid\n\t0x0402: signature-verification failed\n\t0x0502: length of Diag508SigVerifBlock is invalid\n\nSigned-off-by: Collin Walling <walling@linux.ibm.com>\nSigned-off-by: Zhuoying Cai <zycai@linux.ibm.com>\nReviewed-by: Thomas Huth <thuth@redhat.com>\nReviewed-by: Farhan Ali<alifm@linux.ibm.com>\n---\n docs/specs/s390x-secure-ipl.rst | 17 +++++\n include/hw/s390x/ipl/diag508.h | 30 +++++++++\n target/s390x/diag.c | 111 +++++++++++++++++++++++++++++++-\n 3 files changed, 157 insertions(+), 1 deletion(-)", "diff": "diff --git a/docs/specs/s390x-secure-ipl.rst b/docs/specs/s390x-secure-ipl.rst\nindex 488981339d..f35e868e4c 100644\n--- a/docs/specs/s390x-secure-ipl.rst\n+++ b/docs/specs/s390x-secure-ipl.rst\n@@ -80,3 +80,20 @@ that requires assistance from QEMU.\n \n Subcode 0 - query installed subcodes\n Returns a 64-bit mask indicating which subcodes are supported.\n+\n+Subcode 1 - perform signature verification\n+ Perform signature-verification on a signed component, using certificates\n+ from the certificate store and leveraging qcrypto libraries to perform\n+ this operation.\n+\n+ Note: verification of initrd is not supported.\n+\n+ A return code of 1 indicates success, and the index and length of the\n+ corresponding certificate will be set in the Diag508SigVerifBlock.\n+ The following values indicate failure:\n+\n+ * ``0x0102``: no certificates are available in the store\n+ * ``0x0202``: component data is invalid\n+ * ``0x0302``: PKCS#7 format signature is invalid\n+ * ``0x0402``: signature-verification failed\n+ * ``0x0502``: length of Diag508SigVerifBlock is invalid\ndiff --git a/include/hw/s390x/ipl/diag508.h b/include/hw/s390x/ipl/diag508.h\nindex 6281ad8299..8a147f32a0 100644\n--- a/include/hw/s390x/ipl/diag508.h\n+++ b/include/hw/s390x/ipl/diag508.h\n@@ -11,5 +11,35 @@\n #define S390X_DIAG508_H\n \n #define DIAG_508_SUBC_QUERY_SUBC 0x0000\n+#define DIAG_508_SUBC_SIG_VERIF 0x8000\n+\n+#define DIAG_508_RC_OK 0x0001\n+#define DIAG_508_RC_NO_CERTS 0x0102\n+#define DIAG_508_RC_INVAL_COMP_DATA 0x0202\n+#define DIAG_508_RC_INVAL_PKCS7_SIG 0x0302\n+#define DIAG_508_RC_FAIL_VERIF 0x0402\n+#define DIAG_508_RC_INVAL_LEN 0x0502\n+\n+/*\n+ * Maximum componenet and signature sizes for current secure boot implementation\n+ * Not architecturally defined and may need to revisit if increased\n+ */\n+#define DIAG_508_MAX_COMP_LEN 0x10000000\n+#define DIAG_508_MAX_SIG_LEN 4096\n+\n+struct Diag508SigVerifBlock {\n+ uint32_t length;\n+ uint8_t reserved0[3];\n+ uint8_t version;\n+ uint32_t reserved[2];\n+ uint8_t cert_store_index;\n+ uint8_t reserved1[7];\n+ uint64_t cert_len;\n+ uint64_t comp_len;\n+ uint64_t comp_addr;\n+ uint64_t sig_len;\n+ uint64_t sig_addr;\n+};\n+typedef struct Diag508SigVerifBlock Diag508SigVerifBlock;\n \n #endif\ndiff --git a/target/s390x/diag.c b/target/s390x/diag.c\nindex 390a543ede..0d548fadd9 100644\n--- a/target/s390x/diag.c\n+++ b/target/s390x/diag.c\n@@ -640,9 +640,110 @@ void handle_diag_320(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)\n }\n }\n \n+static bool diag_508_verify_sig(uint8_t *cert, size_t cert_size,\n+ uint8_t *comp, size_t comp_size,\n+ uint8_t *sig, size_t sig_size)\n+{\n+ g_autofree uint8_t *sig_pem = NULL;\n+ size_t sig_size_pem;\n+ int rc;\n+\n+ /*\n+ * PKCS#7 signature with DER format\n+ * Convert to PEM format for signature verification\n+ *\n+ * Ignore errors during qcrypto signature format conversion and verification\n+ * Return false on any error, treating it as a verification failure\n+ */\n+ rc = qcrypto_pkcs7_convert_sig_pem(sig, sig_size, &sig_pem, &sig_size_pem, NULL);\n+ if (rc < 0) {\n+ return false;\n+ }\n+\n+ rc = qcrypto_x509_verify_sig(cert, cert_size,\n+ comp, comp_size,\n+ sig_pem, sig_size_pem, NULL);\n+ if (rc < 0) {\n+ return false;\n+ }\n+\n+ return true;\n+}\n+\n+static int handle_diag508_sig_verif(uint64_t addr)\n+{\n+ int verified;\n+ uint32_t svb_len;\n+ uint64_t comp_len, comp_addr;\n+ uint64_t sig_len, sig_addr;\n+ g_autofree uint8_t *comp = NULL;\n+ g_autofree uint8_t *sig = NULL;\n+ g_autofree Diag508SigVerifBlock *svb = NULL;\n+ size_t svb_size = sizeof(Diag508SigVerifBlock);\n+ S390IPLCertificateStore *cs = s390_ipl_get_certificate_store();\n+\n+ if (!cs->count) {\n+ return DIAG_508_RC_NO_CERTS;\n+ }\n+\n+ svb = g_new0(Diag508SigVerifBlock, 1);\n+ cpu_physical_memory_read(addr, svb, svb_size);\n+\n+ svb_len = be32_to_cpu(svb->length);\n+ if (svb_len != svb_size) {\n+ return DIAG_508_RC_INVAL_LEN;\n+ }\n+\n+ comp_len = be64_to_cpu(svb->comp_len);\n+ comp_addr = be64_to_cpu(svb->comp_addr);\n+ sig_len = be64_to_cpu(svb->sig_len);\n+ sig_addr = be64_to_cpu(svb->sig_addr);\n+\n+ if (!comp_len || !comp_addr || comp_len > DIAG_508_MAX_COMP_LEN) {\n+ if (comp_len > DIAG_508_MAX_COMP_LEN) {\n+ warn_report(\"DIAG 0x508: component length %lu exceeds current maximum %u\",\n+ comp_len, DIAG_508_MAX_COMP_LEN);\n+ }\n+ return DIAG_508_RC_INVAL_COMP_DATA;\n+ }\n+\n+ if (!sig_len || !sig_addr || sig_len > DIAG_508_MAX_SIG_LEN) {\n+ if (sig_len > DIAG_508_MAX_SIG_LEN) {\n+ warn_report(\"DIAG 0x508: signature length %lu exceeds current maximum %u\",\n+ sig_len, DIAG_508_MAX_SIG_LEN);\n+ }\n+ return DIAG_508_RC_INVAL_PKCS7_SIG;\n+ }\n+\n+ comp = g_malloc0(comp_len);\n+ cpu_physical_memory_read(comp_addr, comp, comp_len);\n+\n+ sig = g_malloc0(sig_len);\n+ cpu_physical_memory_read(sig_addr, sig, sig_len);\n+\n+ for (int i = 0; i < cs->count; i++) {\n+ verified = diag_508_verify_sig(cs->certs[i].raw,\n+ cs->certs[i].size,\n+ comp, comp_len,\n+ sig, sig_len);\n+ if (verified) {\n+ svb->cert_store_index = i;\n+ svb->cert_len = cpu_to_be64(cs->certs[i].der_size);\n+ cpu_physical_memory_write(addr, svb, svb_size);\n+ return DIAG_508_RC_OK;\n+ }\n+ }\n+\n+ return DIAG_508_RC_FAIL_VERIF;\n+}\n+\n+QEMU_BUILD_BUG_MSG(sizeof(Diag508SigVerifBlock) != 64,\n+ \"size of Diag508SigVerifBlock is wrong\");\n+\n void handle_diag_508(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)\n {\n uint64_t subcode = env->regs[r3];\n+ uint64_t addr = env->regs[r1];\n int rc;\n \n if (env->psw.mask & PSW_MASK_PSTATE) {\n@@ -657,7 +758,15 @@ void handle_diag_508(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)\n \n switch (subcode) {\n case DIAG_508_SUBC_QUERY_SUBC:\n- rc = 0;\n+ rc = DIAG_508_SUBC_SIG_VERIF;\n+ break;\n+ case DIAG_508_SUBC_SIG_VERIF:\n+ if (!diag_parm_addr_valid(addr, sizeof(Diag508SigVerifBlock), true)) {\n+ s390_program_interrupt(env, PGM_ADDRESSING, ra);\n+ return;\n+ }\n+\n+ rc = handle_diag508_sig_verif(addr);\n break;\n default:\n s390_program_interrupt(env, PGM_SPECIFICATION, ra);\n", "prefixes": [ "v11", "13/32" ] }