1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __LINUX_KVM_S390_H
3 #define __LINUX_KVM_S390_H
5 * KVM s390 specific structures and definitions
7 * Copyright IBM Corp. 2008, 2018
9 * Author(s): Carsten Otte <cotte@de.ibm.com>
10 * Christian Borntraeger <borntraeger@de.ibm.com>
12 #include <linux/types.h>
16 struct kvm_s390_skeys
{
24 #define KVM_S390_CMMA_PEEK (1 << 0)
27 * kvm_s390_cmma_log - Used for CMMA migration.
29 * Used both for input and output.
31 * @start_gfn: Guest page number to start from.
32 * @count: Size of the result buffer.
33 * @flags: Control operation mode via KVM_S390_CMMA_* flags
34 * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty
35 * pages are still remaining.
36 * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set
38 * @values: Pointer to the values buffer.
40 * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls.
42 struct kvm_s390_cmma_log
{
53 #define KVM_S390_RESET_POR 1
54 #define KVM_S390_RESET_CLEAR 2
55 #define KVM_S390_RESET_SUBSYSTEM 4
56 #define KVM_S390_RESET_CPU_INIT 8
57 #define KVM_S390_RESET_IPL 16
59 /* for KVM_S390_MEM_OP */
60 struct kvm_s390_mem_op
{
62 __u64 gaddr
; /* the guest address */
63 __u64 flags
; /* flags */
64 __u32 size
; /* amount of bytes */
65 __u32 op
; /* type of operation */
66 __u64 buf
; /* buffer in userspace */
69 __u8 ar
; /* the access register number */
70 __u8 key
; /* access key, ignored if flag unset */
71 __u8 pad1
[6]; /* ignored */
72 __u64 old_addr
; /* ignored if cmpxchg flag unset */
74 __u32 sida_offset
; /* offset into the sida */
75 __u8 reserved
[32]; /* ignored */
78 /* types for kvm_s390_mem_op->op */
79 #define KVM_S390_MEMOP_LOGICAL_READ 0
80 #define KVM_S390_MEMOP_LOGICAL_WRITE 1
81 #define KVM_S390_MEMOP_SIDA_READ 2
82 #define KVM_S390_MEMOP_SIDA_WRITE 3
83 #define KVM_S390_MEMOP_ABSOLUTE_READ 4
84 #define KVM_S390_MEMOP_ABSOLUTE_WRITE 5
85 #define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6
87 /* flags for kvm_s390_mem_op->flags */
88 #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)
89 #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)
90 #define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2)
92 /* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */
93 #define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0)
94 #define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1)
101 /* valid values for type in kvm_s390_interrupt */
102 #define KVM_S390_SIGP_STOP 0xfffe0000u
103 #define KVM_S390_PROGRAM_INT 0xfffe0001u
104 #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u
105 #define KVM_S390_RESTART 0xfffe0003u
106 #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u
107 #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u
108 #define KVM_S390_MCHK 0xfffe1000u
109 #define KVM_S390_INT_CLOCK_COMP 0xffff1004u
110 #define KVM_S390_INT_CPU_TIMER 0xffff1005u
111 #define KVM_S390_INT_VIRTIO 0xffff2603u
112 #define KVM_S390_INT_SERVICE 0xffff2401u
113 #define KVM_S390_INT_EMERGENCY 0xffff1201u
114 #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u
115 /* Anything below 0xfffe0000u is taken by INT_IO */
116 #define KVM_S390_INT_IO(ai,cssid,ssid,schid) \
121 #define KVM_S390_INT_IO_MIN 0x00000000u
122 #define KVM_S390_INT_IO_MAX 0xfffdffffu
123 #define KVM_S390_INT_IO_AI_MASK 0x04000000u
126 struct kvm_s390_interrupt
{
132 struct kvm_s390_io_info
{
139 struct kvm_s390_ext_info
{
145 struct kvm_s390_pgm_info
{
146 __u64 trans_exc_code
;
157 #define KVM_S390_PGM_FLAGS_ILC_VALID 0x01
158 #define KVM_S390_PGM_FLAGS_ILC_0 0x02
159 #define KVM_S390_PGM_FLAGS_ILC_1 0x04
160 #define KVM_S390_PGM_FLAGS_ILC_MASK 0x06
161 #define KVM_S390_PGM_FLAGS_NO_REWIND 0x08
166 struct kvm_s390_prefix_info
{
170 struct kvm_s390_extcall_info
{
174 struct kvm_s390_emerg_info
{
178 #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01
179 struct kvm_s390_stop_info
{
183 struct kvm_s390_mchk_info
{
186 __u64 failing_storage_address
;
187 __u32 ext_damage_code
;
189 __u8 fixed_logout
[16];
192 struct kvm_s390_irq
{
195 struct kvm_s390_io_info io
;
196 struct kvm_s390_ext_info ext
;
197 struct kvm_s390_pgm_info pgm
;
198 struct kvm_s390_emerg_info emerg
;
199 struct kvm_s390_extcall_info extcall
;
200 struct kvm_s390_prefix_info prefix
;
201 struct kvm_s390_stop_info stop
;
202 struct kvm_s390_mchk_info mchk
;
207 struct kvm_s390_irq_state
{
209 __u32 flags
; /* will stay unused for compatibility reasons */
211 __u32 reserved
[4]; /* will stay unused for compatibility reasons */
214 struct kvm_s390_ucas_mapping
{
220 struct kvm_s390_pv_sec_parm
{
225 struct kvm_s390_pv_unp
{
233 KVM_PV_DUMP_CONFIG_STOR_STATE
,
234 KVM_PV_DUMP_COMPLETE
,
238 struct kvm_s390_pv_dmp
{
242 __u64 gaddr
; /* For dump storage state */
246 enum pv_cmd_info_id
{
251 struct kvm_s390_pv_info_dump
{
252 __u64 dump_cpu_buffer_len
;
253 __u64 dump_config_mem_buffer_per_1m
;
254 __u64 dump_config_finalize_len
;
257 struct kvm_s390_pv_info_vm
{
258 __u64 inst_calls_list
[4];
261 __u64 max_guest_addr
;
262 __u64 feature_indication
;
265 struct kvm_s390_pv_info_header
{
272 struct kvm_s390_pv_info
{
273 struct kvm_s390_pv_info_header header
;
275 struct kvm_s390_pv_info_dump dump
;
276 struct kvm_s390_pv_info_vm vm
;
283 KVM_PV_SET_SEC_PARMS
,
290 KVM_PV_ASYNC_CLEANUP_PREPARE
,
291 KVM_PV_ASYNC_CLEANUP_PERFORM
,
295 __u32 cmd
; /* Command to be executed */
296 __u16 rc
; /* Ultravisor return code */
297 __u16 rrc
; /* Ultravisor return reason code */
298 __u64 data
; /* Data or address */
299 __u32 flags
; /* flags for future extensions. Must be 0 for now */
303 struct kvm_s390_zpci_op
{
305 __u32 fh
; /* target device */
306 __u8 op
; /* operation to perform */
309 /* for KVM_S390_ZPCIOP_REG_AEN */
311 __u64 ibv
; /* Guest addr of interrupt bit vector */
312 __u64 sb
; /* Guest addr of summary bit */
314 __u32 noi
; /* Number of interrupts */
315 __u8 isc
; /* Guest interrupt subclass */
316 __u8 sbo
; /* Offset of guest summary bit vector */
323 /* types for kvm_s390_zpci_op->op */
324 #define KVM_S390_ZPCIOP_REG_AEN 0
325 #define KVM_S390_ZPCIOP_DEREG_AEN 1
327 /* flags for kvm_s390_zpci_op->u.reg_aen.flags */
328 #define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0)
330 /* Device control API: s390-specific devices */
331 #define KVM_DEV_FLIC_GET_ALL_IRQS 1
332 #define KVM_DEV_FLIC_ENQUEUE 2
333 #define KVM_DEV_FLIC_CLEAR_IRQS 3
334 #define KVM_DEV_FLIC_APF_ENABLE 4
335 #define KVM_DEV_FLIC_APF_DISABLE_WAIT 5
336 #define KVM_DEV_FLIC_ADAPTER_REGISTER 6
337 #define KVM_DEV_FLIC_ADAPTER_MODIFY 7
338 #define KVM_DEV_FLIC_CLEAR_IO_IRQ 8
339 #define KVM_DEV_FLIC_AISM 9
340 #define KVM_DEV_FLIC_AIRQ_INJECT 10
341 #define KVM_DEV_FLIC_AISM_ALL 11
343 * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
344 * as well as up to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
345 * There are also sclp and machine checks. This gives us
346 * sizeof(kvm_s390_irq)*(4*65536+8+64*64+1+1) = 72 * 266250 = 19170000
347 * Lets round up to 8192 pages.
349 #define KVM_S390_MAX_FLOAT_IRQS 266250
350 #define KVM_S390_FLIC_MAX_BUFFER 0x2000000
352 struct kvm_s390_io_adapter
{
360 #define KVM_S390_ADAPTER_SUPPRESSIBLE 0x01
362 struct kvm_s390_ais_req
{
367 struct kvm_s390_ais_all
{
372 #define KVM_S390_IO_ADAPTER_MASK 1
373 #define KVM_S390_IO_ADAPTER_MAP 2
374 #define KVM_S390_IO_ADAPTER_UNMAP 3
376 struct kvm_s390_io_adapter_req
{
384 /* kvm attr_group on vm fd */
385 #define KVM_S390_VM_MEM_CTRL 0
386 #define KVM_S390_VM_TOD 1
387 #define KVM_S390_VM_CRYPTO 2
388 #define KVM_S390_VM_CPU_MODEL 3
389 #define KVM_S390_VM_MIGRATION 4
390 #define KVM_S390_VM_CPU_TOPOLOGY 5
392 /* kvm attributes for mem_ctrl */
393 #define KVM_S390_VM_MEM_ENABLE_CMMA 0
394 #define KVM_S390_VM_MEM_CLR_CMMA 1
395 #define KVM_S390_VM_MEM_LIMIT_SIZE 2
397 #define KVM_S390_NO_MEM_LIMIT U64_MAX
399 /* kvm attributes for KVM_S390_VM_TOD */
400 #define KVM_S390_VM_TOD_LOW 0
401 #define KVM_S390_VM_TOD_HIGH 1
402 #define KVM_S390_VM_TOD_EXT 2
404 struct kvm_s390_vm_tod_clock
{
409 /* kvm attributes for KVM_S390_VM_CPU_MODEL */
410 /* processor related attributes are r/w */
411 #define KVM_S390_VM_CPU_PROCESSOR 0
412 struct kvm_s390_vm_cpu_processor
{
419 /* machine related attributes are r/o */
420 #define KVM_S390_VM_CPU_MACHINE 1
421 struct kvm_s390_vm_cpu_machine
{
429 #define KVM_S390_VM_CPU_PROCESSOR_FEAT 2
430 #define KVM_S390_VM_CPU_MACHINE_FEAT 3
432 #define KVM_S390_VM_CPU_FEAT_NR_BITS 1024
433 #define KVM_S390_VM_CPU_FEAT_ESOP 0
434 #define KVM_S390_VM_CPU_FEAT_SIEF2 1
435 #define KVM_S390_VM_CPU_FEAT_64BSCAO 2
436 #define KVM_S390_VM_CPU_FEAT_SIIF 3
437 #define KVM_S390_VM_CPU_FEAT_GPERE 4
438 #define KVM_S390_VM_CPU_FEAT_GSLS 5
439 #define KVM_S390_VM_CPU_FEAT_IB 6
440 #define KVM_S390_VM_CPU_FEAT_CEI 7
441 #define KVM_S390_VM_CPU_FEAT_IBS 8
442 #define KVM_S390_VM_CPU_FEAT_SKEY 9
443 #define KVM_S390_VM_CPU_FEAT_CMMA 10
444 #define KVM_S390_VM_CPU_FEAT_PFMFI 11
445 #define KVM_S390_VM_CPU_FEAT_SIGPIF 12
446 #define KVM_S390_VM_CPU_FEAT_KSS 13
447 struct kvm_s390_vm_cpu_feat
{
451 #define KVM_S390_VM_CPU_PROCESSOR_SUBFUNC 4
452 #define KVM_S390_VM_CPU_MACHINE_SUBFUNC 5
453 /* for "test bit" instructions MSB 0 bit ordering, for "query" raw blocks */
454 struct kvm_s390_vm_cpu_subfunc
{
455 __u8 plo
[32]; /* always */
456 __u8 ptff
[16]; /* with TOD-clock steering */
457 __u8 kmac
[16]; /* with MSA */
458 __u8 kmc
[16]; /* with MSA */
459 __u8 km
[16]; /* with MSA */
460 __u8 kimd
[16]; /* with MSA */
461 __u8 klmd
[16]; /* with MSA */
462 __u8 pckmo
[16]; /* with MSA3 */
463 __u8 kmctr
[16]; /* with MSA4 */
464 __u8 kmf
[16]; /* with MSA4 */
465 __u8 kmo
[16]; /* with MSA4 */
466 __u8 pcc
[16]; /* with MSA4 */
467 __u8 ppno
[16]; /* with MSA5 */
468 __u8 kma
[16]; /* with MSA8 */
469 __u8 kdsa
[16]; /* with MSA9 */
470 __u8 sortl
[32]; /* with STFLE.150 */
471 __u8 dfltcc
[32]; /* with STFLE.151 */
475 #define KVM_S390_VM_CPU_PROCESSOR_UV_FEAT_GUEST 6
476 #define KVM_S390_VM_CPU_MACHINE_UV_FEAT_GUEST 7
478 #define KVM_S390_VM_CPU_UV_FEAT_NR_BITS 64
479 struct kvm_s390_vm_cpu_uv_feat
{
483 __u64 ap
: 1; /* bit 4 */
484 __u64 ap_intr
: 1; /* bit 5 */
491 /* kvm attributes for crypto */
492 #define KVM_S390_VM_CRYPTO_ENABLE_AES_KW 0
493 #define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1
494 #define KVM_S390_VM_CRYPTO_DISABLE_AES_KW 2
495 #define KVM_S390_VM_CRYPTO_DISABLE_DEA_KW 3
496 #define KVM_S390_VM_CRYPTO_ENABLE_APIE 4
497 #define KVM_S390_VM_CRYPTO_DISABLE_APIE 5
499 /* kvm attributes for migration mode */
500 #define KVM_S390_VM_MIGRATION_STOP 0
501 #define KVM_S390_VM_MIGRATION_START 1
502 #define KVM_S390_VM_MIGRATION_STATUS 2
504 /* for KVM_GET_REGS and KVM_SET_REGS */
506 /* general purpose regs for s390 */
510 /* for KVM_GET_SREGS and KVM_SET_SREGS */
516 /* for KVM_GET_FPU and KVM_SET_FPU */
522 #define KVM_GUESTDBG_USE_HW_BP 0x00010000
525 #define KVM_HW_WP_WRITE 2
526 #define KVM_SINGLESTEP 4
528 struct kvm_debug_exit_arch
{
531 __u8 pad
[7]; /* Should be set to 0 */
534 struct kvm_hw_breakpoint
{
539 __u8 pad
[7]; /* Should be set to 0 */
542 /* for KVM_SET_GUEST_DEBUG */
543 struct kvm_guest_debug_arch
{
545 __u32 pad
; /* Should be set to 0 */
546 struct kvm_hw_breakpoint
*hw_bp
;
549 /* for KVM_SYNC_PFAULT and KVM_REG_S390_PFTOKEN */
550 #define KVM_S390_PFAULT_TOKEN_INVALID 0xffffffffffffffffULL
552 #define KVM_SYNC_PREFIX (1UL << 0)
553 #define KVM_SYNC_GPRS (1UL << 1)
554 #define KVM_SYNC_ACRS (1UL << 2)
555 #define KVM_SYNC_CRS (1UL << 3)
556 #define KVM_SYNC_ARCH0 (1UL << 4)
557 #define KVM_SYNC_PFAULT (1UL << 5)
558 #define KVM_SYNC_VRS (1UL << 6)
559 #define KVM_SYNC_RICCB (1UL << 7)
560 #define KVM_SYNC_FPRS (1UL << 8)
561 #define KVM_SYNC_GSCB (1UL << 9)
562 #define KVM_SYNC_BPBC (1UL << 10)
563 #define KVM_SYNC_ETOKEN (1UL << 11)
564 #define KVM_SYNC_DIAG318 (1UL << 12)
566 #define KVM_SYNC_S390_VALID_FIELDS \
567 (KVM_SYNC_PREFIX | KVM_SYNC_GPRS | KVM_SYNC_ACRS | KVM_SYNC_CRS | \
568 KVM_SYNC_ARCH0 | KVM_SYNC_PFAULT | KVM_SYNC_VRS | KVM_SYNC_RICCB | \
569 KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN | \
572 /* length and alignment of the sdnx as a power of two */
574 #define SDNXL (1UL << SDNXC)
575 /* definition of registers in kvm_run */
576 struct kvm_sync_regs
{
577 __u64 prefix
; /* prefix register */
578 __u64 gprs
[16]; /* general purpose registers */
579 __u32 acrs
[16]; /* access registers */
580 __u64 crs
[16]; /* control registers */
581 __u64 todpr
; /* tod programmable register [ARCH0] */
582 __u64 cputm
; /* cpu timer [ARCH0] */
583 __u64 ckc
; /* clock comparator [ARCH0] */
584 __u64 pp
; /* program parameter [ARCH0] */
585 __u64 gbea
; /* guest breaking-event address [ARCH0] */
586 __u64 pft
; /* pfault token [PFAULT] */
587 __u64 pfs
; /* pfault select [PFAULT] */
588 __u64 pfc
; /* pfault compare [PFAULT] */
590 __u64 vrs
[32][2]; /* vector registers (KVM_SYNC_VRS) */
591 __u64 fprs
[16]; /* fp registers (KVM_SYNC_FPRS) */
593 __u8 reserved
[512]; /* for future vector expansion */
594 __u32 fpc
; /* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */
595 __u8 bpbc
: 1; /* bp mode */
597 __u8 padding1
[51]; /* riccb needs to be 64byte aligned */
598 __u8 riccb
[64]; /* runtime instrumentation controls block */
599 __u64 diag318
; /* diagnose 0x318 info */
600 __u8 padding2
[184]; /* sdnx needs to be 256byte aligned */
602 __u8 sdnx
[SDNXL
]; /* state description annex */
607 __u64 etoken_extension
;
612 #define KVM_REG_S390_TODPR (KVM_REG_S390 | KVM_REG_SIZE_U32 | 0x1)
613 #define KVM_REG_S390_EPOCHDIFF (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x2)
614 #define KVM_REG_S390_CPU_TIMER (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x3)
615 #define KVM_REG_S390_CLOCK_COMP (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x4)
616 #define KVM_REG_S390_PFTOKEN (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x5)
617 #define KVM_REG_S390_PFCOMPARE (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x6)
618 #define KVM_REG_S390_PFSELECT (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x7)
619 #define KVM_REG_S390_PP (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x8)
620 #define KVM_REG_S390_GBEA (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x9)