2 * QEMU S390x KVM implementation
4 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
5 * Copyright IBM Corp. 2012
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 * Contributions after 2012-10-29 are licensed under the terms of the
18 * GNU GPL, version 2 or (at your option) any later version.
20 * You should have received a copy of the GNU (Lesser) General Public
21 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24 #include <sys/types.h>
25 #include <sys/ioctl.h>
28 #include <linux/kvm.h>
29 #include <asm/ptrace.h>
31 #include "qemu-common.h"
32 #include "qemu/timer.h"
33 #include "sysemu/sysemu.h"
34 #include "sysemu/kvm.h"
37 #include "sysemu/device_tree.h"
38 #include "qapi/qmp/qjson.h"
39 #include "monitor/monitor.h"
40 #include "exec/gdbstub.h"
42 #include "qapi-event.h"
43 #include "hw/s390x/s390-pci-inst.h"
45 /* #define DEBUG_KVM */
48 #define DPRINTF(fmt, ...) \
49 do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
51 #define DPRINTF(fmt, ...) \
55 #define IPA0_DIAG 0x8300
56 #define IPA0_SIGP 0xae00
57 #define IPA0_B2 0xb200
58 #define IPA0_B9 0xb900
59 #define IPA0_EB 0xeb00
60 #define IPA0_E3 0xe300
62 #define PRIV_B2_SCLP_CALL 0x20
63 #define PRIV_B2_CSCH 0x30
64 #define PRIV_B2_HSCH 0x31
65 #define PRIV_B2_MSCH 0x32
66 #define PRIV_B2_SSCH 0x33
67 #define PRIV_B2_STSCH 0x34
68 #define PRIV_B2_TSCH 0x35
69 #define PRIV_B2_TPI 0x36
70 #define PRIV_B2_SAL 0x37
71 #define PRIV_B2_RSCH 0x38
72 #define PRIV_B2_STCRW 0x39
73 #define PRIV_B2_STCPS 0x3a
74 #define PRIV_B2_RCHP 0x3b
75 #define PRIV_B2_SCHM 0x3c
76 #define PRIV_B2_CHSC 0x5f
77 #define PRIV_B2_SIGA 0x74
78 #define PRIV_B2_XSCH 0x76
80 #define PRIV_EB_SQBS 0x8a
81 #define PRIV_EB_PCISTB 0xd0
82 #define PRIV_EB_SIC 0xd1
84 #define PRIV_B9_EQBS 0x9c
85 #define PRIV_B9_CLP 0xa0
86 #define PRIV_B9_PCISTG 0xd0
87 #define PRIV_B9_PCILG 0xd2
88 #define PRIV_B9_RPCIT 0xd3
90 #define PRIV_E3_MPCIFC 0xd0
91 #define PRIV_E3_STPCIFC 0xd4
93 #define DIAG_IPL 0x308
94 #define DIAG_KVM_HYPERCALL 0x500
95 #define DIAG_KVM_BREAKPOINT 0x501
97 #define ICPT_INSTRUCTION 0x04
98 #define ICPT_PROGRAM 0x08
99 #define ICPT_EXT_INT 0x14
100 #define ICPT_WAITPSW 0x1c
101 #define ICPT_SOFT_INTERCEPT 0x24
102 #define ICPT_CPU_STOP 0x28
105 static CPUWatchpoint hw_watchpoint
;
107 * We don't use a list because this structure is also used to transmit the
108 * hardware breakpoints to the kernel.
110 static struct kvm_hw_breakpoint
*hw_breakpoints
;
111 static int nb_hw_breakpoints
;
113 const KVMCapabilityInfo kvm_arch_required_capabilities
[] = {
117 static int cap_sync_regs
;
118 static int cap_async_pf
;
120 static void *legacy_s390_alloc(size_t size
, uint64_t *align
);
122 static int kvm_s390_check_clear_cmma(KVMState
*s
)
124 struct kvm_device_attr attr
= {
125 .group
= KVM_S390_VM_MEM_CTRL
,
126 .attr
= KVM_S390_VM_MEM_CLR_CMMA
,
129 return kvm_vm_ioctl(s
, KVM_HAS_DEVICE_ATTR
, &attr
);
132 static int kvm_s390_check_enable_cmma(KVMState
*s
)
134 struct kvm_device_attr attr
= {
135 .group
= KVM_S390_VM_MEM_CTRL
,
136 .attr
= KVM_S390_VM_MEM_ENABLE_CMMA
,
139 return kvm_vm_ioctl(s
, KVM_HAS_DEVICE_ATTR
, &attr
);
142 void kvm_s390_clear_cmma_callback(void *opaque
)
145 KVMState
*s
= opaque
;
146 struct kvm_device_attr attr
= {
147 .group
= KVM_S390_VM_MEM_CTRL
,
148 .attr
= KVM_S390_VM_MEM_CLR_CMMA
,
151 rc
= kvm_vm_ioctl(s
, KVM_SET_DEVICE_ATTR
, &attr
);
152 trace_kvm_clear_cmma(rc
);
155 static void kvm_s390_enable_cmma(KVMState
*s
)
158 struct kvm_device_attr attr
= {
159 .group
= KVM_S390_VM_MEM_CTRL
,
160 .attr
= KVM_S390_VM_MEM_ENABLE_CMMA
,
163 if (kvm_s390_check_enable_cmma(s
) || kvm_s390_check_clear_cmma(s
)) {
167 rc
= kvm_vm_ioctl(s
, KVM_SET_DEVICE_ATTR
, &attr
);
169 qemu_register_reset(kvm_s390_clear_cmma_callback
, s
);
171 trace_kvm_enable_cmma(rc
);
174 int kvm_arch_init(KVMState
*s
)
176 cap_sync_regs
= kvm_check_extension(s
, KVM_CAP_SYNC_REGS
);
177 cap_async_pf
= kvm_check_extension(s
, KVM_CAP_ASYNC_PF
);
179 if (kvm_check_extension(s
, KVM_CAP_VM_ATTRIBUTES
)) {
180 kvm_s390_enable_cmma(s
);
183 if (!kvm_check_extension(s
, KVM_CAP_S390_GMAP
)
184 || !kvm_check_extension(s
, KVM_CAP_S390_COW
)) {
185 phys_mem_set_alloc(legacy_s390_alloc
);
190 unsigned long kvm_arch_vcpu_id(CPUState
*cpu
)
192 return cpu
->cpu_index
;
195 int kvm_arch_init_vcpu(CPUState
*cs
)
197 S390CPU
*cpu
= S390_CPU(cs
);
198 kvm_s390_set_cpu_state(cpu
, cpu
->env
.cpu_state
);
202 void kvm_s390_reset_vcpu(S390CPU
*cpu
)
204 CPUState
*cs
= CPU(cpu
);
206 /* The initial reset call is needed here to reset in-kernel
207 * vcpu data that we can't access directly from QEMU
208 * (i.e. with older kernels which don't support sync_regs/ONE_REG).
209 * Before this ioctl cpu_synchronize_state() is called in common kvm
211 if (kvm_vcpu_ioctl(cs
, KVM_S390_INITIAL_RESET
, NULL
)) {
212 error_report("Initial CPU reset failed on CPU %i\n", cs
->cpu_index
);
216 static int can_sync_regs(CPUState
*cs
, int regs
)
218 return cap_sync_regs
&& (cs
->kvm_run
->kvm_valid_regs
& regs
) == regs
;
221 int kvm_arch_put_registers(CPUState
*cs
, int level
)
223 S390CPU
*cpu
= S390_CPU(cs
);
224 CPUS390XState
*env
= &cpu
->env
;
225 struct kvm_sregs sregs
;
226 struct kvm_regs regs
;
227 struct kvm_fpu fpu
= {};
231 /* always save the PSW and the GPRS*/
232 cs
->kvm_run
->psw_addr
= env
->psw
.addr
;
233 cs
->kvm_run
->psw_mask
= env
->psw
.mask
;
235 if (can_sync_regs(cs
, KVM_SYNC_GPRS
)) {
236 for (i
= 0; i
< 16; i
++) {
237 cs
->kvm_run
->s
.regs
.gprs
[i
] = env
->regs
[i
];
238 cs
->kvm_run
->kvm_dirty_regs
|= KVM_SYNC_GPRS
;
241 for (i
= 0; i
< 16; i
++) {
242 regs
.gprs
[i
] = env
->regs
[i
];
244 r
= kvm_vcpu_ioctl(cs
, KVM_SET_REGS
, ®s
);
251 for (i
= 0; i
< 16; i
++) {
252 fpu
.fprs
[i
] = env
->fregs
[i
].ll
;
256 r
= kvm_vcpu_ioctl(cs
, KVM_SET_FPU
, &fpu
);
261 /* Do we need to save more than that? */
262 if (level
== KVM_PUT_RUNTIME_STATE
) {
266 if (can_sync_regs(cs
, KVM_SYNC_ARCH0
)) {
267 cs
->kvm_run
->s
.regs
.cputm
= env
->cputm
;
268 cs
->kvm_run
->s
.regs
.ckc
= env
->ckc
;
269 cs
->kvm_run
->s
.regs
.todpr
= env
->todpr
;
270 cs
->kvm_run
->s
.regs
.gbea
= env
->gbea
;
271 cs
->kvm_run
->s
.regs
.pp
= env
->pp
;
272 cs
->kvm_run
->kvm_dirty_regs
|= KVM_SYNC_ARCH0
;
275 * These ONE_REGS are not protected by a capability. As they are only
276 * necessary for migration we just trace a possible error, but don't
277 * return with an error return code.
279 kvm_set_one_reg(cs
, KVM_REG_S390_CPU_TIMER
, &env
->cputm
);
280 kvm_set_one_reg(cs
, KVM_REG_S390_CLOCK_COMP
, &env
->ckc
);
281 kvm_set_one_reg(cs
, KVM_REG_S390_TODPR
, &env
->todpr
);
282 kvm_set_one_reg(cs
, KVM_REG_S390_GBEA
, &env
->gbea
);
283 kvm_set_one_reg(cs
, KVM_REG_S390_PP
, &env
->pp
);
286 /* pfault parameters */
287 if (can_sync_regs(cs
, KVM_SYNC_PFAULT
)) {
288 cs
->kvm_run
->s
.regs
.pft
= env
->pfault_token
;
289 cs
->kvm_run
->s
.regs
.pfs
= env
->pfault_select
;
290 cs
->kvm_run
->s
.regs
.pfc
= env
->pfault_compare
;
291 cs
->kvm_run
->kvm_dirty_regs
|= KVM_SYNC_PFAULT
;
292 } else if (cap_async_pf
) {
293 r
= kvm_set_one_reg(cs
, KVM_REG_S390_PFTOKEN
, &env
->pfault_token
);
297 r
= kvm_set_one_reg(cs
, KVM_REG_S390_PFCOMPARE
, &env
->pfault_compare
);
301 r
= kvm_set_one_reg(cs
, KVM_REG_S390_PFSELECT
, &env
->pfault_select
);
307 /* access registers and control registers*/
308 if (can_sync_regs(cs
, KVM_SYNC_ACRS
| KVM_SYNC_CRS
)) {
309 for (i
= 0; i
< 16; i
++) {
310 cs
->kvm_run
->s
.regs
.acrs
[i
] = env
->aregs
[i
];
311 cs
->kvm_run
->s
.regs
.crs
[i
] = env
->cregs
[i
];
313 cs
->kvm_run
->kvm_dirty_regs
|= KVM_SYNC_ACRS
;
314 cs
->kvm_run
->kvm_dirty_regs
|= KVM_SYNC_CRS
;
316 for (i
= 0; i
< 16; i
++) {
317 sregs
.acrs
[i
] = env
->aregs
[i
];
318 sregs
.crs
[i
] = env
->cregs
[i
];
320 r
= kvm_vcpu_ioctl(cs
, KVM_SET_SREGS
, &sregs
);
326 /* Finally the prefix */
327 if (can_sync_regs(cs
, KVM_SYNC_PREFIX
)) {
328 cs
->kvm_run
->s
.regs
.prefix
= env
->psa
;
329 cs
->kvm_run
->kvm_dirty_regs
|= KVM_SYNC_PREFIX
;
331 /* prefix is only supported via sync regs */
336 int kvm_arch_get_registers(CPUState
*cs
)
338 S390CPU
*cpu
= S390_CPU(cs
);
339 CPUS390XState
*env
= &cpu
->env
;
340 struct kvm_sregs sregs
;
341 struct kvm_regs regs
;
346 env
->psw
.addr
= cs
->kvm_run
->psw_addr
;
347 env
->psw
.mask
= cs
->kvm_run
->psw_mask
;
350 if (can_sync_regs(cs
, KVM_SYNC_GPRS
)) {
351 for (i
= 0; i
< 16; i
++) {
352 env
->regs
[i
] = cs
->kvm_run
->s
.regs
.gprs
[i
];
355 r
= kvm_vcpu_ioctl(cs
, KVM_GET_REGS
, ®s
);
359 for (i
= 0; i
< 16; i
++) {
360 env
->regs
[i
] = regs
.gprs
[i
];
364 /* The ACRS and CRS */
365 if (can_sync_regs(cs
, KVM_SYNC_ACRS
| KVM_SYNC_CRS
)) {
366 for (i
= 0; i
< 16; i
++) {
367 env
->aregs
[i
] = cs
->kvm_run
->s
.regs
.acrs
[i
];
368 env
->cregs
[i
] = cs
->kvm_run
->s
.regs
.crs
[i
];
371 r
= kvm_vcpu_ioctl(cs
, KVM_GET_SREGS
, &sregs
);
375 for (i
= 0; i
< 16; i
++) {
376 env
->aregs
[i
] = sregs
.acrs
[i
];
377 env
->cregs
[i
] = sregs
.crs
[i
];
382 r
= kvm_vcpu_ioctl(cs
, KVM_GET_FPU
, &fpu
);
386 for (i
= 0; i
< 16; i
++) {
387 env
->fregs
[i
].ll
= fpu
.fprs
[i
];
392 if (can_sync_regs(cs
, KVM_SYNC_PREFIX
)) {
393 env
->psa
= cs
->kvm_run
->s
.regs
.prefix
;
396 if (can_sync_regs(cs
, KVM_SYNC_ARCH0
)) {
397 env
->cputm
= cs
->kvm_run
->s
.regs
.cputm
;
398 env
->ckc
= cs
->kvm_run
->s
.regs
.ckc
;
399 env
->todpr
= cs
->kvm_run
->s
.regs
.todpr
;
400 env
->gbea
= cs
->kvm_run
->s
.regs
.gbea
;
401 env
->pp
= cs
->kvm_run
->s
.regs
.pp
;
404 * These ONE_REGS are not protected by a capability. As they are only
405 * necessary for migration we just trace a possible error, but don't
406 * return with an error return code.
408 kvm_get_one_reg(cs
, KVM_REG_S390_CPU_TIMER
, &env
->cputm
);
409 kvm_get_one_reg(cs
, KVM_REG_S390_CLOCK_COMP
, &env
->ckc
);
410 kvm_get_one_reg(cs
, KVM_REG_S390_TODPR
, &env
->todpr
);
411 kvm_get_one_reg(cs
, KVM_REG_S390_GBEA
, &env
->gbea
);
412 kvm_get_one_reg(cs
, KVM_REG_S390_PP
, &env
->pp
);
415 /* pfault parameters */
416 if (can_sync_regs(cs
, KVM_SYNC_PFAULT
)) {
417 env
->pfault_token
= cs
->kvm_run
->s
.regs
.pft
;
418 env
->pfault_select
= cs
->kvm_run
->s
.regs
.pfs
;
419 env
->pfault_compare
= cs
->kvm_run
->s
.regs
.pfc
;
420 } else if (cap_async_pf
) {
421 r
= kvm_get_one_reg(cs
, KVM_REG_S390_PFTOKEN
, &env
->pfault_token
);
425 r
= kvm_get_one_reg(cs
, KVM_REG_S390_PFCOMPARE
, &env
->pfault_compare
);
429 r
= kvm_get_one_reg(cs
, KVM_REG_S390_PFSELECT
, &env
->pfault_select
);
439 * Legacy layout for s390:
440 * Older S390 KVM requires the topmost vma of the RAM to be
441 * smaller than an system defined value, which is at least 256GB.
442 * Larger systems have larger values. We put the guest between
443 * the end of data segment (system break) and this value. We
444 * use 32GB as a base to have enough room for the system break
445 * to grow. We also have to use MAP parameters that avoid
446 * read-only mapping of guest pages.
448 static void *legacy_s390_alloc(size_t size
, uint64_t *align
)
452 mem
= mmap((void *) 0x800000000ULL
, size
,
453 PROT_EXEC
|PROT_READ
|PROT_WRITE
,
454 MAP_SHARED
| MAP_ANONYMOUS
| MAP_FIXED
, -1, 0);
455 return mem
== MAP_FAILED
? NULL
: mem
;
458 /* DIAG 501 is used for sw breakpoints */
459 static const uint8_t diag_501
[] = {0x83, 0x24, 0x05, 0x01};
461 int kvm_arch_insert_sw_breakpoint(CPUState
*cs
, struct kvm_sw_breakpoint
*bp
)
464 if (cpu_memory_rw_debug(cs
, bp
->pc
, (uint8_t *)&bp
->saved_insn
,
465 sizeof(diag_501
), 0) ||
466 cpu_memory_rw_debug(cs
, bp
->pc
, (uint8_t *)diag_501
,
467 sizeof(diag_501
), 1)) {
473 int kvm_arch_remove_sw_breakpoint(CPUState
*cs
, struct kvm_sw_breakpoint
*bp
)
475 uint8_t t
[sizeof(diag_501
)];
477 if (cpu_memory_rw_debug(cs
, bp
->pc
, t
, sizeof(diag_501
), 0)) {
479 } else if (memcmp(t
, diag_501
, sizeof(diag_501
))) {
481 } else if (cpu_memory_rw_debug(cs
, bp
->pc
, (uint8_t *)&bp
->saved_insn
,
482 sizeof(diag_501
), 1)) {
489 static struct kvm_hw_breakpoint
*find_hw_breakpoint(target_ulong addr
,
494 for (n
= 0; n
< nb_hw_breakpoints
; n
++) {
495 if (hw_breakpoints
[n
].addr
== addr
&& hw_breakpoints
[n
].type
== type
&&
496 (hw_breakpoints
[n
].len
== len
|| len
== -1)) {
497 return &hw_breakpoints
[n
];
504 static int insert_hw_breakpoint(target_ulong addr
, int len
, int type
)
508 if (find_hw_breakpoint(addr
, len
, type
)) {
512 size
= (nb_hw_breakpoints
+ 1) * sizeof(struct kvm_hw_breakpoint
);
514 if (!hw_breakpoints
) {
515 nb_hw_breakpoints
= 0;
516 hw_breakpoints
= (struct kvm_hw_breakpoint
*)g_try_malloc(size
);
519 (struct kvm_hw_breakpoint
*)g_try_realloc(hw_breakpoints
, size
);
522 if (!hw_breakpoints
) {
523 nb_hw_breakpoints
= 0;
527 hw_breakpoints
[nb_hw_breakpoints
].addr
= addr
;
528 hw_breakpoints
[nb_hw_breakpoints
].len
= len
;
529 hw_breakpoints
[nb_hw_breakpoints
].type
= type
;
536 int kvm_arch_insert_hw_breakpoint(target_ulong addr
,
537 target_ulong len
, int type
)
540 case GDB_BREAKPOINT_HW
:
543 case GDB_WATCHPOINT_WRITE
:
547 type
= KVM_HW_WP_WRITE
;
552 return insert_hw_breakpoint(addr
, len
, type
);
555 int kvm_arch_remove_hw_breakpoint(target_ulong addr
,
556 target_ulong len
, int type
)
559 struct kvm_hw_breakpoint
*bp
= find_hw_breakpoint(addr
, len
, type
);
566 if (nb_hw_breakpoints
> 0) {
568 * In order to trim the array, move the last element to the position to
569 * be removed - if necessary.
571 if (bp
!= &hw_breakpoints
[nb_hw_breakpoints
]) {
572 *bp
= hw_breakpoints
[nb_hw_breakpoints
];
574 size
= nb_hw_breakpoints
* sizeof(struct kvm_hw_breakpoint
);
576 (struct kvm_hw_breakpoint
*)g_realloc(hw_breakpoints
, size
);
578 g_free(hw_breakpoints
);
579 hw_breakpoints
= NULL
;
585 void kvm_arch_remove_all_hw_breakpoints(void)
587 nb_hw_breakpoints
= 0;
588 g_free(hw_breakpoints
);
589 hw_breakpoints
= NULL
;
592 void kvm_arch_update_guest_debug(CPUState
*cpu
, struct kvm_guest_debug
*dbg
)
596 if (nb_hw_breakpoints
> 0) {
597 dbg
->arch
.nr_hw_bp
= nb_hw_breakpoints
;
598 dbg
->arch
.hw_bp
= hw_breakpoints
;
600 for (i
= 0; i
< nb_hw_breakpoints
; ++i
) {
601 hw_breakpoints
[i
].phys_addr
= s390_cpu_get_phys_addr_debug(cpu
,
602 hw_breakpoints
[i
].addr
);
604 dbg
->control
|= KVM_GUESTDBG_ENABLE
| KVM_GUESTDBG_USE_HW_BP
;
606 dbg
->arch
.nr_hw_bp
= 0;
607 dbg
->arch
.hw_bp
= NULL
;
611 void kvm_arch_pre_run(CPUState
*cpu
, struct kvm_run
*run
)
615 void kvm_arch_post_run(CPUState
*cpu
, struct kvm_run
*run
)
619 int kvm_arch_process_async_events(CPUState
*cs
)
624 static int s390_kvm_irq_to_interrupt(struct kvm_s390_irq
*irq
,
625 struct kvm_s390_interrupt
*interrupt
)
629 interrupt
->type
= irq
->type
;
631 case KVM_S390_INT_VIRTIO
:
632 interrupt
->parm
= irq
->u
.ext
.ext_params
;
634 case KVM_S390_INT_PFAULT_INIT
:
635 case KVM_S390_INT_PFAULT_DONE
:
636 interrupt
->parm64
= irq
->u
.ext
.ext_params2
;
638 case KVM_S390_PROGRAM_INT
:
639 interrupt
->parm
= irq
->u
.pgm
.code
;
641 case KVM_S390_SIGP_SET_PREFIX
:
642 interrupt
->parm
= irq
->u
.prefix
.address
;
644 case KVM_S390_INT_SERVICE
:
645 interrupt
->parm
= irq
->u
.ext
.ext_params
;
648 interrupt
->parm
= irq
->u
.mchk
.cr14
;
649 interrupt
->parm64
= irq
->u
.mchk
.mcic
;
651 case KVM_S390_INT_EXTERNAL_CALL
:
652 interrupt
->parm
= irq
->u
.extcall
.code
;
654 case KVM_S390_INT_EMERGENCY
:
655 interrupt
->parm
= irq
->u
.emerg
.code
;
657 case KVM_S390_SIGP_STOP
:
658 case KVM_S390_RESTART
:
659 break; /* These types have no parameters */
660 case KVM_S390_INT_IO_MIN
...KVM_S390_INT_IO_MAX
:
661 interrupt
->parm
= irq
->u
.io
.subchannel_id
<< 16;
662 interrupt
->parm
|= irq
->u
.io
.subchannel_nr
;
663 interrupt
->parm64
= (uint64_t)irq
->u
.io
.io_int_parm
<< 32;
664 interrupt
->parm64
|= irq
->u
.io
.io_int_word
;
673 void kvm_s390_vcpu_interrupt(S390CPU
*cpu
, struct kvm_s390_irq
*irq
)
675 struct kvm_s390_interrupt kvmint
= {};
676 CPUState
*cs
= CPU(cpu
);
679 r
= s390_kvm_irq_to_interrupt(irq
, &kvmint
);
681 fprintf(stderr
, "%s called with bogus interrupt\n", __func__
);
685 r
= kvm_vcpu_ioctl(cs
, KVM_S390_INTERRUPT
, &kvmint
);
687 fprintf(stderr
, "KVM failed to inject interrupt\n");
692 static void __kvm_s390_floating_interrupt(struct kvm_s390_irq
*irq
)
694 struct kvm_s390_interrupt kvmint
= {};
697 r
= s390_kvm_irq_to_interrupt(irq
, &kvmint
);
699 fprintf(stderr
, "%s called with bogus interrupt\n", __func__
);
703 r
= kvm_vm_ioctl(kvm_state
, KVM_S390_INTERRUPT
, &kvmint
);
705 fprintf(stderr
, "KVM failed to inject interrupt\n");
710 void kvm_s390_floating_interrupt(struct kvm_s390_irq
*irq
)
712 static bool use_flic
= true;
716 r
= kvm_s390_inject_flic(irq
);
724 __kvm_s390_floating_interrupt(irq
);
727 void kvm_s390_virtio_irq(int config_change
, uint64_t token
)
729 struct kvm_s390_irq irq
= {
730 .type
= KVM_S390_INT_VIRTIO
,
731 .u
.ext
.ext_params
= config_change
,
732 .u
.ext
.ext_params2
= token
,
735 kvm_s390_floating_interrupt(&irq
);
738 void kvm_s390_service_interrupt(uint32_t parm
)
740 struct kvm_s390_irq irq
= {
741 .type
= KVM_S390_INT_SERVICE
,
742 .u
.ext
.ext_params
= parm
,
745 kvm_s390_floating_interrupt(&irq
);
748 static void enter_pgmcheck(S390CPU
*cpu
, uint16_t code
)
750 struct kvm_s390_irq irq
= {
751 .type
= KVM_S390_PROGRAM_INT
,
755 kvm_s390_vcpu_interrupt(cpu
, &irq
);
758 static int kvm_sclp_service_call(S390CPU
*cpu
, struct kvm_run
*run
,
761 CPUS390XState
*env
= &cpu
->env
;
766 cpu_synchronize_state(CPU(cpu
));
767 sccb
= env
->regs
[ipbh0
& 0xf];
768 code
= env
->regs
[(ipbh0
& 0xf0) >> 4];
770 r
= sclp_service_call(env
, sccb
, code
);
772 enter_pgmcheck(cpu
, -r
);
780 static int handle_b2(S390CPU
*cpu
, struct kvm_run
*run
, uint8_t ipa1
)
782 CPUS390XState
*env
= &cpu
->env
;
784 uint16_t ipbh0
= (run
->s390_sieic
.ipb
& 0xffff0000) >> 16;
786 cpu_synchronize_state(CPU(cpu
));
790 ioinst_handle_xsch(cpu
, env
->regs
[1]);
793 ioinst_handle_csch(cpu
, env
->regs
[1]);
796 ioinst_handle_hsch(cpu
, env
->regs
[1]);
799 ioinst_handle_msch(cpu
, env
->regs
[1], run
->s390_sieic
.ipb
);
802 ioinst_handle_ssch(cpu
, env
->regs
[1], run
->s390_sieic
.ipb
);
805 ioinst_handle_stcrw(cpu
, run
->s390_sieic
.ipb
);
808 ioinst_handle_stsch(cpu
, env
->regs
[1], run
->s390_sieic
.ipb
);
811 /* We should only get tsch via KVM_EXIT_S390_TSCH. */
812 fprintf(stderr
, "Spurious tsch intercept\n");
815 ioinst_handle_chsc(cpu
, run
->s390_sieic
.ipb
);
818 /* This should have been handled by kvm already. */
819 fprintf(stderr
, "Spurious tpi intercept\n");
822 ioinst_handle_schm(cpu
, env
->regs
[1], env
->regs
[2],
823 run
->s390_sieic
.ipb
);
826 ioinst_handle_rsch(cpu
, env
->regs
[1]);
829 ioinst_handle_rchp(cpu
, env
->regs
[1]);
832 /* We do not provide this instruction, it is suppressed. */
835 ioinst_handle_sal(cpu
, env
->regs
[1]);
838 /* Not provided, set CC = 3 for subchannel not operational */
841 case PRIV_B2_SCLP_CALL
:
842 rc
= kvm_sclp_service_call(cpu
, run
, ipbh0
);
846 DPRINTF("KVM: unhandled PRIV: 0xb2%x\n", ipa1
);
853 static uint64_t get_base_disp_rxy(S390CPU
*cpu
, struct kvm_run
*run
)
855 CPUS390XState
*env
= &cpu
->env
;
856 uint32_t x2
= (run
->s390_sieic
.ipa
& 0x000f);
857 uint32_t base2
= run
->s390_sieic
.ipb
>> 28;
858 uint32_t disp2
= ((run
->s390_sieic
.ipb
& 0x0fff0000) >> 16) +
859 ((run
->s390_sieic
.ipb
& 0xff00) << 4);
861 if (disp2
& 0x80000) {
865 return (base2
? env
->regs
[base2
] : 0) +
866 (x2
? env
->regs
[x2
] : 0) + (long)(int)disp2
;
869 static uint64_t get_base_disp_rsy(S390CPU
*cpu
, struct kvm_run
*run
)
871 CPUS390XState
*env
= &cpu
->env
;
872 uint32_t base2
= run
->s390_sieic
.ipb
>> 28;
873 uint32_t disp2
= ((run
->s390_sieic
.ipb
& 0x0fff0000) >> 16) +
874 ((run
->s390_sieic
.ipb
& 0xff00) << 4);
876 if (disp2
& 0x80000) {
880 return (base2
? env
->regs
[base2
] : 0) + (long)(int)disp2
;
883 static int kvm_clp_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
885 uint8_t r2
= (run
->s390_sieic
.ipb
& 0x000f0000) >> 16;
887 return clp_service_call(cpu
, r2
);
890 static int kvm_pcilg_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
892 uint8_t r1
= (run
->s390_sieic
.ipb
& 0x00f00000) >> 20;
893 uint8_t r2
= (run
->s390_sieic
.ipb
& 0x000f0000) >> 16;
895 return pcilg_service_call(cpu
, r1
, r2
);
898 static int kvm_pcistg_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
900 uint8_t r1
= (run
->s390_sieic
.ipb
& 0x00f00000) >> 20;
901 uint8_t r2
= (run
->s390_sieic
.ipb
& 0x000f0000) >> 16;
903 return pcistg_service_call(cpu
, r1
, r2
);
906 static int kvm_stpcifc_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
908 uint8_t r1
= (run
->s390_sieic
.ipa
& 0x00f0) >> 4;
911 cpu_synchronize_state(CPU(cpu
));
912 fiba
= get_base_disp_rxy(cpu
, run
);
914 return stpcifc_service_call(cpu
, r1
, fiba
);
917 static int kvm_sic_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
923 static int kvm_rpcit_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
925 uint8_t r1
= (run
->s390_sieic
.ipb
& 0x00f00000) >> 20;
926 uint8_t r2
= (run
->s390_sieic
.ipb
& 0x000f0000) >> 16;
928 return rpcit_service_call(cpu
, r1
, r2
);
931 static int kvm_pcistb_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
933 uint8_t r1
= (run
->s390_sieic
.ipa
& 0x00f0) >> 4;
934 uint8_t r3
= run
->s390_sieic
.ipa
& 0x000f;
937 cpu_synchronize_state(CPU(cpu
));
938 gaddr
= get_base_disp_rsy(cpu
, run
);
940 return pcistb_service_call(cpu
, r1
, r3
, gaddr
);
943 static int kvm_mpcifc_service_call(S390CPU
*cpu
, struct kvm_run
*run
)
945 uint8_t r1
= (run
->s390_sieic
.ipa
& 0x00f0) >> 4;
948 cpu_synchronize_state(CPU(cpu
));
949 fiba
= get_base_disp_rxy(cpu
, run
);
951 return mpcifc_service_call(cpu
, r1
, fiba
);
954 static int handle_b9(S390CPU
*cpu
, struct kvm_run
*run
, uint8_t ipa1
)
960 r
= kvm_clp_service_call(cpu
, run
);
963 r
= kvm_pcistg_service_call(cpu
, run
);
966 r
= kvm_pcilg_service_call(cpu
, run
);
969 r
= kvm_rpcit_service_call(cpu
, run
);
972 /* just inject exception */
977 DPRINTF("KVM: unhandled PRIV: 0xb9%x\n", ipa1
);
984 static int handle_eb(S390CPU
*cpu
, struct kvm_run
*run
, uint8_t ipbl
)
990 r
= kvm_pcistb_service_call(cpu
, run
);
993 r
= kvm_sic_service_call(cpu
, run
);
996 /* just inject exception */
1001 DPRINTF("KVM: unhandled PRIV: 0xeb%x\n", ipbl
);
1008 static int handle_e3(S390CPU
*cpu
, struct kvm_run
*run
, uint8_t ipbl
)
1013 case PRIV_E3_MPCIFC
:
1014 r
= kvm_mpcifc_service_call(cpu
, run
);
1016 case PRIV_E3_STPCIFC
:
1017 r
= kvm_stpcifc_service_call(cpu
, run
);
1021 DPRINTF("KVM: unhandled PRIV: 0xe3%x\n", ipbl
);
1028 static int handle_hypercall(S390CPU
*cpu
, struct kvm_run
*run
)
1030 CPUS390XState
*env
= &cpu
->env
;
1033 cpu_synchronize_state(CPU(cpu
));
1034 ret
= s390_virtio_hypercall(env
);
1035 if (ret
== -EINVAL
) {
1036 enter_pgmcheck(cpu
, PGM_SPECIFICATION
);
1043 static void kvm_handle_diag_308(S390CPU
*cpu
, struct kvm_run
*run
)
1047 cpu_synchronize_state(CPU(cpu
));
1048 r1
= (run
->s390_sieic
.ipa
& 0x00f0) >> 8;
1049 r3
= run
->s390_sieic
.ipa
& 0x000f;
1050 handle_diag_308(&cpu
->env
, r1
, r3
);
1053 static int handle_sw_breakpoint(S390CPU
*cpu
, struct kvm_run
*run
)
1055 CPUS390XState
*env
= &cpu
->env
;
1058 cpu_synchronize_state(CPU(cpu
));
1060 pc
= env
->psw
.addr
- 4;
1061 if (kvm_find_sw_breakpoint(CPU(cpu
), pc
)) {
1069 #define DIAG_KVM_CODE_MASK 0x000000000000ffff
1071 static int handle_diag(S390CPU
*cpu
, struct kvm_run
*run
, uint32_t ipb
)
1077 * For any diagnose call we support, bits 48-63 of the resulting
1078 * address specify the function code; the remainder is ignored.
1080 func_code
= decode_basedisp_rs(&cpu
->env
, ipb
) & DIAG_KVM_CODE_MASK
;
1081 switch (func_code
) {
1083 kvm_handle_diag_308(cpu
, run
);
1085 case DIAG_KVM_HYPERCALL
:
1086 r
= handle_hypercall(cpu
, run
);
1088 case DIAG_KVM_BREAKPOINT
:
1089 r
= handle_sw_breakpoint(cpu
, run
);
1092 DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code
);
1100 static void sigp_cpu_start(void *arg
)
1103 S390CPU
*cpu
= S390_CPU(cs
);
1105 s390_cpu_set_state(CPU_STATE_OPERATING
, cpu
);
1106 DPRINTF("DONE: KVM cpu start: %p\n", &cpu
->env
);
1109 static void sigp_cpu_restart(void *arg
)
1112 S390CPU
*cpu
= S390_CPU(cs
);
1113 struct kvm_s390_irq irq
= {
1114 .type
= KVM_S390_RESTART
,
1117 kvm_s390_vcpu_interrupt(cpu
, &irq
);
1118 s390_cpu_set_state(CPU_STATE_OPERATING
, cpu
);
1121 int kvm_s390_cpu_restart(S390CPU
*cpu
)
1123 run_on_cpu(CPU(cpu
), sigp_cpu_restart
, CPU(cpu
));
1124 DPRINTF("DONE: KVM cpu restart: %p\n", &cpu
->env
);
1128 static void sigp_initial_cpu_reset(void *arg
)
1130 CPUState
*cpu
= arg
;
1131 S390CPUClass
*scc
= S390_CPU_GET_CLASS(cpu
);
1133 cpu_synchronize_state(cpu
);
1134 scc
->initial_cpu_reset(cpu
);
1135 cpu_synchronize_post_reset(cpu
);
1138 static void sigp_cpu_reset(void *arg
)
1140 CPUState
*cpu
= arg
;
1141 S390CPUClass
*scc
= S390_CPU_GET_CLASS(cpu
);
1143 cpu_synchronize_state(cpu
);
1144 scc
->cpu_reset(cpu
);
1145 cpu_synchronize_post_reset(cpu
);
1148 #define SIGP_ORDER_MASK 0x000000ff
1150 static int handle_sigp(S390CPU
*cpu
, struct kvm_run
*run
, uint8_t ipa1
)
1152 CPUS390XState
*env
= &cpu
->env
;
1155 S390CPU
*target_cpu
;
1156 uint64_t *statusreg
= &env
->regs
[ipa1
>> 4];
1159 cpu_synchronize_state(CPU(cpu
));
1161 /* get order code */
1162 order_code
= decode_basedisp_rs(env
, run
->s390_sieic
.ipb
) & SIGP_ORDER_MASK
;
1164 cpu_addr
= env
->regs
[ipa1
& 0x0f];
1165 target_cpu
= s390_cpu_addr2state(cpu_addr
);
1166 if (target_cpu
== NULL
) {
1167 cc
= 3; /* not operational */
1171 switch (order_code
) {
1173 run_on_cpu(CPU(target_cpu
), sigp_cpu_start
, CPU(target_cpu
));
1177 run_on_cpu(CPU(target_cpu
), sigp_cpu_restart
, CPU(target_cpu
));
1181 *statusreg
&= 0xffffffff00000000UL
;
1182 *statusreg
|= SIGP_STAT_INVALID_PARAMETER
;
1183 cc
= 1; /* status stored */
1185 case SIGP_INITIAL_CPU_RESET
:
1186 run_on_cpu(CPU(target_cpu
), sigp_initial_cpu_reset
, CPU(target_cpu
));
1189 case SIGP_CPU_RESET
:
1190 run_on_cpu(CPU(target_cpu
), sigp_cpu_reset
, CPU(target_cpu
));
1194 DPRINTF("KVM: unknown SIGP: 0x%x\n", order_code
);
1195 *statusreg
&= 0xffffffff00000000UL
;
1196 *statusreg
|= SIGP_STAT_INVALID_ORDER
;
1197 cc
= 1; /* status stored */
1206 static int handle_instruction(S390CPU
*cpu
, struct kvm_run
*run
)
1208 unsigned int ipa0
= (run
->s390_sieic
.ipa
& 0xff00);
1209 uint8_t ipa1
= run
->s390_sieic
.ipa
& 0x00ff;
1212 DPRINTF("handle_instruction 0x%x 0x%x\n",
1213 run
->s390_sieic
.ipa
, run
->s390_sieic
.ipb
);
1216 r
= handle_b2(cpu
, run
, ipa1
);
1219 r
= handle_b9(cpu
, run
, ipa1
);
1222 r
= handle_eb(cpu
, run
, run
->s390_sieic
.ipb
& 0xff);
1225 r
= handle_e3(cpu
, run
, run
->s390_sieic
.ipb
& 0xff);
1228 r
= handle_diag(cpu
, run
, run
->s390_sieic
.ipb
);
1231 r
= handle_sigp(cpu
, run
, ipa1
);
1237 enter_pgmcheck(cpu
, 0x0001);
1243 static bool is_special_wait_psw(CPUState
*cs
)
1245 /* signal quiesce */
1246 return cs
->kvm_run
->psw_addr
== 0xfffUL
;
1249 static void guest_panicked(void)
1251 qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE
,
1253 vm_stop(RUN_STATE_GUEST_PANICKED
);
1256 static void unmanageable_intercept(S390CPU
*cpu
, const char *str
, int pswoffset
)
1258 CPUState
*cs
= CPU(cpu
);
1260 error_report("Unmanageable %s! CPU%i new PSW: 0x%016lx:%016lx",
1261 str
, cs
->cpu_index
, ldq_phys(cs
->as
, cpu
->env
.psa
+ pswoffset
),
1262 ldq_phys(cs
->as
, cpu
->env
.psa
+ pswoffset
+ 8));
1267 static int handle_intercept(S390CPU
*cpu
)
1269 CPUState
*cs
= CPU(cpu
);
1270 struct kvm_run
*run
= cs
->kvm_run
;
1271 int icpt_code
= run
->s390_sieic
.icptcode
;
1274 DPRINTF("intercept: 0x%x (at 0x%lx)\n", icpt_code
,
1275 (long)cs
->kvm_run
->psw_addr
);
1276 switch (icpt_code
) {
1277 case ICPT_INSTRUCTION
:
1278 r
= handle_instruction(cpu
, run
);
1281 unmanageable_intercept(cpu
, "program interrupt",
1282 offsetof(LowCore
, program_new_psw
));
1286 unmanageable_intercept(cpu
, "external interrupt",
1287 offsetof(LowCore
, external_new_psw
));
1291 /* disabled wait, since enabled wait is handled in kernel */
1292 cpu_synchronize_state(cs
);
1293 if (s390_cpu_halt(cpu
) == 0) {
1294 if (is_special_wait_psw(cs
)) {
1295 qemu_system_shutdown_request();
1303 if (s390_cpu_set_state(CPU_STATE_STOPPED
, cpu
) == 0) {
1304 qemu_system_shutdown_request();
1308 case ICPT_SOFT_INTERCEPT
:
1309 fprintf(stderr
, "KVM unimplemented icpt SOFT\n");
1313 fprintf(stderr
, "KVM unimplemented icpt IO\n");
1317 fprintf(stderr
, "Unknown intercept code: %d\n", icpt_code
);
1325 static int handle_tsch(S390CPU
*cpu
)
1327 CPUS390XState
*env
= &cpu
->env
;
1328 CPUState
*cs
= CPU(cpu
);
1329 struct kvm_run
*run
= cs
->kvm_run
;
1332 cpu_synchronize_state(cs
);
1334 ret
= ioinst_handle_tsch(env
, env
->regs
[1], run
->s390_tsch
.ipb
);
1336 /* Success; set condition code. */
1339 } else if (ret
< -1) {
1342 * If an I/O interrupt had been dequeued, we have to reinject it.
1344 if (run
->s390_tsch
.dequeued
) {
1345 kvm_s390_io_interrupt(run
->s390_tsch
.subchannel_id
,
1346 run
->s390_tsch
.subchannel_nr
,
1347 run
->s390_tsch
.io_int_parm
,
1348 run
->s390_tsch
.io_int_word
);
1355 static int kvm_arch_handle_debug_exit(S390CPU
*cpu
)
1357 CPUState
*cs
= CPU(cpu
);
1358 struct kvm_run
*run
= cs
->kvm_run
;
1361 struct kvm_debug_exit_arch
*arch_info
= &run
->debug
.arch
;
1363 switch (arch_info
->type
) {
1364 case KVM_HW_WP_WRITE
:
1365 if (find_hw_breakpoint(arch_info
->addr
, -1, arch_info
->type
)) {
1366 cs
->watchpoint_hit
= &hw_watchpoint
;
1367 hw_watchpoint
.vaddr
= arch_info
->addr
;
1368 hw_watchpoint
.flags
= BP_MEM_WRITE
;
1373 if (find_hw_breakpoint(arch_info
->addr
, -1, arch_info
->type
)) {
1377 case KVM_SINGLESTEP
:
1378 if (cs
->singlestep_enabled
) {
1389 int kvm_arch_handle_exit(CPUState
*cs
, struct kvm_run
*run
)
1391 S390CPU
*cpu
= S390_CPU(cs
);
1394 switch (run
->exit_reason
) {
1395 case KVM_EXIT_S390_SIEIC
:
1396 ret
= handle_intercept(cpu
);
1398 case KVM_EXIT_S390_RESET
:
1399 qemu_system_reset_request();
1401 case KVM_EXIT_S390_TSCH
:
1402 ret
= handle_tsch(cpu
);
1404 case KVM_EXIT_DEBUG
:
1405 ret
= kvm_arch_handle_debug_exit(cpu
);
1408 fprintf(stderr
, "Unknown KVM exit: %d\n", run
->exit_reason
);
1413 ret
= EXCP_INTERRUPT
;
1418 bool kvm_arch_stop_on_emulation_error(CPUState
*cpu
)
1423 int kvm_arch_on_sigbus_vcpu(CPUState
*cpu
, int code
, void *addr
)
1428 int kvm_arch_on_sigbus(int code
, void *addr
)
1433 void kvm_s390_io_interrupt(uint16_t subchannel_id
,
1434 uint16_t subchannel_nr
, uint32_t io_int_parm
,
1435 uint32_t io_int_word
)
1437 struct kvm_s390_irq irq
= {
1438 .u
.io
.subchannel_id
= subchannel_id
,
1439 .u
.io
.subchannel_nr
= subchannel_nr
,
1440 .u
.io
.io_int_parm
= io_int_parm
,
1441 .u
.io
.io_int_word
= io_int_word
,
1444 if (io_int_word
& IO_INT_WORD_AI
) {
1445 irq
.type
= KVM_S390_INT_IO(1, 0, 0, 0);
1447 irq
.type
= ((subchannel_id
& 0xff00) << 24) |
1448 ((subchannel_id
& 0x00060) << 22) | (subchannel_nr
<< 16);
1450 kvm_s390_floating_interrupt(&irq
);
1453 void kvm_s390_crw_mchk(void)
1455 struct kvm_s390_irq irq
= {
1456 .type
= KVM_S390_MCHK
,
1457 .u
.mchk
.cr14
= 1 << 28,
1458 .u
.mchk
.mcic
= 0x00400f1d40330000ULL
,
1460 kvm_s390_floating_interrupt(&irq
);
1463 void kvm_s390_enable_css_support(S390CPU
*cpu
)
1467 /* Activate host kernel channel subsystem support. */
1468 r
= kvm_vcpu_enable_cap(CPU(cpu
), KVM_CAP_S390_CSS_SUPPORT
, 0);
1472 void kvm_arch_init_irq_routing(KVMState
*s
)
1475 * Note that while irqchip capabilities generally imply that cpustates
1476 * are handled in-kernel, it is not true for s390 (yet); therefore, we
1477 * have to override the common code kvm_halt_in_kernel_allowed setting.
1479 if (kvm_check_extension(s
, KVM_CAP_IRQ_ROUTING
)) {
1480 kvm_gsi_routing_allowed
= true;
1481 kvm_halt_in_kernel_allowed
= false;
1485 int kvm_s390_assign_subch_ioeventfd(EventNotifier
*notifier
, uint32_t sch
,
1486 int vq
, bool assign
)
1488 struct kvm_ioeventfd kick
= {
1489 .flags
= KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY
|
1490 KVM_IOEVENTFD_FLAG_DATAMATCH
,
1491 .fd
= event_notifier_get_fd(notifier
),
1496 if (!kvm_check_extension(kvm_state
, KVM_CAP_IOEVENTFD
)) {
1500 kick
.flags
|= KVM_IOEVENTFD_FLAG_DEASSIGN
;
1502 return kvm_vm_ioctl(kvm_state
, KVM_IOEVENTFD
, &kick
);
1505 int kvm_s390_get_memslot_count(KVMState
*s
)
1507 return kvm_check_extension(s
, KVM_CAP_NR_MEMSLOTS
);
1510 int kvm_s390_set_cpu_state(S390CPU
*cpu
, uint8_t cpu_state
)
1512 struct kvm_mp_state mp_state
= {};
1515 /* the kvm part might not have been initialized yet */
1516 if (CPU(cpu
)->kvm_state
== NULL
) {
1520 switch (cpu_state
) {
1521 case CPU_STATE_STOPPED
:
1522 mp_state
.mp_state
= KVM_MP_STATE_STOPPED
;
1524 case CPU_STATE_CHECK_STOP
:
1525 mp_state
.mp_state
= KVM_MP_STATE_CHECK_STOP
;
1527 case CPU_STATE_OPERATING
:
1528 mp_state
.mp_state
= KVM_MP_STATE_OPERATING
;
1530 case CPU_STATE_LOAD
:
1531 mp_state
.mp_state
= KVM_MP_STATE_LOAD
;
1534 error_report("Requested CPU state is not a valid S390 CPU state: %u",
1539 ret
= kvm_vcpu_ioctl(CPU(cpu
), KVM_SET_MP_STATE
, &mp_state
);
1541 trace_kvm_failed_cpu_state_set(CPU(cpu
)->cpu_index
, cpu_state
,