]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: vsie: Disable some bits when in ESA mode
authorEric Farman <farman@linux.ibm.com>
Wed, 1 Apr 2026 15:12:19 +0000 (17:12 +0200)
committerJanosch Frank <frankja@linux.ibm.com>
Thu, 2 Apr 2026 13:37:01 +0000 (15:37 +0200)
In the event that a nested guest is put in ESA mode,
ensure that some bits are scrubbed from the shadow SCB.

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
arch/s390/kvm/vsie.c

index aa43c6848217aaa1ca6809d3640b613338ffd8ff..2ce406861d225fe66cdb09f72adf4def9c9ccbaf 100644 (file)
@@ -387,6 +387,17 @@ end:
        return 0;
 }
 
+static void shadow_esa(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
+{
+       struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
+
+       /* Ensure these bits are indeed turned off */
+       scb_s->eca &= ~ECA_VX;
+       scb_s->ecb &= ~(ECB_GS | ECB_TE);
+       scb_s->ecb3 &= ~ECB3_RI;
+       scb_s->ecd &= ~ECD_HOSTREGMGMT;
+}
+
 /* shadow (round up/down) the ibc to avoid validity icpt */
 static void prepare_ibc(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 {
@@ -590,6 +601,9 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
        scb_s->hpid = HPID_VSIE;
        scb_s->cpnc = scb_o->cpnc;
 
+       if (!(atomic_read(&scb_s->cpuflags) & CPUSTAT_ZARCH))
+               shadow_esa(vcpu, vsie_page);
+
        prepare_ibc(vcpu, vsie_page);
        rc = shadow_crycb(vcpu, vsie_page);
 out: