linux-user: Remove THREAD macro
[qemu/ar7.git] / target / s390x / misc_helper.c
blobe0b23c1fd114f2b47b061a5d9260f4744d8d0bb2
1 /*
2 * S/390 misc helper routines
4 * Copyright (c) 2009 Ulrich Hecht
5 * Copyright (c) 2009 Alexander Graf
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
22 #include "qemu/main-loop.h"
23 #include "cpu.h"
24 #include "internal.h"
25 #include "exec/memory.h"
26 #include "qemu/host-utils.h"
27 #include "exec/helper-proto.h"
28 #include "qemu/timer.h"
29 #include "exec/address-spaces.h"
30 #include "exec/exec-all.h"
31 #include "exec/cpu_ldst.h"
33 #if !defined(CONFIG_USER_ONLY)
34 #include "sysemu/cpus.h"
35 #include "sysemu/sysemu.h"
36 #include "hw/s390x/ebcdic.h"
37 #include "hw/s390x/s390-virtio-hcall.h"
38 #include "hw/s390x/sclp.h"
39 #include "hw/s390x/s390_flic.h"
40 #include "hw/s390x/ioinst.h"
41 #include "hw/s390x/s390-pci-inst.h"
42 #include "hw/boards.h"
43 #endif
45 /* #define DEBUG_HELPER */
46 #ifdef DEBUG_HELPER
47 #define HELPER_LOG(x...) qemu_log(x)
48 #else
49 #define HELPER_LOG(x...)
50 #endif
52 /* Raise an exception statically from a TB. */
53 void HELPER(exception)(CPUS390XState *env, uint32_t excp)
55 CPUState *cs = CPU(s390_env_get_cpu(env));
57 HELPER_LOG("%s: exception %d\n", __func__, excp);
58 cs->exception_index = excp;
59 cpu_loop_exit(cs);
62 /* Store CPU Timer (also used for EXTRACT CPU TIME) */
63 uint64_t HELPER(stpt)(CPUS390XState *env)
65 #if defined(CONFIG_USER_ONLY)
67 * Fake a descending CPU timer. We could get negative values here,
68 * but we don't care as it is up to the OS when to process that
69 * interrupt and reset to > 0.
71 return UINT64_MAX - (uint64_t)cpu_get_host_ticks();
72 #else
73 return time2tod(env->cputm - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
74 #endif
77 #ifndef CONFIG_USER_ONLY
79 /* SCLP service call */
80 uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
82 qemu_mutex_lock_iothread();
83 int r = sclp_service_call(env, r1, r2);
84 qemu_mutex_unlock_iothread();
85 if (r < 0) {
86 s390_program_interrupt(env, -r, 4, GETPC());
88 return r;
91 void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
93 uint64_t r;
95 switch (num) {
96 case 0x500:
97 /* KVM hypercall */
98 qemu_mutex_lock_iothread();
99 r = s390_virtio_hypercall(env);
100 qemu_mutex_unlock_iothread();
101 break;
102 case 0x44:
103 /* yield */
104 r = 0;
105 break;
106 case 0x308:
107 /* ipl */
108 qemu_mutex_lock_iothread();
109 handle_diag_308(env, r1, r3, GETPC());
110 qemu_mutex_unlock_iothread();
111 r = 0;
112 break;
113 case 0x288:
114 /* time bomb (watchdog) */
115 r = handle_diag_288(env, r1, r3);
116 break;
117 default:
118 r = -1;
119 break;
122 if (r) {
123 s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC());
127 /* Set Prefix */
128 void HELPER(spx)(CPUS390XState *env, uint64_t a1)
130 CPUState *cs = CPU(s390_env_get_cpu(env));
131 uint32_t prefix = a1 & 0x7fffe000;
133 env->psa = prefix;
134 HELPER_LOG("prefix: %#x\n", prefix);
135 tlb_flush_page(cs, 0);
136 tlb_flush_page(cs, TARGET_PAGE_SIZE);
139 /* Store Clock */
140 uint64_t HELPER(stck)(CPUS390XState *env)
142 uint64_t time;
144 time = env->tod_offset +
145 time2tod(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - env->tod_basetime);
147 return time;
150 /* Set Clock Comparator */
151 void HELPER(sckc)(CPUS390XState *env, uint64_t time)
153 if (time == -1ULL) {
154 return;
157 env->ckc = time;
159 /* difference between origins */
160 time -= env->tod_offset;
162 /* nanoseconds */
163 time = tod2time(time);
165 timer_mod(env->tod_timer, env->tod_basetime + time);
168 /* Set Tod Programmable Field */
169 void HELPER(sckpf)(CPUS390XState *env, uint64_t r0)
171 uint32_t val = r0;
173 if (val & 0xffff0000) {
174 s390_program_interrupt(env, PGM_SPECIFICATION, 2, GETPC());
176 env->todpr = val;
179 /* Store Clock Comparator */
180 uint64_t HELPER(stckc)(CPUS390XState *env)
182 return env->ckc;
185 /* Set CPU Timer */
186 void HELPER(spt)(CPUS390XState *env, uint64_t time)
188 if (time == -1ULL) {
189 return;
192 /* nanoseconds */
193 time = tod2time(time);
195 env->cputm = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + time;
197 timer_mod(env->cpu_timer, env->cputm);
200 /* Store System Information */
201 uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1)
203 const uintptr_t ra = GETPC();
204 const uint32_t sel1 = r0 & STSI_R0_SEL1_MASK;
205 const uint32_t sel2 = r1 & STSI_R1_SEL2_MASK;
206 const MachineState *ms = MACHINE(qdev_get_machine());
207 uint16_t total_cpus = 0, conf_cpus = 0, reserved_cpus = 0;
208 S390CPU *cpu = s390_env_get_cpu(env);
209 SysIB sysib = { 0 };
210 int i, cc = 0;
212 if ((r0 & STSI_R0_FC_MASK) > STSI_R0_FC_LEVEL_3) {
213 /* invalid function code: no other checks are performed */
214 return 3;
217 if ((r0 & STSI_R0_RESERVED_MASK) || (r1 & STSI_R1_RESERVED_MASK)) {
218 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
221 if ((r0 & STSI_R0_FC_MASK) == STSI_R0_FC_CURRENT) {
222 /* query the current level: no further checks are performed */
223 env->regs[0] = STSI_R0_FC_LEVEL_3;
224 return 0;
227 if (a0 & ~TARGET_PAGE_MASK) {
228 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
231 /* count the cpus and split them into configured and reserved ones */
232 for (i = 0; i < ms->possible_cpus->len; i++) {
233 total_cpus++;
234 if (ms->possible_cpus->cpus[i].cpu) {
235 conf_cpus++;
236 } else {
237 reserved_cpus++;
242 * In theory, we could report Level 1 / Level 2 as current. However,
243 * the Linux kernel will detect this as running under LPAR and assume
244 * that we have a sclp linemode console (which is always present on
245 * LPAR, but not the default for QEMU), therefore not displaying boot
246 * messages and making booting a Linux kernel under TCG harder.
248 * For now we fake the same SMP configuration on all levels.
250 * TODO: We could later make the level configurable via the machine
251 * and change defaults (linemode console) based on machine type
252 * and accelerator.
254 switch (r0 & STSI_R0_FC_MASK) {
255 case STSI_R0_FC_LEVEL_1:
256 if ((sel1 == 1) && (sel2 == 1)) {
257 /* Basic Machine Configuration */
258 char type[5] = {};
260 ebcdic_put(sysib.sysib_111.manuf, "QEMU ", 16);
261 /* same as machine type number in STORE CPU ID, but in EBCDIC */
262 snprintf(type, ARRAY_SIZE(type), "%X", cpu->model->def->type);
263 ebcdic_put(sysib.sysib_111.type, type, 4);
264 /* model number (not stored in STORE CPU ID for z/Architecure) */
265 ebcdic_put(sysib.sysib_111.model, "QEMU ", 16);
266 ebcdic_put(sysib.sysib_111.sequence, "QEMU ", 16);
267 ebcdic_put(sysib.sysib_111.plant, "QEMU", 4);
268 } else if ((sel1 == 2) && (sel2 == 1)) {
269 /* Basic Machine CPU */
270 ebcdic_put(sysib.sysib_121.sequence, "QEMUQEMUQEMUQEMU", 16);
271 ebcdic_put(sysib.sysib_121.plant, "QEMU", 4);
272 sysib.sysib_121.cpu_addr = cpu_to_be16(env->core_id);
273 } else if ((sel1 == 2) && (sel2 == 2)) {
274 /* Basic Machine CPUs */
275 sysib.sysib_122.capability = cpu_to_be32(0x443afc29);
276 sysib.sysib_122.total_cpus = cpu_to_be16(total_cpus);
277 sysib.sysib_122.conf_cpus = cpu_to_be16(conf_cpus);
278 sysib.sysib_122.reserved_cpus = cpu_to_be16(reserved_cpus);
279 } else {
280 cc = 3;
282 break;
283 case STSI_R0_FC_LEVEL_2:
284 if ((sel1 == 2) && (sel2 == 1)) {
285 /* LPAR CPU */
286 ebcdic_put(sysib.sysib_221.sequence, "QEMUQEMUQEMUQEMU", 16);
287 ebcdic_put(sysib.sysib_221.plant, "QEMU", 4);
288 sysib.sysib_221.cpu_addr = cpu_to_be16(env->core_id);
289 } else if ((sel1 == 2) && (sel2 == 2)) {
290 /* LPAR CPUs */
291 sysib.sysib_222.lcpuc = 0x80; /* dedicated */
292 sysib.sysib_222.total_cpus = cpu_to_be16(total_cpus);
293 sysib.sysib_222.conf_cpus = cpu_to_be16(conf_cpus);
294 sysib.sysib_222.reserved_cpus = cpu_to_be16(reserved_cpus);
295 ebcdic_put(sysib.sysib_222.name, "QEMU ", 8);
296 sysib.sysib_222.caf = cpu_to_be32(1000);
297 sysib.sysib_222.dedicated_cpus = cpu_to_be16(conf_cpus);
298 } else {
299 cc = 3;
301 break;
302 case STSI_R0_FC_LEVEL_3:
303 if ((sel1 == 2) && (sel2 == 2)) {
304 /* VM CPUs */
305 sysib.sysib_322.count = 1;
306 sysib.sysib_322.vm[0].total_cpus = cpu_to_be16(total_cpus);
307 sysib.sysib_322.vm[0].conf_cpus = cpu_to_be16(conf_cpus);
308 sysib.sysib_322.vm[0].reserved_cpus = cpu_to_be16(reserved_cpus);
309 sysib.sysib_322.vm[0].caf = cpu_to_be32(1000);
310 /* Linux kernel uses this to distinguish us from z/VM */
311 ebcdic_put(sysib.sysib_322.vm[0].cpi, "KVM/Linux ", 16);
312 sysib.sysib_322.vm[0].ext_name_encoding = 2; /* UTF-8 */
314 /* If our VM has a name, use the real name */
315 if (qemu_name) {
316 memset(sysib.sysib_322.vm[0].name, 0x40,
317 sizeof(sysib.sysib_322.vm[0].name));
318 ebcdic_put(sysib.sysib_322.vm[0].name, qemu_name,
319 MIN(sizeof(sysib.sysib_322.vm[0].name),
320 strlen(qemu_name)));
321 strncpy((char *)sysib.sysib_322.ext_names[0], qemu_name,
322 sizeof(sysib.sysib_322.ext_names[0]));
323 } else {
324 ebcdic_put(sysib.sysib_322.vm[0].name, "TCGguest", 8);
325 strcpy((char *)sysib.sysib_322.ext_names[0], "TCGguest");
328 /* add the uuid */
329 memcpy(sysib.sysib_322.vm[0].uuid, &qemu_uuid,
330 sizeof(sysib.sysib_322.vm[0].uuid));
331 } else {
332 cc = 3;
334 break;
337 if (cc == 0) {
338 if (s390_cpu_virt_mem_write(cpu, a0, 0, &sysib, sizeof(sysib))) {
339 s390_cpu_virt_mem_handle_exc(cpu, ra);
343 return cc;
346 uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,
347 uint32_t r3)
349 int cc;
351 /* TODO: needed to inject interrupts - push further down */
352 qemu_mutex_lock_iothread();
353 cc = handle_sigp(env, order_code & SIGP_ORDER_MASK, r1, r3);
354 qemu_mutex_unlock_iothread();
356 return cc;
358 #endif
360 #ifndef CONFIG_USER_ONLY
361 void HELPER(xsch)(CPUS390XState *env, uint64_t r1)
363 S390CPU *cpu = s390_env_get_cpu(env);
364 qemu_mutex_lock_iothread();
365 ioinst_handle_xsch(cpu, r1, GETPC());
366 qemu_mutex_unlock_iothread();
369 void HELPER(csch)(CPUS390XState *env, uint64_t r1)
371 S390CPU *cpu = s390_env_get_cpu(env);
372 qemu_mutex_lock_iothread();
373 ioinst_handle_csch(cpu, r1, GETPC());
374 qemu_mutex_unlock_iothread();
377 void HELPER(hsch)(CPUS390XState *env, uint64_t r1)
379 S390CPU *cpu = s390_env_get_cpu(env);
380 qemu_mutex_lock_iothread();
381 ioinst_handle_hsch(cpu, r1, GETPC());
382 qemu_mutex_unlock_iothread();
385 void HELPER(msch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
387 S390CPU *cpu = s390_env_get_cpu(env);
388 qemu_mutex_lock_iothread();
389 ioinst_handle_msch(cpu, r1, inst >> 16, GETPC());
390 qemu_mutex_unlock_iothread();
393 void HELPER(rchp)(CPUS390XState *env, uint64_t r1)
395 S390CPU *cpu = s390_env_get_cpu(env);
396 qemu_mutex_lock_iothread();
397 ioinst_handle_rchp(cpu, r1, GETPC());
398 qemu_mutex_unlock_iothread();
401 void HELPER(rsch)(CPUS390XState *env, uint64_t r1)
403 S390CPU *cpu = s390_env_get_cpu(env);
404 qemu_mutex_lock_iothread();
405 ioinst_handle_rsch(cpu, r1, GETPC());
406 qemu_mutex_unlock_iothread();
409 void HELPER(sal)(CPUS390XState *env, uint64_t r1)
411 S390CPU *cpu = s390_env_get_cpu(env);
413 qemu_mutex_lock_iothread();
414 ioinst_handle_sal(cpu, r1, GETPC());
415 qemu_mutex_unlock_iothread();
418 void HELPER(schm)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint64_t inst)
420 S390CPU *cpu = s390_env_get_cpu(env);
422 qemu_mutex_lock_iothread();
423 ioinst_handle_schm(cpu, r1, r2, inst >> 16, GETPC());
424 qemu_mutex_unlock_iothread();
427 void HELPER(ssch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
429 S390CPU *cpu = s390_env_get_cpu(env);
430 qemu_mutex_lock_iothread();
431 ioinst_handle_ssch(cpu, r1, inst >> 16, GETPC());
432 qemu_mutex_unlock_iothread();
435 void HELPER(stcrw)(CPUS390XState *env, uint64_t inst)
437 S390CPU *cpu = s390_env_get_cpu(env);
439 qemu_mutex_lock_iothread();
440 ioinst_handle_stcrw(cpu, inst >> 16, GETPC());
441 qemu_mutex_unlock_iothread();
444 void HELPER(stsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
446 S390CPU *cpu = s390_env_get_cpu(env);
447 qemu_mutex_lock_iothread();
448 ioinst_handle_stsch(cpu, r1, inst >> 16, GETPC());
449 qemu_mutex_unlock_iothread();
452 uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr)
454 const uintptr_t ra = GETPC();
455 S390CPU *cpu = s390_env_get_cpu(env);
456 QEMUS390FLICState *flic = s390_get_qemu_flic(s390_get_flic());
457 QEMUS390FlicIO *io = NULL;
458 LowCore *lowcore;
460 if (addr & 0x3) {
461 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
464 qemu_mutex_lock_iothread();
465 io = qemu_s390_flic_dequeue_io(flic, env->cregs[6]);
466 if (!io) {
467 qemu_mutex_unlock_iothread();
468 return 0;
471 if (addr) {
472 struct {
473 uint16_t id;
474 uint16_t nr;
475 uint32_t parm;
476 } intc = {
477 .id = cpu_to_be16(io->id),
478 .nr = cpu_to_be16(io->nr),
479 .parm = cpu_to_be32(io->parm),
482 if (s390_cpu_virt_mem_write(cpu, addr, 0, &intc, sizeof(intc))) {
483 /* writing failed, reinject and properly clean up */
484 s390_io_interrupt(io->id, io->nr, io->parm, io->word);
485 qemu_mutex_unlock_iothread();
486 g_free(io);
487 s390_cpu_virt_mem_handle_exc(cpu, ra);
488 return 0;
490 } else {
491 /* no protection applies */
492 lowcore = cpu_map_lowcore(env);
493 lowcore->subchannel_id = cpu_to_be16(io->id);
494 lowcore->subchannel_nr = cpu_to_be16(io->nr);
495 lowcore->io_int_parm = cpu_to_be32(io->parm);
496 lowcore->io_int_word = cpu_to_be32(io->word);
497 cpu_unmap_lowcore(lowcore);
500 g_free(io);
501 qemu_mutex_unlock_iothread();
502 return 1;
505 void HELPER(tsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
507 S390CPU *cpu = s390_env_get_cpu(env);
508 qemu_mutex_lock_iothread();
509 ioinst_handle_tsch(cpu, r1, inst >> 16, GETPC());
510 qemu_mutex_unlock_iothread();
513 void HELPER(chsc)(CPUS390XState *env, uint64_t inst)
515 S390CPU *cpu = s390_env_get_cpu(env);
516 qemu_mutex_lock_iothread();
517 ioinst_handle_chsc(cpu, inst >> 16, GETPC());
518 qemu_mutex_unlock_iothread();
520 #endif
522 #ifndef CONFIG_USER_ONLY
523 void HELPER(per_check_exception)(CPUS390XState *env)
525 uint32_t ilen;
527 if (env->per_perc_atmid) {
529 * FIXME: ILEN_AUTO is most probably the right thing to use. ilen
530 * always has to match the instruction referenced in the PSW. E.g.
531 * if a PER interrupt is triggered via EXECUTE, we have to use ilen
532 * of EXECUTE, while per_address contains the target of EXECUTE.
534 ilen = get_ilen(cpu_ldub_code(env, env->per_address));
535 s390_program_interrupt(env, PGM_PER, ilen, GETPC());
539 /* Check if an address is within the PER starting address and the PER
540 ending address. The address range might loop. */
541 static inline bool get_per_in_range(CPUS390XState *env, uint64_t addr)
543 if (env->cregs[10] <= env->cregs[11]) {
544 return env->cregs[10] <= addr && addr <= env->cregs[11];
545 } else {
546 return env->cregs[10] <= addr || addr <= env->cregs[11];
550 void HELPER(per_branch)(CPUS390XState *env, uint64_t from, uint64_t to)
552 if ((env->cregs[9] & PER_CR9_EVENT_BRANCH)) {
553 if (!(env->cregs[9] & PER_CR9_CONTROL_BRANCH_ADDRESS)
554 || get_per_in_range(env, to)) {
555 env->per_address = from;
556 env->per_perc_atmid = PER_CODE_EVENT_BRANCH | get_per_atmid(env);
561 void HELPER(per_ifetch)(CPUS390XState *env, uint64_t addr)
563 if ((env->cregs[9] & PER_CR9_EVENT_IFETCH) && get_per_in_range(env, addr)) {
564 env->per_address = addr;
565 env->per_perc_atmid = PER_CODE_EVENT_IFETCH | get_per_atmid(env);
567 /* If the instruction has to be nullified, trigger the
568 exception immediately. */
569 if (env->cregs[9] & PER_CR9_EVENT_NULLIFICATION) {
570 CPUState *cs = CPU(s390_env_get_cpu(env));
572 env->per_perc_atmid |= PER_CODE_EVENT_NULLIFICATION;
573 env->int_pgm_code = PGM_PER;
574 env->int_pgm_ilen = get_ilen(cpu_ldub_code(env, addr));
576 cs->exception_index = EXCP_PGM;
577 cpu_loop_exit(cs);
581 #endif
583 static uint8_t stfl_bytes[2048];
584 static unsigned int used_stfl_bytes;
586 static void prepare_stfl(void)
588 static bool initialized;
589 int i;
591 /* racy, but we don't care, the same values are always written */
592 if (initialized) {
593 return;
596 s390_get_feat_block(S390_FEAT_TYPE_STFL, stfl_bytes);
597 for (i = 0; i < sizeof(stfl_bytes); i++) {
598 if (stfl_bytes[i]) {
599 used_stfl_bytes = i + 1;
602 initialized = true;
605 #ifndef CONFIG_USER_ONLY
606 void HELPER(stfl)(CPUS390XState *env)
608 LowCore *lowcore;
610 lowcore = cpu_map_lowcore(env);
611 prepare_stfl();
612 memcpy(&lowcore->stfl_fac_list, stfl_bytes, sizeof(lowcore->stfl_fac_list));
613 cpu_unmap_lowcore(lowcore);
615 #endif
617 uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)
619 const uintptr_t ra = GETPC();
620 const int count_bytes = ((env->regs[0] & 0xff) + 1) * 8;
621 const int max_bytes = ROUND_UP(used_stfl_bytes, 8);
622 int i;
624 if (addr & 0x7) {
625 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
628 prepare_stfl();
629 for (i = 0; i < count_bytes; ++i) {
630 cpu_stb_data_ra(env, addr + i, stfl_bytes[i], ra);
633 env->regs[0] = deposit64(env->regs[0], 0, 8, (max_bytes / 8) - 1);
634 return count_bytes >= max_bytes ? 0 : 3;
637 #ifndef CONFIG_USER_ONLY
639 * Note: we ignore any return code of the functions called for the pci
640 * instructions, as the only time they return !0 is when the stub is
641 * called, and in that case we didn't even offer the zpci facility.
642 * The only exception is SIC, where program checks need to be handled
643 * by the caller.
645 void HELPER(clp)(CPUS390XState *env, uint32_t r2)
647 S390CPU *cpu = s390_env_get_cpu(env);
649 qemu_mutex_lock_iothread();
650 clp_service_call(cpu, r2, GETPC());
651 qemu_mutex_unlock_iothread();
654 void HELPER(pcilg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
656 S390CPU *cpu = s390_env_get_cpu(env);
658 qemu_mutex_lock_iothread();
659 pcilg_service_call(cpu, r1, r2, GETPC());
660 qemu_mutex_unlock_iothread();
663 void HELPER(pcistg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
665 S390CPU *cpu = s390_env_get_cpu(env);
667 qemu_mutex_lock_iothread();
668 pcistg_service_call(cpu, r1, r2, GETPC());
669 qemu_mutex_unlock_iothread();
672 void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
673 uint32_t ar)
675 S390CPU *cpu = s390_env_get_cpu(env);
677 qemu_mutex_lock_iothread();
678 stpcifc_service_call(cpu, r1, fiba, ar, GETPC());
679 qemu_mutex_unlock_iothread();
682 void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)
684 int r;
686 qemu_mutex_lock_iothread();
687 r = css_do_sic(env, (r3 >> 27) & 0x7, r1 & 0xffff);
688 qemu_mutex_unlock_iothread();
689 /* css_do_sic() may actually return a PGM_xxx value to inject */
690 if (r) {
691 s390_program_interrupt(env, -r, 4, GETPC());
695 void HELPER(rpcit)(CPUS390XState *env, uint32_t r1, uint32_t r2)
697 S390CPU *cpu = s390_env_get_cpu(env);
699 qemu_mutex_lock_iothread();
700 rpcit_service_call(cpu, r1, r2, GETPC());
701 qemu_mutex_unlock_iothread();
704 void HELPER(pcistb)(CPUS390XState *env, uint32_t r1, uint32_t r3,
705 uint64_t gaddr, uint32_t ar)
707 S390CPU *cpu = s390_env_get_cpu(env);
709 qemu_mutex_lock_iothread();
710 pcistb_service_call(cpu, r1, r3, gaddr, ar, GETPC());
711 qemu_mutex_unlock_iothread();
714 void HELPER(mpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
715 uint32_t ar)
717 S390CPU *cpu = s390_env_get_cpu(env);
719 qemu_mutex_lock_iothread();
720 mpcifc_service_call(cpu, r1, fiba, ar, GETPC());
721 qemu_mutex_unlock_iothread();
723 #endif