aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/include')
-rw-r--r--arch/s390/include/asm/irq.h1
-rw-r--r--arch/s390/include/asm/kvm_host.h98
-rw-r--r--arch/s390/include/asm/pgtable.h2
-rw-r--r--arch/s390/include/asm/processor.h1
-rw-r--r--arch/s390/include/uapi/asm/kvm.h43
5 files changed, 108 insertions, 37 deletions
diff --git a/arch/s390/include/asm/irq.h b/arch/s390/include/asm/irq.h
index 5f8bcc5fe423..35f0faab5361 100644
--- a/arch/s390/include/asm/irq.h
+++ b/arch/s390/include/asm/irq.h
@@ -53,6 +53,7 @@ enum interruption_class {
53 IRQIO_PCI, 53 IRQIO_PCI,
54 IRQIO_MSI, 54 IRQIO_MSI,
55 IRQIO_VIR, 55 IRQIO_VIR,
56 IRQIO_VAI,
56 NMI_NMI, 57 NMI_NMI,
57 CPU_RST, 58 CPU_RST,
58 NR_ARCH_IRQS 59 NR_ARCH_IRQS
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 9bf95bb30f1a..154b60089be9 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -16,12 +16,22 @@
16#include <linux/hrtimer.h> 16#include <linux/hrtimer.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/kvm_host.h> 18#include <linux/kvm_host.h>
19#include <linux/kvm.h>
19#include <asm/debug.h> 20#include <asm/debug.h>
20#include <asm/cpu.h> 21#include <asm/cpu.h>
22#include <asm/isc.h>
21 23
22#define KVM_MAX_VCPUS 64 24#define KVM_MAX_VCPUS 64
23#define KVM_USER_MEM_SLOTS 32 25#define KVM_USER_MEM_SLOTS 32
24 26
27/*
28 * These seem to be used for allocating ->chip in the routing table,
29 * which we don't use. 4096 is an out-of-thin-air value. If we need
30 * to look at ->chip later on, we'll need to revisit this.
31 */
32#define KVM_NR_IRQCHIPS 1
33#define KVM_IRQCHIP_NUM_PINS 4096
34
25struct sca_entry { 35struct sca_entry {
26 atomic_t scn; 36 atomic_t scn;
27 __u32 reserved; 37 __u32 reserved;
@@ -108,7 +118,9 @@ struct kvm_s390_sie_block {
108 __u32 fac; /* 0x01a0 */ 118 __u32 fac; /* 0x01a0 */
109 __u8 reserved1a4[20]; /* 0x01a4 */ 119 __u8 reserved1a4[20]; /* 0x01a4 */
110 __u64 cbrlo; /* 0x01b8 */ 120 __u64 cbrlo; /* 0x01b8 */
111 __u8 reserved1c0[40]; /* 0x01c0 */ 121 __u8 reserved1c0[30]; /* 0x01c0 */
122 __u64 pp; /* 0x01de */
123 __u8 reserved1e6[2]; /* 0x01e6 */
112 __u64 itdba; /* 0x01e8 */ 124 __u64 itdba; /* 0x01e8 */
113 __u8 reserved1f0[16]; /* 0x01f0 */ 125 __u8 reserved1f0[16]; /* 0x01f0 */
114} __attribute__((packed)); 126} __attribute__((packed));
@@ -171,18 +183,6 @@ struct kvm_vcpu_stat {
171 u32 diagnose_9c; 183 u32 diagnose_9c;
172}; 184};
173 185
174struct kvm_s390_io_info {
175 __u16 subchannel_id; /* 0x0b8 */
176 __u16 subchannel_nr; /* 0x0ba */
177 __u32 io_int_parm; /* 0x0bc */
178 __u32 io_int_word; /* 0x0c0 */
179};
180
181struct kvm_s390_ext_info {
182 __u32 ext_params;
183 __u64 ext_params2;
184};
185
186#define PGM_OPERATION 0x01 186#define PGM_OPERATION 0x01
187#define PGM_PRIVILEGED_OP 0x02 187#define PGM_PRIVILEGED_OP 0x02
188#define PGM_EXECUTE 0x03 188#define PGM_EXECUTE 0x03
@@ -191,27 +191,6 @@ struct kvm_s390_ext_info {
191#define PGM_SPECIFICATION 0x06 191#define PGM_SPECIFICATION 0x06
192#define PGM_DATA 0x07 192#define PGM_DATA 0x07
193 193
194struct kvm_s390_pgm_info {
195 __u16 code;
196};
197
198struct kvm_s390_prefix_info {
199 __u32 address;
200};
201
202struct kvm_s390_extcall_info {
203 __u16 code;
204};
205
206struct kvm_s390_emerg_info {
207 __u16 code;
208};
209
210struct kvm_s390_mchk_info {
211 __u64 cr14;
212 __u64 mcic;
213};
214
215struct kvm_s390_interrupt_info { 194struct kvm_s390_interrupt_info {
216 struct list_head list; 195 struct list_head list;
217 u64 type; 196 u64 type;
@@ -246,9 +225,8 @@ struct kvm_s390_float_interrupt {
246 struct list_head list; 225 struct list_head list;
247 atomic_t active; 226 atomic_t active;
248 int next_rr_cpu; 227 int next_rr_cpu;
249 unsigned long idle_mask[(KVM_MAX_VCPUS + sizeof(long) - 1) 228 unsigned long idle_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)];
250 / sizeof(long)]; 229 unsigned int irq_count;
251 struct kvm_s390_local_interrupt *local_int[KVM_MAX_VCPUS];
252}; 230};
253 231
254 232
@@ -265,6 +243,10 @@ struct kvm_vcpu_arch {
265 u64 stidp_data; 243 u64 stidp_data;
266 }; 244 };
267 struct gmap *gmap; 245 struct gmap *gmap;
246#define KVM_S390_PFAULT_TOKEN_INVALID (-1UL)
247 unsigned long pfault_token;
248 unsigned long pfault_select;
249 unsigned long pfault_compare;
268}; 250};
269 251
270struct kvm_vm_stat { 252struct kvm_vm_stat {
@@ -274,12 +256,36 @@ struct kvm_vm_stat {
274struct kvm_arch_memory_slot { 256struct kvm_arch_memory_slot {
275}; 257};
276 258
259struct s390_map_info {
260 struct list_head list;
261 __u64 guest_addr;
262 __u64 addr;
263 struct page *page;
264};
265
266struct s390_io_adapter {
267 unsigned int id;
268 int isc;
269 bool maskable;
270 bool masked;
271 bool swap;
272 struct rw_semaphore maps_lock;
273 struct list_head maps;
274 atomic_t nr_maps;
275};
276
277#define MAX_S390_IO_ADAPTERS ((MAX_ISC + 1) * 8)
278#define MAX_S390_ADAPTER_MAPS 256
279
277struct kvm_arch{ 280struct kvm_arch{
278 struct sca_block *sca; 281 struct sca_block *sca;
279 debug_info_t *dbf; 282 debug_info_t *dbf;
280 struct kvm_s390_float_interrupt float_int; 283 struct kvm_s390_float_interrupt float_int;
284 struct kvm_device *flic;
281 struct gmap *gmap; 285 struct gmap *gmap;
282 int css_support; 286 int css_support;
287 int use_irqchip;
288 struct s390_io_adapter *adapters[MAX_S390_IO_ADAPTERS];
283}; 289};
284 290
285#define KVM_HVA_ERR_BAD (-1UL) 291#define KVM_HVA_ERR_BAD (-1UL)
@@ -290,6 +296,24 @@ static inline bool kvm_is_error_hva(unsigned long addr)
290 return IS_ERR_VALUE(addr); 296 return IS_ERR_VALUE(addr);
291} 297}
292 298
299#define ASYNC_PF_PER_VCPU 64
300struct kvm_vcpu;
301struct kvm_async_pf;
302struct kvm_arch_async_pf {
303 unsigned long pfault_token;
304};
305
306bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu);
307
308void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
309 struct kvm_async_pf *work);
310
311void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu,
312 struct kvm_async_pf *work);
313
314void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
315 struct kvm_async_pf *work);
316
293extern int sie64a(struct kvm_s390_sie_block *, u64 *); 317extern int sie64a(struct kvm_s390_sie_block *, u64 *);
294extern char sie_exit; 318extern char sie_exit;
295#endif 319#endif
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 1ab75eaacbd4..50a75d96f939 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -782,6 +782,7 @@ static inline void pgste_set_pte(pte_t *ptep, pte_t entry)
782 * @table: pointer to the page directory 782 * @table: pointer to the page directory
783 * @asce: address space control element for gmap page table 783 * @asce: address space control element for gmap page table
784 * @crst_list: list of all crst tables used in the guest address space 784 * @crst_list: list of all crst tables used in the guest address space
785 * @pfault_enabled: defines if pfaults are applicable for the guest
785 */ 786 */
786struct gmap { 787struct gmap {
787 struct list_head list; 788 struct list_head list;
@@ -790,6 +791,7 @@ struct gmap {
790 unsigned long asce; 791 unsigned long asce;
791 void *private; 792 void *private;
792 struct list_head crst_list; 793 struct list_head crst_list;
794 bool pfault_enabled;
793}; 795};
794 796
795/** 797/**
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 0a876bc543d3..dc5fc4f90e52 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -79,6 +79,7 @@ struct thread_struct {
79 unsigned long ksp; /* kernel stack pointer */ 79 unsigned long ksp; /* kernel stack pointer */
80 mm_segment_t mm_segment; 80 mm_segment_t mm_segment;
81 unsigned long gmap_addr; /* address of last gmap fault. */ 81 unsigned long gmap_addr; /* address of last gmap fault. */
82 unsigned int gmap_pfault; /* signal of a pending guest pfault */
82 struct per_regs per_user; /* User specified PER registers */ 83 struct per_regs per_user; /* User specified PER registers */
83 struct per_event per_event; /* Cause of the last PER trap */ 84 struct per_event per_event; /* Cause of the last PER trap */
84 unsigned long per_flags; /* Flags to control debug behavior */ 85 unsigned long per_flags; /* Flags to control debug behavior */
diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
index d25da598ec62..c003c6a73b1e 100644
--- a/arch/s390/include/uapi/asm/kvm.h
+++ b/arch/s390/include/uapi/asm/kvm.h
@@ -16,6 +16,44 @@
16 16
17#define __KVM_S390 17#define __KVM_S390
18 18
19/* Device control API: s390-specific devices */
20#define KVM_DEV_FLIC_GET_ALL_IRQS 1
21#define KVM_DEV_FLIC_ENQUEUE 2
22#define KVM_DEV_FLIC_CLEAR_IRQS 3
23#define KVM_DEV_FLIC_APF_ENABLE 4
24#define KVM_DEV_FLIC_APF_DISABLE_WAIT 5
25#define KVM_DEV_FLIC_ADAPTER_REGISTER 6
26#define KVM_DEV_FLIC_ADAPTER_MODIFY 7
27/*
28 * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
29 * as well as up to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
30 * There are also sclp and machine checks. This gives us
31 * sizeof(kvm_s390_irq)*(4*65536+8+64*64+1+1) = 72 * 266250 = 19170000
32 * Lets round up to 8192 pages.
33 */
34#define KVM_S390_MAX_FLOAT_IRQS 266250
35#define KVM_S390_FLIC_MAX_BUFFER 0x2000000
36
37struct kvm_s390_io_adapter {
38 __u32 id;
39 __u8 isc;
40 __u8 maskable;
41 __u8 swap;
42 __u8 pad;
43};
44
45#define KVM_S390_IO_ADAPTER_MASK 1
46#define KVM_S390_IO_ADAPTER_MAP 2
47#define KVM_S390_IO_ADAPTER_UNMAP 3
48
49struct kvm_s390_io_adapter_req {
50 __u32 id;
51 __u8 type;
52 __u8 mask;
53 __u16 pad0;
54 __u64 addr;
55};
56
19/* for KVM_GET_REGS and KVM_SET_REGS */ 57/* for KVM_GET_REGS and KVM_SET_REGS */
20struct kvm_regs { 58struct kvm_regs {
21 /* general purpose regs for s390 */ 59 /* general purpose regs for s390 */
@@ -57,4 +95,9 @@ struct kvm_sync_regs {
57#define KVM_REG_S390_EPOCHDIFF (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x2) 95#define KVM_REG_S390_EPOCHDIFF (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x2)
58#define KVM_REG_S390_CPU_TIMER (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x3) 96#define KVM_REG_S390_CPU_TIMER (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x3)
59#define KVM_REG_S390_CLOCK_COMP (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x4) 97#define KVM_REG_S390_CLOCK_COMP (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x4)
98#define KVM_REG_S390_PFTOKEN (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x5)
99#define KVM_REG_S390_PFCOMPARE (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x6)
100#define KVM_REG_S390_PFSELECT (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x7)
101#define KVM_REG_S390_PP (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x8)
102#define KVM_REG_S390_GBEA (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x9)
60#endif 103#endif