epapr_paravirt.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * ePAPR para-virtualization support.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License, version 2, as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. *
  17. * Copyright (C) 2012 Freescale Semiconductor, Inc.
  18. */
  19. #include <linux/of.h>
  20. #include <asm/epapr_hcalls.h>
  21. #include <asm/cacheflush.h>
  22. #include <asm/code-patching.h>
  23. bool epapr_paravirt_enabled;
  24. static int __init epapr_paravirt_init(void)
  25. {
  26. struct device_node *hyper_node;
  27. const u32 *insts;
  28. int len, i;
  29. hyper_node = of_find_node_by_path("/hypervisor");
  30. if (!hyper_node)
  31. return -ENODEV;
  32. insts = of_get_property(hyper_node, "hcall-instructions", &len);
  33. if (!insts)
  34. return -ENODEV;
  35. if (len % 4 || len > (4 * 4))
  36. return -ENODEV;
  37. for (i = 0; i < (len / 4); i++)
  38. patch_instruction(epapr_hypercall_start + i, insts[i]);
  39. epapr_paravirt_enabled = true;
  40. return 0;
  41. }
  42. early_initcall(epapr_paravirt_init);