1 // SPDX-License-Identifier: GPL-2.0
3 * kvm nested virtualization support for s390x
5 * Copyright IBM Corp. 2016, 2018
7 * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
9 #include <linux/vmalloc.h>
10 #include <linux/kvm_host.h>
11 #include <linux/bug.h>
12 #include <linux/list.h>
13 #include <linux/bitmap.h>
14 #include <linux/sched/signal.h>
17 #include <asm/mmu_context.h>
25 struct kvm_s390_sie_block scb_s; /* 0x0000 */
27 * the backup info for machine check. ensure it's at
28 * the same offset as that in struct sie_page!
30 struct mcck_volatile_info mcck_info; /* 0x0200 */
32 * The pinned original scb. Be aware that other VCPUs can modify
33 * it while we read from it. Values that are used for conditions or
34 * are reused conditionally, should be accessed via READ_ONCE.
36 struct kvm_s390_sie_block *scb_o; /* 0x0218 */
37 /* the shadow gmap in use by the vsie_page */
38 struct gmap *gmap; /* 0x0220 */
39 /* address of the last reported fault to guest2 */
40 unsigned long fault_addr; /* 0x0228 */
41 /* calculated guest addresses of satellite control blocks */
42 gpa_t sca_gpa; /* 0x0230 */
43 gpa_t itdba_gpa; /* 0x0238 */
44 gpa_t gvrd_gpa; /* 0x0240 */
45 gpa_t riccbd_gpa; /* 0x0248 */
46 gpa_t sdnx_gpa; /* 0x0250 */
47 __u8 reserved[0x0700 - 0x0258]; /* 0x0258 */
48 struct kvm_s390_crypto_cb crycb; /* 0x0700 */
49 __u8 fac[S390_ARCH_FAC_LIST_SIZE_BYTE]; /* 0x0800 */
52 /* trigger a validity icpt for the given scb */
53 static int set_validity_icpt(struct kvm_s390_sie_block *scb,
57 scb->ipb = ((__u32) reason_code) << 16;
58 scb->icptcode = ICPT_VALIDITY;
62 /* mark the prefix as unmapped, this will block the VSIE */
63 static void prefix_unmapped(struct vsie_page *vsie_page)
65 atomic_or(PROG_REQUEST, &vsie_page->scb_s.prog20);
68 /* mark the prefix as unmapped and wait until the VSIE has been left */
69 static void prefix_unmapped_sync(struct vsie_page *vsie_page)
71 prefix_unmapped(vsie_page);
72 if (vsie_page->scb_s.prog0c & PROG_IN_SIE)
73 atomic_or(CPUSTAT_STOP_INT, &vsie_page->scb_s.cpuflags);
74 while (vsie_page->scb_s.prog0c & PROG_IN_SIE)
78 /* mark the prefix as mapped, this will allow the VSIE to run */
79 static void prefix_mapped(struct vsie_page *vsie_page)
81 atomic_andnot(PROG_REQUEST, &vsie_page->scb_s.prog20);
84 /* test if the prefix is mapped into the gmap shadow */
85 static int prefix_is_mapped(struct vsie_page *vsie_page)
87 return !(atomic_read(&vsie_page->scb_s.prog20) & PROG_REQUEST);
90 /* copy the updated intervention request bits into the shadow scb */
91 static void update_intervention_requests(struct vsie_page *vsie_page)
93 const int bits = CPUSTAT_STOP_INT | CPUSTAT_IO_INT | CPUSTAT_EXT_INT;
96 cpuflags = atomic_read(&vsie_page->scb_o->cpuflags);
97 atomic_andnot(bits, &vsie_page->scb_s.cpuflags);
98 atomic_or(cpuflags & bits, &vsie_page->scb_s.cpuflags);
101 /* shadow (filter and validate) the cpuflags */
102 static int prepare_cpuflags(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
104 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
105 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
106 int newflags, cpuflags = atomic_read(&scb_o->cpuflags);
108 /* we don't allow ESA/390 guests */
109 if (!(cpuflags & CPUSTAT_ZARCH))
110 return set_validity_icpt(scb_s, 0x0001U);
112 if (cpuflags & (CPUSTAT_RRF | CPUSTAT_MCDS))
113 return set_validity_icpt(scb_s, 0x0001U);
114 else if (cpuflags & (CPUSTAT_SLSV | CPUSTAT_SLSR))
115 return set_validity_icpt(scb_s, 0x0007U);
117 /* intervention requests will be set later */
118 newflags = CPUSTAT_ZARCH;
119 if (cpuflags & CPUSTAT_GED && test_kvm_facility(vcpu->kvm, 8))
120 newflags |= CPUSTAT_GED;
121 if (cpuflags & CPUSTAT_GED2 && test_kvm_facility(vcpu->kvm, 78)) {
122 if (cpuflags & CPUSTAT_GED)
123 return set_validity_icpt(scb_s, 0x0001U);
124 newflags |= CPUSTAT_GED2;
126 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_GPERE))
127 newflags |= cpuflags & CPUSTAT_P;
128 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_GSLS))
129 newflags |= cpuflags & CPUSTAT_SM;
130 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_IBS))
131 newflags |= cpuflags & CPUSTAT_IBS;
132 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_KSS))
133 newflags |= cpuflags & CPUSTAT_KSS;
135 atomic_set(&scb_s->cpuflags, newflags);
138 /* Copy to APCB FORMAT1 from APCB FORMAT0 */
139 static int setup_apcb10(struct kvm_vcpu *vcpu, struct kvm_s390_apcb1 *apcb_s,
140 unsigned long apcb_o, struct kvm_s390_apcb1 *apcb_h)
142 struct kvm_s390_apcb0 tmp;
144 if (read_guest_real(vcpu, apcb_o, &tmp, sizeof(struct kvm_s390_apcb0)))
147 apcb_s->apm[0] = apcb_h->apm[0] & tmp.apm[0];
148 apcb_s->aqm[0] = apcb_h->aqm[0] & tmp.aqm[0] & 0xffff000000000000UL;
149 apcb_s->adm[0] = apcb_h->adm[0] & tmp.adm[0] & 0xffff000000000000UL;
156 * setup_apcb00 - Copy to APCB FORMAT0 from APCB FORMAT0
157 * @vcpu: pointer to the virtual CPU
158 * @apcb_s: pointer to start of apcb in the shadow crycb
159 * @apcb_o: pointer to start of original apcb in the guest2
160 * @apcb_h: pointer to start of apcb in the guest1
162 * Returns 0 and -EFAULT on error reading guest apcb
164 static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
165 unsigned long apcb_o, unsigned long *apcb_h)
167 if (read_guest_real(vcpu, apcb_o, apcb_s,
168 sizeof(struct kvm_s390_apcb0)))
171 bitmap_and(apcb_s, apcb_s, apcb_h,
172 BITS_PER_BYTE * sizeof(struct kvm_s390_apcb0));
178 * setup_apcb11 - Copy the FORMAT1 APCB from the guest to the shadow CRYCB
179 * @vcpu: pointer to the virtual CPU
180 * @apcb_s: pointer to start of apcb in the shadow crycb
181 * @apcb_o: pointer to start of original guest apcb
182 * @apcb_h: pointer to start of apcb in the host
184 * Returns 0 and -EFAULT on error reading guest apcb
186 static int setup_apcb11(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
187 unsigned long apcb_o,
188 unsigned long *apcb_h)
190 if (read_guest_real(vcpu, apcb_o, apcb_s,
191 sizeof(struct kvm_s390_apcb1)))
194 bitmap_and(apcb_s, apcb_s, apcb_h,
195 BITS_PER_BYTE * sizeof(struct kvm_s390_apcb1));
201 * setup_apcb - Create a shadow copy of the apcb.
202 * @vcpu: pointer to the virtual CPU
203 * @crycb_s: pointer to shadow crycb
204 * @crycb_o: pointer to original guest crycb
205 * @crycb_h: pointer to the host crycb
206 * @fmt_o: format of the original guest crycb.
207 * @fmt_h: format of the host crycb.
209 * Checks the compatibility between the guest and host crycb and calls the
210 * appropriate copy function.
212 * Return 0 or an error number if the guest and host crycb are incompatible.
214 static int setup_apcb(struct kvm_vcpu *vcpu, struct kvm_s390_crypto_cb *crycb_s,
216 struct kvm_s390_crypto_cb *crycb_h,
217 int fmt_o, int fmt_h)
219 struct kvm_s390_crypto_cb *crycb;
221 crycb = (struct kvm_s390_crypto_cb *) (unsigned long)crycb_o;
225 if ((crycb_o & PAGE_MASK) != ((crycb_o + 256) & PAGE_MASK))
227 if (fmt_h != CRYCB_FORMAT2)
229 return setup_apcb11(vcpu, (unsigned long *)&crycb_s->apcb1,
230 (unsigned long) &crycb->apcb1,
231 (unsigned long *)&crycb_h->apcb1);
235 return setup_apcb10(vcpu, &crycb_s->apcb1,
236 (unsigned long) &crycb->apcb0,
239 return setup_apcb00(vcpu,
240 (unsigned long *) &crycb_s->apcb0,
241 (unsigned long) &crycb->apcb0,
242 (unsigned long *) &crycb_h->apcb0);
246 if ((crycb_o & PAGE_MASK) != ((crycb_o + 32) & PAGE_MASK))
251 return setup_apcb10(vcpu, &crycb_s->apcb1,
252 (unsigned long) &crycb->apcb0,
256 return setup_apcb00(vcpu,
257 (unsigned long *) &crycb_s->apcb0,
258 (unsigned long) &crycb->apcb0,
259 (unsigned long *) &crycb_h->apcb0);
266 * shadow_crycb - Create a shadow copy of the crycb block
267 * @vcpu: a pointer to the virtual CPU
268 * @vsie_page: a pointer to internal date used for the vSIE
270 * Create a shadow copy of the crycb block and setup key wrapping, if
271 * requested for guest 3 and enabled for guest 2.
273 * We accept format-1 or format-2, but we convert format-1 into format-2
274 * in the shadow CRYCB.
275 * Using format-2 enables the firmware to choose the right format when
276 * scheduling the SIE.
277 * There is nothing to do for format-0.
279 * This function centralize the issuing of set_validity_icpt() for all
280 * the subfunctions working on the crycb.
282 * Returns: - 0 if shadowed or nothing to do
283 * - > 0 if control has to be given to guest 2
285 static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
287 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
288 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
289 const uint32_t crycbd_o = READ_ONCE(scb_o->crycbd);
290 const u32 crycb_addr = crycbd_o & 0x7ffffff8U;
291 unsigned long *b1, *b2;
296 int key_msk = test_kvm_facility(vcpu->kvm, 76);
297 int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
298 int fmt_h = vcpu->arch.sie_block->crycbd & CRYCB_FORMAT_MASK;
303 apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
304 apie_s = apie_h & scb_o->eca;
305 if (!apie_s && (!key_msk || (fmt_o == CRYCB_FORMAT0)))
309 return set_validity_icpt(scb_s, 0x0039U);
311 if (fmt_o == CRYCB_FORMAT1)
312 if ((crycb_addr & PAGE_MASK) !=
313 ((crycb_addr + 128) & PAGE_MASK))
314 return set_validity_icpt(scb_s, 0x003CU);
317 ret = setup_apcb(vcpu, &vsie_page->crycb, crycb_addr,
318 vcpu->kvm->arch.crypto.crycb,
322 scb_s->eca |= scb_o->eca & ECA_APIE;
325 /* we may only allow it if enabled for guest 2 */
326 ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 &
327 (ECB3_AES | ECB3_DEA);
328 ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & ECD_ECC;
329 if (!ecb3_flags && !ecd_flags)
332 /* copy only the wrapping keys */
333 if (read_guest_real(vcpu, crycb_addr + 72,
334 vsie_page->crycb.dea_wrapping_key_mask, 56))
335 return set_validity_icpt(scb_s, 0x0035U);
337 scb_s->ecb3 |= ecb3_flags;
338 scb_s->ecd |= ecd_flags;
340 /* xor both blocks in one run */
341 b1 = (unsigned long *) vsie_page->crycb.dea_wrapping_key_mask;
342 b2 = (unsigned long *)
343 vcpu->kvm->arch.crypto.crycb->dea_wrapping_key_mask;
344 /* as 56%8 == 0, bitmap_xor won't overwrite any data */
345 bitmap_xor(b1, b1, b2, BITS_PER_BYTE * 56);
349 return set_validity_icpt(scb_s, 0x0022U);
351 return set_validity_icpt(scb_s, 0x0035U);
353 return set_validity_icpt(scb_s, 0x003CU);
355 scb_s->crycbd = ((__u32)(__u64) &vsie_page->crycb) | CRYCB_FORMAT2;
359 /* shadow (round up/down) the ibc to avoid validity icpt */
360 static void prepare_ibc(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
362 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
363 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
364 /* READ_ONCE does not work on bitfields - use a temporary variable */
365 const uint32_t __new_ibc = scb_o->ibc;
366 const uint32_t new_ibc = READ_ONCE(__new_ibc) & 0x0fffU;
367 __u64 min_ibc = (sclp.ibc >> 16) & 0x0fffU;
370 /* ibc installed in g2 and requested for g3 */
371 if (vcpu->kvm->arch.model.ibc && new_ibc) {
372 scb_s->ibc = new_ibc;
373 /* takte care of the minimum ibc level of the machine */
374 if (scb_s->ibc < min_ibc)
375 scb_s->ibc = min_ibc;
376 /* take care of the maximum ibc level set for the guest */
377 if (scb_s->ibc > vcpu->kvm->arch.model.ibc)
378 scb_s->ibc = vcpu->kvm->arch.model.ibc;
382 /* unshadow the scb, copying parameters back to the real scb */
383 static void unshadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
385 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
386 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
389 scb_o->icptcode = scb_s->icptcode;
390 scb_o->icptstatus = scb_s->icptstatus;
391 scb_o->ipa = scb_s->ipa;
392 scb_o->ipb = scb_s->ipb;
393 scb_o->gbea = scb_s->gbea;
396 scb_o->cputm = scb_s->cputm;
397 scb_o->ckc = scb_s->ckc;
398 scb_o->todpr = scb_s->todpr;
401 scb_o->gpsw = scb_s->gpsw;
402 scb_o->gg14 = scb_s->gg14;
403 scb_o->gg15 = scb_s->gg15;
404 memcpy(scb_o->gcr, scb_s->gcr, 128);
405 scb_o->pp = scb_s->pp;
407 /* branch prediction */
408 if (test_kvm_facility(vcpu->kvm, 82)) {
409 scb_o->fpf &= ~FPF_BPBC;
410 scb_o->fpf |= scb_s->fpf & FPF_BPBC;
413 /* interrupt intercept */
414 switch (scb_s->icptcode) {
418 memcpy((void *)((u64)scb_o + 0xc0),
419 (void *)((u64)scb_s + 0xc0), 0xf0 - 0xc0);
423 memcpy((void *)((u64)scb_o + 0xc0),
424 (void *)((u64)scb_s + 0xc0), 0xd0 - 0xc0);
428 if (scb_s->ihcpu != 0xffffU)
429 scb_o->ihcpu = scb_s->ihcpu;
433 * Setup the shadow scb by copying and checking the relevant parts of the g2
436 * Returns: - 0 if the scb has been shadowed
437 * - > 0 if control has to be given to guest 2
439 static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
441 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
442 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
443 /* READ_ONCE does not work on bitfields - use a temporary variable */
444 const uint32_t __new_prefix = scb_o->prefix;
445 const uint32_t new_prefix = READ_ONCE(__new_prefix);
446 const bool wants_tx = READ_ONCE(scb_o->ecb) & ECB_TE;
447 bool had_tx = scb_s->ecb & ECB_TE;
448 unsigned long new_mso = 0;
451 /* make sure we don't have any leftovers when reusing the scb */
461 rc = prepare_cpuflags(vcpu, vsie_page);
466 scb_s->cputm = scb_o->cputm;
467 scb_s->ckc = scb_o->ckc;
468 scb_s->todpr = scb_o->todpr;
469 scb_s->epoch = scb_o->epoch;
472 scb_s->gpsw = scb_o->gpsw;
473 scb_s->gg14 = scb_o->gg14;
474 scb_s->gg15 = scb_o->gg15;
475 memcpy(scb_s->gcr, scb_o->gcr, 128);
476 scb_s->pp = scb_o->pp;
478 /* interception / execution handling */
479 scb_s->gbea = scb_o->gbea;
480 scb_s->lctl = scb_o->lctl;
481 scb_s->svcc = scb_o->svcc;
482 scb_s->ictl = scb_o->ictl;
484 * SKEY handling functions can't deal with false setting of PTE invalid
485 * bits. Therefore we cannot provide interpretation and would later
486 * have to provide own emulation handlers.
488 if (!(atomic_read(&scb_s->cpuflags) & CPUSTAT_KSS))
489 scb_s->ictl |= ICTL_ISKE | ICTL_SSKE | ICTL_RRBE;
491 scb_s->icpua = scb_o->icpua;
493 if (!(atomic_read(&scb_s->cpuflags) & CPUSTAT_SM))
494 new_mso = READ_ONCE(scb_o->mso) & 0xfffffffffff00000UL;
495 /* if the hva of the prefix changes, we have to remap the prefix */
496 if (scb_s->mso != new_mso || scb_s->prefix != new_prefix)
497 prefix_unmapped(vsie_page);
498 /* SIE will do mso/msl validity and exception checks for us */
499 scb_s->msl = scb_o->msl & 0xfffffffffff00000UL;
500 scb_s->mso = new_mso;
501 scb_s->prefix = new_prefix;
503 /* We have to definetly flush the tlb if this scb never ran */
504 if (scb_s->ihcpu != 0xffffU)
505 scb_s->ihcpu = scb_o->ihcpu;
507 /* MVPG and Protection Exception Interpretation are always available */
508 scb_s->eca |= scb_o->eca & (ECA_MVPGI | ECA_PROTEXCI);
509 /* Host-protection-interruption introduced with ESOP */
510 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_ESOP))
511 scb_s->ecb |= scb_o->ecb & ECB_HOSTPROTINT;
512 /* transactional execution */
513 if (test_kvm_facility(vcpu->kvm, 73) && wants_tx) {
514 /* remap the prefix is tx is toggled on */
516 prefix_unmapped(vsie_page);
517 scb_s->ecb |= ECB_TE;
519 /* branch prediction */
520 if (test_kvm_facility(vcpu->kvm, 82))
521 scb_s->fpf |= scb_o->fpf & FPF_BPBC;
523 if (test_kvm_facility(vcpu->kvm, 129)) {
524 scb_s->eca |= scb_o->eca & ECA_VX;
525 scb_s->ecd |= scb_o->ecd & ECD_HOSTREGMGMT;
527 /* Run-time-Instrumentation */
528 if (test_kvm_facility(vcpu->kvm, 64))
529 scb_s->ecb3 |= scb_o->ecb3 & ECB3_RI;
530 /* Instruction Execution Prevention */
531 if (test_kvm_facility(vcpu->kvm, 130))
532 scb_s->ecb2 |= scb_o->ecb2 & ECB2_IEP;
533 /* Guarded Storage */
534 if (test_kvm_facility(vcpu->kvm, 133)) {
535 scb_s->ecb |= scb_o->ecb & ECB_GS;
536 scb_s->ecd |= scb_o->ecd & ECD_HOSTREGMGMT;
538 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_SIIF))
539 scb_s->eca |= scb_o->eca & ECA_SII;
540 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_IB))
541 scb_s->eca |= scb_o->eca & ECA_IB;
542 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_CEI))
543 scb_s->eca |= scb_o->eca & ECA_CEI;
544 /* Epoch Extension */
545 if (test_kvm_facility(vcpu->kvm, 139)) {
546 scb_s->ecd |= scb_o->ecd & ECD_MEF;
547 scb_s->epdx = scb_o->epdx;
551 if (test_kvm_facility(vcpu->kvm, 156))
552 scb_s->ecd |= scb_o->ecd & ECD_ETOKENF;
554 scb_s->hpid = HPID_VSIE;
556 prepare_ibc(vcpu, vsie_page);
557 rc = shadow_crycb(vcpu, vsie_page);
560 unshadow_scb(vcpu, vsie_page);
564 void kvm_s390_vsie_gmap_notifier(struct gmap *gmap, unsigned long start,
567 struct kvm *kvm = gmap->private;
568 struct vsie_page *cur;
569 unsigned long prefix;
573 if (!gmap_is_shadow(gmap))
575 if (start >= 1UL << 31)
576 /* We are only interested in prefix pages */
580 * Only new shadow blocks are added to the list during runtime,
581 * therefore we can safely reference them all the time.
583 for (i = 0; i < kvm->arch.vsie.page_count; i++) {
584 page = READ_ONCE(kvm->arch.vsie.pages[i]);
587 cur = page_to_virt(page);
588 if (READ_ONCE(cur->gmap) != gmap)
590 prefix = cur->scb_s.prefix << GUEST_PREFIX_SHIFT;
591 /* with mso/msl, the prefix lies at an offset */
592 prefix += cur->scb_s.mso;
593 if (prefix <= end && start <= prefix + 2 * PAGE_SIZE - 1)
594 prefix_unmapped_sync(cur);
599 * Map the first prefix page and if tx is enabled also the second prefix page.
601 * The prefix will be protected, a gmap notifier will inform about unmaps.
602 * The shadow scb must not be executed until the prefix is remapped, this is
603 * guaranteed by properly handling PROG_REQUEST.
605 * Returns: - 0 on if successfully mapped or already mapped
606 * - > 0 if control has to be given to guest 2
607 * - -EAGAIN if the caller can retry immediately
608 * - -ENOMEM if out of memory
610 static int map_prefix(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
612 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
613 u64 prefix = scb_s->prefix << GUEST_PREFIX_SHIFT;
616 if (prefix_is_mapped(vsie_page))
619 /* mark it as mapped so we can catch any concurrent unmappers */
620 prefix_mapped(vsie_page);
622 /* with mso/msl, the prefix lies at offset *mso* */
623 prefix += scb_s->mso;
625 rc = kvm_s390_shadow_fault(vcpu, vsie_page->gmap, prefix);
626 if (!rc && (scb_s->ecb & ECB_TE))
627 rc = kvm_s390_shadow_fault(vcpu, vsie_page->gmap,
630 * We don't have to mprotect, we will be called for all unshadows.
631 * SIE will detect if protection applies and trigger a validity.
634 prefix_unmapped(vsie_page);
635 if (rc > 0 || rc == -EFAULT)
636 rc = set_validity_icpt(scb_s, 0x0037U);
641 * Pin the guest page given by gpa and set hpa to the pinned host address.
642 * Will always be pinned writable.
644 * Returns: - 0 on success
645 * - -EINVAL if the gpa is not valid guest storage
647 static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa)
651 page = gfn_to_page(kvm, gpa_to_gfn(gpa));
652 if (is_error_page(page))
654 *hpa = (hpa_t) page_to_virt(page) + (gpa & ~PAGE_MASK);
658 /* Unpins a page previously pinned via pin_guest_page, marking it as dirty. */
659 static void unpin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t hpa)
661 kvm_release_pfn_dirty(hpa >> PAGE_SHIFT);
662 /* mark the page always as dirty for migration */
663 mark_page_dirty(kvm, gpa_to_gfn(gpa));
666 /* unpin all blocks previously pinned by pin_blocks(), marking them dirty */
667 static void unpin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
669 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
672 hpa = (u64) scb_s->scaoh << 32 | scb_s->scaol;
674 unpin_guest_page(vcpu->kvm, vsie_page->sca_gpa, hpa);
675 vsie_page->sca_gpa = 0;
682 unpin_guest_page(vcpu->kvm, vsie_page->itdba_gpa, hpa);
683 vsie_page->itdba_gpa = 0;
689 unpin_guest_page(vcpu->kvm, vsie_page->gvrd_gpa, hpa);
690 vsie_page->gvrd_gpa = 0;
696 unpin_guest_page(vcpu->kvm, vsie_page->riccbd_gpa, hpa);
697 vsie_page->riccbd_gpa = 0;
703 unpin_guest_page(vcpu->kvm, vsie_page->sdnx_gpa, hpa);
704 vsie_page->sdnx_gpa = 0;
710 * Instead of shadowing some blocks, we can simply forward them because the
711 * addresses in the scb are 64 bit long.
713 * This works as long as the data lies in one page. If blocks ever exceed one
714 * page, we have to fall back to shadowing.
716 * As we reuse the sca, the vcpu pointers contained in it are invalid. We must
717 * therefore not enable any facilities that access these pointers (e.g. SIGPIF).
719 * Returns: - 0 if all blocks were pinned.
720 * - > 0 if control has to be given to guest 2
721 * - -ENOMEM if out of memory
723 static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
725 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
726 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
731 gpa = READ_ONCE(scb_o->scaol) & ~0xfUL;
732 if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_64BSCAO))
733 gpa |= (u64) READ_ONCE(scb_o->scaoh) << 32;
735 if (gpa < 2 * PAGE_SIZE)
736 rc = set_validity_icpt(scb_s, 0x0038U);
737 else if ((gpa & ~0x1fffUL) == kvm_s390_get_prefix(vcpu))
738 rc = set_validity_icpt(scb_s, 0x0011U);
739 else if ((gpa & PAGE_MASK) !=
740 ((gpa + sizeof(struct bsca_block) - 1) & PAGE_MASK))
741 rc = set_validity_icpt(scb_s, 0x003bU);
743 rc = pin_guest_page(vcpu->kvm, gpa, &hpa);
745 rc = set_validity_icpt(scb_s, 0x0034U);
749 vsie_page->sca_gpa = gpa;
750 scb_s->scaoh = (u32)((u64)hpa >> 32);
751 scb_s->scaol = (u32)(u64)hpa;
754 gpa = READ_ONCE(scb_o->itdba) & ~0xffUL;
755 if (gpa && (scb_s->ecb & ECB_TE)) {
756 if (gpa < 2 * PAGE_SIZE) {
757 rc = set_validity_icpt(scb_s, 0x0080U);
760 /* 256 bytes cannot cross page boundaries */
761 rc = pin_guest_page(vcpu->kvm, gpa, &hpa);
763 rc = set_validity_icpt(scb_s, 0x0080U);
766 vsie_page->itdba_gpa = gpa;
770 gpa = READ_ONCE(scb_o->gvrd) & ~0x1ffUL;
771 if (gpa && (scb_s->eca & ECA_VX) && !(scb_s->ecd & ECD_HOSTREGMGMT)) {
772 if (gpa < 2 * PAGE_SIZE) {
773 rc = set_validity_icpt(scb_s, 0x1310U);
777 * 512 bytes vector registers cannot cross page boundaries
778 * if this block gets bigger, we have to shadow it.
780 rc = pin_guest_page(vcpu->kvm, gpa, &hpa);
782 rc = set_validity_icpt(scb_s, 0x1310U);
785 vsie_page->gvrd_gpa = gpa;
789 gpa = READ_ONCE(scb_o->riccbd) & ~0x3fUL;
790 if (gpa && (scb_s->ecb3 & ECB3_RI)) {
791 if (gpa < 2 * PAGE_SIZE) {
792 rc = set_validity_icpt(scb_s, 0x0043U);
795 /* 64 bytes cannot cross page boundaries */
796 rc = pin_guest_page(vcpu->kvm, gpa, &hpa);
798 rc = set_validity_icpt(scb_s, 0x0043U);
801 /* Validity 0x0044 will be checked by SIE */
802 vsie_page->riccbd_gpa = gpa;
805 if (((scb_s->ecb & ECB_GS) && !(scb_s->ecd & ECD_HOSTREGMGMT)) ||
806 (scb_s->ecd & ECD_ETOKENF)) {
809 gpa = READ_ONCE(scb_o->sdnxo) & ~0xfUL;
810 sdnxc = READ_ONCE(scb_o->sdnxo) & 0xfUL;
811 if (!gpa || gpa < 2 * PAGE_SIZE) {
812 rc = set_validity_icpt(scb_s, 0x10b0U);
815 if (sdnxc < 6 || sdnxc > 12) {
816 rc = set_validity_icpt(scb_s, 0x10b1U);
819 if (gpa & ((1 << sdnxc) - 1)) {
820 rc = set_validity_icpt(scb_s, 0x10b2U);
823 /* Due to alignment rules (checked above) this cannot
824 * cross page boundaries
826 rc = pin_guest_page(vcpu->kvm, gpa, &hpa);
828 rc = set_validity_icpt(scb_s, 0x10b0U);
831 vsie_page->sdnx_gpa = gpa;
832 scb_s->sdnxo = hpa | sdnxc;
836 unpin_blocks(vcpu, vsie_page);
840 /* unpin the scb provided by guest 2, marking it as dirty */
841 static void unpin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,
844 hpa_t hpa = (hpa_t) vsie_page->scb_o;
847 unpin_guest_page(vcpu->kvm, gpa, hpa);
848 vsie_page->scb_o = NULL;
852 * Pin the scb at gpa provided by guest 2 at vsie_page->scb_o.
854 * Returns: - 0 if the scb was pinned.
855 * - > 0 if control has to be given to guest 2
857 static int pin_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,
863 rc = pin_guest_page(vcpu->kvm, gpa, &hpa);
865 rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
869 vsie_page->scb_o = (struct kvm_s390_sie_block *) hpa;
874 * Inject a fault into guest 2.
876 * Returns: - > 0 if control has to be given to guest 2
877 * < 0 if an error occurred during injection.
879 static int inject_fault(struct kvm_vcpu *vcpu, __u16 code, __u64 vaddr,
882 struct kvm_s390_pgm_info pgm = {
885 /* 0-51: virtual address */
886 (vaddr & 0xfffffffffffff000UL) |
887 /* 52-53: store / fetch */
888 (((unsigned int) !write_flag) + 1) << 10,
889 /* 62-63: asce id (alway primary == 0) */
890 .exc_access_id = 0, /* always primary */
891 .op_access_id = 0, /* not MVPG */
895 if (code == PGM_PROTECTION)
896 pgm.trans_exc_code |= 0x4UL;
898 rc = kvm_s390_inject_prog_irq(vcpu, &pgm);
903 * Handle a fault during vsie execution on a gmap shadow.
905 * Returns: - 0 if the fault was resolved
906 * - > 0 if control has to be given to guest 2
907 * - < 0 if an error occurred
909 static int handle_fault(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
913 if (current->thread.gmap_int_code == PGM_PROTECTION)
914 /* we can directly forward all protection exceptions */
915 return inject_fault(vcpu, PGM_PROTECTION,
916 current->thread.gmap_addr, 1);
918 rc = kvm_s390_shadow_fault(vcpu, vsie_page->gmap,
919 current->thread.gmap_addr);
921 rc = inject_fault(vcpu, rc,
922 current->thread.gmap_addr,
923 current->thread.gmap_write_flag);
925 vsie_page->fault_addr = current->thread.gmap_addr;
931 * Retry the previous fault that required guest 2 intervention. This avoids
932 * one superfluous SIE re-entry and direct exit.
934 * Will ignore any errors. The next SIE fault will do proper fault handling.
936 static void handle_last_fault(struct kvm_vcpu *vcpu,
937 struct vsie_page *vsie_page)
939 if (vsie_page->fault_addr)
940 kvm_s390_shadow_fault(vcpu, vsie_page->gmap,
941 vsie_page->fault_addr);
942 vsie_page->fault_addr = 0;
945 static inline void clear_vsie_icpt(struct vsie_page *vsie_page)
947 vsie_page->scb_s.icptcode = 0;
950 /* rewind the psw and clear the vsie icpt, so we can retry execution */
951 static void retry_vsie_icpt(struct vsie_page *vsie_page)
953 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
954 int ilen = insn_length(scb_s->ipa >> 8);
956 /* take care of EXECUTE instructions */
957 if (scb_s->icptstatus & 1) {
958 ilen = (scb_s->icptstatus >> 4) & 0x6;
962 scb_s->gpsw.addr = __rewind_psw(scb_s->gpsw, ilen);
963 clear_vsie_icpt(vsie_page);
967 * Try to shadow + enable the guest 2 provided facility list.
968 * Retry instruction execution if enabled for and provided by guest 2.
970 * Returns: - 0 if handled (retry or guest 2 icpt)
971 * - > 0 if control has to be given to guest 2
973 static int handle_stfle(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
975 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
976 __u32 fac = READ_ONCE(vsie_page->scb_o->fac) & 0x7ffffff8U;
978 if (fac && test_kvm_facility(vcpu->kvm, 7)) {
979 retry_vsie_icpt(vsie_page);
980 if (read_guest_real(vcpu, fac, &vsie_page->fac,
981 sizeof(vsie_page->fac)))
982 return set_validity_icpt(scb_s, 0x1090U);
983 scb_s->fac = (__u32)(__u64) &vsie_page->fac;
989 * Run the vsie on a shadow scb and a shadow gmap, without any further
990 * sanity checks, handling SIE faults.
992 * Returns: - 0 everything went fine
993 * - > 0 if control has to be given to guest 2
994 * - < 0 if an error occurred
996 static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
997 __releases(vcpu->kvm->srcu)
998 __acquires(vcpu->kvm->srcu)
1000 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
1001 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
1002 int guest_bp_isolation;
1005 handle_last_fault(vcpu, vsie_page);
1009 if (test_cpu_flag(CIF_MCCK_PENDING))
1012 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
1014 /* save current guest state of bp isolation override */
1015 guest_bp_isolation = test_thread_flag(TIF_ISOLATE_BP_GUEST);
1018 * The guest is running with BPBC, so we have to force it on for our
1019 * nested guest. This is done by enabling BPBC globally, so the BPBC
1020 * control in the SCB (which the nested guest can modify) is simply
1023 if (test_kvm_facility(vcpu->kvm, 82) &&
1024 vcpu->arch.sie_block->fpf & FPF_BPBC)
1025 set_thread_flag(TIF_ISOLATE_BP_GUEST);
1027 local_irq_disable();
1028 guest_enter_irqoff();
1032 * Simulate a SIE entry of the VCPU (see sie64a), so VCPU blocking
1033 * and VCPU requests also hinder the vSIE from running and lead
1034 * to an immediate exit. kvm_s390_vsie_kick() has to be used to
1035 * also kick the vSIE.
1037 vcpu->arch.sie_block->prog0c |= PROG_IN_SIE;
1039 if (!kvm_s390_vcpu_sie_inhibited(vcpu))
1040 rc = sie64a(scb_s, vcpu->run->s.regs.gprs);
1042 vcpu->arch.sie_block->prog0c &= ~PROG_IN_SIE;
1044 local_irq_disable();
1045 guest_exit_irqoff();
1048 /* restore guest state for bp isolation override */
1049 if (!guest_bp_isolation)
1050 clear_thread_flag(TIF_ISOLATE_BP_GUEST);
1052 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
1055 VCPU_EVENT(vcpu, 3, "%s", "machine check");
1056 kvm_s390_reinject_machine_check(vcpu, &vsie_page->mcck_info);
1061 rc = 0; /* we could still have an icpt */
1062 else if (rc == -EFAULT)
1063 return handle_fault(vcpu, vsie_page);
1065 switch (scb_s->icptcode) {
1067 if (scb_s->ipa == 0xb2b0)
1068 rc = handle_stfle(vcpu, vsie_page);
1071 /* stop not requested by g2 - must have been a kick */
1072 if (!(atomic_read(&scb_o->cpuflags) & CPUSTAT_STOP_INT))
1073 clear_vsie_icpt(vsie_page);
1076 if ((scb_s->ipa & 0xf000) != 0xf000)
1077 scb_s->ipa += 0x1000;
1083 static void release_gmap_shadow(struct vsie_page *vsie_page)
1085 if (vsie_page->gmap)
1086 gmap_put(vsie_page->gmap);
1087 WRITE_ONCE(vsie_page->gmap, NULL);
1088 prefix_unmapped(vsie_page);
1091 static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
1092 struct vsie_page *vsie_page)
1099 asce = vcpu->arch.sie_block->gcr[1];
1100 cr0.val = vcpu->arch.sie_block->gcr[0];
1101 edat = cr0.edat && test_kvm_facility(vcpu->kvm, 8);
1102 edat += edat && test_kvm_facility(vcpu->kvm, 78);
1105 * ASCE or EDAT could have changed since last icpt, or the gmap
1106 * we're holding has been unshadowed. If the gmap is still valid,
1107 * we can safely reuse it.
1109 if (vsie_page->gmap && gmap_shadow_valid(vsie_page->gmap, asce, edat))
1112 /* release the old shadow - if any, and mark the prefix as unmapped */
1113 release_gmap_shadow(vsie_page);
1114 gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
1116 return PTR_ERR(gmap);
1117 gmap->private = vcpu->kvm;
1118 WRITE_ONCE(vsie_page->gmap, gmap);
1123 * Register the shadow scb at the VCPU, e.g. for kicking out of vsie.
1125 static void register_shadow_scb(struct kvm_vcpu *vcpu,
1126 struct vsie_page *vsie_page)
1128 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
1130 WRITE_ONCE(vcpu->arch.vsie_block, &vsie_page->scb_s);
1132 * External calls have to lead to a kick of the vcpu and
1133 * therefore the vsie -> Simulate Wait state.
1135 kvm_s390_set_cpuflags(vcpu, CPUSTAT_WAIT);
1137 * We have to adjust the g3 epoch by the g2 epoch. The epoch will
1138 * automatically be adjusted on tod clock changes via kvm_sync_clock.
1141 scb_s->epoch += vcpu->kvm->arch.epoch;
1143 if (scb_s->ecd & ECD_MEF) {
1144 scb_s->epdx += vcpu->kvm->arch.epdx;
1145 if (scb_s->epoch < vcpu->kvm->arch.epoch)
1153 * Unregister a shadow scb from a VCPU.
1155 static void unregister_shadow_scb(struct kvm_vcpu *vcpu)
1157 kvm_s390_clear_cpuflags(vcpu, CPUSTAT_WAIT);
1158 WRITE_ONCE(vcpu->arch.vsie_block, NULL);
1162 * Run the vsie on a shadowed scb, managing the gmap shadow, handling
1163 * prefix pages and faults.
1165 * Returns: - 0 if no errors occurred
1166 * - > 0 if control has to be given to guest 2
1167 * - -ENOMEM if out of memory
1169 static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
1171 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
1175 rc = acquire_gmap_shadow(vcpu, vsie_page);
1177 rc = map_prefix(vcpu, vsie_page);
1179 gmap_enable(vsie_page->gmap);
1180 update_intervention_requests(vsie_page);
1181 rc = do_vsie_run(vcpu, vsie_page);
1182 gmap_enable(vcpu->arch.gmap);
1184 atomic_andnot(PROG_BLOCK_SIE, &scb_s->prog20);
1188 if (rc || scb_s->icptcode || signal_pending(current) ||
1189 kvm_s390_vcpu_has_irq(vcpu, 0) ||
1190 kvm_s390_vcpu_sie_inhibited(vcpu))
1194 if (rc == -EFAULT) {
1196 * Addressing exceptions are always presentes as intercepts.
1197 * As addressing exceptions are suppressing and our guest 3 PSW
1198 * points at the responsible instruction, we have to
1199 * forward the PSW and set the ilc. If we can't read guest 3
1200 * instruction, we can use an arbitrary ilc. Let's always use
1201 * ilen = 4 for now, so we can avoid reading in guest 3 virtual
1202 * memory. (we could also fake the shadow so the hardware
1205 scb_s->icptcode = ICPT_PROGI;
1206 scb_s->iprcc = PGM_ADDRESSING;
1208 scb_s->gpsw.addr = __rewind_psw(scb_s->gpsw, 4);
1215 * Get or create a vsie page for a scb address.
1217 * Returns: - address of a vsie page (cached or new one)
1218 * - NULL if the same scb address is already used by another VCPU
1219 * - ERR_PTR(-ENOMEM) if out of memory
1221 static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr)
1223 struct vsie_page *vsie_page;
1228 page = radix_tree_lookup(&kvm->arch.vsie.addr_to_page, addr >> 9);
1231 if (page_ref_inc_return(page) == 2)
1232 return page_to_virt(page);
1237 * We want at least #online_vcpus shadows, so every VCPU can execute
1238 * the VSIE in parallel.
1240 nr_vcpus = atomic_read(&kvm->online_vcpus);
1242 mutex_lock(&kvm->arch.vsie.mutex);
1243 if (kvm->arch.vsie.page_count < nr_vcpus) {
1244 page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA);
1246 mutex_unlock(&kvm->arch.vsie.mutex);
1247 return ERR_PTR(-ENOMEM);
1250 kvm->arch.vsie.pages[kvm->arch.vsie.page_count] = page;
1251 kvm->arch.vsie.page_count++;
1253 /* reuse an existing entry that belongs to nobody */
1255 page = kvm->arch.vsie.pages[kvm->arch.vsie.next];
1256 if (page_ref_inc_return(page) == 2)
1259 kvm->arch.vsie.next++;
1260 kvm->arch.vsie.next %= nr_vcpus;
1262 radix_tree_delete(&kvm->arch.vsie.addr_to_page, page->index >> 9);
1265 /* double use of the same address */
1266 if (radix_tree_insert(&kvm->arch.vsie.addr_to_page, addr >> 9, page)) {
1268 mutex_unlock(&kvm->arch.vsie.mutex);
1271 mutex_unlock(&kvm->arch.vsie.mutex);
1273 vsie_page = page_to_virt(page);
1274 memset(&vsie_page->scb_s, 0, sizeof(struct kvm_s390_sie_block));
1275 release_gmap_shadow(vsie_page);
1276 vsie_page->fault_addr = 0;
1277 vsie_page->scb_s.ihcpu = 0xffffU;
1281 /* put a vsie page acquired via get_vsie_page */
1282 static void put_vsie_page(struct kvm *kvm, struct vsie_page *vsie_page)
1284 struct page *page = pfn_to_page(__pa(vsie_page) >> PAGE_SHIFT);
1289 int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu)
1291 struct vsie_page *vsie_page;
1292 unsigned long scb_addr;
1295 vcpu->stat.instruction_sie++;
1296 if (!test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_SIEF2))
1298 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
1299 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
1301 BUILD_BUG_ON(sizeof(struct vsie_page) != PAGE_SIZE);
1302 scb_addr = kvm_s390_get_base_disp_s(vcpu, NULL);
1304 /* 512 byte alignment */
1305 if (unlikely(scb_addr & 0x1ffUL))
1306 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
1308 if (signal_pending(current) || kvm_s390_vcpu_has_irq(vcpu, 0) ||
1309 kvm_s390_vcpu_sie_inhibited(vcpu))
1312 vsie_page = get_vsie_page(vcpu->kvm, scb_addr);
1313 if (IS_ERR(vsie_page))
1314 return PTR_ERR(vsie_page);
1315 else if (!vsie_page)
1316 /* double use of sie control block - simply do nothing */
1319 rc = pin_scb(vcpu, vsie_page, scb_addr);
1322 rc = shadow_scb(vcpu, vsie_page);
1325 rc = pin_blocks(vcpu, vsie_page);
1328 register_shadow_scb(vcpu, vsie_page);
1329 rc = vsie_run(vcpu, vsie_page);
1330 unregister_shadow_scb(vcpu);
1331 unpin_blocks(vcpu, vsie_page);
1333 unshadow_scb(vcpu, vsie_page);
1335 unpin_scb(vcpu, vsie_page, scb_addr);
1337 put_vsie_page(vcpu->kvm, vsie_page);
1339 return rc < 0 ? rc : 0;
1342 /* Init the vsie data structures. To be called when a vm is initialized. */
1343 void kvm_s390_vsie_init(struct kvm *kvm)
1345 mutex_init(&kvm->arch.vsie.mutex);
1346 INIT_RADIX_TREE(&kvm->arch.vsie.addr_to_page, GFP_KERNEL);
1349 /* Destroy the vsie data structures. To be called when a vm is destroyed. */
1350 void kvm_s390_vsie_destroy(struct kvm *kvm)
1352 struct vsie_page *vsie_page;
1356 mutex_lock(&kvm->arch.vsie.mutex);
1357 for (i = 0; i < kvm->arch.vsie.page_count; i++) {
1358 page = kvm->arch.vsie.pages[i];
1359 kvm->arch.vsie.pages[i] = NULL;
1360 vsie_page = page_to_virt(page);
1361 release_gmap_shadow(vsie_page);
1362 /* free the radix tree entry */
1363 radix_tree_delete(&kvm->arch.vsie.addr_to_page, page->index >> 9);
1366 kvm->arch.vsie.page_count = 0;
1367 mutex_unlock(&kvm->arch.vsie.mutex);
1370 void kvm_s390_vsie_kick(struct kvm_vcpu *vcpu)
1372 struct kvm_s390_sie_block *scb = READ_ONCE(vcpu->arch.vsie_block);
1375 * Even if the VCPU lets go of the shadow sie block reference, it is
1376 * still valid in the cache. So we can safely kick it.
1379 atomic_or(PROG_BLOCK_SIE, &scb->prog20);
1380 if (scb->prog0c & PROG_IN_SIE)
1381 atomic_or(CPUSTAT_STOP_INT, &scb->cpuflags);