Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 652ADC43458 for ; Tue, 7 Jul 2026 23:13:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1whEy3-0007F6-IC; Tue, 07 Jul 2026 19:12:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1whEy2-0007Db-3T; Tue, 07 Jul 2026 19:12:42 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1whEy0-0008PH-Ao; Tue, 07 Jul 2026 19:12:41 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 667MmLju819793; Tue, 7 Jul 2026 23:12:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=o/OoW4i77/okyrSNF jdzC5BYQSSPw/qqpEqwbxojaqM=; b=RT7sXqcrO0rRoGs94KdBqs/HHSJk6cHuL ti/FvYab9CXZrxEGpPgYVQlcjaW/DuS9gaM1JPIcgMiXTLDrqUEc/LpiXOScmzZ3 quN29u4Q0VhDLZvE0C/plgqXB3WoW0Jxjj6/60v5FXT5TTAORxcTBUPImQPmW4AY gxT+jAL5DLlLDQPGN+MsXpyn52xcoBj8LUQjb1rjV51aVcI7yaQjZi45w3bOlN+p EZ02j2Vbva6NBxsLRlFtTcCN1NKDu8mP2mJrPuHZQT0RGdNGSk1p1pQcgBteeNua cUIzjRcSq6HhLE/2HQEHlPN1FJjyqQyp1J/WY2reKqlHr7wvlOkEA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4f6sw4sr2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2026 23:12:36 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 667N4dsR017945; Tue, 7 Jul 2026 23:12:35 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4f7dgk52ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2026 23:12:35 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 667NCYgl31720110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Jul 2026 23:12:34 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57FBB58050; Tue, 7 Jul 2026 23:12:34 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8372158052; Tue, 7 Jul 2026 23:12:31 +0000 (GMT) Received: from fedora-workstation.ibmuc.com (unknown [9.61.32.2]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 7 Jul 2026 23:12:31 +0000 (GMT) From: Zhuoying Cai To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: jrossi@linux.ibm.com, cohuck@redhat.com, berrange@redhat.com, richard.henderson@linaro.org, david@kernel.org, walling@linux.ibm.com, jjherne@linux.ibm.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, mjrosato@linux.ibm.com, iii@linux.ibm.com, eblake@redhat.com, armbru@redhat.com, zycai@linux.ibm.com, alifm@linux.ibm.com, brueckner@linux.ibm.com, pierrick.bouvier@oss.qualcomm.com, jdaley@linux.ibm.com Subject: [PATCH v16 18/33] hw/s390x/ipl: Rework s390_ipl_map_iplb_chain for certificate storage Date: Tue, 7 Jul 2026 19:11:16 -0400 Message-ID: <20260707231132.2492104-19-zycai@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260707231132.2492104-1-zycai@linux.ibm.com> References: <20260707231132.2492104-1-zycai@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: eUBWoRtFfSOpHNwo_a1tuvBACBzZv1H8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzA3MDIyNCBTYWx0ZWRfX0MZ2jsR4cz8L rJwt029lBcbgBoGsBsiSfygnq//ZrCGAuEGXyo1EQ9hs5XZ83g8X4YBFk/PXOAT1lPnOT2AkOd5 SxSAMrcuD7onKsAsLZfofriY2BH5oCLL4h198PCRJuPT8YoZpsiVQM1zELWrcmPZWkTUs8Ngo8x 2SzUyGawZGLdUAcjog2Ykm8p+Aul6a8z8eMHy4B/7sMFc8oV08XlejgymjYm6lJmfmYhnbLsAef DJAjIbknED/e70bB8h0hcpdy5WCs48D+ZfDJGv92JCEuTyKOhoo+ApDW2sPhLKXAy5zxMcVk+Hh Xm8Um5BBWY7cUTqL8PvxuLqaMxCBsYPz2xCjIAtuzAyJr6trb8HvUzEsqFrph+YaDOMbCjp7Q77 OWJVpCJ2uXplxXOAVQZc3f555VLG2f6dYxyUUpwIrmZuC4Txs29VB7Vg/uuVE7LMX+FyYSEIlJ9 Z1bMttzUfsMC9LU3fqg== X-Proofpoint-ORIG-GUID: eUBWoRtFfSOpHNwo_a1tuvBACBzZv1H8 X-Authority-Analysis: v=2.4 cv=FqQ1OWrq c=1 sm=1 tr=0 ts=6a4d87e4 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=6n7imOYxnT_JOqVJOMMA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzA3MDIyNCBTYWx0ZWRfX+WhBQL8c7kM2 5clwEzjrApazb9xywrjBpkAFXymhA2/Ph0geJIje1ZkP1koUWq2e0NNVvMwZ7sgKbzQ13iBDhvr XFy2F8qvJ2XXn3ilv0wyXdDm4XarJy0= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-07_06,2026-07-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607070224 Received-SPF: pass client-ip=148.163.156.1; envelope-from=zycai@linux.ibm.com; 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, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Rework s390_ipl_map_iplb_chain to always allocate maximum memory for the IPLB chain, regardless of the number of boot devices. This space is also used to store certificates during secure boot, providing a safe location for certificates until the kernel reads them during boot. Rename next_iplb to ipl_data to better reflect its multiple purposes: storing both IPLB chains and certificate data. Signed-off-by: Zhuoying Cai Reviewed-by: Eric Farman Reviewed-by: Matthew Rosato --- hw/s390x/ipl.c | 18 ++++++++++++++---- hw/s390x/ipl.h | 2 -- include/hw/s390x/ipl/qipl.h | 5 ++++- pc-bios/s390-ccw/iplb.h | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 627544b361..85fe2d3cb4 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -426,10 +426,9 @@ static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *devtype) return pbdev; } -static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) +static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain, uint16_t count) { S390IPLState *ipl = get_ipl_device(); - uint16_t count = be16_to_cpu(ipl->qipl.chain_len); uint64_t len = sizeof(IplParameterBlock) * count; uint64_t chain_addr = find_iplb_chain_addr(ipl->bios_start_addr, count); @@ -593,7 +592,7 @@ void s390_rebuild_iplb(uint16_t dev_index, IplParameterBlock *iplb) static bool s390_init_all_iplbs(S390IPLState *ipl) { int iplb_num = 0; - IplParameterBlock iplb_chain[7]; + IplParameterBlock iplb_chain[MAX_BOOT_DEVS - 1] = { 0 }; DeviceState *dev_st = get_boot_device(0); Object *machine = qdev_get_machine(); @@ -639,13 +638,24 @@ static bool s390_init_all_iplbs(S390IPLState *ipl) dev_st = get_boot_device(i); s390_build_iplb(dev_st, &iplb_chain[i - 1]); } + } - ipl->qipl.next_iplb = cpu_to_be64(s390_ipl_map_iplb_chain(iplb_chain)); + /* + * Allocate maximum space for IPLB chain and/or certificate storage. + * Once a valid boot device is found, this space will be used to store + * certificates if secure boot is enabled. + */ + if (iplb_num > 1 || s390_has_certificate()) { + ipl->qipl.ipl_data = cpu_to_be64(s390_ipl_map_iplb_chain(iplb_chain, + MAX_BOOT_DEVS - 1)); } return iplb_num; } +QEMU_BUILD_BUG_MSG(sizeof(IplParameterBlock) * (MAX_BOOT_DEVS - 1) != CERT_BUF_SIZE, + "certificate buffer size is wrong"); + static void update_machine_ipl_properties(IplParameterBlock *iplb) { Object *machine = qdev_get_machine(); diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index 9807ef18f2..7b8a51452b 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -23,8 +23,6 @@ #include "qom/object.h" #include "target/s390x/kvm/pv.h" -#define MAX_BOOT_DEVS 8 /* Max number of devices that may have a bootindex */ - void s390_ipl_convert_loadparm(char *ascii_lp, uint8_t *ebcdic_lp); void s390_ipl_fmt_loadparm(uint8_t *loadparm, char *str, Error **errp); void s390_rebuild_iplb(uint16_t index, IplParameterBlock *iplb); diff --git a/include/hw/s390x/ipl/qipl.h b/include/hw/s390x/ipl/qipl.h index a2180719b1..37452faaa6 100644 --- a/include/hw/s390x/ipl/qipl.h +++ b/include/hw/s390x/ipl/qipl.h @@ -41,7 +41,10 @@ typedef enum S390IplType S390IplType; #define S390_IPLB_MIN_QEMU_SCSI_LEN 200 #define S390_IPLB_MAX_LEN 4096 +#define MAX_BOOT_DEVS 8 /* Max number of devices that may have a bootindex */ + #define MAX_CERTIFICATES 64 +#define CERT_BUF_SIZE ((MAX_BOOT_DEVS - 1) * 4096) /* largest supported block size - same as VIRTIO_DASD_DEFAULT_BLOCK_SIZE */ #define VIRTIO_MAX_BLOCK_SIZE 4096 #define MAX_COMP_ENTRIES ((VIRTIO_MAX_BLOCK_SIZE - 32) / 32) @@ -61,7 +64,7 @@ struct QemuIplParameters { uint32_t boot_menu_timeout; uint8_t reserved3[2]; uint16_t chain_len; - uint64_t next_iplb; + uint64_t ipl_data; } QEMU_PACKED; typedef struct QemuIplParameters QemuIplParameters; diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index c92a3d0f0c..c807e7f49b 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -61,11 +61,11 @@ static inline bool load_next_iplb(void) } qipl.index++; - next_iplb = (IplParameterBlock *) qipl.next_iplb; + next_iplb = (IplParameterBlock *) qipl.ipl_data; memcpy(iplb, next_iplb, sizeof(IplParameterBlock)); qipl.chain_len--; - qipl.next_iplb = qipl.next_iplb + sizeof(IplParameterBlock); + qipl.ipl_data = qipl.ipl_data + sizeof(IplParameterBlock); return true; } -- 2.54.0