kvm-s390.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * definition for kvm on s390
  4. *
  5. * Copyright IBM Corp. 2008, 2020
  6. *
  7. * Author(s): Carsten Otte <[email protected]>
  8. * Christian Borntraeger <[email protected]>
  9. * Christian Ehrhardt <[email protected]>
  10. */
  11. #ifndef ARCH_S390_KVM_S390_H
  12. #define ARCH_S390_KVM_S390_H
  13. #include <linux/hrtimer.h>
  14. #include <linux/kvm.h>
  15. #include <linux/kvm_host.h>
  16. #include <linux/lockdep.h>
  17. #include <asm/facility.h>
  18. #include <asm/processor.h>
  19. #include <asm/sclp.h>
  20. /* Transactional Memory Execution related macros */
  21. #define IS_TE_ENABLED(vcpu) ((vcpu->arch.sie_block->ecb & ECB_TE))
  22. #define TDB_FORMAT1 1
  23. #define IS_ITDB_VALID(vcpu) ((*(char *)vcpu->arch.sie_block->itdba == TDB_FORMAT1))
  24. extern debug_info_t *kvm_s390_dbf;
  25. extern debug_info_t *kvm_s390_dbf_uv;
  26. #define KVM_UV_EVENT(d_kvm, d_loglevel, d_string, d_args...)\
  27. do { \
  28. debug_sprintf_event((d_kvm)->arch.dbf, d_loglevel, d_string "\n", \
  29. d_args); \
  30. debug_sprintf_event(kvm_s390_dbf_uv, d_loglevel, \
  31. "%d: " d_string "\n", (d_kvm)->userspace_pid, \
  32. d_args); \
  33. } while (0)
  34. #define KVM_EVENT(d_loglevel, d_string, d_args...)\
  35. do { \
  36. debug_sprintf_event(kvm_s390_dbf, d_loglevel, d_string "\n", \
  37. d_args); \
  38. } while (0)
  39. #define VM_EVENT(d_kvm, d_loglevel, d_string, d_args...)\
  40. do { \
  41. debug_sprintf_event(d_kvm->arch.dbf, d_loglevel, d_string "\n", \
  42. d_args); \
  43. } while (0)
  44. #define VCPU_EVENT(d_vcpu, d_loglevel, d_string, d_args...)\
  45. do { \
  46. debug_sprintf_event(d_vcpu->kvm->arch.dbf, d_loglevel, \
  47. "%02d[%016lx-%016lx]: " d_string "\n", d_vcpu->vcpu_id, \
  48. d_vcpu->arch.sie_block->gpsw.mask, d_vcpu->arch.sie_block->gpsw.addr,\
  49. d_args); \
  50. } while (0)
  51. static inline void kvm_s390_set_cpuflags(struct kvm_vcpu *vcpu, u32 flags)
  52. {
  53. atomic_or(flags, &vcpu->arch.sie_block->cpuflags);
  54. }
  55. static inline void kvm_s390_clear_cpuflags(struct kvm_vcpu *vcpu, u32 flags)
  56. {
  57. atomic_andnot(flags, &vcpu->arch.sie_block->cpuflags);
  58. }
  59. static inline bool kvm_s390_test_cpuflags(struct kvm_vcpu *vcpu, u32 flags)
  60. {
  61. return (atomic_read(&vcpu->arch.sie_block->cpuflags) & flags) == flags;
  62. }
  63. static inline int is_vcpu_stopped(struct kvm_vcpu *vcpu)
  64. {
  65. return kvm_s390_test_cpuflags(vcpu, CPUSTAT_STOPPED);
  66. }
  67. static inline int is_vcpu_idle(struct kvm_vcpu *vcpu)
  68. {
  69. return test_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask);
  70. }
  71. static inline int kvm_is_ucontrol(struct kvm *kvm)
  72. {
  73. #ifdef CONFIG_KVM_S390_UCONTROL
  74. if (kvm->arch.gmap)
  75. return 0;
  76. return 1;
  77. #else
  78. return 0;
  79. #endif
  80. }
  81. #define GUEST_PREFIX_SHIFT 13
  82. static inline u32 kvm_s390_get_prefix(struct kvm_vcpu *vcpu)
  83. {
  84. return vcpu->arch.sie_block->prefix << GUEST_PREFIX_SHIFT;
  85. }
  86. static inline void kvm_s390_set_prefix(struct kvm_vcpu *vcpu, u32 prefix)
  87. {
  88. VCPU_EVENT(vcpu, 3, "set prefix of cpu %03u to 0x%x", vcpu->vcpu_id,
  89. prefix);
  90. vcpu->arch.sie_block->prefix = prefix >> GUEST_PREFIX_SHIFT;
  91. kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
  92. kvm_make_request(KVM_REQ_REFRESH_GUEST_PREFIX, vcpu);
  93. }
  94. static inline u64 kvm_s390_get_base_disp_s(struct kvm_vcpu *vcpu, u8 *ar)
  95. {
  96. u32 base2 = vcpu->arch.sie_block->ipb >> 28;
  97. u32 disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16);
  98. if (ar)
  99. *ar = base2;
  100. return (base2 ? vcpu->run->s.regs.gprs[base2] : 0) + disp2;
  101. }
  102. static inline void kvm_s390_get_base_disp_sse(struct kvm_vcpu *vcpu,
  103. u64 *address1, u64 *address2,
  104. u8 *ar_b1, u8 *ar_b2)
  105. {
  106. u32 base1 = (vcpu->arch.sie_block->ipb & 0xf0000000) >> 28;
  107. u32 disp1 = (vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16;
  108. u32 base2 = (vcpu->arch.sie_block->ipb & 0xf000) >> 12;
  109. u32 disp2 = vcpu->arch.sie_block->ipb & 0x0fff;
  110. *address1 = (base1 ? vcpu->run->s.regs.gprs[base1] : 0) + disp1;
  111. *address2 = (base2 ? vcpu->run->s.regs.gprs[base2] : 0) + disp2;
  112. if (ar_b1)
  113. *ar_b1 = base1;
  114. if (ar_b2)
  115. *ar_b2 = base2;
  116. }
  117. static inline void kvm_s390_get_regs_rre(struct kvm_vcpu *vcpu, int *r1, int *r2)
  118. {
  119. if (r1)
  120. *r1 = (vcpu->arch.sie_block->ipb & 0x00f00000) >> 20;
  121. if (r2)
  122. *r2 = (vcpu->arch.sie_block->ipb & 0x000f0000) >> 16;
  123. }
  124. static inline u64 kvm_s390_get_base_disp_rsy(struct kvm_vcpu *vcpu, u8 *ar)
  125. {
  126. u32 base2 = vcpu->arch.sie_block->ipb >> 28;
  127. u32 disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16) +
  128. ((vcpu->arch.sie_block->ipb & 0xff00) << 4);
  129. /* The displacement is a 20bit _SIGNED_ value */
  130. if (disp2 & 0x80000)
  131. disp2+=0xfff00000;
  132. if (ar)
  133. *ar = base2;
  134. return (base2 ? vcpu->run->s.regs.gprs[base2] : 0) + (long)(int)disp2;
  135. }
  136. static inline u64 kvm_s390_get_base_disp_rs(struct kvm_vcpu *vcpu, u8 *ar)
  137. {
  138. u32 base2 = vcpu->arch.sie_block->ipb >> 28;
  139. u32 disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16);
  140. if (ar)
  141. *ar = base2;
  142. return (base2 ? vcpu->run->s.regs.gprs[base2] : 0) + disp2;
  143. }
  144. /* Set the condition code in the guest program status word */
  145. static inline void kvm_s390_set_psw_cc(struct kvm_vcpu *vcpu, unsigned long cc)
  146. {
  147. vcpu->arch.sie_block->gpsw.mask &= ~(3UL << 44);
  148. vcpu->arch.sie_block->gpsw.mask |= cc << 44;
  149. }
  150. /* test availability of facility in a kvm instance */
  151. static inline int test_kvm_facility(struct kvm *kvm, unsigned long nr)
  152. {
  153. return __test_facility(nr, kvm->arch.model.fac_mask) &&
  154. __test_facility(nr, kvm->arch.model.fac_list);
  155. }
  156. static inline int set_kvm_facility(u64 *fac_list, unsigned long nr)
  157. {
  158. unsigned char *ptr;
  159. if (nr >= MAX_FACILITY_BIT)
  160. return -EINVAL;
  161. ptr = (unsigned char *) fac_list + (nr >> 3);
  162. *ptr |= (0x80UL >> (nr & 7));
  163. return 0;
  164. }
  165. static inline int test_kvm_cpu_feat(struct kvm *kvm, unsigned long nr)
  166. {
  167. WARN_ON_ONCE(nr >= KVM_S390_VM_CPU_FEAT_NR_BITS);
  168. return test_bit_inv(nr, kvm->arch.cpu_feat);
  169. }
  170. /* are cpu states controlled by user space */
  171. static inline int kvm_s390_user_cpu_state_ctrl(struct kvm *kvm)
  172. {
  173. return kvm->arch.user_cpu_state_ctrl != 0;
  174. }
  175. static inline void kvm_s390_set_user_cpu_state_ctrl(struct kvm *kvm)
  176. {
  177. if (kvm->arch.user_cpu_state_ctrl)
  178. return;
  179. VM_EVENT(kvm, 3, "%s", "ENABLE: Userspace CPU state control");
  180. kvm->arch.user_cpu_state_ctrl = 1;
  181. }
  182. /* get the end gfn of the last (highest gfn) memslot */
  183. static inline unsigned long kvm_s390_get_gfn_end(struct kvm_memslots *slots)
  184. {
  185. struct rb_node *node;
  186. struct kvm_memory_slot *ms;
  187. if (WARN_ON(kvm_memslots_empty(slots)))
  188. return 0;
  189. node = rb_last(&slots->gfn_tree);
  190. ms = container_of(node, struct kvm_memory_slot, gfn_node[slots->node_idx]);
  191. return ms->base_gfn + ms->npages;
  192. }
  193. static inline u32 kvm_s390_get_gisa_desc(struct kvm *kvm)
  194. {
  195. u32 gd = (u32)(u64)kvm->arch.gisa_int.origin;
  196. if (gd && sclp.has_gisaf)
  197. gd |= GISA_FORMAT1;
  198. return gd;
  199. }
  200. /* implemented in pv.c */
  201. int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);
  202. int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);
  203. int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc);
  204. int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc);
  205. int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc,
  206. u16 *rrc);
  207. int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size,
  208. unsigned long tweak, u16 *rc, u16 *rrc);
  209. int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state);
  210. int kvm_s390_pv_dump_cpu(struct kvm_vcpu *vcpu, void *buff, u16 *rc, u16 *rrc);
  211. int kvm_s390_pv_dump_stor_state(struct kvm *kvm, void __user *buff_user,
  212. u64 *gaddr, u64 buff_user_len, u16 *rc, u16 *rrc);
  213. int kvm_s390_pv_dump_complete(struct kvm *kvm, void __user *buff_user,
  214. u16 *rc, u16 *rrc);
  215. static inline u64 kvm_s390_pv_get_handle(struct kvm *kvm)
  216. {
  217. return kvm->arch.pv.handle;
  218. }
  219. static inline u64 kvm_s390_pv_cpu_get_handle(struct kvm_vcpu *vcpu)
  220. {
  221. return vcpu->arch.pv.handle;
  222. }
  223. static inline bool kvm_s390_pv_is_protected(struct kvm *kvm)
  224. {
  225. lockdep_assert_held(&kvm->lock);
  226. return !!kvm_s390_pv_get_handle(kvm);
  227. }
  228. static inline bool kvm_s390_pv_cpu_is_protected(struct kvm_vcpu *vcpu)
  229. {
  230. lockdep_assert_held(&vcpu->mutex);
  231. return !!kvm_s390_pv_cpu_get_handle(vcpu);
  232. }
  233. /* implemented in interrupt.c */
  234. int kvm_s390_handle_wait(struct kvm_vcpu *vcpu);
  235. void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu);
  236. enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer);
  237. int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu);
  238. void kvm_s390_clear_local_irqs(struct kvm_vcpu *vcpu);
  239. void kvm_s390_clear_float_irqs(struct kvm *kvm);
  240. int __must_check kvm_s390_inject_vm(struct kvm *kvm,
  241. struct kvm_s390_interrupt *s390int);
  242. int __must_check kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
  243. struct kvm_s390_irq *irq);
  244. static inline int kvm_s390_inject_prog_irq(struct kvm_vcpu *vcpu,
  245. struct kvm_s390_pgm_info *pgm_info)
  246. {
  247. struct kvm_s390_irq irq = {
  248. .type = KVM_S390_PROGRAM_INT,
  249. .u.pgm = *pgm_info,
  250. };
  251. return kvm_s390_inject_vcpu(vcpu, &irq);
  252. }
  253. static inline int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code)
  254. {
  255. struct kvm_s390_irq irq = {
  256. .type = KVM_S390_PROGRAM_INT,
  257. .u.pgm.code = code,
  258. };
  259. return kvm_s390_inject_vcpu(vcpu, &irq);
  260. }
  261. struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
  262. u64 isc_mask, u32 schid);
  263. int kvm_s390_reinject_io_int(struct kvm *kvm,
  264. struct kvm_s390_interrupt_info *inti);
  265. int kvm_s390_mask_adapter(struct kvm *kvm, unsigned int id, bool masked);
  266. /* implemented in intercept.c */
  267. u8 kvm_s390_get_ilen(struct kvm_vcpu *vcpu);
  268. int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu);
  269. static inline void kvm_s390_rewind_psw(struct kvm_vcpu *vcpu, int ilen)
  270. {
  271. struct kvm_s390_sie_block *sie_block = vcpu->arch.sie_block;
  272. sie_block->gpsw.addr = __rewind_psw(sie_block->gpsw, ilen);
  273. }
  274. static inline void kvm_s390_forward_psw(struct kvm_vcpu *vcpu, int ilen)
  275. {
  276. kvm_s390_rewind_psw(vcpu, -ilen);
  277. }
  278. static inline void kvm_s390_retry_instr(struct kvm_vcpu *vcpu)
  279. {
  280. /* don't inject PER events if we re-execute the instruction */
  281. vcpu->arch.sie_block->icptstatus &= ~0x02;
  282. kvm_s390_rewind_psw(vcpu, kvm_s390_get_ilen(vcpu));
  283. }
  284. int handle_sthyi(struct kvm_vcpu *vcpu);
  285. /* implemented in priv.c */
  286. int is_valid_psw(psw_t *psw);
  287. int kvm_s390_handle_aa(struct kvm_vcpu *vcpu);
  288. int kvm_s390_handle_b2(struct kvm_vcpu *vcpu);
  289. int kvm_s390_handle_e3(struct kvm_vcpu *vcpu);
  290. int kvm_s390_handle_e5(struct kvm_vcpu *vcpu);
  291. int kvm_s390_handle_01(struct kvm_vcpu *vcpu);
  292. int kvm_s390_handle_b9(struct kvm_vcpu *vcpu);
  293. int kvm_s390_handle_lpsw(struct kvm_vcpu *vcpu);
  294. int kvm_s390_handle_stctl(struct kvm_vcpu *vcpu);
  295. int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu);
  296. int kvm_s390_handle_eb(struct kvm_vcpu *vcpu);
  297. int kvm_s390_skey_check_enable(struct kvm_vcpu *vcpu);
  298. /* implemented in vsie.c */
  299. int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu);
  300. void kvm_s390_vsie_kick(struct kvm_vcpu *vcpu);
  301. void kvm_s390_vsie_gmap_notifier(struct gmap *gmap, unsigned long start,
  302. unsigned long end);
  303. void kvm_s390_vsie_init(struct kvm *kvm);
  304. void kvm_s390_vsie_destroy(struct kvm *kvm);
  305. /* implemented in sigp.c */
  306. int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu);
  307. int kvm_s390_handle_sigp_pei(struct kvm_vcpu *vcpu);
  308. /* implemented in kvm-s390.c */
  309. int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_clock *gtod);
  310. long kvm_arch_fault_in_page(struct kvm_vcpu *vcpu, gpa_t gpa, int writable);
  311. int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr);
  312. int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr);
  313. int kvm_s390_vcpu_start(struct kvm_vcpu *vcpu);
  314. int kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu);
  315. void kvm_s390_vcpu_block(struct kvm_vcpu *vcpu);
  316. void kvm_s390_vcpu_unblock(struct kvm_vcpu *vcpu);
  317. bool kvm_s390_vcpu_sie_inhibited(struct kvm_vcpu *vcpu);
  318. void exit_sie(struct kvm_vcpu *vcpu);
  319. void kvm_s390_sync_request(int req, struct kvm_vcpu *vcpu);
  320. int kvm_s390_vcpu_setup_cmma(struct kvm_vcpu *vcpu);
  321. void kvm_s390_vcpu_unsetup_cmma(struct kvm_vcpu *vcpu);
  322. void kvm_s390_set_cpu_timer(struct kvm_vcpu *vcpu, __u64 cputm);
  323. __u64 kvm_s390_get_cpu_timer(struct kvm_vcpu *vcpu);
  324. int kvm_s390_cpus_from_pv(struct kvm *kvm, u16 *rc, u16 *rrc);
  325. /* implemented in diag.c */
  326. int kvm_s390_handle_diag(struct kvm_vcpu *vcpu);
  327. static inline void kvm_s390_vcpu_block_all(struct kvm *kvm)
  328. {
  329. unsigned long i;
  330. struct kvm_vcpu *vcpu;
  331. WARN_ON(!mutex_is_locked(&kvm->lock));
  332. kvm_for_each_vcpu(i, vcpu, kvm)
  333. kvm_s390_vcpu_block(vcpu);
  334. }
  335. static inline void kvm_s390_vcpu_unblock_all(struct kvm *kvm)
  336. {
  337. unsigned long i;
  338. struct kvm_vcpu *vcpu;
  339. kvm_for_each_vcpu(i, vcpu, kvm)
  340. kvm_s390_vcpu_unblock(vcpu);
  341. }
  342. static inline u64 kvm_s390_get_tod_clock_fast(struct kvm *kvm)
  343. {
  344. u64 rc;
  345. preempt_disable();
  346. rc = get_tod_clock_fast() + kvm->arch.epoch;
  347. preempt_enable();
  348. return rc;
  349. }
  350. /**
  351. * kvm_s390_inject_prog_cond - conditionally inject a program check
  352. * @vcpu: virtual cpu
  353. * @rc: original return/error code
  354. *
  355. * This function is supposed to be used after regular guest access functions
  356. * failed, to conditionally inject a program check to a vcpu. The typical
  357. * pattern would look like
  358. *
  359. * rc = write_guest(vcpu, addr, data, len);
  360. * if (rc)
  361. * return kvm_s390_inject_prog_cond(vcpu, rc);
  362. *
  363. * A negative return code from guest access functions implies an internal error
  364. * like e.g. out of memory. In these cases no program check should be injected
  365. * to the guest.
  366. * A positive value implies that an exception happened while accessing a guest's
  367. * memory. In this case all data belonging to the corresponding program check
  368. * has been stored in vcpu->arch.pgm and can be injected with
  369. * kvm_s390_inject_prog_irq().
  370. *
  371. * Returns: - the original @rc value if @rc was negative (internal error)
  372. * - zero if @rc was already zero
  373. * - zero or error code from injecting if @rc was positive
  374. * (program check injected to @vcpu)
  375. */
  376. static inline int kvm_s390_inject_prog_cond(struct kvm_vcpu *vcpu, int rc)
  377. {
  378. if (rc <= 0)
  379. return rc;
  380. return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm);
  381. }
  382. int s390int_to_s390irq(struct kvm_s390_interrupt *s390int,
  383. struct kvm_s390_irq *s390irq);
  384. /* implemented in interrupt.c */
  385. int kvm_s390_vcpu_has_irq(struct kvm_vcpu *vcpu, int exclude_stop);
  386. int psw_extint_disabled(struct kvm_vcpu *vcpu);
  387. void kvm_s390_destroy_adapters(struct kvm *kvm);
  388. int kvm_s390_ext_call_pending(struct kvm_vcpu *vcpu);
  389. extern struct kvm_device_ops kvm_flic_ops;
  390. int kvm_s390_is_stop_irq_pending(struct kvm_vcpu *vcpu);
  391. int kvm_s390_is_restart_irq_pending(struct kvm_vcpu *vcpu);
  392. void kvm_s390_clear_stop_irq(struct kvm_vcpu *vcpu);
  393. int kvm_s390_set_irq_state(struct kvm_vcpu *vcpu,
  394. void __user *buf, int len);
  395. int kvm_s390_get_irq_state(struct kvm_vcpu *vcpu,
  396. __u8 __user *buf, int len);
  397. void kvm_s390_gisa_init(struct kvm *kvm);
  398. void kvm_s390_gisa_clear(struct kvm *kvm);
  399. void kvm_s390_gisa_destroy(struct kvm *kvm);
  400. void kvm_s390_gisa_disable(struct kvm *kvm);
  401. void kvm_s390_gisa_enable(struct kvm *kvm);
  402. int kvm_s390_gib_init(u8 nisc);
  403. void kvm_s390_gib_destroy(void);
  404. /* implemented in guestdbg.c */
  405. void kvm_s390_backup_guest_per_regs(struct kvm_vcpu *vcpu);
  406. void kvm_s390_restore_guest_per_regs(struct kvm_vcpu *vcpu);
  407. void kvm_s390_patch_guest_per_regs(struct kvm_vcpu *vcpu);
  408. int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
  409. struct kvm_guest_debug *dbg);
  410. void kvm_s390_clear_bp_data(struct kvm_vcpu *vcpu);
  411. void kvm_s390_prepare_debug_exit(struct kvm_vcpu *vcpu);
  412. int kvm_s390_handle_per_ifetch_icpt(struct kvm_vcpu *vcpu);
  413. int kvm_s390_handle_per_event(struct kvm_vcpu *vcpu);
  414. /* support for Basic/Extended SCA handling */
  415. static inline union ipte_control *kvm_s390_get_ipte_control(struct kvm *kvm)
  416. {
  417. struct bsca_block *sca = kvm->arch.sca; /* SCA version doesn't matter */
  418. return &sca->ipte_control;
  419. }
  420. static inline int kvm_s390_use_sca_entries(void)
  421. {
  422. /*
  423. * Without SIGP interpretation, only SRS interpretation (if available)
  424. * might use the entries. By not setting the entries and keeping them
  425. * invalid, hardware will not access them but intercept.
  426. */
  427. return sclp.has_sigpif;
  428. }
  429. void kvm_s390_reinject_machine_check(struct kvm_vcpu *vcpu,
  430. struct mcck_volatile_info *mcck_info);
  431. /**
  432. * kvm_s390_vcpu_crypto_reset_all
  433. *
  434. * Reset the crypto attributes for each vcpu. This can be done while the vcpus
  435. * are running as each vcpu will be removed from SIE before resetting the crypt
  436. * attributes and restored to SIE afterward.
  437. *
  438. * Note: The kvm->lock must be held while calling this function
  439. *
  440. * @kvm: the KVM guest
  441. */
  442. void kvm_s390_vcpu_crypto_reset_all(struct kvm *kvm);
  443. /**
  444. * kvm_s390_vcpu_pci_enable_interp
  445. *
  446. * Set the associated PCI attributes for each vcpu to allow for zPCI Load/Store
  447. * interpretation as well as adapter interruption forwarding.
  448. *
  449. * @kvm: the KVM guest
  450. */
  451. void kvm_s390_vcpu_pci_enable_interp(struct kvm *kvm);
  452. /**
  453. * diag9c_forwarding_hz
  454. *
  455. * Set the maximum number of diag9c forwarding per second
  456. */
  457. extern unsigned int diag9c_forwarding_hz;
  458. #endif