aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kvm/priv.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/kvm/priv.c')
-rw-r--r--arch/s390/kvm/priv.c144
1 files changed, 93 insertions, 51 deletions
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 351116939ea2..d22d8ee1ff9d 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -36,15 +36,16 @@ static int handle_set_clock(struct kvm_vcpu *vcpu)
36 struct kvm_vcpu *cpup; 36 struct kvm_vcpu *cpup;
37 s64 hostclk, val; 37 s64 hostclk, val;
38 int i, rc; 38 int i, rc;
39 ar_t ar;
39 u64 op2; 40 u64 op2;
40 41
41 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 42 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
42 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 43 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
43 44
44 op2 = kvm_s390_get_base_disp_s(vcpu); 45 op2 = kvm_s390_get_base_disp_s(vcpu, &ar);
45 if (op2 & 7) /* Operand must be on a doubleword boundary */ 46 if (op2 & 7) /* Operand must be on a doubleword boundary */
46 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 47 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
47 rc = read_guest(vcpu, op2, &val, sizeof(val)); 48 rc = read_guest(vcpu, op2, ar, &val, sizeof(val));
48 if (rc) 49 if (rc)
49 return kvm_s390_inject_prog_cond(vcpu, rc); 50 return kvm_s390_inject_prog_cond(vcpu, rc);
50 51
@@ -68,20 +69,21 @@ static int handle_set_prefix(struct kvm_vcpu *vcpu)
68 u64 operand2; 69 u64 operand2;
69 u32 address; 70 u32 address;
70 int rc; 71 int rc;
72 ar_t ar;
71 73
72 vcpu->stat.instruction_spx++; 74 vcpu->stat.instruction_spx++;
73 75
74 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 76 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
75 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 77 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
76 78
77 operand2 = kvm_s390_get_base_disp_s(vcpu); 79 operand2 = kvm_s390_get_base_disp_s(vcpu, &ar);
78 80
79 /* must be word boundary */ 81 /* must be word boundary */
80 if (operand2 & 3) 82 if (operand2 & 3)
81 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 83 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
82 84
83 /* get the value */ 85 /* get the value */
84 rc = read_guest(vcpu, operand2, &address, sizeof(address)); 86 rc = read_guest(vcpu, operand2, ar, &address, sizeof(address));
85 if (rc) 87 if (rc)
86 return kvm_s390_inject_prog_cond(vcpu, rc); 88 return kvm_s390_inject_prog_cond(vcpu, rc);
87 89
@@ -107,13 +109,14 @@ static int handle_store_prefix(struct kvm_vcpu *vcpu)
107 u64 operand2; 109 u64 operand2;
108 u32 address; 110 u32 address;
109 int rc; 111 int rc;
112 ar_t ar;
110 113
111 vcpu->stat.instruction_stpx++; 114 vcpu->stat.instruction_stpx++;
112 115
113 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 116 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
114 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 117 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
115 118
116 operand2 = kvm_s390_get_base_disp_s(vcpu); 119 operand2 = kvm_s390_get_base_disp_s(vcpu, &ar);
117 120
118 /* must be word boundary */ 121 /* must be word boundary */
119 if (operand2 & 3) 122 if (operand2 & 3)
@@ -122,7 +125,7 @@ static int handle_store_prefix(struct kvm_vcpu *vcpu)
122 address = kvm_s390_get_prefix(vcpu); 125 address = kvm_s390_get_prefix(vcpu);
123 126
124 /* get the value */ 127 /* get the value */
125 rc = write_guest(vcpu, operand2, &address, sizeof(address)); 128 rc = write_guest(vcpu, operand2, ar, &address, sizeof(address));
126 if (rc) 129 if (rc)
127 return kvm_s390_inject_prog_cond(vcpu, rc); 130 return kvm_s390_inject_prog_cond(vcpu, rc);
128 131
@@ -136,18 +139,19 @@ static int handle_store_cpu_address(struct kvm_vcpu *vcpu)
136 u16 vcpu_id = vcpu->vcpu_id; 139 u16 vcpu_id = vcpu->vcpu_id;
137 u64 ga; 140 u64 ga;
138 int rc; 141 int rc;
142 ar_t ar;
139 143
140 vcpu->stat.instruction_stap++; 144 vcpu->stat.instruction_stap++;
141 145
142 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 146 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
143 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 147 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
144 148
145 ga = kvm_s390_get_base_disp_s(vcpu); 149 ga = kvm_s390_get_base_disp_s(vcpu, &ar);
146 150
147 if (ga & 1) 151 if (ga & 1)
148 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 152 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
149 153
150 rc = write_guest(vcpu, ga, &vcpu_id, sizeof(vcpu_id)); 154 rc = write_guest(vcpu, ga, ar, &vcpu_id, sizeof(vcpu_id));
151 if (rc) 155 if (rc)
152 return kvm_s390_inject_prog_cond(vcpu, rc); 156 return kvm_s390_inject_prog_cond(vcpu, rc);
153 157
@@ -207,7 +211,7 @@ static int handle_test_block(struct kvm_vcpu *vcpu)
207 kvm_s390_get_regs_rre(vcpu, NULL, &reg2); 211 kvm_s390_get_regs_rre(vcpu, NULL, &reg2);
208 addr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; 212 addr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK;
209 addr = kvm_s390_logical_to_effective(vcpu, addr); 213 addr = kvm_s390_logical_to_effective(vcpu, addr);
210 if (kvm_s390_check_low_addr_protection(vcpu, addr)) 214 if (kvm_s390_check_low_addr_prot_real(vcpu, addr))
211 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); 215 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm);
212 addr = kvm_s390_real_to_abs(vcpu, addr); 216 addr = kvm_s390_real_to_abs(vcpu, addr);
213 217
@@ -229,18 +233,20 @@ static int handle_tpi(struct kvm_vcpu *vcpu)
229 struct kvm_s390_interrupt_info *inti; 233 struct kvm_s390_interrupt_info *inti;
230 unsigned long len; 234 unsigned long len;
231 u32 tpi_data[3]; 235 u32 tpi_data[3];
232 int cc, rc; 236 int rc;
233 u64 addr; 237 u64 addr;
238 ar_t ar;
234 239
235 rc = 0; 240 addr = kvm_s390_get_base_disp_s(vcpu, &ar);
236 addr = kvm_s390_get_base_disp_s(vcpu);
237 if (addr & 3) 241 if (addr & 3)
238 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 242 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
239 cc = 0; 243
240 inti = kvm_s390_get_io_int(vcpu->kvm, vcpu->arch.sie_block->gcr[6], 0); 244 inti = kvm_s390_get_io_int(vcpu->kvm, vcpu->arch.sie_block->gcr[6], 0);
241 if (!inti) 245 if (!inti) {
242 goto no_interrupt; 246 kvm_s390_set_psw_cc(vcpu, 0);
243 cc = 1; 247 return 0;
248 }
249
244 tpi_data[0] = inti->io.subchannel_id << 16 | inti->io.subchannel_nr; 250 tpi_data[0] = inti->io.subchannel_id << 16 | inti->io.subchannel_nr;
245 tpi_data[1] = inti->io.io_int_parm; 251 tpi_data[1] = inti->io.io_int_parm;
246 tpi_data[2] = inti->io.io_int_word; 252 tpi_data[2] = inti->io.io_int_word;
@@ -250,40 +256,51 @@ static int handle_tpi(struct kvm_vcpu *vcpu)
250 * provided area. 256 * provided area.
251 */ 257 */
252 len = sizeof(tpi_data) - 4; 258 len = sizeof(tpi_data) - 4;
253 rc = write_guest(vcpu, addr, &tpi_data, len); 259 rc = write_guest(vcpu, addr, ar, &tpi_data, len);
254 if (rc) 260 if (rc) {
255 return kvm_s390_inject_prog_cond(vcpu, rc); 261 rc = kvm_s390_inject_prog_cond(vcpu, rc);
262 goto reinject_interrupt;
263 }
256 } else { 264 } else {
257 /* 265 /*
258 * Store the three-word I/O interruption code into 266 * Store the three-word I/O interruption code into
259 * the appropriate lowcore area. 267 * the appropriate lowcore area.
260 */ 268 */
261 len = sizeof(tpi_data); 269 len = sizeof(tpi_data);
262 if (write_guest_lc(vcpu, __LC_SUBCHANNEL_ID, &tpi_data, len)) 270 if (write_guest_lc(vcpu, __LC_SUBCHANNEL_ID, &tpi_data, len)) {
271 /* failed writes to the low core are not recoverable */
263 rc = -EFAULT; 272 rc = -EFAULT;
273 goto reinject_interrupt;
274 }
264 } 275 }
276
277 /* irq was successfully handed to the guest */
278 kfree(inti);
279 kvm_s390_set_psw_cc(vcpu, 1);
280 return 0;
281reinject_interrupt:
265 /* 282 /*
266 * If we encounter a problem storing the interruption code, the 283 * If we encounter a problem storing the interruption code, the
267 * instruction is suppressed from the guest's view: reinject the 284 * instruction is suppressed from the guest's view: reinject the
268 * interrupt. 285 * interrupt.
269 */ 286 */
270 if (!rc) 287 if (kvm_s390_reinject_io_int(vcpu->kvm, inti)) {
271 kfree(inti); 288 kfree(inti);
272 else 289 rc = -EFAULT;
273 kvm_s390_reinject_io_int(vcpu->kvm, inti); 290 }
274no_interrupt: 291 /* don't set the cc, a pgm irq was injected or we drop to user space */
275 /* Set condition code and we're done. */
276 if (!rc)
277 kvm_s390_set_psw_cc(vcpu, cc);
278 return rc ? -EFAULT : 0; 292 return rc ? -EFAULT : 0;
279} 293}
280 294
281static int handle_tsch(struct kvm_vcpu *vcpu) 295static int handle_tsch(struct kvm_vcpu *vcpu)
282{ 296{
283 struct kvm_s390_interrupt_info *inti; 297 struct kvm_s390_interrupt_info *inti = NULL;
298 const u64 isc_mask = 0xffUL << 24; /* all iscs set */
284 299
285 inti = kvm_s390_get_io_int(vcpu->kvm, 0, 300 /* a valid schid has at least one bit set */
286 vcpu->run->s.regs.gprs[1]); 301 if (vcpu->run->s.regs.gprs[1])
302 inti = kvm_s390_get_io_int(vcpu->kvm, isc_mask,
303 vcpu->run->s.regs.gprs[1]);
287 304
288 /* 305 /*
289 * Prepare exit to userspace. 306 * Prepare exit to userspace.
@@ -386,15 +403,16 @@ int kvm_s390_handle_lpsw(struct kvm_vcpu *vcpu)
386 psw_compat_t new_psw; 403 psw_compat_t new_psw;
387 u64 addr; 404 u64 addr;
388 int rc; 405 int rc;
406 ar_t ar;
389 407
390 if (gpsw->mask & PSW_MASK_PSTATE) 408 if (gpsw->mask & PSW_MASK_PSTATE)
391 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 409 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
392 410
393 addr = kvm_s390_get_base_disp_s(vcpu); 411 addr = kvm_s390_get_base_disp_s(vcpu, &ar);
394 if (addr & 7) 412 if (addr & 7)
395 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 413 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
396 414
397 rc = read_guest(vcpu, addr, &new_psw, sizeof(new_psw)); 415 rc = read_guest(vcpu, addr, ar, &new_psw, sizeof(new_psw));
398 if (rc) 416 if (rc)
399 return kvm_s390_inject_prog_cond(vcpu, rc); 417 return kvm_s390_inject_prog_cond(vcpu, rc);
400 if (!(new_psw.mask & PSW32_MASK_BASE)) 418 if (!(new_psw.mask & PSW32_MASK_BASE))
@@ -412,14 +430,15 @@ static int handle_lpswe(struct kvm_vcpu *vcpu)
412 psw_t new_psw; 430 psw_t new_psw;
413 u64 addr; 431 u64 addr;
414 int rc; 432 int rc;
433 ar_t ar;
415 434
416 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 435 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
417 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 436 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
418 437
419 addr = kvm_s390_get_base_disp_s(vcpu); 438 addr = kvm_s390_get_base_disp_s(vcpu, &ar);
420 if (addr & 7) 439 if (addr & 7)
421 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 440 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
422 rc = read_guest(vcpu, addr, &new_psw, sizeof(new_psw)); 441 rc = read_guest(vcpu, addr, ar, &new_psw, sizeof(new_psw));
423 if (rc) 442 if (rc)
424 return kvm_s390_inject_prog_cond(vcpu, rc); 443 return kvm_s390_inject_prog_cond(vcpu, rc);
425 vcpu->arch.sie_block->gpsw = new_psw; 444 vcpu->arch.sie_block->gpsw = new_psw;
@@ -433,18 +452,19 @@ static int handle_stidp(struct kvm_vcpu *vcpu)
433 u64 stidp_data = vcpu->arch.stidp_data; 452 u64 stidp_data = vcpu->arch.stidp_data;
434 u64 operand2; 453 u64 operand2;
435 int rc; 454 int rc;
455 ar_t ar;
436 456
437 vcpu->stat.instruction_stidp++; 457 vcpu->stat.instruction_stidp++;
438 458
439 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 459 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
440 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 460 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
441 461
442 operand2 = kvm_s390_get_base_disp_s(vcpu); 462 operand2 = kvm_s390_get_base_disp_s(vcpu, &ar);
443 463
444 if (operand2 & 7) 464 if (operand2 & 7)
445 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 465 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
446 466
447 rc = write_guest(vcpu, operand2, &stidp_data, sizeof(stidp_data)); 467 rc = write_guest(vcpu, operand2, ar, &stidp_data, sizeof(stidp_data));
448 if (rc) 468 if (rc)
449 return kvm_s390_inject_prog_cond(vcpu, rc); 469 return kvm_s390_inject_prog_cond(vcpu, rc);
450 470
@@ -467,6 +487,7 @@ static void handle_stsi_3_2_2(struct kvm_vcpu *vcpu, struct sysinfo_3_2_2 *mem)
467 for (n = mem->count - 1; n > 0 ; n--) 487 for (n = mem->count - 1; n > 0 ; n--)
468 memcpy(&mem->vm[n], &mem->vm[n - 1], sizeof(mem->vm[0])); 488 memcpy(&mem->vm[n], &mem->vm[n - 1], sizeof(mem->vm[0]));
469 489
490 memset(&mem->vm[0], 0, sizeof(mem->vm[0]));
470 mem->vm[0].cpus_total = cpus; 491 mem->vm[0].cpus_total = cpus;
471 mem->vm[0].cpus_configured = cpus; 492 mem->vm[0].cpus_configured = cpus;
472 mem->vm[0].cpus_standby = 0; 493 mem->vm[0].cpus_standby = 0;
@@ -478,6 +499,17 @@ static void handle_stsi_3_2_2(struct kvm_vcpu *vcpu, struct sysinfo_3_2_2 *mem)
478 ASCEBC(mem->vm[0].cpi, 16); 499 ASCEBC(mem->vm[0].cpi, 16);
479} 500}
480 501
502static void insert_stsi_usr_data(struct kvm_vcpu *vcpu, u64 addr, ar_t ar,
503 u8 fc, u8 sel1, u16 sel2)
504{
505 vcpu->run->exit_reason = KVM_EXIT_S390_STSI;
506 vcpu->run->s390_stsi.addr = addr;
507 vcpu->run->s390_stsi.ar = ar;
508 vcpu->run->s390_stsi.fc = fc;
509 vcpu->run->s390_stsi.sel1 = sel1;
510 vcpu->run->s390_stsi.sel2 = sel2;
511}
512
481static int handle_stsi(struct kvm_vcpu *vcpu) 513static int handle_stsi(struct kvm_vcpu *vcpu)
482{ 514{
483 int fc = (vcpu->run->s.regs.gprs[0] & 0xf0000000) >> 28; 515 int fc = (vcpu->run->s.regs.gprs[0] & 0xf0000000) >> 28;
@@ -486,6 +518,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
486 unsigned long mem = 0; 518 unsigned long mem = 0;
487 u64 operand2; 519 u64 operand2;
488 int rc = 0; 520 int rc = 0;
521 ar_t ar;
489 522
490 vcpu->stat.instruction_stsi++; 523 vcpu->stat.instruction_stsi++;
491 VCPU_EVENT(vcpu, 4, "stsi: fc: %x sel1: %x sel2: %x", fc, sel1, sel2); 524 VCPU_EVENT(vcpu, 4, "stsi: fc: %x sel1: %x sel2: %x", fc, sel1, sel2);
@@ -508,7 +541,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
508 return 0; 541 return 0;
509 } 542 }
510 543
511 operand2 = kvm_s390_get_base_disp_s(vcpu); 544 operand2 = kvm_s390_get_base_disp_s(vcpu, &ar);
512 545
513 if (operand2 & 0xfff) 546 if (operand2 & 0xfff)
514 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 547 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -532,16 +565,20 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
532 break; 565 break;
533 } 566 }
534 567
535 rc = write_guest(vcpu, operand2, (void *)mem, PAGE_SIZE); 568 rc = write_guest(vcpu, operand2, ar, (void *)mem, PAGE_SIZE);
536 if (rc) { 569 if (rc) {
537 rc = kvm_s390_inject_prog_cond(vcpu, rc); 570 rc = kvm_s390_inject_prog_cond(vcpu, rc);
538 goto out; 571 goto out;
539 } 572 }
573 if (vcpu->kvm->arch.user_stsi) {
574 insert_stsi_usr_data(vcpu, operand2, ar, fc, sel1, sel2);
575 rc = -EREMOTE;
576 }
540 trace_kvm_s390_handle_stsi(vcpu, fc, sel1, sel2, operand2); 577 trace_kvm_s390_handle_stsi(vcpu, fc, sel1, sel2, operand2);
541 free_page(mem); 578 free_page(mem);
542 kvm_s390_set_psw_cc(vcpu, 0); 579 kvm_s390_set_psw_cc(vcpu, 0);
543 vcpu->run->s.regs.gprs[0] = 0; 580 vcpu->run->s.regs.gprs[0] = 0;
544 return 0; 581 return rc;
545out_no_data: 582out_no_data:
546 kvm_s390_set_psw_cc(vcpu, 3); 583 kvm_s390_set_psw_cc(vcpu, 3);
547out: 584out:
@@ -670,7 +707,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
670 } 707 }
671 708
672 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { 709 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) {
673 if (kvm_s390_check_low_addr_protection(vcpu, start)) 710 if (kvm_s390_check_low_addr_prot_real(vcpu, start))
674 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); 711 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm);
675 } 712 }
676 713
@@ -776,13 +813,14 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu)
776 int reg, rc, nr_regs; 813 int reg, rc, nr_regs;
777 u32 ctl_array[16]; 814 u32 ctl_array[16];
778 u64 ga; 815 u64 ga;
816 ar_t ar;
779 817
780 vcpu->stat.instruction_lctl++; 818 vcpu->stat.instruction_lctl++;
781 819
782 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 820 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
783 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 821 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
784 822
785 ga = kvm_s390_get_base_disp_rs(vcpu); 823 ga = kvm_s390_get_base_disp_rs(vcpu, &ar);
786 824
787 if (ga & 3) 825 if (ga & 3)
788 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 826 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -791,7 +829,7 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu)
791 trace_kvm_s390_handle_lctl(vcpu, 0, reg1, reg3, ga); 829 trace_kvm_s390_handle_lctl(vcpu, 0, reg1, reg3, ga);
792 830
793 nr_regs = ((reg3 - reg1) & 0xf) + 1; 831 nr_regs = ((reg3 - reg1) & 0xf) + 1;
794 rc = read_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u32)); 832 rc = read_guest(vcpu, ga, ar, ctl_array, nr_regs * sizeof(u32));
795 if (rc) 833 if (rc)
796 return kvm_s390_inject_prog_cond(vcpu, rc); 834 return kvm_s390_inject_prog_cond(vcpu, rc);
797 reg = reg1; 835 reg = reg1;
@@ -814,13 +852,14 @@ int kvm_s390_handle_stctl(struct kvm_vcpu *vcpu)
814 int reg, rc, nr_regs; 852 int reg, rc, nr_regs;
815 u32 ctl_array[16]; 853 u32 ctl_array[16];
816 u64 ga; 854 u64 ga;
855 ar_t ar;
817 856
818 vcpu->stat.instruction_stctl++; 857 vcpu->stat.instruction_stctl++;
819 858
820 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 859 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
821 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 860 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
822 861
823 ga = kvm_s390_get_base_disp_rs(vcpu); 862 ga = kvm_s390_get_base_disp_rs(vcpu, &ar);
824 863
825 if (ga & 3) 864 if (ga & 3)
826 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 865 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -836,7 +875,7 @@ int kvm_s390_handle_stctl(struct kvm_vcpu *vcpu)
836 break; 875 break;
837 reg = (reg + 1) % 16; 876 reg = (reg + 1) % 16;
838 } while (1); 877 } while (1);
839 rc = write_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u32)); 878 rc = write_guest(vcpu, ga, ar, ctl_array, nr_regs * sizeof(u32));
840 return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0; 879 return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0;
841} 880}
842 881
@@ -847,13 +886,14 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
847 int reg, rc, nr_regs; 886 int reg, rc, nr_regs;
848 u64 ctl_array[16]; 887 u64 ctl_array[16];
849 u64 ga; 888 u64 ga;
889 ar_t ar;
850 890
851 vcpu->stat.instruction_lctlg++; 891 vcpu->stat.instruction_lctlg++;
852 892
853 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 893 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
854 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 894 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
855 895
856 ga = kvm_s390_get_base_disp_rsy(vcpu); 896 ga = kvm_s390_get_base_disp_rsy(vcpu, &ar);
857 897
858 if (ga & 7) 898 if (ga & 7)
859 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 899 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -862,7 +902,7 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
862 trace_kvm_s390_handle_lctl(vcpu, 1, reg1, reg3, ga); 902 trace_kvm_s390_handle_lctl(vcpu, 1, reg1, reg3, ga);
863 903
864 nr_regs = ((reg3 - reg1) & 0xf) + 1; 904 nr_regs = ((reg3 - reg1) & 0xf) + 1;
865 rc = read_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u64)); 905 rc = read_guest(vcpu, ga, ar, ctl_array, nr_regs * sizeof(u64));
866 if (rc) 906 if (rc)
867 return kvm_s390_inject_prog_cond(vcpu, rc); 907 return kvm_s390_inject_prog_cond(vcpu, rc);
868 reg = reg1; 908 reg = reg1;
@@ -884,13 +924,14 @@ static int handle_stctg(struct kvm_vcpu *vcpu)
884 int reg, rc, nr_regs; 924 int reg, rc, nr_regs;
885 u64 ctl_array[16]; 925 u64 ctl_array[16];
886 u64 ga; 926 u64 ga;
927 ar_t ar;
887 928
888 vcpu->stat.instruction_stctg++; 929 vcpu->stat.instruction_stctg++;
889 930
890 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 931 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
891 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 932 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
892 933
893 ga = kvm_s390_get_base_disp_rsy(vcpu); 934 ga = kvm_s390_get_base_disp_rsy(vcpu, &ar);
894 935
895 if (ga & 7) 936 if (ga & 7)
896 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 937 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -906,7 +947,7 @@ static int handle_stctg(struct kvm_vcpu *vcpu)
906 break; 947 break;
907 reg = (reg + 1) % 16; 948 reg = (reg + 1) % 16;
908 } while (1); 949 } while (1);
909 rc = write_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u64)); 950 rc = write_guest(vcpu, ga, ar, ctl_array, nr_regs * sizeof(u64));
910 return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0; 951 return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0;
911} 952}
912 953
@@ -931,13 +972,14 @@ static int handle_tprot(struct kvm_vcpu *vcpu)
931 unsigned long hva, gpa; 972 unsigned long hva, gpa;
932 int ret = 0, cc = 0; 973 int ret = 0, cc = 0;
933 bool writable; 974 bool writable;
975 ar_t ar;
934 976
935 vcpu->stat.instruction_tprot++; 977 vcpu->stat.instruction_tprot++;
936 978
937 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) 979 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
938 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); 980 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
939 981
940 kvm_s390_get_base_disp_sse(vcpu, &address1, &address2); 982 kvm_s390_get_base_disp_sse(vcpu, &address1, &address2, &ar, NULL);
941 983
942 /* we only handle the Linux memory detection case: 984 /* we only handle the Linux memory detection case:
943 * access key == 0 985 * access key == 0
@@ -946,11 +988,11 @@ static int handle_tprot(struct kvm_vcpu *vcpu)
946 return -EOPNOTSUPP; 988 return -EOPNOTSUPP;
947 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT) 989 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT)
948 ipte_lock(vcpu); 990 ipte_lock(vcpu);
949 ret = guest_translate_address(vcpu, address1, &gpa, 1); 991 ret = guest_translate_address(vcpu, address1, ar, &gpa, 1);
950 if (ret == PGM_PROTECTION) { 992 if (ret == PGM_PROTECTION) {
951 /* Write protected? Try again with read-only... */ 993 /* Write protected? Try again with read-only... */
952 cc = 1; 994 cc = 1;
953 ret = guest_translate_address(vcpu, address1, &gpa, 0); 995 ret = guest_translate_address(vcpu, address1, ar, &gpa, 0);
954 } 996 }
955 if (ret) { 997 if (ret) {
956 if (ret == PGM_ADDRESSING || ret == PGM_TRANSLATION_SPEC) { 998 if (ret == PGM_ADDRESSING || ret == PGM_TRANSLATION_SPEC) {