OSDN Git Service

s390/ipl: Provide has_secure sysfs attribute
authorPhilipp Rudo <prudo@linux.ibm.com>
Mon, 8 Apr 2019 12:24:08 +0000 (14:24 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 29 Apr 2019 08:44:04 +0000 (10:44 +0200)
Provide an interface for userspace so it can find out if a machine is
capeable of doing secure boot. The interface is, for example, needed for
zipl so it can find out which file format it can/should write to disk.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/sclp.h
arch/s390/kernel/ipl.c
drivers/s390/char/sclp.h
drivers/s390/char/sclp_early.c

index ef4c9de..ef5d8fa 100644 (file)
@@ -79,6 +79,8 @@ struct sclp_info {
        unsigned char has_kss : 1;
        unsigned char has_gisaf : 1;
        unsigned char has_diag318 : 1;
+       unsigned char has_sipl : 1;
+       unsigned char has_sipl_g2 : 1;
        unsigned int ibc;
        unsigned int mtid;
        unsigned int mtid_cp;
index 6f2bb64..e123c0d 100644 (file)
@@ -283,6 +283,20 @@ static ssize_t ipl_secure_show(struct kobject *kobj,
 static struct kobj_attribute sys_ipl_secure_attr =
        __ATTR(secure, 0444, ipl_secure_show, NULL);
 
+static ssize_t ipl_has_secure_show(struct kobject *kobj,
+                                  struct kobj_attribute *attr, char *page)
+{
+       if (MACHINE_IS_LPAR)
+               return sprintf(page, "%i\n", !!sclp.has_sipl);
+       else if (MACHINE_IS_VM)
+               return sprintf(page, "%i\n", !!sclp.has_sipl_g2);
+       else
+               return sprintf(page, "%i\n", 0);
+}
+
+static struct kobj_attribute sys_ipl_has_secure_attr =
+       __ATTR(has_secure, 0444, ipl_has_secure_show, NULL);
+
 static ssize_t ipl_vm_parm_show(struct kobject *kobj,
                                struct kobj_attribute *attr, char *page)
 {
@@ -379,6 +393,7 @@ static struct attribute *ipl_fcp_attrs[] = {
        &sys_ipl_fcp_br_lba_attr.attr,
        &sys_ipl_ccw_loadparm_attr.attr,
        &sys_ipl_secure_attr.attr,
+       &sys_ipl_has_secure_attr.attr,
        NULL,
 };
 
@@ -395,6 +410,7 @@ static struct attribute *ipl_ccw_attrs_vm[] = {
        &sys_ipl_ccw_loadparm_attr.attr,
        &sys_ipl_vm_parm_attr.attr,
        &sys_ipl_secure_attr.attr,
+       &sys_ipl_has_secure_attr.attr,
        NULL,
 };
 
@@ -403,6 +419,7 @@ static struct attribute *ipl_ccw_attrs_lpar[] = {
        &sys_ipl_device_attr.attr,
        &sys_ipl_ccw_loadparm_attr.attr,
        &sys_ipl_secure_attr.attr,
+       &sys_ipl_has_secure_attr.attr,
        NULL,
 };
 
index 367e9d3..287382d 100644 (file)
@@ -197,7 +197,9 @@ struct read_info_sccb {
        u32     hmfai;                  /* 124-127 */
        u8      _pad_128[134 - 128];    /* 128-133 */
        u8      byte_134;                       /* 134 */
-       u8      _pad_135[4096 - 135];   /* 135-4095 */
+       u8      _pad_135;               /* 135 */
+       u16     cbl;                    /* 136-137 */
+       u8      _pad_138[4096 - 138];   /* 138-4095 */
 } __packed __aligned(PAGE_SIZE);
 
 struct read_storage_sccb {
index 8332788..dae9de3 100644 (file)
@@ -40,6 +40,8 @@ static void __init sclp_early_facilities_detect(struct read_info_sccb *sccb)
        sclp.has_gisaf = !!(sccb->fac118 & 0x08);
        sclp.has_hvs = !!(sccb->fac119 & 0x80);
        sclp.has_kss = !!(sccb->fac98 & 0x01);
+       sclp.has_sipl = !!(sccb->cbl & 0x02);
+       sclp.has_sipl_g2 = !!(sccb->cbl & 0x04);
        if (sccb->fac85 & 0x02)
                S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP;
        if (sccb->fac91 & 0x40)