paravirt.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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_H
  21. #define __ASM_PARAVIRT_H
  22. #ifndef __ASSEMBLY__
  23. /******************************************************************************
  24. * fsys related addresses
  25. */
  26. struct pv_fsys_data {
  27. unsigned long *fsyscall_table;
  28. void *fsys_bubble_down;
  29. };
  30. extern struct pv_fsys_data pv_fsys_data;
  31. unsigned long *paravirt_get_fsyscall_table(void);
  32. char *paravirt_get_fsys_bubble_down(void);
  33. /******************************************************************************
  34. * patchlist addresses for gate page
  35. */
  36. enum pv_gate_patchlist {
  37. PV_GATE_START_FSYSCALL,
  38. PV_GATE_END_FSYSCALL,
  39. PV_GATE_START_BRL_FSYS_BUBBLE_DOWN,
  40. PV_GATE_END_BRL_FSYS_BUBBLE_DOWN,
  41. PV_GATE_START_VTOP,
  42. PV_GATE_END_VTOP,
  43. PV_GATE_START_MCKINLEY_E9,
  44. PV_GATE_END_MCKINLEY_E9,
  45. };
  46. struct pv_patchdata {
  47. unsigned long start_fsyscall_patchlist;
  48. unsigned long end_fsyscall_patchlist;
  49. unsigned long start_brl_fsys_bubble_down_patchlist;
  50. unsigned long end_brl_fsys_bubble_down_patchlist;
  51. unsigned long start_vtop_patchlist;
  52. unsigned long end_vtop_patchlist;
  53. unsigned long start_mckinley_e9_patchlist;
  54. unsigned long end_mckinley_e9_patchlist;
  55. void *gate_section;
  56. };
  57. extern struct pv_patchdata pv_patchdata;
  58. unsigned long paravirt_get_gate_patchlist(enum pv_gate_patchlist type);
  59. void *paravirt_get_gate_section(void);
  60. #endif
  61. #ifdef CONFIG_PARAVIRT_GUEST
  62. #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
  63. #ifndef __ASSEMBLY__
  64. #include <asm/hw_irq.h>
  65. #include <asm/meminit.h>
  66. /******************************************************************************
  67. * general info
  68. */
  69. struct pv_info {
  70. unsigned int kernel_rpl;
  71. int paravirt_enabled;
  72. const char *name;
  73. };
  74. extern struct pv_info pv_info;
  75. static inline int paravirt_enabled(void)
  76. {
  77. return pv_info.paravirt_enabled;
  78. }
  79. static inline unsigned int get_kernel_rpl(void)
  80. {
  81. return pv_info.kernel_rpl;
  82. }
  83. /******************************************************************************
  84. * initialization hooks.
  85. */
  86. struct rsvd_region;
  87. struct pv_init_ops {
  88. void (*banner)(void);
  89. int (*reserve_memory)(struct rsvd_region *region);
  90. void (*arch_setup_early)(void);
  91. void (*arch_setup_console)(char **cmdline_p);
  92. int (*arch_setup_nomca)(void);
  93. void (*post_smp_prepare_boot_cpu)(void);
  94. #ifdef ASM_SUPPORTED
  95. unsigned long (*patch_bundle)(void *sbundle, void *ebundle,
  96. unsigned long type);
  97. unsigned long (*patch_inst)(unsigned long stag, unsigned long etag,
  98. unsigned long type);
  99. #endif
  100. void (*patch_branch)(unsigned long tag, unsigned long type);
  101. };
  102. extern struct pv_init_ops pv_init_ops;
  103. static inline void paravirt_banner(void)
  104. {
  105. if (pv_init_ops.banner)
  106. pv_init_ops.banner();
  107. }
  108. static inline int paravirt_reserve_memory(struct rsvd_region *region)
  109. {
  110. if (pv_init_ops.reserve_memory)
  111. return pv_init_ops.reserve_memory(region);
  112. return 0;
  113. }
  114. static inline void paravirt_arch_setup_early(void)
  115. {
  116. if (pv_init_ops.arch_setup_early)
  117. pv_init_ops.arch_setup_early();
  118. }
  119. static inline void paravirt_arch_setup_console(char **cmdline_p)
  120. {
  121. if (pv_init_ops.arch_setup_console)
  122. pv_init_ops.arch_setup_console(cmdline_p);
  123. }
  124. static inline int paravirt_arch_setup_nomca(void)
  125. {
  126. if (pv_init_ops.arch_setup_nomca)
  127. return pv_init_ops.arch_setup_nomca();
  128. return 0;
  129. }
  130. static inline void paravirt_post_smp_prepare_boot_cpu(void)
  131. {
  132. if (pv_init_ops.post_smp_prepare_boot_cpu)
  133. pv_init_ops.post_smp_prepare_boot_cpu();
  134. }
  135. /******************************************************************************
  136. * replacement of iosapic operations.
  137. */
  138. struct pv_iosapic_ops {
  139. void (*pcat_compat_init)(void);
  140. struct irq_chip *(*__get_irq_chip)(unsigned long trigger);
  141. unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
  142. void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
  143. };
  144. extern struct pv_iosapic_ops pv_iosapic_ops;
  145. static inline void
  146. iosapic_pcat_compat_init(void)
  147. {
  148. if (pv_iosapic_ops.pcat_compat_init)
  149. pv_iosapic_ops.pcat_compat_init();
  150. }
  151. static inline struct irq_chip*
  152. iosapic_get_irq_chip(unsigned long trigger)
  153. {
  154. return pv_iosapic_ops.__get_irq_chip(trigger);
  155. }
  156. static inline unsigned int
  157. __iosapic_read(char __iomem *iosapic, unsigned int reg)
  158. {
  159. return pv_iosapic_ops.__read(iosapic, reg);
  160. }
  161. static inline void
  162. __iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
  163. {
  164. return pv_iosapic_ops.__write(iosapic, reg, val);
  165. }
  166. /******************************************************************************
  167. * replacement of irq operations.
  168. */
  169. struct pv_irq_ops {
  170. void (*register_ipi)(void);
  171. int (*assign_irq_vector)(int irq);
  172. void (*free_irq_vector)(int vector);
  173. void (*register_percpu_irq)(ia64_vector vec,
  174. struct irqaction *action);
  175. void (*resend_irq)(unsigned int vector);
  176. };
  177. extern struct pv_irq_ops pv_irq_ops;
  178. static inline void
  179. ia64_register_ipi(void)
  180. {
  181. pv_irq_ops.register_ipi();
  182. }
  183. static inline int
  184. assign_irq_vector(int irq)
  185. {
  186. return pv_irq_ops.assign_irq_vector(irq);
  187. }
  188. static inline void
  189. free_irq_vector(int vector)
  190. {
  191. return pv_irq_ops.free_irq_vector(vector);
  192. }
  193. static inline void
  194. register_percpu_irq(ia64_vector vec, struct irqaction *action)
  195. {
  196. pv_irq_ops.register_percpu_irq(vec, action);
  197. }
  198. static inline void
  199. ia64_resend_irq(unsigned int vector)
  200. {
  201. pv_irq_ops.resend_irq(vector);
  202. }
  203. /******************************************************************************
  204. * replacement of time operations.
  205. */
  206. extern struct itc_jitter_data_t itc_jitter_data;
  207. extern volatile int time_keeper_id;
  208. struct pv_time_ops {
  209. void (*init_missing_ticks_accounting)(int cpu);
  210. int (*do_steal_accounting)(unsigned long *new_itm);
  211. void (*clocksource_resume)(void);
  212. unsigned long long (*sched_clock)(void);
  213. };
  214. extern struct pv_time_ops pv_time_ops;
  215. static inline void
  216. paravirt_init_missing_ticks_accounting(int cpu)
  217. {
  218. if (pv_time_ops.init_missing_ticks_accounting)
  219. pv_time_ops.init_missing_ticks_accounting(cpu);
  220. }
  221. struct static_key;
  222. extern struct static_key paravirt_steal_enabled;
  223. extern struct static_key paravirt_steal_rq_enabled;
  224. static inline int
  225. paravirt_do_steal_accounting(unsigned long *new_itm)
  226. {
  227. return pv_time_ops.do_steal_accounting(new_itm);
  228. }
  229. static inline unsigned long long paravirt_sched_clock(void)
  230. {
  231. return pv_time_ops.sched_clock();
  232. }
  233. #endif /* !__ASSEMBLY__ */
  234. #else
  235. /* fallback for native case */
  236. #ifndef __ASSEMBLY__
  237. #define paravirt_banner() do { } while (0)
  238. #define paravirt_reserve_memory(region) 0
  239. #define paravirt_arch_setup_early() do { } while (0)
  240. #define paravirt_arch_setup_console(cmdline_p) do { } while (0)
  241. #define paravirt_arch_setup_nomca() 0
  242. #define paravirt_post_smp_prepare_boot_cpu() do { } while (0)
  243. #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
  244. #define paravirt_do_steal_accounting(new_itm) 0
  245. #endif /* __ASSEMBLY__ */
  246. #endif /* CONFIG_PARAVIRT_GUEST */
  247. #endif /* __ASM_PARAVIRT_H */