spapr_cpu_core: convert last snprintf() to g_strdup_printf()
[qemu.git] / target / s390x / misc_helper.c
blobde1ced20826e5405b557708dad5e18e892975947
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/exec-all.h"
30 #include "exec/cpu_ldst.h"
32 #if !defined(CONFIG_USER_ONLY)
33 #include "sysemu/cpus.h"
34 #include "sysemu/sysemu.h"
35 #include "hw/s390x/ebcdic.h"
36 #include "hw/s390x/s390-virtio-hcall.h"
37 #include "hw/s390x/sclp.h"
38 #include "hw/s390x/s390_flic.h"
39 #include "hw/s390x/ioinst.h"
40 #include "hw/s390x/s390-pci-inst.h"
41 #include "hw/boards.h"
42 #endif
44 /* #define DEBUG_HELPER */
45 #ifdef DEBUG_HELPER
46 #define HELPER_LOG(x...) qemu_log(x)
47 #else
48 #define HELPER_LOG(x...)
49 #endif
51 /* Raise an exception statically from a TB. */
52 void HELPER(exception)(CPUS390XState *env, uint32_t excp)
54 CPUState *cs = CPU(s390_env_get_cpu(env));
56 HELPER_LOG("%s: exception %d\n", __func__, excp);
57 cs->exception_index = excp;
58 cpu_loop_exit(cs);
61 /* Store CPU Timer (also used for EXTRACT CPU TIME) */
62 uint64_t HELPER(stpt)(CPUS390XState *env)
64 #if defined(CONFIG_USER_ONLY)
66 * Fake a descending CPU timer. We could get negative values here,
67 * but we don't care as it is up to the OS when to process that
68 * interrupt and reset to > 0.
70 return UINT64_MAX - (uint64_t)cpu_get_host_ticks();
71 #else
72 return time2tod(env->cputm - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
73 #endif
76 #ifndef CONFIG_USER_ONLY
78 /* SCLP service call */
79 uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
81 qemu_mutex_lock_iothread();
82 int r = sclp_service_call(env, r1, r2);
83 qemu_mutex_unlock_iothread();
84 if (r < 0) {
85 s390_program_interrupt(env, -r, 4, GETPC());
87 return r;
90 void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
92 uint64_t r;
94 switch (num) {
95 case 0x500:
96 /* KVM hypercall */
97 qemu_mutex_lock_iothread();
98 r = s390_virtio_hypercall(env);
99 qemu_mutex_unlock_iothread();
100 break;
101 case 0x44:
102 /* yield */
103 r = 0;
104 break;
105 case 0x308:
106 /* ipl */
107 qemu_mutex_lock_iothread();
108 handle_diag_308(env, r1, r3, GETPC());
109 qemu_mutex_unlock_iothread();
110 r = 0;
111 break;
112 case 0x288:
113 /* time bomb (watchdog) */
114 r = handle_diag_288(env, r1, r3);
115 break;
116 default:
117 r = -1;
118 break;
121 if (r) {
122 s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC());
126 /* Set Prefix */
127 void HELPER(spx)(CPUS390XState *env, uint64_t a1)
129 CPUState *cs = CPU(s390_env_get_cpu(env));
130 uint32_t prefix = a1 & 0x7fffe000;
132 env->psa = prefix;
133 HELPER_LOG("prefix: %#x\n", prefix);
134 tlb_flush_page(cs, 0);
135 tlb_flush_page(cs, TARGET_PAGE_SIZE);
138 /* Store Clock */
139 uint64_t HELPER(stck)(CPUS390XState *env)
141 uint64_t time;
143 time = env->tod_offset +
144 time2tod(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - env->tod_basetime);
146 return time;
149 /* Set Clock Comparator */
150 void HELPER(sckc)(CPUS390XState *env, uint64_t time)
152 if (time == -1ULL) {
153 return;
156 env->ckc = time;
158 /* difference between origins */
159 time -= env->tod_offset;
161 /* nanoseconds */
162 time = tod2time(time);
164 timer_mod(env->tod_timer, env->tod_basetime + time);
167 /* Set Tod Programmable Field */
168 void HELPER(sckpf)(CPUS390XState *env, uint64_t r0)
170 uint32_t val = r0;
172 if (val & 0xffff0000) {
173 s390_program_interrupt(env, PGM_SPECIFICATION, 2, GETPC());
175 env->todpr = val;
178 /* Store Clock Comparator */
179 uint64_t HELPER(stckc)(CPUS390XState *env)
181 return env->ckc;
184 /* Set CPU Timer */
185 void HELPER(spt)(CPUS390XState *env, uint64_t time)
187 if (time == -1ULL) {
188 return;
191 /* nanoseconds */
192 time = tod2time(time);
194 env->cputm = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + time;
196 timer_mod(env->cpu_timer, env->cputm);
199 /* Store System Information */
200 uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1)
202 const uintptr_t ra = GETPC();
203 const uint32_t sel1 = r0 & STSI_R0_SEL1_MASK;
204 const uint32_t sel2 = r1 & STSI_R1_SEL2_MASK;
205 const MachineState *ms = MACHINE(qdev_get_machine());
206 uint16_t total_cpus = 0, conf_cpus = 0, reserved_cpus = 0;
207 S390CPU *cpu = s390_env_get_cpu(env);
208 SysIB sysib = { };
209 int i, cc = 0;
211 if ((r0 & STSI_R0_FC_MASK) > STSI_R0_FC_LEVEL_3) {
212 /* invalid function code: no other checks are performed */
213 return 3;
216 if ((r0 & STSI_R0_RESERVED_MASK) || (r1 & STSI_R1_RESERVED_MASK)) {
217 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
220 if ((r0 & STSI_R0_FC_MASK) == STSI_R0_FC_CURRENT) {
221 /* query the current level: no further checks are performed */
222 env->regs[0] = STSI_R0_FC_LEVEL_3;
223 return 0;
226 if (a0 & ~TARGET_PAGE_MASK) {
227 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
230 /* count the cpus and split them into configured and reserved ones */
231 for (i = 0; i < ms->possible_cpus->len; i++) {
232 total_cpus++;
233 if (ms->possible_cpus->cpus[i].cpu) {
234 conf_cpus++;
235 } else {
236 reserved_cpus++;
241 * In theory, we could report Level 1 / Level 2 as current. However,
242 * the Linux kernel will detect this as running under LPAR and assume
243 * that we have a sclp linemode console (which is always present on
244 * LPAR, but not the default for QEMU), therefore not displaying boot
245 * messages and making booting a Linux kernel under TCG harder.
247 * For now we fake the same SMP configuration on all levels.
249 * TODO: We could later make the level configurable via the machine
250 * and change defaults (linemode console) based on machine type
251 * and accelerator.
253 switch (r0 & STSI_R0_FC_MASK) {
254 case STSI_R0_FC_LEVEL_1:
255 if ((sel1 == 1) && (sel2 == 1)) {
256 /* Basic Machine Configuration */
257 char type[5] = {};
259 ebcdic_put(sysib.sysib_111.manuf, "QEMU ", 16);
260 /* same as machine type number in STORE CPU ID, but in EBCDIC */
261 snprintf(type, ARRAY_SIZE(type), "%X", cpu->model->def->type);
262 ebcdic_put(sysib.sysib_111.type, type, 4);
263 /* model number (not stored in STORE CPU ID for z/Architecure) */
264 ebcdic_put(sysib.sysib_111.model, "QEMU ", 16);
265 ebcdic_put(sysib.sysib_111.sequence, "QEMU ", 16);
266 ebcdic_put(sysib.sysib_111.plant, "QEMU", 4);
267 } else if ((sel1 == 2) && (sel2 == 1)) {
268 /* Basic Machine CPU */
269 ebcdic_put(sysib.sysib_121.sequence, "QEMUQEMUQEMUQEMU", 16);
270 ebcdic_put(sysib.sysib_121.plant, "QEMU", 4);
271 sysib.sysib_121.cpu_addr = cpu_to_be16(env->core_id);
272 } else if ((sel1 == 2) && (sel2 == 2)) {
273 /* Basic Machine CPUs */
274 sysib.sysib_122.capability = cpu_to_be32(0x443afc29);
275 sysib.sysib_122.total_cpus = cpu_to_be16(total_cpus);
276 sysib.sysib_122.conf_cpus = cpu_to_be16(conf_cpus);
277 sysib.sysib_122.reserved_cpus = cpu_to_be16(reserved_cpus);
278 } else {
279 cc = 3;
281 break;
282 case STSI_R0_FC_LEVEL_2:
283 if ((sel1 == 2) && (sel2 == 1)) {
284 /* LPAR CPU */
285 ebcdic_put(sysib.sysib_221.sequence, "QEMUQEMUQEMUQEMU", 16);
286 ebcdic_put(sysib.sysib_221.plant, "QEMU", 4);
287 sysib.sysib_221.cpu_addr = cpu_to_be16(env->core_id);
288 } else if ((sel1 == 2) && (sel2 == 2)) {
289 /* LPAR CPUs */
290 sysib.sysib_222.lcpuc = 0x80; /* dedicated */
291 sysib.sysib_222.total_cpus = cpu_to_be16(total_cpus);
292 sysib.sysib_222.conf_cpus = cpu_to_be16(conf_cpus);
293 sysib.sysib_222.reserved_cpus = cpu_to_be16(reserved_cpus);
294 ebcdic_put(sysib.sysib_222.name, "QEMU ", 8);
295 sysib.sysib_222.caf = cpu_to_be32(1000);
296 sysib.sysib_222.dedicated_cpus = cpu_to_be16(conf_cpus);
297 } else {
298 cc = 3;
300 break;
301 case STSI_R0_FC_LEVEL_3:
302 if ((sel1 == 2) && (sel2 == 2)) {
303 /* VM CPUs */
304 sysib.sysib_322.count = 1;
305 sysib.sysib_322.vm[0].total_cpus = cpu_to_be16(total_cpus);
306 sysib.sysib_322.vm[0].conf_cpus = cpu_to_be16(conf_cpus);
307 sysib.sysib_322.vm[0].reserved_cpus = cpu_to_be16(reserved_cpus);
308 sysib.sysib_322.vm[0].caf = cpu_to_be32(1000);
309 /* Linux kernel uses this to distinguish us from z/VM */
310 ebcdic_put(sysib.sysib_322.vm[0].cpi, "KVM/Linux ", 16);
311 sysib.sysib_322.vm[0].ext_name_encoding = 2; /* UTF-8 */
313 /* If our VM has a name, use the real name */
314 if (qemu_name) {
315 memset(sysib.sysib_322.vm[0].name, 0x40,
316 sizeof(sysib.sysib_322.vm[0].name));
317 ebcdic_put(sysib.sysib_322.vm[0].name, qemu_name,
318 MIN(sizeof(sysib.sysib_322.vm[0].name),
319 strlen(qemu_name)));
320 strncpy((char *)sysib.sysib_322.ext_names[0], qemu_name,
321 sizeof(sysib.sysib_322.ext_names[0]));
322 } else {
323 ebcdic_put(sysib.sysib_322.vm[0].name, "TCGguest", 8);
324 strcpy((char *)sysib.sysib_322.ext_names[0], "TCGguest");
327 /* add the uuid */
328 memcpy(sysib.sysib_322.vm[0].uuid, &qemu_uuid,
329 sizeof(sysib.sysib_322.vm[0].uuid));
330 } else {
331 cc = 3;
333 break;
336 if (cc == 0) {
337 if (s390_cpu_virt_mem_write(cpu, a0, 0, &sysib, sizeof(sysib))) {
338 s390_cpu_virt_mem_handle_exc(cpu, ra);
342 return cc;
345 uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,
346 uint32_t r3)
348 int cc;
350 /* TODO: needed to inject interrupts - push further down */
351 qemu_mutex_lock_iothread();
352 cc = handle_sigp(env, order_code & SIGP_ORDER_MASK, r1, r3);
353 qemu_mutex_unlock_iothread();
355 return cc;
357 #endif
359 #ifndef CONFIG_USER_ONLY
360 void HELPER(xsch)(CPUS390XState *env, uint64_t r1)
362 S390CPU *cpu = s390_env_get_cpu(env);
363 qemu_mutex_lock_iothread();
364 ioinst_handle_xsch(cpu, r1, GETPC());
365 qemu_mutex_unlock_iothread();
368 void HELPER(csch)(CPUS390XState *env, uint64_t r1)
370 S390CPU *cpu = s390_env_get_cpu(env);
371 qemu_mutex_lock_iothread();
372 ioinst_handle_csch(cpu, r1, GETPC());
373 qemu_mutex_unlock_iothread();
376 void HELPER(hsch)(CPUS390XState *env, uint64_t r1)
378 S390CPU *cpu = s390_env_get_cpu(env);
379 qemu_mutex_lock_iothread();
380 ioinst_handle_hsch(cpu, r1, GETPC());
381 qemu_mutex_unlock_iothread();
384 void HELPER(msch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
386 S390CPU *cpu = s390_env_get_cpu(env);
387 qemu_mutex_lock_iothread();
388 ioinst_handle_msch(cpu, r1, inst >> 16, GETPC());
389 qemu_mutex_unlock_iothread();
392 void HELPER(rchp)(CPUS390XState *env, uint64_t r1)
394 S390CPU *cpu = s390_env_get_cpu(env);
395 qemu_mutex_lock_iothread();
396 ioinst_handle_rchp(cpu, r1, GETPC());
397 qemu_mutex_unlock_iothread();
400 void HELPER(rsch)(CPUS390XState *env, uint64_t r1)
402 S390CPU *cpu = s390_env_get_cpu(env);
403 qemu_mutex_lock_iothread();
404 ioinst_handle_rsch(cpu, r1, GETPC());
405 qemu_mutex_unlock_iothread();
408 void HELPER(sal)(CPUS390XState *env, uint64_t r1)
410 S390CPU *cpu = s390_env_get_cpu(env);
412 qemu_mutex_lock_iothread();
413 ioinst_handle_sal(cpu, r1, GETPC());
414 qemu_mutex_unlock_iothread();
417 void HELPER(schm)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint64_t inst)
419 S390CPU *cpu = s390_env_get_cpu(env);
421 qemu_mutex_lock_iothread();
422 ioinst_handle_schm(cpu, r1, r2, inst >> 16, GETPC());
423 qemu_mutex_unlock_iothread();
426 void HELPER(ssch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
428 S390CPU *cpu = s390_env_get_cpu(env);
429 qemu_mutex_lock_iothread();
430 ioinst_handle_ssch(cpu, r1, inst >> 16, GETPC());
431 qemu_mutex_unlock_iothread();
434 void HELPER(stcrw)(CPUS390XState *env, uint64_t inst)
436 S390CPU *cpu = s390_env_get_cpu(env);
438 qemu_mutex_lock_iothread();
439 ioinst_handle_stcrw(cpu, inst >> 16, GETPC());
440 qemu_mutex_unlock_iothread();
443 void HELPER(stsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
445 S390CPU *cpu = s390_env_get_cpu(env);
446 qemu_mutex_lock_iothread();
447 ioinst_handle_stsch(cpu, r1, inst >> 16, GETPC());
448 qemu_mutex_unlock_iothread();
451 uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr)
453 const uintptr_t ra = GETPC();
454 S390CPU *cpu = s390_env_get_cpu(env);
455 QEMUS390FLICState *flic = s390_get_qemu_flic(s390_get_flic());
456 QEMUS390FlicIO *io = NULL;
457 LowCore *lowcore;
459 if (addr & 0x3) {
460 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
463 qemu_mutex_lock_iothread();
464 io = qemu_s390_flic_dequeue_io(flic, env->cregs[6]);
465 if (!io) {
466 qemu_mutex_unlock_iothread();
467 return 0;
470 if (addr) {
471 struct {
472 uint16_t id;
473 uint16_t nr;
474 uint32_t parm;
475 } intc = {
476 .id = cpu_to_be16(io->id),
477 .nr = cpu_to_be16(io->nr),
478 .parm = cpu_to_be32(io->parm),
481 if (s390_cpu_virt_mem_write(cpu, addr, 0, &intc, sizeof(intc))) {
482 /* writing failed, reinject and properly clean up */
483 s390_io_interrupt(io->id, io->nr, io->parm, io->word);
484 qemu_mutex_unlock_iothread();
485 g_free(io);
486 s390_cpu_virt_mem_handle_exc(cpu, ra);
487 return 0;
489 } else {
490 /* no protection applies */
491 lowcore = cpu_map_lowcore(env);
492 lowcore->subchannel_id = cpu_to_be16(io->id);
493 lowcore->subchannel_nr = cpu_to_be16(io->nr);
494 lowcore->io_int_parm = cpu_to_be32(io->parm);
495 lowcore->io_int_word = cpu_to_be32(io->word);
496 cpu_unmap_lowcore(lowcore);
499 g_free(io);
500 qemu_mutex_unlock_iothread();
501 return 1;
504 void HELPER(tsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
506 S390CPU *cpu = s390_env_get_cpu(env);
507 qemu_mutex_lock_iothread();
508 ioinst_handle_tsch(cpu, r1, inst >> 16, GETPC());
509 qemu_mutex_unlock_iothread();
512 void HELPER(chsc)(CPUS390XState *env, uint64_t inst)
514 S390CPU *cpu = s390_env_get_cpu(env);
515 qemu_mutex_lock_iothread();
516 ioinst_handle_chsc(cpu, inst >> 16, GETPC());
517 qemu_mutex_unlock_iothread();
519 #endif
521 #ifndef CONFIG_USER_ONLY
522 void HELPER(per_check_exception)(CPUS390XState *env)
524 uint32_t ilen;
526 if (env->per_perc_atmid) {
528 * FIXME: ILEN_AUTO is most probably the right thing to use. ilen
529 * always has to match the instruction referenced in the PSW. E.g.
530 * if a PER interrupt is triggered via EXECUTE, we have to use ilen
531 * of EXECUTE, while per_address contains the target of EXECUTE.
533 ilen = get_ilen(cpu_ldub_code(env, env->per_address));
534 s390_program_interrupt(env, PGM_PER, ilen, GETPC());
538 /* Check if an address is within the PER starting address and the PER
539 ending address. The address range might loop. */
540 static inline bool get_per_in_range(CPUS390XState *env, uint64_t addr)
542 if (env->cregs[10] <= env->cregs[11]) {
543 return env->cregs[10] <= addr && addr <= env->cregs[11];
544 } else {
545 return env->cregs[10] <= addr || addr <= env->cregs[11];
549 void HELPER(per_branch)(CPUS390XState *env, uint64_t from, uint64_t to)
551 if ((env->cregs[9] & PER_CR9_EVENT_BRANCH)) {
552 if (!(env->cregs[9] & PER_CR9_CONTROL_BRANCH_ADDRESS)
553 || get_per_in_range(env, to)) {
554 env->per_address = from;
555 env->per_perc_atmid = PER_CODE_EVENT_BRANCH | get_per_atmid(env);
560 void HELPER(per_ifetch)(CPUS390XState *env, uint64_t addr)
562 if ((env->cregs[9] & PER_CR9_EVENT_IFETCH) && get_per_in_range(env, addr)) {
563 env->per_address = addr;
564 env->per_perc_atmid = PER_CODE_EVENT_IFETCH | get_per_atmid(env);
566 /* If the instruction has to be nullified, trigger the
567 exception immediately. */
568 if (env->cregs[9] & PER_CR9_EVENT_NULLIFICATION) {
569 CPUState *cs = CPU(s390_env_get_cpu(env));
571 env->per_perc_atmid |= PER_CODE_EVENT_NULLIFICATION;
572 env->int_pgm_code = PGM_PER;
573 env->int_pgm_ilen = get_ilen(cpu_ldub_code(env, addr));
575 cs->exception_index = EXCP_PGM;
576 cpu_loop_exit(cs);
580 #endif
582 static uint8_t stfl_bytes[2048];
583 static unsigned int used_stfl_bytes;
585 static void prepare_stfl(void)
587 static bool initialized;
588 int i;
590 /* racy, but we don't care, the same values are always written */
591 if (initialized) {
592 return;
595 s390_get_feat_block(S390_FEAT_TYPE_STFL, stfl_bytes);
596 for (i = 0; i < sizeof(stfl_bytes); i++) {
597 if (stfl_bytes[i]) {
598 used_stfl_bytes = i + 1;
601 initialized = true;
604 #ifndef CONFIG_USER_ONLY
605 void HELPER(stfl)(CPUS390XState *env)
607 LowCore *lowcore;
609 lowcore = cpu_map_lowcore(env);
610 prepare_stfl();
611 memcpy(&lowcore->stfl_fac_list, stfl_bytes, sizeof(lowcore->stfl_fac_list));
612 cpu_unmap_lowcore(lowcore);
614 #endif
616 uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)
618 const uintptr_t ra = GETPC();
619 const int count_bytes = ((env->regs[0] & 0xff) + 1) * 8;
620 const int max_bytes = ROUND_UP(used_stfl_bytes, 8);
621 int i;
623 if (addr & 0x7) {
624 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
627 prepare_stfl();
628 for (i = 0; i < count_bytes; ++i) {
629 cpu_stb_data_ra(env, addr + i, stfl_bytes[i], ra);
632 env->regs[0] = deposit64(env->regs[0], 0, 8, (max_bytes / 8) - 1);
633 return count_bytes >= max_bytes ? 0 : 3;
636 #ifndef CONFIG_USER_ONLY
638 * Note: we ignore any return code of the functions called for the pci
639 * instructions, as the only time they return !0 is when the stub is
640 * called, and in that case we didn't even offer the zpci facility.
641 * The only exception is SIC, where program checks need to be handled
642 * by the caller.
644 void HELPER(clp)(CPUS390XState *env, uint32_t r2)
646 S390CPU *cpu = s390_env_get_cpu(env);
648 qemu_mutex_lock_iothread();
649 clp_service_call(cpu, r2, GETPC());
650 qemu_mutex_unlock_iothread();
653 void HELPER(pcilg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
655 S390CPU *cpu = s390_env_get_cpu(env);
657 qemu_mutex_lock_iothread();
658 pcilg_service_call(cpu, r1, r2, GETPC());
659 qemu_mutex_unlock_iothread();
662 void HELPER(pcistg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
664 S390CPU *cpu = s390_env_get_cpu(env);
666 qemu_mutex_lock_iothread();
667 pcistg_service_call(cpu, r1, r2, GETPC());
668 qemu_mutex_unlock_iothread();
671 void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
672 uint32_t ar)
674 S390CPU *cpu = s390_env_get_cpu(env);
676 qemu_mutex_lock_iothread();
677 stpcifc_service_call(cpu, r1, fiba, ar, GETPC());
678 qemu_mutex_unlock_iothread();
681 void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)
683 int r;
685 qemu_mutex_lock_iothread();
686 r = css_do_sic(env, (r3 >> 27) & 0x7, r1 & 0xffff);
687 qemu_mutex_unlock_iothread();
688 /* css_do_sic() may actually return a PGM_xxx value to inject */
689 if (r) {
690 s390_program_interrupt(env, -r, 4, GETPC());
694 void HELPER(rpcit)(CPUS390XState *env, uint32_t r1, uint32_t r2)
696 S390CPU *cpu = s390_env_get_cpu(env);
698 qemu_mutex_lock_iothread();
699 rpcit_service_call(cpu, r1, r2, GETPC());
700 qemu_mutex_unlock_iothread();
703 void HELPER(pcistb)(CPUS390XState *env, uint32_t r1, uint32_t r3,
704 uint64_t gaddr, uint32_t ar)
706 S390CPU *cpu = s390_env_get_cpu(env);
708 qemu_mutex_lock_iothread();
709 pcistb_service_call(cpu, r1, r3, gaddr, ar, GETPC());
710 qemu_mutex_unlock_iothread();
713 void HELPER(mpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
714 uint32_t ar)
716 S390CPU *cpu = s390_env_get_cpu(env);
718 qemu_mutex_lock_iothread();
719 mpcifc_service_call(cpu, r1, fiba, ar, GETPC());
720 qemu_mutex_unlock_iothread();
722 #endif