{"id":2219380,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2219380/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","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":""},"msgid":"<20260402221453.1602899-11-zycai@linux.ibm.com>","date":"2026-04-02T22:14:32","name":"[v10,10/30] s390x/diag: Introduce DIAG 508 for secure IPL operations","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ff7a7bd4ccbb75f209e3761cc931b930f10a7d26","submitter":{"id":90643,"url":"http://patchwork.ozlabs.org/api/1.0/people/90643/?format=json","name":"Zhuoying Cai","email":"zycai@linux.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260402221453.1602899-11-zycai@linux.ibm.com/mbox/","series":[{"id":498557,"url":"http://patchwork.ozlabs.org/api/1.0/series/498557/?format=json","date":"2026-04-02T22:14:35","name":"Secure IPL Support for SCSI Scheme of virtio-blk/virtio-scsi Devices","version":10,"mbox":"http://patchwork.ozlabs.org/series/498557/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219380/checks/","tags":{},"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=Z5IvUcjg;\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 4fmx6Q4k7kz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 09:17:02 +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 1w8QK3-0000o2-U8; Thu, 02 Apr 2026 18:15:31 -0400","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 1w8QK1-0000n1-Vz; Thu, 02 Apr 2026 18:15:30 -0400","from mx0b-001b2d01.pphosted.com ([148.163.158.5])\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 1w8QK0-0004nr-5K; Thu, 02 Apr 2026 18:15:29 -0400","from pps.filterd (m0356516.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 632BoiUG3661208; Thu, 2 Apr 2026 22:15:24 GMT","from ppma13.dal12v.mail.ibm.com\n (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d64dgx0r8-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 02 Apr 2026 22:15:24 +0000 (GMT)","from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1])\n by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 632Li4Ga031007;\n Thu, 2 Apr 2026 22:15:23 GMT","from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69])\n by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d6uhk3rmc-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 02 Apr 2026 22:15:23 +0000","from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com\n [10.241.53.104])\n by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 632MFL2X27197982\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Thu, 2 Apr 2026 22:15:21 GMT","from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 5310358052;\n Thu,  2 Apr 2026 22:15:21 +0000 (GMT)","from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id F386E58065;\n Thu,  2 Apr 2026 22:15:19 +0000 (GMT)","from fedora-workstation.ibmuc.com (unknown [9.61.183.185])\n by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP;\n Thu,  2 Apr 2026 22:15:19 +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=YFSVgddncazjv+xZp\n n3NVIrZMQLZZaodPY8GsrK39W4=; b=Z5IvUcjg7nydSnTGRxJCEl76CUL62pzfj\n wvoqP937uQYfIlhvn/TkaBl3bKfMUsCWo/kBqh2zBAdOI5NYd5Guwvl9NrB5t123\n CYUurpnU50oRXtE8hfG+O5u+NXzdGTsLWG6uL4gSHOsvSpO2g93IsAUFXR3CLjqZ\n 7CTYbGhItN6RAIJhA7CGWJ6X1iix03TbyezSVD8TlwN/byWn2tCbomAiIY/H21KP\n BEHa+nAoKuh4VXVKUH7aYZrj3Gc5Ir0l8J345/rbXxis2AKwdMqLqoUW5EGe/eXV\n vskNeevEk1kDpvu+sJusrUe+knHJILwzwZkWP51lOIx8BaZQ6Tc+g==","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, pierrick.bouvier@linaro.org,\n 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, jdaley@linux.ibm.com","Subject":"[PATCH v10 10/30] s390x/diag: Introduce DIAG 508 for secure IPL\n operations","Date":"Thu,  2 Apr 2026 18:14:32 -0400","Message-ID":"<20260402221453.1602899-11-zycai@linux.ibm.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260402221453.1602899-1-zycai@linux.ibm.com>","References":"<20260402221453.1602899-1-zycai@linux.ibm.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-TM-AS-GCONF":"00","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDAyMDE5NSBTYWx0ZWRfX9IAdNtoaTku2\n Tbfo0Y2uUalAg1CnHG826AVxPVr1ry+Zp8rw1YpRRTMY4crGg8DKY+yCIVb+8S9353fBipgRR5y\n adpK25roSNH5at4lvgJ6ezduCDcKMCDNK5ut8sjrAn7gfqPXI1yN4cqtEhn0LIbEdlbuhGPtj5H\n Fln1o0vG0Iuwmgbgn+1cFtDf6cll+VK+NnWrn/h4VPOQZNQwFvYL4wH09l4lyk/Kuq0+UVByrYq\n cH7EvC1gC3bxYU8sBplNtrlfTIhPE+sZsym3Thl7CMyLKB5ZkSlRMgQr5vdVAl8wdCEZllnBgQt\n 4zzmSSmxY7Vs6ZjIDfhLELMQonqKJ9Do3icSPqJEbXZib4vzjcLbcLgAiFOgYZUbp7zjQJAaohq\n H3tmM8dzZ3lMUyGHhM+cOuRis1cqdG6KT8/gworzhQ7ZQNxIbHU/L0KqDQ/dlGWfWzcOq+tqEvW\n Be/59PwJkbyLm8sAqCw==","X-Authority-Analysis":"v=2.4 cv=QKZlhwLL c=1 sm=1 tr=0 ts=69ceea7c cx=c_pps\n a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17\n a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8\n a=hXQcL9AfcS-IPDpH2m0A:9","X-Proofpoint-GUID":"P_N5w5eZxZjQeWgsVPO5pMezxITC3y9A","X-Proofpoint-ORIG-GUID":"P_N5w5eZxZjQeWgsVPO5pMezxITC3y9A","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-04-02_04,2026-04-02_05,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1015\n spamscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 malwarescore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2604020195","Received-SPF":"pass client-ip=148.163.158.5; envelope-from=zycai@linux.ibm.com;\n helo=mx0b-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,\n RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001,\n RCVD_IN_VALIDITY_RPBL_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":"From: Collin Walling <walling@linux.ibm.com>\n\nIn order to support secure IPL (aka secure boot) for the s390-ccw BIOS,\na new s390 DIAGNOSE instruction is introduced to leverage QEMU for\nhandling operations such as signature verification and certificate\nretrieval.\n\nCurrently, only subcode 0 is supported with this patch, which is used to\nquery a bitmap of which subcodes are supported.\n\nSigned-off-by: Collin Walling <walling@linux.ibm.com>\nReviewed-by: Farhan Ali <alifm@linux.ibm.com>\nReviewed-by: Thomas Huth <thuth@redhat.com>\n---\n docs/specs/s390x-secure-ipl.rst | 18 ++++++++++++++++++\n include/hw/s390x/ipl/diag508.h  | 15 +++++++++++++++\n target/s390x/diag.c             | 27 +++++++++++++++++++++++++++\n target/s390x/kvm/kvm.c          | 14 ++++++++++++++\n target/s390x/s390x-internal.h   |  2 ++\n target/s390x/tcg/misc_helper.c  |  7 +++++++\n 6 files changed, 83 insertions(+)\n create mode 100644 include/hw/s390x/ipl/diag508.h","diff":"diff --git a/docs/specs/s390x-secure-ipl.rst b/docs/specs/s390x-secure-ipl.rst\nindex 1a712a0e0c..83feb5d6b5 100644\n--- a/docs/specs/s390x-secure-ipl.rst\n+++ b/docs/specs/s390x-secure-ipl.rst\n@@ -62,3 +62,21 @@ Subcode 2 - store verification certificates\n     contiguously in a VCE (with zero-padding). Following the header, the\n     key-id is immediately stored. The hash and certificate data follow and\n     may be accessed via the respective offset fields stored in the VCE.\n+\n+\n+Secure IPL Data Structures, Facilities, and Functions\n+=====================================================\n+\n+DIAGNOSE function code 'X'508' - IPL extensions\n+---------------------------------------------------\n+\n+DIAGNOSE 'X'508' is reserved for guest use in order to facilitate communication\n+of additional IPL operations that cannot be handled by guest code, such as\n+signature verification for secure IPL.\n+\n+If the function code specifies 0x508, IPL extension functions are performed.\n+These functions are meant to provide extended functionality for s390 guest boot\n+that requires assistance from QEMU.\n+\n+Subcode 0 - query installed subcodes\n+    Returns a 64-bit mask indicating which subcodes are supported.\ndiff --git a/include/hw/s390x/ipl/diag508.h b/include/hw/s390x/ipl/diag508.h\nnew file mode 100644\nindex 0000000000..6281ad8299\n--- /dev/null\n+++ b/include/hw/s390x/ipl/diag508.h\n@@ -0,0 +1,15 @@\n+/*\n+ * S/390 DIAGNOSE 508 definitions and structures\n+ *\n+ * Copyright 2025 IBM Corp.\n+ * Author(s): Collin Walling <walling@linux.ibm.com>\n+ *\n+ * SPDX-License-Identifier: GPL-2.0-or-later\n+ */\n+\n+#ifndef S390X_DIAG508_H\n+#define S390X_DIAG508_H\n+\n+#define DIAG_508_SUBC_QUERY_SUBC    0x0000\n+\n+#endif\ndiff --git a/target/s390x/diag.c b/target/s390x/diag.c\nindex d62e134f74..343a1fa584 100644\n--- a/target/s390x/diag.c\n+++ b/target/s390x/diag.c\n@@ -20,6 +20,7 @@\n #include \"hw/s390x/cert-store.h\"\n #include \"hw/s390x/ipl.h\"\n #include \"hw/s390x/ipl/diag320.h\"\n+#include \"hw/s390x/ipl/diag508.h\"\n #include \"hw/s390x/s390-virtio-ccw.h\"\n #include \"system/kvm.h\"\n #include \"kvm/kvm_s390x.h\"\n@@ -635,3 +636,29 @@ void handle_diag_320(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)\n         break;\n     }\n }\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+    int rc;\n+\n+    if (env->psw.mask & PSW_MASK_PSTATE) {\n+        s390_program_interrupt(env, PGM_PRIVILEGED, ra);\n+        return;\n+    }\n+\n+    if ((subcode & ~0x0ffffULL) || (r1 & 1)) {\n+        s390_program_interrupt(env, PGM_SPECIFICATION, ra);\n+        return;\n+    }\n+\n+    switch (subcode) {\n+    case DIAG_508_SUBC_QUERY_SUBC:\n+        rc = 0;\n+        break;\n+    default:\n+        s390_program_interrupt(env, PGM_SPECIFICATION, ra);\n+        return;\n+    }\n+    env->regs[r1 + 1] = rc;\n+}\ndiff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c\nindex fb7a99f380..cba431688b 100644\n--- a/target/s390x/kvm/kvm.c\n+++ b/target/s390x/kvm/kvm.c\n@@ -101,6 +101,7 @@\n #define DIAG_CERT_STORE                 0x320\n #define DIAG_KVM_HYPERCALL              0x500\n #define DIAG_KVM_BREAKPOINT             0x501\n+#define DIAG_SECURE_IPL                 0x508\n \n #define ICPT_INSTRUCTION                0x04\n #define ICPT_PROGRAM                    0x08\n@@ -1571,6 +1572,16 @@ static void kvm_handle_diag_320(S390CPU *cpu, struct kvm_run *run)\n     handle_diag_320(&cpu->env, r1, r3, RA_IGNORED);\n }\n \n+static void kvm_handle_diag_508(S390CPU *cpu, struct kvm_run *run)\n+{\n+    uint64_t r1, r3;\n+\n+    r1 = (run->s390_sieic.ipa & 0x00f0) >> 4;\n+    r3 = run->s390_sieic.ipa & 0x000f;\n+\n+    handle_diag_508(&cpu->env, r1, r3, RA_IGNORED);\n+}\n+\n #define DIAG_KVM_CODE_MASK 0x000000000000ffff\n \n static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)\n@@ -1604,6 +1615,9 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)\n     case DIAG_CERT_STORE:\n         kvm_handle_diag_320(cpu, run);\n         break;\n+    case DIAG_SECURE_IPL:\n+        kvm_handle_diag_508(cpu, run);\n+        break;\n     default:\n         trace_kvm_insn_diag(func_code);\n         kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION);\ndiff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h\nindex b16490bce6..367df65970 100644\n--- a/target/s390x/s390x-internal.h\n+++ b/target/s390x/s390x-internal.h\n@@ -390,6 +390,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3,\n                      uintptr_t ra);\n void handle_diag_320(CPUS390XState *env, uint64_t r1, uint64_t r3,\n                      uintptr_t ra);\n+void handle_diag_508(CPUS390XState *env, uint64_t r1, uint64_t r3,\n+                     uintptr_t ra);\n \n \n /* translate.c */\ndiff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c\nindex 4d73475d95..562dde9cb3 100644\n--- a/target/s390x/tcg/misc_helper.c\n+++ b/target/s390x/tcg/misc_helper.c\n@@ -149,6 +149,13 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)\n         bql_unlock();\n         r = 0;\n         break;\n+    case 0x508:\n+        /* secure ipl operations */\n+        bql_lock();\n+        handle_diag_508(env, r1, r3, GETPC());\n+        bql_unlock();\n+        r = 0;\n+        break;\n     default:\n         r = -1;\n         break;\n","prefixes":["v10","10/30"]}