From nobody Sat Nov 23 23:31:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1728350294; cv=none; d=zohomail.com; s=zohoarc; b=KSU7D+G0vN2lxZG34VgQqPttcdSW1rNtY2UGvd0VSmR/kbiAapjS3x+PDeuge+uKc/gIMbFtsfGX8N6dl6yTDir50af7cbSNsUcOHN3U9IfBXvXzH+PFUSRYimfrHmhAqTqUU9dJTaN8inq22sQw6Z3VnUDfmM9mlivRlzPFf9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728350294; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DEFEPPwca8cbUrn5c+Sf8o9VCEUuCEQCcf30CbCJe1Y=; b=gk9VXNZ6Qr5eO6d8cwZcDZQVHxQc4q/ElIOF1jn1zO9wlegetlEVUTY0wHapxU4+jVcWTe+UsjiYToVc6gzLYSW1uqbmGVmGhwPz9nlVtl+PLruIOBiWa9Eo5TpgZZOJFRU2l/MsFWSG6D7U13FtiUdsNmRyMsg2azWlxHYeVzw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728350294299106.89050327928851; Mon, 7 Oct 2024 18:18:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxyq8-0004IN-9p; Mon, 07 Oct 2024 21:16:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxypo-00048f-Vt; Mon, 07 Oct 2024 21:16:22 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxypn-0008LG-4o; Mon, 07 Oct 2024 21:16:20 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 497NvUax029225; Tue, 8 Oct 2024 01:16:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 424sr4g7hk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 01:16:17 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4981GH23017715; Tue, 8 Oct 2024 01:16:17 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 424sr4g7he-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 01:16:17 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 497LNald022844; Tue, 8 Oct 2024 01:16:16 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 423h9jsfjq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 01:16:16 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4981GF4p49676784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Oct 2024 01:16:15 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7113958055; Tue, 8 Oct 2024 01:16:15 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E973058043; Tue, 8 Oct 2024 01:16:14 +0000 (GMT) Received: from localhost.localdomain (unknown [9.61.51.58]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Oct 2024 01:16:14 +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-transfer-encoding; s=pp1; bh=DEFEPPwca8cbU rn5c+Sf8o9VCEUuCEQCcf30CbCJe1Y=; b=JkYLk7ekKyyTFsyuaMqGHXCIN5bKZ ZuDWzVeYKNGxkGJhqbioD1Y7o8igJtBoyKKyrQiPgWiAkdf4jJwKP/+F2dx64xAv y2fdByL9FdZhmuj3rrVxQ4eXlbLpwmWV4yfXIZSFbFgLapKP1mCqVEi9rguGRZDL icuOOG7lCcx4++4SwerGFLtoIASgwx+ENCZ7uZNjQ8+0wsbMDCQSPy0WXuI/omH2 6c0h9gA2oAiv4RfP+H+rjFeW66HEygD6HFIOy2BC8gTu4EvwUPdWkYCJluhy1FLz 3KAZYtrWUVtz/n29JboiOA1S5mU9rueZ+NnVw0R7omq82LTtN4+4U2Seg== From: jrossi@linux.ibm.com To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, thuth@redhat.com Cc: frankja@linux.ibm.com, jrossi@linux.ibm.com Subject: [PATCH v3 14/19] s390x: Add individual loadparm assignment to CCW device Date: Mon, 7 Oct 2024 21:15:47 -0400 Message-ID: <20241008011552.2645520-15-jrossi@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241008011552.2645520-1-jrossi@linux.ibm.com> References: <20241008011552.2645520-1-jrossi@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Fh-BN6dAaSQtFOrmu2wl_VMzVGTrksWL X-Proofpoint-GUID: FpRlehbUfgDSYag91MvHy7TIPUOP-xi6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-07_16,2024-10-07_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 bulkscore=0 clxscore=1015 spamscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410080003 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=jrossi@linux.ibm.com; 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, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1728350296431116600 Content-Type: text/plain; charset="utf-8" From: Jared Rossi Add a loadparm property to the VirtioCcwDevice object so that different loadparms can be defined on a per-device basis for CCW boot devices. The machine/global loadparm is still supported. If both a global and per-de= vice loadparm are defined, the per-device value will override the global value f= or that device, but any other devices that do not specify a per-device loadparm will still use the global loadparm. It is invalid to assign a loadparm to a non-boot device. Signed-off-by: Jared Rossi Reviewed-by: Thomas Huth --- hw/s390x/ccw-device.h | 2 ++ hw/s390x/ipl.h | 3 +- hw/s390x/ccw-device.c | 46 ++++++++++++++++++++++++++ hw/s390x/ipl.c | 66 +++++++++++++++++++++++--------------- hw/s390x/s390-virtio-ccw.c | 18 +---------- hw/s390x/sclp.c | 3 +- pc-bios/s390-ccw/main.c | 10 ++++-- 7 files changed, 100 insertions(+), 48 deletions(-) diff --git a/hw/s390x/ccw-device.h b/hw/s390x/ccw-device.h index 5feeb0ee7a..1e1737c0f3 100644 --- a/hw/s390x/ccw-device.h +++ b/hw/s390x/ccw-device.h @@ -26,6 +26,8 @@ struct CcwDevice { CssDevId dev_id; /* The actual busid of the virtual subchannel. */ CssDevId subch_id; + /* If set, use this loadparm value when device is boot target */ + uint8_t loadparm[8]; }; typedef struct CcwDevice CcwDevice; =20 diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index fa394c339d..b670bad551 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -21,7 +21,8 @@ =20 #define DIAG308_FLAGS_LP_VALID 0x80 =20 -int s390_ipl_set_loadparm(uint8_t *loadparm); +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_ipl_update_diag308(IplParameterBlock *iplb); int s390_ipl_prepare_pv_header(Error **errp); int s390_ipl_pv_unpack(void); diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c index 14c24e3890..230cc09e03 100644 --- a/hw/s390x/ccw-device.c +++ b/hw/s390x/ccw-device.c @@ -13,6 +13,10 @@ #include "ccw-device.h" #include "hw/qdev-properties.h" #include "qemu/module.h" +#include "ipl.h" +#include "qapi/visitor.h" +#include "qemu/ctype.h" +#include "qapi/error.h" =20 static void ccw_device_refill_ids(CcwDevice *dev) { @@ -37,10 +41,52 @@ static bool ccw_device_realize(CcwDevice *dev, Error **= errp) return true; } =20 +static void ccw_device_get_loadparm(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + CcwDevice *dev =3D CCW_DEVICE(obj); + char *str =3D g_strndup((char *) dev->loadparm, sizeof(dev->loadparm)); + + visit_type_str(v, name, &str, errp); + g_free(str); +} + +static void ccw_device_set_loadparm(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + CcwDevice *dev =3D CCW_DEVICE(obj); + char *val; + int index; + + index =3D object_property_get_int(obj, "bootindex", NULL); + + if (index < 0) { + error_setg(errp, "LOADPARM is only valid for boot devices!"); + } + + if (!visit_type_str(v, name, &val, errp)) { + return; + } + + s390_ipl_fmt_loadparm(dev->loadparm, val, errp); +} + +static const PropertyInfo ccw_loadparm =3D { + .name =3D "ccw_loadparm", + .description =3D "Up to 8 chars in set of [A-Za-z0-9. ] to pass" + " to the guest loader/kernel", + .get =3D ccw_device_get_loadparm, + .set =3D ccw_device_set_loadparm, +}; + static Property ccw_device_properties[] =3D { DEFINE_PROP_CSS_DEV_ID("devno", CcwDevice, devno), DEFINE_PROP_CSS_DEV_ID_RO("dev_id", CcwDevice, dev_id), DEFINE_PROP_CSS_DEV_ID_RO("subch_id", CcwDevice, subch_id), + DEFINE_PROP("loadparm", CcwDevice, loadparm, ccw_loadparm, + typeof(uint8_t[8])), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 8c490eeb52..55a83bb836 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -34,6 +34,7 @@ #include "qemu/config-file.h" #include "qemu/cutils.h" #include "qemu/option.h" +#include "qemu/ctype.h" #include "standard-headers/linux/virtio_ids.h" =20 #define KERN_IMAGE_START 0x010000UL @@ -397,12 +398,43 @@ static CcwDevice *s390_get_ccw_device(DeviceState *de= v_st, int *devtype) return ccw_dev; } =20 +void s390_ipl_fmt_loadparm(uint8_t *loadparm, char *str, Error **errp) +{ + int i; + + /* Initialize the loadparm with spaces */ + memset(loadparm, ' ', LOADPARM_LEN); + for (i =3D 0; i < LOADPARM_LEN && str[i]; i++) { + uint8_t c =3D qemu_toupper(str[i]); /* mimic HMC */ + + if (qemu_isalnum(c) || c =3D=3D '.' || c =3D=3D ' ') { + loadparm[i] =3D c; + } else { + error_setg(errp, "LOADPARM: invalid character '%c' (ASCII 0x%0= 2x)", + c, c); + return; + } + } +} + +void s390_ipl_convert_loadparm(char *ascii_lp, uint8_t *ebcdic_lp) +{ + int i; + + /* Initialize the loadparm with EBCDIC spaces (0x40) */ + memset(ebcdic_lp, '@', LOADPARM_LEN); + for (i =3D 0; i < LOADPARM_LEN && ascii_lp[i]; i++) { + ebcdic_lp[i] =3D ascii2ebcdic[(uint8_t) ascii_lp[i]]; + } +} + static bool s390_gen_initial_iplb(S390IPLState *ipl) { DeviceState *dev_st; CcwDevice *ccw_dev =3D NULL; SCSIDevice *sd; int devtype; + uint8_t *lp; =20 dev_st =3D get_boot_device(0); if (dev_st) { @@ -413,6 +445,8 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) * Currently allow IPL only from CCW devices. */ if (ccw_dev) { + lp =3D ccw_dev->loadparm; + switch (devtype) { case CCW_DEVTYPE_SCSI: sd =3D SCSI_DEVICE(dev_st); @@ -445,40 +479,20 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) break; } =20 - if (!s390_ipl_set_loadparm(ipl->iplb.loadparm)) { - ipl->iplb.flags |=3D DIAG308_FLAGS_LP_VALID; + /* If the device loadparm is empty use the global machine loadparm= */ + if (memcmp(lp, "\0\0\0\0\0\0\0\0", 8) =3D=3D 0) { + lp =3D S390_CCW_MACHINE(qdev_get_machine())->loadparm; } =20 + s390_ipl_convert_loadparm((char *)lp, ipl->iplb.loadparm); + ipl->iplb.flags |=3D DIAG308_FLAGS_LP_VALID; + return true; } =20 return false; } =20 -int s390_ipl_set_loadparm(uint8_t *loadparm) -{ - MachineState *machine =3D MACHINE(qdev_get_machine()); - char *lp =3D object_property_get_str(OBJECT(machine), "loadparm", NULL= ); - - if (lp) { - int i; - - /* lp is an uppercase string without leading/embedded spaces */ - for (i =3D 0; i < 8 && lp[i]; i++) { - loadparm[i] =3D ascii2ebcdic[(uint8_t) lp[i]]; - } - - if (i < 8) { - memset(loadparm + i, 0x40, 8 - i); /* fill with EBCDIC spaces = */ - } - - g_free(lp); - return 0; - } - - return -1; -} - static bool is_virtio_ccw_device_of_type(IplParameterBlock *iplb, int virtio_id) { diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 529e53f308..fe03f716f3 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -722,28 +722,12 @@ static void machine_set_loadparm(Object *obj, Visitor= *v, { S390CcwMachineState *ms =3D S390_CCW_MACHINE(obj); char *val; - int i; =20 if (!visit_type_str(v, name, &val, errp)) { return; } =20 - for (i =3D 0; i < sizeof(ms->loadparm) && val[i]; i++) { - uint8_t c =3D qemu_toupper(val[i]); /* mimic HMC */ - - if (('A' <=3D c && c <=3D 'Z') || ('0' <=3D c && c <=3D '9') || (c= =3D=3D '.') || - (c =3D=3D ' ')) { - ms->loadparm[i] =3D c; - } else { - error_setg(errp, "LOADPARM: invalid character '%c' (ASCII 0x%0= 2x)", - c, c); - return; - } - } - - for (; i < sizeof(ms->loadparm); i++) { - ms->loadparm[i] =3D ' '; /* pad right with spaces */ - } + s390_ipl_fmt_loadparm(ms->loadparm, val, errp); } =20 static void ccw_machine_class_init(ObjectClass *oc, void *data) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index e725dcd5fd..8b2d7a88bd 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -175,7 +175,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) memcpy(&read_info->loadparm, &ipib->loadparm, sizeof(read_info->loadparm)); } else { - s390_ipl_set_loadparm(read_info->loadparm); + s390_ipl_convert_loadparm((char *)S390_CCW_MACHINE(machine)->loadp= arm, + read_info->loadparm); } =20 sccb->h.response_code =3D cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION); diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index f818bd7210..d7c457e0ed 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -183,8 +183,14 @@ static void css_setup(void) static void boot_setup(void) { char lpmsg[] =3D "LOADPARM=3D[________]\n"; + have_iplb =3D store_iplb(&iplb); + + if (memcmp(iplb.loadparm, "@@@@@@@@", LOADPARM_LEN) !=3D 0) { + ebcdic_to_ascii((char *) iplb.loadparm, loadparm_str, LOADPARM_LEN= ); + } else { + sclp_get_loadparm_ascii(loadparm_str); + } =20 - sclp_get_loadparm_ascii(loadparm_str); memcpy(lpmsg + 10, loadparm_str, 8); puts(lpmsg); =20 @@ -193,8 +199,6 @@ static void boot_setup(void) * so we don't taint our decision-making process during a reboot. */ memset((char *)S390EP, 0, 6); - - have_iplb =3D store_iplb(&iplb); } =20 static bool find_boot_device(void) --=20 2.45.1