@samitouri / QOSamiQemu / commits / d6de77dab6

s390x: Guest support for Secure-IPL Facility

Introduce Secure-IPL (SIPL) facility. Use fac_ipl to represent bytes 136 and 137 for IPL device facilities of the SCLP Read SCP Info. Availability of SIPL facility is determined by byte 136 bit 1 of the SCLP Read SCP Info. Byte 136's facilities cannot be represented without the availability of the extended-length-SCCB, so add it as a check for consistency. Secure IPL is not available for guests under protected virtualization. This feature is available starting with the gen16 CPU model. Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com> Reviewed-by: Collin Walling <walling@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260730214624.2328883-20-zycai@linux.ibm.com Signed-off-by: Eric Farman <farman@linux.ibm.com>

Zhuoying Cai committed Jul 30, 2026 at 17:46 UTC d6de77dab6edbd01ffc3e6bed9bb122c7021f490
8 files changed +21 -2
hw/s390x/sclp.c
+2
@@ -146,6 +146,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)
146 if (s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB)) {
147 s390_get_feat_block(S390_FEAT_TYPE_SCLP_FAC134,
148 &read_info->fac134);
149 + s390_get_feat_block(S390_FEAT_TYPE_SCLP_FAC_IPL,
150 + read_info->fac_ipl);
151 s390_get_feat_block(S390_FEAT_TYPE_SCLP_FAC139,
152 &read_info->fac139);
153 }
include/hw/s390x/sclp.h
+4 -2
@@ -136,9 +136,11 @@ typedef struct ReadInfo {
136 uint32_t hmfai;
137 uint8_t _reserved7[134 - 128]; /* 128-133 */
138 uint8_t fac134;
139 - uint8_t _reserved8[139 - 135]; /* 135-138 */
139 + uint8_t _reserved8;
140 + uint8_t fac_ipl[2]; /* 136-137 */
141 + uint8_t _reserved9;
142 uint8_t fac139;
141 - uint8_t _reserved9[144 - 140]; /* 140-143 */
143 + uint8_t _reserved10[144 - 140]; /* 140-143 */
144 struct CPUEntry entries[];
145 /*
146 * When the Extended-Length SCCB (ELS) feature is enabled the
target/s390x/cpu_features.c
+4
@@ -119,6 +119,7 @@ void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type,
119 * Some facilities are not available for CPUs in protected mode:
120 * - All SIE facilities because SIE is not available
121 * - DIAG318
122 + * - Secure IPL Facility
123 *
124 * As VMs can move in and out of protected mode the CPU model
125 * doesn't protect us from that problem because it is only
@@ -149,6 +150,9 @@ void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type,
150 clear_be_bit(s390_feat_def(S390_FEAT_DIAG_318)->bit, data);
151 clear_be_bit(s390_feat_def(S390_FEAT_CERT_STORE)->bit, data);
152 break;
153 + case S390_FEAT_TYPE_SCLP_FAC_IPL:
154 + clear_be_bit(s390_feat_def(S390_FEAT_SIPL)->bit, data);
155 + break;
156 case S390_FEAT_TYPE_SCLP_FAC139:
157 clear_be_bit(s390_feat_def(S390_FEAT_SIE_ASTFLEIE2)->bit, data);
158 break;
target/s390x/cpu_features.h
+1
@@ -24,6 +24,7 @@ typedef enum {
24 S390_FEAT_TYPE_SCLP_CONF_CHAR,
25 S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT,
26 S390_FEAT_TYPE_SCLP_FAC134,
27 + S390_FEAT_TYPE_SCLP_FAC_IPL,
28 S390_FEAT_TYPE_SCLP_FAC139,
29 S390_FEAT_TYPE_SCLP_CPU,
30 S390_FEAT_TYPE_MISC,
target/s390x/cpu_features_def.h.inc
+3
@@ -140,6 +140,9 @@ DEF_FEAT(SIE_IBS, "ibs", SCLP_CONF_CHAR_EXT, 10, "SIE: Interlock-and-broadcast-s
140 DEF_FEAT(DIAG_318, "diag318", SCLP_FAC134, 0, "Control program name and version codes")
141 DEF_FEAT(CERT_STORE, "cstore", SCLP_FAC134, 5, "Certificate Store functions")
142
143 +/* Features exposed via SCLP SCCB Facilities byte 136 - 137 (bit numbers relative to byte-136) */
144 +DEF_FEAT(SIPL, "sipl", SCLP_FAC_IPL, 1, "Secure-IPL facility")
145 +
146 /* Features exposed via SCLP SCCB Facilities byte 139 (bit numbers relative to byte-139) */
147 DEF_FEAT(SIE_ASTFLEIE2, "astfleie2", SCLP_FAC139, 1, "SIE: ASTFLE interpretation execution facility 2")
148
target/s390x/cpu_models.c
+2
@@ -263,6 +263,7 @@ bool s390_has_feat(S390Feat feat)
263 case S390_FEAT_SIE_CMMA:
264 case S390_FEAT_SIE_PFMFI:
265 case S390_FEAT_SIE_IBS:
266 + case S390_FEAT_SIPL:
267 case S390_FEAT_CONFIGURATION_TOPOLOGY:
268 case S390_FEAT_SIE_ASTFLEIE2:
269 return false;
@@ -508,6 +509,7 @@ static void check_consistency(const S390CPUModel *model)
509 { S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_AP },
510 { S390_FEAT_DIAG_318, S390_FEAT_EXTENDED_LENGTH_SCCB },
511 { S390_FEAT_CERT_STORE, S390_FEAT_EXTENDED_LENGTH_SCCB },
512 + { S390_FEAT_SIPL, S390_FEAT_EXTENDED_LENGTH_SCCB },
513 { S390_FEAT_NNPA, S390_FEAT_VECTOR },
514 { S390_FEAT_RDP, S390_FEAT_LOCAL_TLB_CLEARING },
515 { S390_FEAT_UV_FEAT_AP, S390_FEAT_AP },
target/s390x/gen-features.c
+2
@@ -722,6 +722,7 @@ static uint16_t full_GEN16_GA1[] = {
722 S390_FEAT_UV_FEAT_AP_INTR,
723 S390_FEAT_SIE_ASTFLEIE2,
724 S390_FEAT_CERT_STORE,
725 + S390_FEAT_SIPL,
726 };
727
728 static uint16_t full_GEN17_GA1[] = {
@@ -923,6 +924,7 @@ static uint16_t qemu_MAX[] = {
924 S390_FEAT_PRNO_TRNG,
925 S390_FEAT_EXTENDED_LENGTH_SCCB,
926 S390_FEAT_CERT_STORE,
927 + S390_FEAT_SIPL,
928 };
929
930 /****** END FEATURE DEFS ******/
target/s390x/kvm/kvm.c
+3
@@ -2502,6 +2502,9 @@ bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)
2502
2503 set_bit(S390_FEAT_CERT_STORE, model->features);
2504
2505 + /* Some Secure IPL facilities are emulated by QEMU */
2506 + set_bit(S390_FEAT_SIPL, model->features);
2507 +
2508 /* Test for Ultravisor features that influence secure guest behavior */
2509 query_uv_feat_guest(model->features);
2510