Skip to content

Commit 6992860

Browse files
Michael HolzheuMartin Schwidefsky
authored andcommitted
s390/ipl: Add missing SCSI loadparm attributes to /sys/firmware
Currently the loadparm is only supported for CCW IPL. But also for SCSI IPL it can be specified either on the HMC load panel respectively z/VM console or via diagnose 308. So fix this for SCSI and add the required sysfs attributes for reading the IPL loadparm and for setting the loadparm for re-IPL. With this patch the following two sysfs attributes are introduced: - /sys/firmware/ipl/loadparm (for system that have been IPLed from SCSI) - /sys/firmware/reipl/fcp/loadparm Because the loadparm is now available for SCSI and CCW it is moved now from "struct ipl_block_ccw" to the generic "struct ipl_list_hdr". Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 3b12693 commit 6992860

2 files changed

Lines changed: 89 additions & 47 deletions

File tree

‎arch/s390/include/asm/ipl.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#define IPL_PARM_BLK_FCP_LEN (sizeof(struct ipl_list_hdr) + \
1818
sizeof(struct ipl_block_fcp))
1919

20-
#define IPL_PARM_BLK0_FCP_LEN (sizeof(struct ipl_block_fcp) + 8)
20+
#define IPL_PARM_BLK0_FCP_LEN (sizeof(struct ipl_block_fcp) + 16)
2121

2222
#define IPL_PARM_BLK_CCW_LEN (sizeof(struct ipl_list_hdr) + \
2323
sizeof(struct ipl_block_ccw))
2424

25-
#define IPL_PARM_BLK0_CCW_LEN (sizeof(struct ipl_block_ccw) + 8)
25+
#define IPL_PARM_BLK0_CCW_LEN (sizeof(struct ipl_block_ccw) + 16)
2626

2727
#define IPL_MAX_SUPPORTED_VERSION (0)
2828

@@ -38,10 +38,11 @@ struct ipl_list_hdr {
3838
u8 pbt;
3939
u8 flags;
4040
u16 reserved2;
41+
u8 loadparm[8];
4142
} __attribute__((packed));
4243

4344
struct ipl_block_fcp {
44-
u8 reserved1[313-1];
45+
u8 reserved1[305-1];
4546
u8 opt;
4647
u8 reserved2[3];
4748
u16 reserved3;
@@ -62,7 +63,6 @@ struct ipl_block_fcp {
6263
offsetof(struct ipl_block_fcp, scp_data)))
6364

6465
struct ipl_block_ccw {
65-
u8 load_parm[8];
6666
u8 reserved1[84];
6767
u8 reserved2[2];
6868
u16 devno;

‎arch/s390/kernel/ipl.c‎

Lines changed: 85 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -455,22 +455,6 @@ DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long)
455455
DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long)
456456
IPL_PARMBLOCK_START->ipl_info.fcp.br_lba);
457457

458-
static struct attribute *ipl_fcp_attrs[] = {
459-
&sys_ipl_type_attr.attr,
460-
&sys_ipl_device_attr.attr,
461-
&sys_ipl_fcp_wwpn_attr.attr,
462-
&sys_ipl_fcp_lun_attr.attr,
463-
&sys_ipl_fcp_bootprog_attr.attr,
464-
&sys_ipl_fcp_br_lba_attr.attr,
465-
NULL,
466-
};
467-
468-
static struct attribute_group ipl_fcp_attr_group = {
469-
.attrs = ipl_fcp_attrs,
470-
};
471-
472-
/* CCW ipl device attributes */
473-
474458
static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj,
475459
struct kobj_attribute *attr, char *page)
476460
{
@@ -487,6 +471,23 @@ static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj,
487471
static struct kobj_attribute sys_ipl_ccw_loadparm_attr =
488472
__ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
489473

474+
static struct attribute *ipl_fcp_attrs[] = {
475+
&sys_ipl_type_attr.attr,
476+
&sys_ipl_device_attr.attr,
477+
&sys_ipl_fcp_wwpn_attr.attr,
478+
&sys_ipl_fcp_lun_attr.attr,
479+
&sys_ipl_fcp_bootprog_attr.attr,
480+
&sys_ipl_fcp_br_lba_attr.attr,
481+
&sys_ipl_ccw_loadparm_attr.attr,
482+
NULL,
483+
};
484+
485+
static struct attribute_group ipl_fcp_attr_group = {
486+
.attrs = ipl_fcp_attrs,
487+
};
488+
489+
/* CCW ipl device attributes */
490+
490491
static struct attribute *ipl_ccw_attrs_vm[] = {
491492
&sys_ipl_type_attr.attr,
492493
&sys_ipl_device_attr.attr,
@@ -765,28 +766,10 @@ DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n",
765766
DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
766767
reipl_block_fcp->ipl_info.fcp.devno);
767768

768-
static struct attribute *reipl_fcp_attrs[] = {
769-
&sys_reipl_fcp_device_attr.attr,
770-
&sys_reipl_fcp_wwpn_attr.attr,
771-
&sys_reipl_fcp_lun_attr.attr,
772-
&sys_reipl_fcp_bootprog_attr.attr,
773-
&sys_reipl_fcp_br_lba_attr.attr,
774-
NULL,
775-
};
776-
777-
static struct attribute_group reipl_fcp_attr_group = {
778-
.attrs = reipl_fcp_attrs,
779-
};
780-
781-
/* CCW reipl device attributes */
782-
783-
DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
784-
reipl_block_ccw->ipl_info.ccw.devno);
785-
786769
static void reipl_get_ascii_loadparm(char *loadparm,
787770
struct ipl_parameter_block *ibp)
788771
{
789-
memcpy(loadparm, ibp->ipl_info.ccw.load_parm, LOADPARM_LEN);
772+
memcpy(loadparm, ibp->hdr.loadparm, LOADPARM_LEN);
790773
EBCASC(loadparm, LOADPARM_LEN);
791774
loadparm[LOADPARM_LEN] = 0;
792775
strim(loadparm);
@@ -821,13 +804,50 @@ static ssize_t reipl_generic_loadparm_store(struct ipl_parameter_block *ipb,
821804
return -EINVAL;
822805
}
823806
/* initialize loadparm with blanks */
824-
memset(ipb->ipl_info.ccw.load_parm, ' ', LOADPARM_LEN);
807+
memset(ipb->hdr.loadparm, ' ', LOADPARM_LEN);
825808
/* copy and convert to ebcdic */
826-
memcpy(ipb->ipl_info.ccw.load_parm, buf, lp_len);
827-
ASCEBC(ipb->ipl_info.ccw.load_parm, LOADPARM_LEN);
809+
memcpy(ipb->hdr.loadparm, buf, lp_len);
810+
ASCEBC(ipb->hdr.loadparm, LOADPARM_LEN);
828811
return len;
829812
}
830813

814+
/* FCP wrapper */
815+
static ssize_t reipl_fcp_loadparm_show(struct kobject *kobj,
816+
struct kobj_attribute *attr, char *page)
817+
{
818+
return reipl_generic_loadparm_show(reipl_block_fcp, page);
819+
}
820+
821+
static ssize_t reipl_fcp_loadparm_store(struct kobject *kobj,
822+
struct kobj_attribute *attr,
823+
const char *buf, size_t len)
824+
{
825+
return reipl_generic_loadparm_store(reipl_block_fcp, buf, len);
826+
}
827+
828+
static struct kobj_attribute sys_reipl_fcp_loadparm_attr =
829+
__ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_fcp_loadparm_show,
830+
reipl_fcp_loadparm_store);
831+
832+
static struct attribute *reipl_fcp_attrs[] = {
833+
&sys_reipl_fcp_device_attr.attr,
834+
&sys_reipl_fcp_wwpn_attr.attr,
835+
&sys_reipl_fcp_lun_attr.attr,
836+
&sys_reipl_fcp_bootprog_attr.attr,
837+
&sys_reipl_fcp_br_lba_attr.attr,
838+
&sys_reipl_fcp_loadparm_attr.attr,
839+
NULL,
840+
};
841+
842+
static struct attribute_group reipl_fcp_attr_group = {
843+
.attrs = reipl_fcp_attrs,
844+
};
845+
846+
/* CCW reipl device attributes */
847+
848+
DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
849+
reipl_block_ccw->ipl_info.ccw.devno);
850+
831851
/* NSS wrapper */
832852
static ssize_t reipl_nss_loadparm_show(struct kobject *kobj,
833853
struct kobj_attribute *attr, char *page)
@@ -1125,11 +1145,10 @@ static void reipl_block_ccw_fill_parms(struct ipl_parameter_block *ipb)
11251145
/* LOADPARM */
11261146
/* check if read scp info worked and set loadparm */
11271147
if (sclp_ipl_info.is_valid)
1128-
memcpy(ipb->ipl_info.ccw.load_parm,
1129-
&sclp_ipl_info.loadparm, LOADPARM_LEN);
1148+
memcpy(ipb->hdr.loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN);
11301149
else
11311150
/* read scp info failed: set empty loadparm (EBCDIC blanks) */
1132-
memset(ipb->ipl_info.ccw.load_parm, 0x40, LOADPARM_LEN);
1151+
memset(ipb->hdr.loadparm, 0x40, LOADPARM_LEN);
11331152
ipb->hdr.flags = DIAG308_FLAGS_LP_VALID;
11341153

11351154
/* VM PARM */
@@ -1251,9 +1270,16 @@ static int __init reipl_fcp_init(void)
12511270
return rc;
12521271
}
12531272

1254-
if (ipl_info.type == IPL_TYPE_FCP)
1273+
if (ipl_info.type == IPL_TYPE_FCP) {
12551274
memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE);
1256-
else {
1275+
/*
1276+
* Fix loadparm: There are systems where the (SCSI) LOADPARM
1277+
* is invalid in the SCSI IPL parameter block, so take it
1278+
* always from sclp_ipl_info.
1279+
*/
1280+
memcpy(reipl_block_fcp->hdr.loadparm, sclp_ipl_info.loadparm,
1281+
LOADPARM_LEN);
1282+
} else {
12571283
reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
12581284
reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
12591285
reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN;
@@ -1864,7 +1890,23 @@ static void __init shutdown_actions_init(void)
18641890

18651891
static int __init s390_ipl_init(void)
18661892
{
1893+
char str[8] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40};
1894+
18671895
sclp_get_ipl_info(&sclp_ipl_info);
1896+
/*
1897+
* Fix loadparm: There are systems where the (SCSI) LOADPARM
1898+
* returned by read SCP info is invalid (contains EBCDIC blanks)
1899+
* when the system has been booted via diag308. In that case we use
1900+
* the value from diag308, if available.
1901+
*
1902+
* There are also systems where diag308 store does not work in
1903+
* case the system is booted from HMC. Fortunately in this case
1904+
* READ SCP info provides the correct value.
1905+
*/
1906+
if (memcmp(sclp_ipl_info.loadparm, str, sizeof(str)) == 0 &&
1907+
diag308_set_works)
1908+
memcpy(sclp_ipl_info.loadparm, ipl_block.hdr.loadparm,
1909+
LOADPARM_LEN);
18681910
shutdown_actions_init();
18691911
shutdown_triggers_init();
18701912
return 0;

0 commit comments

Comments
 (0)