s390_flic_kvm.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /*
  2. * QEMU S390x KVM floating interrupt controller (flic)
  3. *
  4. * Copyright 2014 IBM Corp.
  5. * Author(s): Jens Freimann <jfrei@linux.vnet.ibm.com>
  6. * Cornelia Huck <cornelia.huck@de.ibm.com>
  7. *
  8. * This work is licensed under the terms of the GNU GPL, version 2 or (at
  9. * your option) any later version. See the COPYING file in the top-level
  10. * directory.
  11. */
  12. #include "qemu/osdep.h"
  13. #include "cpu.h"
  14. #include "kvm_s390x.h"
  15. #include <sys/ioctl.h>
  16. #include "qemu/error-report.h"
  17. #include "qemu/module.h"
  18. #include "qapi/error.h"
  19. #include "hw/sysbus.h"
  20. #include "sysemu/kvm.h"
  21. #include "hw/s390x/s390_flic.h"
  22. #include "hw/s390x/adapter.h"
  23. #include "hw/s390x/css.h"
  24. #include "migration/qemu-file-types.h"
  25. #include "trace.h"
  26. #define FLIC_SAVE_INITIAL_SIZE qemu_real_host_page_size
  27. #define FLIC_FAILED (-1UL)
  28. #define FLIC_SAVEVM_VERSION 1
  29. typedef struct KVMS390FLICState {
  30. S390FLICState parent_obj;
  31. uint32_t fd;
  32. bool clear_io_supported;
  33. } KVMS390FLICState;
  34. static KVMS390FLICState *s390_get_kvm_flic(S390FLICState *fs)
  35. {
  36. static KVMS390FLICState *flic;
  37. if (!flic) {
  38. /* we only have one flic device, so this is fine to cache */
  39. flic = KVM_S390_FLIC(fs);
  40. }
  41. return flic;
  42. }
  43. /**
  44. * flic_get_all_irqs - store all pending irqs in buffer
  45. * @buf: pointer to buffer which is passed to kernel
  46. * @len: length of buffer
  47. * @flic: pointer to flic device state
  48. *
  49. * Returns: -ENOMEM if buffer is too small,
  50. * -EINVAL if attr.group is invalid,
  51. * -EFAULT if copying to userspace failed,
  52. * on success return number of stored interrupts
  53. */
  54. static int flic_get_all_irqs(KVMS390FLICState *flic,
  55. void *buf, int len)
  56. {
  57. struct kvm_device_attr attr = {
  58. .group = KVM_DEV_FLIC_GET_ALL_IRQS,
  59. .addr = (uint64_t) buf,
  60. .attr = len,
  61. };
  62. int rc;
  63. rc = ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr);
  64. return rc == -1 ? -errno : rc;
  65. }
  66. static void flic_enable_pfault(KVMS390FLICState *flic)
  67. {
  68. struct kvm_device_attr attr = {
  69. .group = KVM_DEV_FLIC_APF_ENABLE,
  70. };
  71. int rc;
  72. rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
  73. if (rc) {
  74. fprintf(stderr, "flic: couldn't enable pfault\n");
  75. }
  76. }
  77. static void flic_disable_wait_pfault(KVMS390FLICState *flic)
  78. {
  79. struct kvm_device_attr attr = {
  80. .group = KVM_DEV_FLIC_APF_DISABLE_WAIT,
  81. };
  82. int rc;
  83. rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
  84. if (rc) {
  85. fprintf(stderr, "flic: couldn't disable pfault\n");
  86. }
  87. }
  88. /** flic_enqueue_irqs - returns 0 on success
  89. * @buf: pointer to buffer which is passed to kernel
  90. * @len: length of buffer
  91. * @flic: pointer to flic device state
  92. *
  93. * Returns: -EINVAL if attr.group is unknown
  94. */
  95. static int flic_enqueue_irqs(void *buf, uint64_t len,
  96. KVMS390FLICState *flic)
  97. {
  98. int rc;
  99. struct kvm_device_attr attr = {
  100. .group = KVM_DEV_FLIC_ENQUEUE,
  101. .addr = (uint64_t) buf,
  102. .attr = len,
  103. };
  104. rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
  105. return rc ? -errno : 0;
  106. }
  107. static void kvm_s390_inject_flic(S390FLICState *fs, struct kvm_s390_irq *irq)
  108. {
  109. static bool use_flic = true;
  110. int r;
  111. if (use_flic) {
  112. r = flic_enqueue_irqs(irq, sizeof(*irq), s390_get_kvm_flic(fs));
  113. if (r == -ENOSYS) {
  114. use_flic = false;
  115. }
  116. if (!r) {
  117. return;
  118. }
  119. }
  120. /* fallback to legacy KVM IOCTL in case FLIC fails */
  121. kvm_s390_floating_interrupt_legacy(irq);
  122. }
  123. static void kvm_s390_inject_service(S390FLICState *fs, uint32_t parm)
  124. {
  125. struct kvm_s390_irq irq = {
  126. .type = KVM_S390_INT_SERVICE,
  127. .u.ext.ext_params = parm,
  128. };
  129. kvm_s390_inject_flic(fs, &irq);
  130. }
  131. static void kvm_s390_inject_io(S390FLICState *fs, uint16_t subchannel_id,
  132. uint16_t subchannel_nr, uint32_t io_int_parm,
  133. uint32_t io_int_word)
  134. {
  135. struct kvm_s390_irq irq = {
  136. .u.io.subchannel_id = subchannel_id,
  137. .u.io.subchannel_nr = subchannel_nr,
  138. .u.io.io_int_parm = io_int_parm,
  139. .u.io.io_int_word = io_int_word,
  140. };
  141. if (io_int_word & IO_INT_WORD_AI) {
  142. irq.type = KVM_S390_INT_IO(1, 0, 0, 0);
  143. } else {
  144. irq.type = KVM_S390_INT_IO(0, (subchannel_id & 0xff00) >> 8,
  145. (subchannel_id & 0x0006),
  146. subchannel_nr);
  147. }
  148. kvm_s390_inject_flic(fs, &irq);
  149. }
  150. static void kvm_s390_inject_crw_mchk(S390FLICState *fs)
  151. {
  152. struct kvm_s390_irq irq = {
  153. .type = KVM_S390_MCHK,
  154. .u.mchk.cr14 = CR14_CHANNEL_REPORT_SC,
  155. .u.mchk.mcic = s390_build_validity_mcic() | MCIC_SC_CP,
  156. };
  157. kvm_s390_inject_flic(fs, &irq);
  158. }
  159. static int kvm_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
  160. uint16_t subchannel_nr)
  161. {
  162. KVMS390FLICState *flic = s390_get_kvm_flic(fs);
  163. int rc;
  164. uint32_t sid = subchannel_id << 16 | subchannel_nr;
  165. struct kvm_device_attr attr = {
  166. .group = KVM_DEV_FLIC_CLEAR_IO_IRQ,
  167. .addr = (uint64_t) &sid,
  168. .attr = sizeof(sid),
  169. };
  170. if (unlikely(!flic->clear_io_supported)) {
  171. return -ENOSYS;
  172. }
  173. rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
  174. return rc ? -errno : 0;
  175. }
  176. static int kvm_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,
  177. uint16_t mode)
  178. {
  179. KVMS390FLICState *flic = s390_get_kvm_flic(fs);
  180. struct kvm_s390_ais_req req = {
  181. .isc = isc,
  182. .mode = mode,
  183. };
  184. struct kvm_device_attr attr = {
  185. .group = KVM_DEV_FLIC_AISM,
  186. .addr = (uint64_t)&req,
  187. };
  188. if (!fs->ais_supported) {
  189. return -ENOSYS;
  190. }
  191. return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0;
  192. }
  193. static int kvm_s390_inject_airq(S390FLICState *fs, uint8_t type,
  194. uint8_t isc, uint8_t flags)
  195. {
  196. KVMS390FLICState *flic = s390_get_kvm_flic(fs);
  197. uint32_t id = css_get_adapter_id(type, isc);
  198. struct kvm_device_attr attr = {
  199. .group = KVM_DEV_FLIC_AIRQ_INJECT,
  200. .attr = id,
  201. };
  202. if (!fs->ais_supported) {
  203. return -ENOSYS;
  204. }
  205. return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0;
  206. }
  207. /**
  208. * __get_all_irqs - store all pending irqs in buffer
  209. * @flic: pointer to flic device state
  210. * @buf: pointer to pointer to a buffer
  211. * @len: length of buffer
  212. *
  213. * Returns: return value of flic_get_all_irqs
  214. * Note: Retry and increase buffer size until flic_get_all_irqs
  215. * either returns a value >= 0 or a negative error code.
  216. * -ENOMEM is an exception, which means the buffer is too small
  217. * and we should try again. Other negative error codes can be
  218. * -EFAULT and -EINVAL which we ignore at this point
  219. */
  220. static int __get_all_irqs(KVMS390FLICState *flic,
  221. void **buf, int len)
  222. {
  223. int r;
  224. do {
  225. /* returns -ENOMEM if buffer is too small and number
  226. * of queued interrupts on success */
  227. r = flic_get_all_irqs(flic, *buf, len);
  228. if (r >= 0) {
  229. break;
  230. }
  231. len *= 2;
  232. *buf = g_try_realloc(*buf, len);
  233. if (!buf) {
  234. return -ENOMEM;
  235. }
  236. } while (r == -ENOMEM && len <= KVM_S390_FLIC_MAX_BUFFER);
  237. return r;
  238. }
  239. static int kvm_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
  240. uint8_t isc, bool swap,
  241. bool is_maskable, uint8_t flags)
  242. {
  243. struct kvm_s390_io_adapter adapter = {
  244. .id = id,
  245. .isc = isc,
  246. .maskable = is_maskable,
  247. .swap = swap,
  248. .flags = flags,
  249. };
  250. KVMS390FLICState *flic = KVM_S390_FLIC(fs);
  251. int r;
  252. struct kvm_device_attr attr = {
  253. .group = KVM_DEV_FLIC_ADAPTER_REGISTER,
  254. .addr = (uint64_t)&adapter,
  255. };
  256. if (!kvm_gsi_routing_enabled()) {
  257. /* nothing to do */
  258. return 0;
  259. }
  260. r = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
  261. return r ? -errno : 0;
  262. }
  263. static int kvm_s390_io_adapter_map(S390FLICState *fs, uint32_t id,
  264. uint64_t map_addr, bool do_map)
  265. {
  266. struct kvm_s390_io_adapter_req req = {
  267. .id = id,
  268. .type = do_map ? KVM_S390_IO_ADAPTER_MAP : KVM_S390_IO_ADAPTER_UNMAP,
  269. .addr = map_addr,
  270. };
  271. struct kvm_device_attr attr = {
  272. .group = KVM_DEV_FLIC_ADAPTER_MODIFY,
  273. .addr = (uint64_t)&req,
  274. };
  275. KVMS390FLICState *flic = s390_get_kvm_flic(fs);
  276. int r;
  277. if (!kvm_gsi_routing_enabled()) {
  278. /* nothing to do */
  279. return 0;
  280. }
  281. r = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
  282. return r ? -errno : 0;
  283. }
  284. static int kvm_s390_add_adapter_routes(S390FLICState *fs,
  285. AdapterRoutes *routes)
  286. {
  287. int ret, i;
  288. uint64_t ind_offset = routes->adapter.ind_offset;
  289. for (i = 0; i < routes->num_routes; i++) {
  290. ret = kvm_irqchip_add_adapter_route(kvm_state, &routes->adapter);
  291. if (ret < 0) {
  292. goto out_undo;
  293. }
  294. routes->gsi[i] = ret;
  295. routes->adapter.ind_offset++;
  296. }
  297. kvm_irqchip_commit_routes(kvm_state);
  298. /* Restore passed-in structure to original state. */
  299. routes->adapter.ind_offset = ind_offset;
  300. return 0;
  301. out_undo:
  302. while (--i >= 0) {
  303. kvm_irqchip_release_virq(kvm_state, routes->gsi[i]);
  304. routes->gsi[i] = -1;
  305. }
  306. routes->adapter.ind_offset = ind_offset;
  307. return ret;
  308. }
  309. static void kvm_s390_release_adapter_routes(S390FLICState *fs,
  310. AdapterRoutes *routes)
  311. {
  312. int i;
  313. for (i = 0; i < routes->num_routes; i++) {
  314. if (routes->gsi[i] >= 0) {
  315. kvm_irqchip_release_virq(kvm_state, routes->gsi[i]);
  316. routes->gsi[i] = -1;
  317. }
  318. }
  319. }
  320. /**
  321. * kvm_flic_save - Save pending floating interrupts
  322. * @f: QEMUFile containing migration state
  323. * @opaque: pointer to flic device state
  324. * @size: ignored
  325. *
  326. * Note: Pass buf and len to kernel. Start with one page and
  327. * increase until buffer is sufficient or maxium size is
  328. * reached
  329. */
  330. static int kvm_flic_save(QEMUFile *f, void *opaque, size_t size,
  331. const VMStateField *field, QJSON *vmdesc)
  332. {
  333. KVMS390FLICState *flic = opaque;
  334. int len = FLIC_SAVE_INITIAL_SIZE;
  335. void *buf;
  336. int count;
  337. int r = 0;
  338. flic_disable_wait_pfault((struct KVMS390FLICState *) opaque);
  339. buf = g_try_malloc0(len);
  340. if (!buf) {
  341. /* Storing FLIC_FAILED into the count field here will cause the
  342. * target system to fail when attempting to load irqs from the
  343. * migration state */
  344. error_report("flic: couldn't allocate memory");
  345. qemu_put_be64(f, FLIC_FAILED);
  346. return -ENOMEM;
  347. }
  348. count = __get_all_irqs(flic, &buf, len);
  349. if (count < 0) {
  350. error_report("flic: couldn't retrieve irqs from kernel, rc %d",
  351. count);
  352. /* Storing FLIC_FAILED into the count field here will cause the
  353. * target system to fail when attempting to load irqs from the
  354. * migration state */
  355. qemu_put_be64(f, FLIC_FAILED);
  356. r = count;
  357. } else {
  358. qemu_put_be64(f, count);
  359. qemu_put_buffer(f, (uint8_t *) buf,
  360. count * sizeof(struct kvm_s390_irq));
  361. }
  362. g_free(buf);
  363. return r;
  364. }
  365. /**
  366. * kvm_flic_load - Load pending floating interrupts
  367. * @f: QEMUFile containing migration state
  368. * @opaque: pointer to flic device state
  369. * @size: ignored
  370. *
  371. * Returns: value of flic_enqueue_irqs, -EINVAL on error
  372. * Note: Do nothing when no interrupts where stored
  373. * in QEMUFile
  374. */
  375. static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size,
  376. const VMStateField *field)
  377. {
  378. uint64_t len = 0;
  379. uint64_t count = 0;
  380. void *buf = NULL;
  381. int r = 0;
  382. flic_enable_pfault((struct KVMS390FLICState *) opaque);
  383. count = qemu_get_be64(f);
  384. len = count * sizeof(struct kvm_s390_irq);
  385. if (count == FLIC_FAILED) {
  386. r = -EINVAL;
  387. goto out;
  388. }
  389. if (count == 0) {
  390. r = 0;
  391. goto out;
  392. }
  393. buf = g_try_malloc0(len);
  394. if (!buf) {
  395. r = -ENOMEM;
  396. goto out;
  397. }
  398. if (qemu_get_buffer(f, (uint8_t *) buf, len) != len) {
  399. r = -EINVAL;
  400. goto out_free;
  401. }
  402. r = flic_enqueue_irqs(buf, len, (struct KVMS390FLICState *) opaque);
  403. out_free:
  404. g_free(buf);
  405. out:
  406. return r;
  407. }
  408. typedef struct KVMS390FLICStateMigTmp {
  409. KVMS390FLICState *parent;
  410. uint8_t simm;
  411. uint8_t nimm;
  412. } KVMS390FLICStateMigTmp;
  413. static int kvm_flic_ais_pre_save(void *opaque)
  414. {
  415. KVMS390FLICStateMigTmp *tmp = opaque;
  416. KVMS390FLICState *flic = tmp->parent;
  417. struct kvm_s390_ais_all ais;
  418. struct kvm_device_attr attr = {
  419. .group = KVM_DEV_FLIC_AISM_ALL,
  420. .addr = (uint64_t)&ais,
  421. .attr = sizeof(ais),
  422. };
  423. if (ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr)) {
  424. error_report("Failed to retrieve kvm flic ais states");
  425. return -EINVAL;
  426. }
  427. tmp->simm = ais.simm;
  428. tmp->nimm = ais.nimm;
  429. return 0;
  430. }
  431. static int kvm_flic_ais_post_load(void *opaque, int version_id)
  432. {
  433. KVMS390FLICStateMigTmp *tmp = opaque;
  434. KVMS390FLICState *flic = tmp->parent;
  435. struct kvm_s390_ais_all ais = {
  436. .simm = tmp->simm,
  437. .nimm = tmp->nimm,
  438. };
  439. struct kvm_device_attr attr = {
  440. .group = KVM_DEV_FLIC_AISM_ALL,
  441. .addr = (uint64_t)&ais,
  442. };
  443. /* This can happen when the user mis-configures its guests in an
  444. * incompatible fashion or without a CPU model. For example using
  445. * qemu with -cpu host (which is not migration safe) and do a
  446. * migration from a host that has AIS to a host that has no AIS.
  447. * In that case the target system will reject the migration here.
  448. */
  449. if (!ais_needed(flic)) {
  450. return -ENOSYS;
  451. }
  452. return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0;
  453. }
  454. static const VMStateDescription kvm_s390_flic_ais_tmp = {
  455. .name = "s390-flic-ais-tmp",
  456. .pre_save = kvm_flic_ais_pre_save,
  457. .post_load = kvm_flic_ais_post_load,
  458. .fields = (VMStateField[]) {
  459. VMSTATE_UINT8(simm, KVMS390FLICStateMigTmp),
  460. VMSTATE_UINT8(nimm, KVMS390FLICStateMigTmp),
  461. VMSTATE_END_OF_LIST()
  462. }
  463. };
  464. static const VMStateDescription kvm_s390_flic_vmstate_ais = {
  465. .name = "s390-flic/ais",
  466. .version_id = 1,
  467. .minimum_version_id = 1,
  468. .needed = ais_needed,
  469. .fields = (VMStateField[]) {
  470. VMSTATE_WITH_TMP(KVMS390FLICState, KVMS390FLICStateMigTmp,
  471. kvm_s390_flic_ais_tmp),
  472. VMSTATE_END_OF_LIST()
  473. }
  474. };
  475. static const VMStateDescription kvm_s390_flic_vmstate = {
  476. /* should have been like kvm-s390-flic,
  477. * can't change without breaking compat */
  478. .name = "s390-flic",
  479. .version_id = FLIC_SAVEVM_VERSION,
  480. .minimum_version_id = FLIC_SAVEVM_VERSION,
  481. .fields = (VMStateField[]) {
  482. {
  483. .name = "irqs",
  484. .info = &(const VMStateInfo) {
  485. .name = "irqs",
  486. .get = kvm_flic_load,
  487. .put = kvm_flic_save,
  488. },
  489. .flags = VMS_SINGLE,
  490. },
  491. VMSTATE_END_OF_LIST()
  492. },
  493. .subsections = (const VMStateDescription * []) {
  494. &kvm_s390_flic_vmstate_ais,
  495. NULL
  496. }
  497. };
  498. typedef struct KVMS390FLICStateClass {
  499. S390FLICStateClass parent_class;
  500. DeviceRealize parent_realize;
  501. } KVMS390FLICStateClass;
  502. #define KVM_S390_FLIC_GET_CLASS(obj) \
  503. OBJECT_GET_CLASS(KVMS390FLICStateClass, (obj), TYPE_KVM_S390_FLIC)
  504. #define KVM_S390_FLIC_CLASS(klass) \
  505. OBJECT_CLASS_CHECK(KVMS390FLICStateClass, (klass), TYPE_KVM_S390_FLIC)
  506. static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
  507. {
  508. KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);
  509. struct kvm_create_device cd = {0};
  510. struct kvm_device_attr test_attr = {0};
  511. int ret;
  512. Error *errp_local = NULL;
  513. KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &errp_local);
  514. if (errp_local) {
  515. goto fail;
  516. }
  517. flic_state->fd = -1;
  518. cd.type = KVM_DEV_TYPE_FLIC;
  519. ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd);
  520. if (ret < 0) {
  521. error_setg_errno(&errp_local, errno, "Creating the KVM device failed");
  522. trace_flic_create_device(errno);
  523. goto fail;
  524. }
  525. flic_state->fd = cd.fd;
  526. /* Check clear_io_irq support */
  527. test_attr.group = KVM_DEV_FLIC_CLEAR_IO_IRQ;
  528. flic_state->clear_io_supported = !ioctl(flic_state->fd,
  529. KVM_HAS_DEVICE_ATTR, test_attr);
  530. return;
  531. fail:
  532. error_propagate(errp, errp_local);
  533. }
  534. static void kvm_s390_flic_reset(DeviceState *dev)
  535. {
  536. KVMS390FLICState *flic = KVM_S390_FLIC(dev);
  537. S390FLICState *fs = S390_FLIC_COMMON(dev);
  538. struct kvm_device_attr attr = {
  539. .group = KVM_DEV_FLIC_CLEAR_IRQS,
  540. };
  541. int rc = 0;
  542. uint8_t isc;
  543. if (flic->fd == -1) {
  544. return;
  545. }
  546. flic_disable_wait_pfault(flic);
  547. if (fs->ais_supported) {
  548. for (isc = 0; isc <= MAX_ISC; isc++) {
  549. rc = kvm_s390_modify_ais_mode(fs, isc, SIC_IRQ_MODE_ALL);
  550. if (rc) {
  551. error_report("Failed to reset ais mode for isc %d: %s",
  552. isc, strerror(-rc));
  553. }
  554. }
  555. }
  556. rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
  557. if (rc) {
  558. trace_flic_reset_failed(errno);
  559. }
  560. flic_enable_pfault(flic);
  561. }
  562. static void kvm_s390_flic_class_init(ObjectClass *oc, void *data)
  563. {
  564. DeviceClass *dc = DEVICE_CLASS(oc);
  565. S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
  566. KVM_S390_FLIC_CLASS(oc)->parent_realize = dc->realize;
  567. dc->realize = kvm_s390_flic_realize;
  568. dc->vmsd = &kvm_s390_flic_vmstate;
  569. dc->reset = kvm_s390_flic_reset;
  570. fsc->register_io_adapter = kvm_s390_register_io_adapter;
  571. fsc->io_adapter_map = kvm_s390_io_adapter_map;
  572. fsc->add_adapter_routes = kvm_s390_add_adapter_routes;
  573. fsc->release_adapter_routes = kvm_s390_release_adapter_routes;
  574. fsc->clear_io_irq = kvm_s390_clear_io_flic;
  575. fsc->modify_ais_mode = kvm_s390_modify_ais_mode;
  576. fsc->inject_airq = kvm_s390_inject_airq;
  577. fsc->inject_service = kvm_s390_inject_service;
  578. fsc->inject_io = kvm_s390_inject_io;
  579. fsc->inject_crw_mchk = kvm_s390_inject_crw_mchk;
  580. }
  581. static const TypeInfo kvm_s390_flic_info = {
  582. .name = TYPE_KVM_S390_FLIC,
  583. .parent = TYPE_S390_FLIC_COMMON,
  584. .instance_size = sizeof(KVMS390FLICState),
  585. .class_size = sizeof(KVMS390FLICStateClass),
  586. .class_init = kvm_s390_flic_class_init,
  587. };
  588. static void kvm_s390_flic_register_types(void)
  589. {
  590. type_register_static(&kvm_s390_flic_info);
  591. }
  592. type_init(kvm_s390_flic_register_types)