hvc_xen.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * xen console driver interface to hvc_console.c
  4. *
  5. * (c) 2007 Gerd Hoffmann <kraxel@suse.de>
  6. */
  7. #include <linux/console.h>
  8. #include <linux/delay.h>
  9. #include <linux/err.h>
  10. #include <linux/irq.h>
  11. #include <linux/init.h>
  12. #include <linux/types.h>
  13. #include <linux/list.h>
  14. #include <linux/serial_core.h>
  15. #include <asm/io.h>
  16. #include <asm/xen/hypervisor.h>
  17. #include <xen/xen.h>
  18. #include <xen/interface/xen.h>
  19. #include <xen/hvm.h>
  20. #include <xen/grant_table.h>
  21. #include <xen/page.h>
  22. #include <xen/events.h>
  23. #include <xen/interface/io/console.h>
  24. #include <xen/interface/sched.h>
  25. #include <xen/hvc-console.h>
  26. #include <xen/xenbus.h>
  27. #include "hvc_console.h"
  28. #define HVC_COOKIE 0x58656e /* "Xen" in hex */
  29. struct xencons_info {
  30. struct list_head list;
  31. struct xenbus_device *xbdev;
  32. struct xencons_interface *intf;
  33. unsigned int evtchn;
  34. XENCONS_RING_IDX out_cons;
  35. unsigned int out_cons_same;
  36. struct hvc_struct *hvc;
  37. int irq;
  38. int vtermno;
  39. grant_ref_t gntref;
  40. };
  41. static LIST_HEAD(xenconsoles);
  42. static DEFINE_SPINLOCK(xencons_lock);
  43. /* ------------------------------------------------------------------ */
  44. static struct xencons_info *vtermno_to_xencons(int vtermno)
  45. {
  46. struct xencons_info *entry, *n, *ret = NULL;
  47. if (list_empty(&xenconsoles))
  48. return NULL;
  49. list_for_each_entry_safe(entry, n, &xenconsoles, list) {
  50. if (entry->vtermno == vtermno) {
  51. ret = entry;
  52. break;
  53. }
  54. }
  55. return ret;
  56. }
  57. static inline int xenbus_devid_to_vtermno(int devid)
  58. {
  59. return devid + HVC_COOKIE;
  60. }
  61. static inline void notify_daemon(struct xencons_info *cons)
  62. {
  63. /* Use evtchn: this is called early, before irq is set up. */
  64. notify_remote_via_evtchn(cons->evtchn);
  65. }
  66. static int __write_console(struct xencons_info *xencons,
  67. const char *data, int len)
  68. {
  69. XENCONS_RING_IDX cons, prod;
  70. struct xencons_interface *intf = xencons->intf;
  71. int sent = 0;
  72. cons = intf->out_cons;
  73. prod = intf->out_prod;
  74. mb(); /* update queue values before going on */
  75. if ((prod - cons) > sizeof(intf->out)) {
  76. pr_err_once("xencons: Illegal ring page indices");
  77. return -EINVAL;
  78. }
  79. while ((sent < len) && ((prod - cons) < sizeof(intf->out)))
  80. intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = data[sent++];
  81. wmb(); /* write ring before updating pointer */
  82. intf->out_prod = prod;
  83. if (sent)
  84. notify_daemon(xencons);
  85. return sent;
  86. }
  87. static int domU_write_console(uint32_t vtermno, const char *data, int len)
  88. {
  89. int ret = len;
  90. struct xencons_info *cons = vtermno_to_xencons(vtermno);
  91. if (cons == NULL)
  92. return -EINVAL;
  93. /*
  94. * Make sure the whole buffer is emitted, polling if
  95. * necessary. We don't ever want to rely on the hvc daemon
  96. * because the most interesting console output is when the
  97. * kernel is crippled.
  98. */
  99. while (len) {
  100. int sent = __write_console(cons, data, len);
  101. if (sent < 0)
  102. return sent;
  103. data += sent;
  104. len -= sent;
  105. if (unlikely(len))
  106. HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
  107. }
  108. return ret;
  109. }
  110. static int domU_read_console(uint32_t vtermno, char *buf, int len)
  111. {
  112. struct xencons_interface *intf;
  113. XENCONS_RING_IDX cons, prod;
  114. int recv = 0;
  115. struct xencons_info *xencons = vtermno_to_xencons(vtermno);
  116. unsigned int eoiflag = 0;
  117. if (xencons == NULL)
  118. return -EINVAL;
  119. intf = xencons->intf;
  120. cons = intf->in_cons;
  121. prod = intf->in_prod;
  122. mb(); /* get pointers before reading ring */
  123. if ((prod - cons) > sizeof(intf->in)) {
  124. pr_err_once("xencons: Illegal ring page indices");
  125. return -EINVAL;
  126. }
  127. while (cons != prod && recv < len)
  128. buf[recv++] = intf->in[MASK_XENCONS_IDX(cons++, intf->in)];
  129. mb(); /* read ring before consuming */
  130. intf->in_cons = cons;
  131. /*
  132. * When to mark interrupt having been spurious:
  133. * - there was no new data to be read, and
  134. * - the backend did not consume some output bytes, and
  135. * - the previous round with no read data didn't see consumed bytes
  136. * (we might have a race with an interrupt being in flight while
  137. * updating xencons->out_cons, so account for that by allowing one
  138. * round without any visible reason)
  139. */
  140. if (intf->out_cons != xencons->out_cons) {
  141. xencons->out_cons = intf->out_cons;
  142. xencons->out_cons_same = 0;
  143. }
  144. if (recv) {
  145. notify_daemon(xencons);
  146. } else if (xencons->out_cons_same++ > 1) {
  147. eoiflag = XEN_EOI_FLAG_SPURIOUS;
  148. }
  149. xen_irq_lateeoi(xencons->irq, eoiflag);
  150. return recv;
  151. }
  152. static const struct hv_ops domU_hvc_ops = {
  153. .get_chars = domU_read_console,
  154. .put_chars = domU_write_console,
  155. .notifier_add = notifier_add_irq,
  156. .notifier_del = notifier_del_irq,
  157. .notifier_hangup = notifier_hangup_irq,
  158. };
  159. static int dom0_read_console(uint32_t vtermno, char *buf, int len)
  160. {
  161. return HYPERVISOR_console_io(CONSOLEIO_read, len, buf);
  162. }
  163. /*
  164. * Either for a dom0 to write to the system console, or a domU with a
  165. * debug version of Xen
  166. */
  167. static int dom0_write_console(uint32_t vtermno, const char *str, int len)
  168. {
  169. int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str);
  170. if (rc < 0)
  171. return rc;
  172. return len;
  173. }
  174. static const struct hv_ops dom0_hvc_ops = {
  175. .get_chars = dom0_read_console,
  176. .put_chars = dom0_write_console,
  177. .notifier_add = notifier_add_irq,
  178. .notifier_del = notifier_del_irq,
  179. .notifier_hangup = notifier_hangup_irq,
  180. };
  181. static int xen_hvm_console_init(void)
  182. {
  183. int r;
  184. uint64_t v = 0;
  185. unsigned long gfn;
  186. struct xencons_info *info;
  187. if (!xen_hvm_domain())
  188. return -ENODEV;
  189. info = vtermno_to_xencons(HVC_COOKIE);
  190. if (!info) {
  191. info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
  192. if (!info)
  193. return -ENOMEM;
  194. } else if (info->intf != NULL) {
  195. /* already configured */
  196. return 0;
  197. }
  198. /*
  199. * If the toolstack (or the hypervisor) hasn't set these values, the
  200. * default value is 0. Even though gfn = 0 and evtchn = 0 are
  201. * theoretically correct values, in practice they never are and they
  202. * mean that a legacy toolstack hasn't initialized the pv console correctly.
  203. */
  204. r = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v);
  205. if (r < 0 || v == 0)
  206. goto err;
  207. info->evtchn = v;
  208. v = 0;
  209. r = hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &v);
  210. if (r < 0 || v == 0)
  211. goto err;
  212. gfn = v;
  213. info->intf = xen_remap(gfn << XEN_PAGE_SHIFT, XEN_PAGE_SIZE);
  214. if (info->intf == NULL)
  215. goto err;
  216. info->vtermno = HVC_COOKIE;
  217. spin_lock(&xencons_lock);
  218. list_add_tail(&info->list, &xenconsoles);
  219. spin_unlock(&xencons_lock);
  220. return 0;
  221. err:
  222. kfree(info);
  223. return -ENODEV;
  224. }
  225. static int xencons_info_pv_init(struct xencons_info *info, int vtermno)
  226. {
  227. info->evtchn = xen_start_info->console.domU.evtchn;
  228. /* GFN == MFN for PV guest */
  229. info->intf = gfn_to_virt(xen_start_info->console.domU.mfn);
  230. info->vtermno = vtermno;
  231. list_add_tail(&info->list, &xenconsoles);
  232. return 0;
  233. }
  234. static int xen_pv_console_init(void)
  235. {
  236. struct xencons_info *info;
  237. if (!xen_pv_domain())
  238. return -ENODEV;
  239. if (!xen_start_info->console.domU.evtchn)
  240. return -ENODEV;
  241. info = vtermno_to_xencons(HVC_COOKIE);
  242. if (!info) {
  243. info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
  244. if (!info)
  245. return -ENOMEM;
  246. } else if (info->intf != NULL) {
  247. /* already configured */
  248. return 0;
  249. }
  250. spin_lock(&xencons_lock);
  251. xencons_info_pv_init(info, HVC_COOKIE);
  252. spin_unlock(&xencons_lock);
  253. return 0;
  254. }
  255. static int xen_initial_domain_console_init(void)
  256. {
  257. struct xencons_info *info;
  258. if (!xen_initial_domain())
  259. return -ENODEV;
  260. info = vtermno_to_xencons(HVC_COOKIE);
  261. if (!info) {
  262. info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
  263. if (!info)
  264. return -ENOMEM;
  265. }
  266. info->irq = bind_virq_to_irq(VIRQ_CONSOLE, 0, false);
  267. info->vtermno = HVC_COOKIE;
  268. spin_lock(&xencons_lock);
  269. list_add_tail(&info->list, &xenconsoles);
  270. spin_unlock(&xencons_lock);
  271. return 0;
  272. }
  273. static void xen_console_update_evtchn(struct xencons_info *info)
  274. {
  275. if (xen_hvm_domain()) {
  276. uint64_t v = 0;
  277. int err;
  278. err = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v);
  279. if (!err && v)
  280. info->evtchn = v;
  281. } else
  282. info->evtchn = xen_start_info->console.domU.evtchn;
  283. }
  284. void xen_console_resume(void)
  285. {
  286. struct xencons_info *info = vtermno_to_xencons(HVC_COOKIE);
  287. if (info != NULL && info->irq) {
  288. if (!xen_initial_domain())
  289. xen_console_update_evtchn(info);
  290. rebind_evtchn_irq(info->evtchn, info->irq);
  291. }
  292. }
  293. #ifdef CONFIG_HVC_XEN_FRONTEND
  294. static void xencons_disconnect_backend(struct xencons_info *info)
  295. {
  296. if (info->irq > 0)
  297. unbind_from_irqhandler(info->irq, NULL);
  298. info->irq = 0;
  299. if (info->evtchn > 0)
  300. xenbus_free_evtchn(info->xbdev, info->evtchn);
  301. info->evtchn = 0;
  302. if (info->gntref > 0)
  303. gnttab_free_grant_references(info->gntref);
  304. info->gntref = 0;
  305. if (info->hvc != NULL)
  306. hvc_remove(info->hvc);
  307. info->hvc = NULL;
  308. }
  309. static void xencons_free(struct xencons_info *info)
  310. {
  311. free_page((unsigned long)info->intf);
  312. info->intf = NULL;
  313. info->vtermno = 0;
  314. kfree(info);
  315. }
  316. static int xen_console_remove(struct xencons_info *info)
  317. {
  318. xencons_disconnect_backend(info);
  319. spin_lock(&xencons_lock);
  320. list_del(&info->list);
  321. spin_unlock(&xencons_lock);
  322. if (info->xbdev != NULL)
  323. xencons_free(info);
  324. else {
  325. if (xen_hvm_domain())
  326. iounmap(info->intf);
  327. kfree(info);
  328. }
  329. return 0;
  330. }
  331. static int xencons_remove(struct xenbus_device *dev)
  332. {
  333. return xen_console_remove(dev_get_drvdata(&dev->dev));
  334. }
  335. static int xencons_connect_backend(struct xenbus_device *dev,
  336. struct xencons_info *info)
  337. {
  338. int ret, evtchn, devid, ref, irq;
  339. struct xenbus_transaction xbt;
  340. grant_ref_t gref_head;
  341. ret = xenbus_alloc_evtchn(dev, &evtchn);
  342. if (ret)
  343. return ret;
  344. info->evtchn = evtchn;
  345. irq = bind_interdomain_evtchn_to_irq_lateeoi(dev->otherend_id, evtchn);
  346. if (irq < 0)
  347. return irq;
  348. info->irq = irq;
  349. devid = dev->nodename[strlen(dev->nodename) - 1] - '0';
  350. info->hvc = hvc_alloc(xenbus_devid_to_vtermno(devid),
  351. irq, &domU_hvc_ops, 256);
  352. if (IS_ERR(info->hvc))
  353. return PTR_ERR(info->hvc);
  354. ret = gnttab_alloc_grant_references(1, &gref_head);
  355. if (ret < 0)
  356. return ret;
  357. info->gntref = gref_head;
  358. ref = gnttab_claim_grant_reference(&gref_head);
  359. if (ref < 0)
  360. return ref;
  361. gnttab_grant_foreign_access_ref(ref, info->xbdev->otherend_id,
  362. virt_to_gfn(info->intf), 0);
  363. again:
  364. ret = xenbus_transaction_start(&xbt);
  365. if (ret) {
  366. xenbus_dev_fatal(dev, ret, "starting transaction");
  367. return ret;
  368. }
  369. ret = xenbus_printf(xbt, dev->nodename, "ring-ref", "%d", ref);
  370. if (ret)
  371. goto error_xenbus;
  372. ret = xenbus_printf(xbt, dev->nodename, "port", "%u",
  373. evtchn);
  374. if (ret)
  375. goto error_xenbus;
  376. ret = xenbus_transaction_end(xbt, 0);
  377. if (ret) {
  378. if (ret == -EAGAIN)
  379. goto again;
  380. xenbus_dev_fatal(dev, ret, "completing transaction");
  381. return ret;
  382. }
  383. xenbus_switch_state(dev, XenbusStateInitialised);
  384. return 0;
  385. error_xenbus:
  386. xenbus_transaction_end(xbt, 1);
  387. xenbus_dev_fatal(dev, ret, "writing xenstore");
  388. return ret;
  389. }
  390. static int xencons_probe(struct xenbus_device *dev,
  391. const struct xenbus_device_id *id)
  392. {
  393. int ret, devid;
  394. struct xencons_info *info;
  395. devid = dev->nodename[strlen(dev->nodename) - 1] - '0';
  396. if (devid == 0)
  397. return -ENODEV;
  398. info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
  399. if (!info)
  400. return -ENOMEM;
  401. dev_set_drvdata(&dev->dev, info);
  402. info->xbdev = dev;
  403. info->vtermno = xenbus_devid_to_vtermno(devid);
  404. info->intf = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
  405. if (!info->intf)
  406. goto error_nomem;
  407. ret = xencons_connect_backend(dev, info);
  408. if (ret < 0)
  409. goto error;
  410. spin_lock(&xencons_lock);
  411. list_add_tail(&info->list, &xenconsoles);
  412. spin_unlock(&xencons_lock);
  413. return 0;
  414. error_nomem:
  415. ret = -ENOMEM;
  416. xenbus_dev_fatal(dev, ret, "allocating device memory");
  417. error:
  418. xencons_disconnect_backend(info);
  419. xencons_free(info);
  420. return ret;
  421. }
  422. static int xencons_resume(struct xenbus_device *dev)
  423. {
  424. struct xencons_info *info = dev_get_drvdata(&dev->dev);
  425. xencons_disconnect_backend(info);
  426. memset(info->intf, 0, XEN_PAGE_SIZE);
  427. return xencons_connect_backend(dev, info);
  428. }
  429. static void xencons_backend_changed(struct xenbus_device *dev,
  430. enum xenbus_state backend_state)
  431. {
  432. switch (backend_state) {
  433. case XenbusStateReconfiguring:
  434. case XenbusStateReconfigured:
  435. case XenbusStateInitialising:
  436. case XenbusStateInitialised:
  437. case XenbusStateUnknown:
  438. break;
  439. case XenbusStateInitWait:
  440. break;
  441. case XenbusStateConnected:
  442. xenbus_switch_state(dev, XenbusStateConnected);
  443. break;
  444. case XenbusStateClosed:
  445. if (dev->state == XenbusStateClosed)
  446. break;
  447. fallthrough; /* Missed the backend's CLOSING state */
  448. case XenbusStateClosing:
  449. xenbus_frontend_closed(dev);
  450. break;
  451. }
  452. }
  453. static const struct xenbus_device_id xencons_ids[] = {
  454. { "console" },
  455. { "" }
  456. };
  457. static struct xenbus_driver xencons_driver = {
  458. .name = "xenconsole",
  459. .ids = xencons_ids,
  460. .probe = xencons_probe,
  461. .remove = xencons_remove,
  462. .resume = xencons_resume,
  463. .otherend_changed = xencons_backend_changed,
  464. };
  465. #endif /* CONFIG_HVC_XEN_FRONTEND */
  466. static int __init xen_hvc_init(void)
  467. {
  468. int r;
  469. struct xencons_info *info;
  470. const struct hv_ops *ops;
  471. if (!xen_domain())
  472. return -ENODEV;
  473. if (xen_initial_domain()) {
  474. ops = &dom0_hvc_ops;
  475. r = xen_initial_domain_console_init();
  476. if (r < 0)
  477. return r;
  478. info = vtermno_to_xencons(HVC_COOKIE);
  479. } else {
  480. ops = &domU_hvc_ops;
  481. if (xen_hvm_domain())
  482. r = xen_hvm_console_init();
  483. else
  484. r = xen_pv_console_init();
  485. if (r < 0)
  486. return r;
  487. info = vtermno_to_xencons(HVC_COOKIE);
  488. info->irq = bind_evtchn_to_irq_lateeoi(info->evtchn);
  489. }
  490. if (info->irq < 0)
  491. info->irq = 0; /* NO_IRQ */
  492. else
  493. irq_set_noprobe(info->irq);
  494. info->hvc = hvc_alloc(HVC_COOKIE, info->irq, ops, 256);
  495. if (IS_ERR(info->hvc)) {
  496. r = PTR_ERR(info->hvc);
  497. spin_lock(&xencons_lock);
  498. list_del(&info->list);
  499. spin_unlock(&xencons_lock);
  500. if (info->irq)
  501. unbind_from_irqhandler(info->irq, NULL);
  502. kfree(info);
  503. return r;
  504. }
  505. r = 0;
  506. #ifdef CONFIG_HVC_XEN_FRONTEND
  507. r = xenbus_register_frontend(&xencons_driver);
  508. #endif
  509. return r;
  510. }
  511. device_initcall(xen_hvc_init);
  512. static int xen_cons_init(void)
  513. {
  514. const struct hv_ops *ops;
  515. if (!xen_domain())
  516. return 0;
  517. if (xen_initial_domain())
  518. ops = &dom0_hvc_ops;
  519. else {
  520. int r;
  521. ops = &domU_hvc_ops;
  522. if (xen_hvm_domain())
  523. r = xen_hvm_console_init();
  524. else
  525. r = xen_pv_console_init();
  526. if (r < 0)
  527. return r;
  528. }
  529. hvc_instantiate(HVC_COOKIE, 0, ops);
  530. return 0;
  531. }
  532. console_initcall(xen_cons_init);
  533. #ifdef CONFIG_X86
  534. static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len)
  535. {
  536. if (xen_cpuid_base())
  537. outsb(0xe9, str, len);
  538. }
  539. #else
  540. static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) { }
  541. #endif
  542. #ifdef CONFIG_EARLY_PRINTK
  543. static int __init xenboot_console_setup(struct console *console, char *string)
  544. {
  545. static struct xencons_info xenboot;
  546. if (xen_initial_domain())
  547. return 0;
  548. if (!xen_pv_domain())
  549. return -ENODEV;
  550. return xencons_info_pv_init(&xenboot, 0);
  551. }
  552. static void xenboot_write_console(struct console *console, const char *string,
  553. unsigned len)
  554. {
  555. unsigned int linelen, off = 0;
  556. const char *pos;
  557. if (!xen_pv_domain()) {
  558. xen_hvm_early_write(0, string, len);
  559. return;
  560. }
  561. dom0_write_console(0, string, len);
  562. if (xen_initial_domain())
  563. return;
  564. domU_write_console(0, "(early) ", 8);
  565. while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
  566. linelen = pos-string+off;
  567. if (off + linelen > len)
  568. break;
  569. domU_write_console(0, string+off, linelen);
  570. domU_write_console(0, "\r\n", 2);
  571. off += linelen + 1;
  572. }
  573. if (off < len)
  574. domU_write_console(0, string+off, len-off);
  575. }
  576. struct console xenboot_console = {
  577. .name = "xenboot",
  578. .write = xenboot_write_console,
  579. .setup = xenboot_console_setup,
  580. .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
  581. .index = -1,
  582. };
  583. #endif /* CONFIG_EARLY_PRINTK */
  584. void xen_raw_console_write(const char *str)
  585. {
  586. ssize_t len = strlen(str);
  587. int rc = 0;
  588. if (xen_domain()) {
  589. rc = dom0_write_console(0, str, len);
  590. if (rc != -ENOSYS || !xen_hvm_domain())
  591. return;
  592. }
  593. xen_hvm_early_write(0, str, len);
  594. }
  595. void xen_raw_printk(const char *fmt, ...)
  596. {
  597. static char buf[512];
  598. va_list ap;
  599. va_start(ap, fmt);
  600. vsnprintf(buf, sizeof(buf), fmt, ap);
  601. va_end(ap);
  602. xen_raw_console_write(buf);
  603. }
  604. static void xenboot_earlycon_write(struct console *console,
  605. const char *string,
  606. unsigned len)
  607. {
  608. dom0_write_console(0, string, len);
  609. }
  610. static int __init xenboot_earlycon_setup(struct earlycon_device *device,
  611. const char *opt)
  612. {
  613. device->con->write = xenboot_earlycon_write;
  614. return 0;
  615. }
  616. EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup);