paravirt_patch.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /******************************************************************************
  2. * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
  3. * VA Linux Systems Japan K.K.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. */
  20. #ifndef __ASM_PARAVIRT_PATCH_H
  21. #define __ASM_PARAVIRT_PATCH_H
  22. #ifdef __ASSEMBLY__
  23. .section .paravirt_branches, "a"
  24. .previous
  25. #define PARAVIRT_PATCH_SITE_BR(type) \
  26. { \
  27. [1:] ; \
  28. br.cond.sptk.many 2f ; \
  29. nop.b 0 ; \
  30. nop.b 0;; ; \
  31. } ; \
  32. 2: \
  33. .xdata8 ".paravirt_branches", 1b, type
  34. #else
  35. #include <linux/stringify.h>
  36. #include <asm/intrinsics.h>
  37. /* for binary patch */
  38. struct paravirt_patch_site_bundle {
  39. void *sbundle;
  40. void *ebundle;
  41. unsigned long type;
  42. };
  43. /* label means the beginning of new bundle */
  44. #define paravirt_alt_bundle(instr, privop) \
  45. "\t998:\n" \
  46. "\t" instr "\n" \
  47. "\t999:\n" \
  48. "\t.pushsection .paravirt_bundles, \"a\"\n" \
  49. "\t.popsection\n" \
  50. "\t.xdata8 \".paravirt_bundles\", 998b, 999b, " \
  51. __stringify(privop) "\n"
  52. struct paravirt_patch_bundle_elem {
  53. const void *sbundle;
  54. const void *ebundle;
  55. unsigned long type;
  56. };
  57. struct paravirt_patch_site_inst {
  58. unsigned long stag;
  59. unsigned long etag;
  60. unsigned long type;
  61. };
  62. #define paravirt_alt_inst(instr, privop) \
  63. "\t[998:]\n" \
  64. "\t" instr "\n" \
  65. "\t[999:]\n" \
  66. "\t.pushsection .paravirt_insts, \"a\"\n" \
  67. "\t.popsection\n" \
  68. "\t.xdata8 \".paravirt_insts\", 998b, 999b, " \
  69. __stringify(privop) "\n"
  70. struct paravirt_patch_site_branch {
  71. unsigned long tag;
  72. unsigned long type;
  73. };
  74. struct paravirt_patch_branch_target {
  75. const void *entry;
  76. unsigned long type;
  77. };
  78. void
  79. __paravirt_patch_apply_branch(
  80. unsigned long tag, unsigned long type,
  81. const struct paravirt_patch_branch_target *entries,
  82. unsigned int nr_entries);
  83. void
  84. paravirt_patch_reloc_br(unsigned long tag, const void *target);
  85. void
  86. paravirt_patch_reloc_brl(unsigned long tag, const void *target);
  87. #if defined(ASM_SUPPORTED) && defined(CONFIG_PARAVIRT)
  88. unsigned long
  89. ia64_native_patch_bundle(void *sbundle, void *ebundle, unsigned long type);
  90. unsigned long
  91. __paravirt_patch_apply_bundle(void *sbundle, void *ebundle, unsigned long type,
  92. const struct paravirt_patch_bundle_elem *elems,
  93. unsigned long nelems,
  94. const struct paravirt_patch_bundle_elem **found);
  95. void
  96. paravirt_patch_apply_bundle(const struct paravirt_patch_site_bundle *start,
  97. const struct paravirt_patch_site_bundle *end);
  98. void
  99. paravirt_patch_apply_inst(const struct paravirt_patch_site_inst *start,
  100. const struct paravirt_patch_site_inst *end);
  101. void paravirt_patch_apply(void);
  102. #else
  103. #define paravirt_patch_apply_bundle(start, end) do { } while (0)
  104. #define paravirt_patch_apply_inst(start, end) do { } while (0)
  105. #define paravirt_patch_apply() do { } while (0)
  106. #endif
  107. #endif /* !__ASSEMBLEY__ */
  108. #endif /* __ASM_PARAVIRT_PATCH_H */
  109. /*
  110. * Local variables:
  111. * mode: C
  112. * c-set-style: "linux"
  113. * c-basic-offset: 8
  114. * tab-width: 8
  115. * indent-tabs-mode: t
  116. * End:
  117. */