paravirt.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. #ifndef __ASM_PARAVIRT_H
  2. #define __ASM_PARAVIRT_H
  3. /* Various instructions on x86 need to be replaced for
  4. * para-virtualization: those hooks are defined here. */
  5. #ifdef CONFIG_PARAVIRT
  6. #include <asm/page.h>
  7. /* Bitmask of what can be clobbered: usually at least eax. */
  8. #define CLBR_NONE 0x0
  9. #define CLBR_EAX 0x1
  10. #define CLBR_ECX 0x2
  11. #define CLBR_EDX 0x4
  12. #define CLBR_ANY 0x7
  13. #ifndef __ASSEMBLY__
  14. #include <linux/types.h>
  15. #include <linux/cpumask.h>
  16. #include <asm/kmap_types.h>
  17. struct page;
  18. struct thread_struct;
  19. struct Xgt_desc_struct;
  20. struct tss_struct;
  21. struct mm_struct;
  22. struct desc_struct;
  23. /* general info */
  24. struct pv_info {
  25. unsigned int kernel_rpl;
  26. int shared_kernel_pmd;
  27. int paravirt_enabled;
  28. const char *name;
  29. };
  30. struct pv_init_ops {
  31. /*
  32. * Patch may replace one of the defined code sequences with
  33. * arbitrary code, subject to the same register constraints.
  34. * This generally means the code is not free to clobber any
  35. * registers other than EAX. The patch function should return
  36. * the number of bytes of code generated, as we nop pad the
  37. * rest in generic code.
  38. */
  39. unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
  40. unsigned long addr, unsigned len);
  41. /* Basic arch-specific setup */
  42. void (*arch_setup)(void);
  43. char *(*memory_setup)(void);
  44. void (*post_allocator_init)(void);
  45. /* Print a banner to identify the environment */
  46. void (*banner)(void);
  47. };
  48. struct pv_lazy_ops {
  49. /* Set deferred update mode, used for batching operations. */
  50. void (*enter)(void);
  51. void (*leave)(void);
  52. };
  53. struct pv_time_ops {
  54. void (*time_init)(void);
  55. /* Set and set time of day */
  56. unsigned long (*get_wallclock)(void);
  57. int (*set_wallclock)(unsigned long);
  58. unsigned long long (*sched_clock)(void);
  59. unsigned long (*get_cpu_khz)(void);
  60. };
  61. struct pv_cpu_ops {
  62. /* hooks for various privileged instructions */
  63. unsigned long (*get_debugreg)(int regno);
  64. void (*set_debugreg)(int regno, unsigned long value);
  65. void (*clts)(void);
  66. unsigned long (*read_cr0)(void);
  67. void (*write_cr0)(unsigned long);
  68. unsigned long (*read_cr4_safe)(void);
  69. unsigned long (*read_cr4)(void);
  70. void (*write_cr4)(unsigned long);
  71. /* Segment descriptor handling */
  72. void (*load_tr_desc)(void);
  73. void (*load_gdt)(const struct Xgt_desc_struct *);
  74. void (*load_idt)(const struct Xgt_desc_struct *);
  75. void (*store_gdt)(struct Xgt_desc_struct *);
  76. void (*store_idt)(struct Xgt_desc_struct *);
  77. void (*set_ldt)(const void *desc, unsigned entries);
  78. unsigned long (*store_tr)(void);
  79. void (*load_tls)(struct thread_struct *t, unsigned int cpu);
  80. void (*write_ldt_entry)(struct desc_struct *,
  81. int entrynum, u32 low, u32 high);
  82. void (*write_gdt_entry)(struct desc_struct *,
  83. int entrynum, u32 low, u32 high);
  84. void (*write_idt_entry)(struct desc_struct *,
  85. int entrynum, u32 low, u32 high);
  86. void (*load_esp0)(struct tss_struct *tss, struct thread_struct *t);
  87. void (*set_iopl_mask)(unsigned mask);
  88. void (*wbinvd)(void);
  89. void (*io_delay)(void);
  90. /* cpuid emulation, mostly so that caps bits can be disabled */
  91. void (*cpuid)(unsigned int *eax, unsigned int *ebx,
  92. unsigned int *ecx, unsigned int *edx);
  93. /* MSR, PMC and TSR operations.
  94. err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */
  95. u64 (*read_msr)(unsigned int msr, int *err);
  96. int (*write_msr)(unsigned int msr, u64 val);
  97. u64 (*read_tsc)(void);
  98. u64 (*read_pmc)(void);
  99. /* These two are jmp to, not actually called. */
  100. void (*irq_enable_sysexit)(void);
  101. void (*iret)(void);
  102. struct pv_lazy_ops lazy_mode;
  103. };
  104. struct pv_irq_ops {
  105. void (*init_IRQ)(void);
  106. /*
  107. * Get/set interrupt state. save_fl and restore_fl are only
  108. * expected to use X86_EFLAGS_IF; all other bits
  109. * returned from save_fl are undefined, and may be ignored by
  110. * restore_fl.
  111. */
  112. unsigned long (*save_fl)(void);
  113. void (*restore_fl)(unsigned long);
  114. void (*irq_disable)(void);
  115. void (*irq_enable)(void);
  116. void (*safe_halt)(void);
  117. void (*halt)(void);
  118. };
  119. struct pv_apic_ops {
  120. #ifdef CONFIG_X86_LOCAL_APIC
  121. /*
  122. * Direct APIC operations, principally for VMI. Ideally
  123. * these shouldn't be in this interface.
  124. */
  125. void (*apic_write)(unsigned long reg, unsigned long v);
  126. void (*apic_write_atomic)(unsigned long reg, unsigned long v);
  127. unsigned long (*apic_read)(unsigned long reg);
  128. void (*setup_boot_clock)(void);
  129. void (*setup_secondary_clock)(void);
  130. void (*startup_ipi_hook)(int phys_apicid,
  131. unsigned long start_eip,
  132. unsigned long start_esp);
  133. #endif
  134. };
  135. struct pv_mmu_ops {
  136. /*
  137. * Called before/after init_mm pagetable setup. setup_start
  138. * may reset %cr3, and may pre-install parts of the pagetable;
  139. * pagetable setup is expected to preserve any existing
  140. * mapping.
  141. */
  142. void (*pagetable_setup_start)(pgd_t *pgd_base);
  143. void (*pagetable_setup_done)(pgd_t *pgd_base);
  144. unsigned long (*read_cr2)(void);
  145. void (*write_cr2)(unsigned long);
  146. unsigned long (*read_cr3)(void);
  147. void (*write_cr3)(unsigned long);
  148. /*
  149. * Hooks for intercepting the creation/use/destruction of an
  150. * mm_struct.
  151. */
  152. void (*activate_mm)(struct mm_struct *prev,
  153. struct mm_struct *next);
  154. void (*dup_mmap)(struct mm_struct *oldmm,
  155. struct mm_struct *mm);
  156. void (*exit_mmap)(struct mm_struct *mm);
  157. /* TLB operations */
  158. void (*flush_tlb_user)(void);
  159. void (*flush_tlb_kernel)(void);
  160. void (*flush_tlb_single)(unsigned long addr);
  161. void (*flush_tlb_others)(const cpumask_t *cpus, struct mm_struct *mm,
  162. unsigned long va);
  163. /* Hooks for allocating/releasing pagetable pages */
  164. void (*alloc_pt)(struct mm_struct *mm, u32 pfn);
  165. void (*alloc_pd)(u32 pfn);
  166. void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
  167. void (*release_pt)(u32 pfn);
  168. void (*release_pd)(u32 pfn);
  169. /* Pagetable manipulation functions */
  170. void (*set_pte)(pte_t *ptep, pte_t pteval);
  171. void (*set_pte_at)(struct mm_struct *mm, unsigned long addr,
  172. pte_t *ptep, pte_t pteval);
  173. void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval);
  174. void (*pte_update)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  175. void (*pte_update_defer)(struct mm_struct *mm,
  176. unsigned long addr, pte_t *ptep);
  177. #ifdef CONFIG_X86_PAE
  178. void (*set_pte_atomic)(pte_t *ptep, pte_t pteval);
  179. void (*set_pte_present)(struct mm_struct *mm, unsigned long addr,
  180. pte_t *ptep, pte_t pte);
  181. void (*set_pud)(pud_t *pudp, pud_t pudval);
  182. void (*pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  183. void (*pmd_clear)(pmd_t *pmdp);
  184. unsigned long long (*pte_val)(pte_t);
  185. unsigned long long (*pmd_val)(pmd_t);
  186. unsigned long long (*pgd_val)(pgd_t);
  187. pte_t (*make_pte)(unsigned long long pte);
  188. pmd_t (*make_pmd)(unsigned long long pmd);
  189. pgd_t (*make_pgd)(unsigned long long pgd);
  190. #else
  191. unsigned long (*pte_val)(pte_t);
  192. unsigned long (*pgd_val)(pgd_t);
  193. pte_t (*make_pte)(unsigned long pte);
  194. pgd_t (*make_pgd)(unsigned long pgd);
  195. #endif
  196. #ifdef CONFIG_HIGHPTE
  197. void *(*kmap_atomic_pte)(struct page *page, enum km_type type);
  198. #endif
  199. struct pv_lazy_ops lazy_mode;
  200. };
  201. /* This contains all the paravirt structures: we get a convenient
  202. * number for each function using the offset which we use to indicate
  203. * what to patch. */
  204. struct paravirt_patch_template
  205. {
  206. struct pv_init_ops pv_init_ops;
  207. struct pv_time_ops pv_time_ops;
  208. struct pv_cpu_ops pv_cpu_ops;
  209. struct pv_irq_ops pv_irq_ops;
  210. struct pv_apic_ops pv_apic_ops;
  211. struct pv_mmu_ops pv_mmu_ops;
  212. };
  213. extern struct pv_info pv_info;
  214. extern struct pv_init_ops pv_init_ops;
  215. extern struct pv_time_ops pv_time_ops;
  216. extern struct pv_cpu_ops pv_cpu_ops;
  217. extern struct pv_irq_ops pv_irq_ops;
  218. extern struct pv_apic_ops pv_apic_ops;
  219. extern struct pv_mmu_ops pv_mmu_ops;
  220. #define PARAVIRT_PATCH(x) \
  221. (offsetof(struct paravirt_patch_template, x) / sizeof(void *))
  222. #define paravirt_type(op) \
  223. [paravirt_typenum] "i" (PARAVIRT_PATCH(op)), \
  224. [paravirt_opptr] "m" (op)
  225. #define paravirt_clobber(clobber) \
  226. [paravirt_clobber] "i" (clobber)
  227. /*
  228. * Generate some code, and mark it as patchable by the
  229. * apply_paravirt() alternate instruction patcher.
  230. */
  231. #define _paravirt_alt(insn_string, type, clobber) \
  232. "771:\n\t" insn_string "\n" "772:\n" \
  233. ".pushsection .parainstructions,\"a\"\n" \
  234. " .long 771b\n" \
  235. " .byte " type "\n" \
  236. " .byte 772b-771b\n" \
  237. " .short " clobber "\n" \
  238. ".popsection\n"
  239. /* Generate patchable code, with the default asm parameters. */
  240. #define paravirt_alt(insn_string) \
  241. _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
  242. unsigned paravirt_patch_nop(void);
  243. unsigned paravirt_patch_ignore(unsigned len);
  244. unsigned paravirt_patch_call(void *insnbuf,
  245. const void *target, u16 tgt_clobbers,
  246. unsigned long addr, u16 site_clobbers,
  247. unsigned len);
  248. unsigned paravirt_patch_jmp(void *insnbuf, const void *target,
  249. unsigned long addr, unsigned len);
  250. unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
  251. unsigned long addr, unsigned len);
  252. unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
  253. const char *start, const char *end);
  254. int paravirt_disable_iospace(void);
  255. /*
  256. * This generates an indirect call based on the operation type number.
  257. * The type number, computed in PARAVIRT_PATCH, is derived from the
  258. * offset into the paravirt_patch_template structure, and can therefore be
  259. * freely converted back into a structure offset.
  260. */
  261. #define PARAVIRT_CALL "call *%[paravirt_opptr];"
  262. /*
  263. * These macros are intended to wrap calls through one of the paravirt
  264. * ops structs, so that they can be later identified and patched at
  265. * runtime.
  266. *
  267. * Normally, a call to a pv_op function is a simple indirect call:
  268. * (paravirt_ops.operations)(args...).
  269. *
  270. * Unfortunately, this is a relatively slow operation for modern CPUs,
  271. * because it cannot necessarily determine what the destination
  272. * address is. In this case, the address is a runtime constant, so at
  273. * the very least we can patch the call to e a simple direct call, or
  274. * ideally, patch an inline implementation into the callsite. (Direct
  275. * calls are essentially free, because the call and return addresses
  276. * are completely predictable.)
  277. *
  278. * These macros rely on the standard gcc "regparm(3)" calling
  279. * convention, in which the first three arguments are placed in %eax,
  280. * %edx, %ecx (in that order), and the remaining arguments are placed
  281. * on the stack. All caller-save registers (eax,edx,ecx) are expected
  282. * to be modified (either clobbered or used for return values).
  283. *
  284. * The call instruction itself is marked by placing its start address
  285. * and size into the .parainstructions section, so that
  286. * apply_paravirt() in arch/i386/kernel/alternative.c can do the
  287. * appropriate patching under the control of the backend pv_init_ops
  288. * implementation.
  289. *
  290. * Unfortunately there's no way to get gcc to generate the args setup
  291. * for the call, and then allow the call itself to be generated by an
  292. * inline asm. Because of this, we must do the complete arg setup and
  293. * return value handling from within these macros. This is fairly
  294. * cumbersome.
  295. *
  296. * There are 5 sets of PVOP_* macros for dealing with 0-4 arguments.
  297. * It could be extended to more arguments, but there would be little
  298. * to be gained from that. For each number of arguments, there are
  299. * the two VCALL and CALL variants for void and non-void functions.
  300. *
  301. * When there is a return value, the invoker of the macro must specify
  302. * the return type. The macro then uses sizeof() on that type to
  303. * determine whether its a 32 or 64 bit value, and places the return
  304. * in the right register(s) (just %eax for 32-bit, and %edx:%eax for
  305. * 64-bit).
  306. *
  307. * 64-bit arguments are passed as a pair of adjacent 32-bit arguments
  308. * in low,high order.
  309. *
  310. * Small structures are passed and returned in registers. The macro
  311. * calling convention can't directly deal with this, so the wrapper
  312. * functions must do this.
  313. *
  314. * These PVOP_* macros are only defined within this header. This
  315. * means that all uses must be wrapped in inline functions. This also
  316. * makes sure the incoming and outgoing types are always correct.
  317. */
  318. #define __PVOP_CALL(rettype, op, pre, post, ...) \
  319. ({ \
  320. rettype __ret; \
  321. unsigned long __eax, __edx, __ecx; \
  322. if (sizeof(rettype) > sizeof(unsigned long)) { \
  323. asm volatile(pre \
  324. paravirt_alt(PARAVIRT_CALL) \
  325. post \
  326. : "=a" (__eax), "=d" (__edx), \
  327. "=c" (__ecx) \
  328. : paravirt_type(op), \
  329. paravirt_clobber(CLBR_ANY), \
  330. ##__VA_ARGS__ \
  331. : "memory", "cc"); \
  332. __ret = (rettype)((((u64)__edx) << 32) | __eax); \
  333. } else { \
  334. asm volatile(pre \
  335. paravirt_alt(PARAVIRT_CALL) \
  336. post \
  337. : "=a" (__eax), "=d" (__edx), \
  338. "=c" (__ecx) \
  339. : paravirt_type(op), \
  340. paravirt_clobber(CLBR_ANY), \
  341. ##__VA_ARGS__ \
  342. : "memory", "cc"); \
  343. __ret = (rettype)__eax; \
  344. } \
  345. __ret; \
  346. })
  347. #define __PVOP_VCALL(op, pre, post, ...) \
  348. ({ \
  349. unsigned long __eax, __edx, __ecx; \
  350. asm volatile(pre \
  351. paravirt_alt(PARAVIRT_CALL) \
  352. post \
  353. : "=a" (__eax), "=d" (__edx), "=c" (__ecx) \
  354. : paravirt_type(op), \
  355. paravirt_clobber(CLBR_ANY), \
  356. ##__VA_ARGS__ \
  357. : "memory", "cc"); \
  358. })
  359. #define PVOP_CALL0(rettype, op) \
  360. __PVOP_CALL(rettype, op, "", "")
  361. #define PVOP_VCALL0(op) \
  362. __PVOP_VCALL(op, "", "")
  363. #define PVOP_CALL1(rettype, op, arg1) \
  364. __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)))
  365. #define PVOP_VCALL1(op, arg1) \
  366. __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)))
  367. #define PVOP_CALL2(rettype, op, arg1, arg2) \
  368. __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2)))
  369. #define PVOP_VCALL2(op, arg1, arg2) \
  370. __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2)))
  371. #define PVOP_CALL3(rettype, op, arg1, arg2, arg3) \
  372. __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), \
  373. "1"((u32)(arg2)), "2"((u32)(arg3)))
  374. #define PVOP_VCALL3(op, arg1, arg2, arg3) \
  375. __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1"((u32)(arg2)), \
  376. "2"((u32)(arg3)))
  377. #define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \
  378. __PVOP_CALL(rettype, op, \
  379. "push %[_arg4];", "lea 4(%%esp),%%esp;", \
  380. "0" ((u32)(arg1)), "1" ((u32)(arg2)), \
  381. "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4)))
  382. #define PVOP_VCALL4(op, arg1, arg2, arg3, arg4) \
  383. __PVOP_VCALL(op, \
  384. "push %[_arg4];", "lea 4(%%esp),%%esp;", \
  385. "0" ((u32)(arg1)), "1" ((u32)(arg2)), \
  386. "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4)))
  387. static inline int paravirt_enabled(void)
  388. {
  389. return pv_info.paravirt_enabled;
  390. }
  391. static inline void load_esp0(struct tss_struct *tss,
  392. struct thread_struct *thread)
  393. {
  394. PVOP_VCALL2(pv_cpu_ops.load_esp0, tss, thread);
  395. }
  396. #define ARCH_SETUP pv_init_ops.arch_setup();
  397. static inline unsigned long get_wallclock(void)
  398. {
  399. return PVOP_CALL0(unsigned long, pv_time_ops.get_wallclock);
  400. }
  401. static inline int set_wallclock(unsigned long nowtime)
  402. {
  403. return PVOP_CALL1(int, pv_time_ops.set_wallclock, nowtime);
  404. }
  405. static inline void (*choose_time_init(void))(void)
  406. {
  407. return pv_time_ops.time_init;
  408. }
  409. /* The paravirtualized CPUID instruction. */
  410. static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
  411. unsigned int *ecx, unsigned int *edx)
  412. {
  413. PVOP_VCALL4(pv_cpu_ops.cpuid, eax, ebx, ecx, edx);
  414. }
  415. /*
  416. * These special macros can be used to get or set a debugging register
  417. */
  418. static inline unsigned long paravirt_get_debugreg(int reg)
  419. {
  420. return PVOP_CALL1(unsigned long, pv_cpu_ops.get_debugreg, reg);
  421. }
  422. #define get_debugreg(var, reg) var = paravirt_get_debugreg(reg)
  423. static inline void set_debugreg(unsigned long val, int reg)
  424. {
  425. PVOP_VCALL2(pv_cpu_ops.set_debugreg, reg, val);
  426. }
  427. static inline void clts(void)
  428. {
  429. PVOP_VCALL0(pv_cpu_ops.clts);
  430. }
  431. static inline unsigned long read_cr0(void)
  432. {
  433. return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr0);
  434. }
  435. static inline void write_cr0(unsigned long x)
  436. {
  437. PVOP_VCALL1(pv_cpu_ops.write_cr0, x);
  438. }
  439. static inline unsigned long read_cr2(void)
  440. {
  441. return PVOP_CALL0(unsigned long, pv_mmu_ops.read_cr2);
  442. }
  443. static inline void write_cr2(unsigned long x)
  444. {
  445. PVOP_VCALL1(pv_mmu_ops.write_cr2, x);
  446. }
  447. static inline unsigned long read_cr3(void)
  448. {
  449. return PVOP_CALL0(unsigned long, pv_mmu_ops.read_cr3);
  450. }
  451. static inline void write_cr3(unsigned long x)
  452. {
  453. PVOP_VCALL1(pv_mmu_ops.write_cr3, x);
  454. }
  455. static inline unsigned long read_cr4(void)
  456. {
  457. return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr4);
  458. }
  459. static inline unsigned long read_cr4_safe(void)
  460. {
  461. return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr4_safe);
  462. }
  463. static inline void write_cr4(unsigned long x)
  464. {
  465. PVOP_VCALL1(pv_cpu_ops.write_cr4, x);
  466. }
  467. static inline void raw_safe_halt(void)
  468. {
  469. PVOP_VCALL0(pv_irq_ops.safe_halt);
  470. }
  471. static inline void halt(void)
  472. {
  473. PVOP_VCALL0(pv_irq_ops.safe_halt);
  474. }
  475. static inline void wbinvd(void)
  476. {
  477. PVOP_VCALL0(pv_cpu_ops.wbinvd);
  478. }
  479. #define get_kernel_rpl() (pv_info.kernel_rpl)
  480. static inline u64 paravirt_read_msr(unsigned msr, int *err)
  481. {
  482. return PVOP_CALL2(u64, pv_cpu_ops.read_msr, msr, err);
  483. }
  484. static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high)
  485. {
  486. return PVOP_CALL3(int, pv_cpu_ops.write_msr, msr, low, high);
  487. }
  488. /* These should all do BUG_ON(_err), but our headers are too tangled. */
  489. #define rdmsr(msr,val1,val2) do { \
  490. int _err; \
  491. u64 _l = paravirt_read_msr(msr, &_err); \
  492. val1 = (u32)_l; \
  493. val2 = _l >> 32; \
  494. } while(0)
  495. #define wrmsr(msr,val1,val2) do { \
  496. paravirt_write_msr(msr, val1, val2); \
  497. } while(0)
  498. #define rdmsrl(msr,val) do { \
  499. int _err; \
  500. val = paravirt_read_msr(msr, &_err); \
  501. } while(0)
  502. #define wrmsrl(msr,val) wrmsr(msr, (u32)((u64)(val)), ((u64)(val))>>32)
  503. #define wrmsr_safe(msr,a,b) paravirt_write_msr(msr, a, b)
  504. /* rdmsr with exception handling */
  505. #define rdmsr_safe(msr,a,b) ({ \
  506. int _err; \
  507. u64 _l = paravirt_read_msr(msr, &_err); \
  508. (*a) = (u32)_l; \
  509. (*b) = _l >> 32; \
  510. _err; })
  511. static inline u64 paravirt_read_tsc(void)
  512. {
  513. return PVOP_CALL0(u64, pv_cpu_ops.read_tsc);
  514. }
  515. #define rdtscl(low) do { \
  516. u64 _l = paravirt_read_tsc(); \
  517. low = (int)_l; \
  518. } while(0)
  519. #define rdtscll(val) (val = paravirt_read_tsc())
  520. static inline unsigned long long paravirt_sched_clock(void)
  521. {
  522. return PVOP_CALL0(unsigned long long, pv_time_ops.sched_clock);
  523. }
  524. #define calculate_cpu_khz() (pv_time_ops.get_cpu_khz())
  525. #define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
  526. static inline unsigned long long paravirt_read_pmc(int counter)
  527. {
  528. return PVOP_CALL1(u64, pv_cpu_ops.read_pmc, counter);
  529. }
  530. #define rdpmc(counter,low,high) do { \
  531. u64 _l = paravirt_read_pmc(counter); \
  532. low = (u32)_l; \
  533. high = _l >> 32; \
  534. } while(0)
  535. static inline void load_TR_desc(void)
  536. {
  537. PVOP_VCALL0(pv_cpu_ops.load_tr_desc);
  538. }
  539. static inline void load_gdt(const struct Xgt_desc_struct *dtr)
  540. {
  541. PVOP_VCALL1(pv_cpu_ops.load_gdt, dtr);
  542. }
  543. static inline void load_idt(const struct Xgt_desc_struct *dtr)
  544. {
  545. PVOP_VCALL1(pv_cpu_ops.load_idt, dtr);
  546. }
  547. static inline void set_ldt(const void *addr, unsigned entries)
  548. {
  549. PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries);
  550. }
  551. static inline void store_gdt(struct Xgt_desc_struct *dtr)
  552. {
  553. PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr);
  554. }
  555. static inline void store_idt(struct Xgt_desc_struct *dtr)
  556. {
  557. PVOP_VCALL1(pv_cpu_ops.store_idt, dtr);
  558. }
  559. static inline unsigned long paravirt_store_tr(void)
  560. {
  561. return PVOP_CALL0(unsigned long, pv_cpu_ops.store_tr);
  562. }
  563. #define store_tr(tr) ((tr) = paravirt_store_tr())
  564. static inline void load_TLS(struct thread_struct *t, unsigned cpu)
  565. {
  566. PVOP_VCALL2(pv_cpu_ops.load_tls, t, cpu);
  567. }
  568. static inline void write_ldt_entry(void *dt, int entry, u32 low, u32 high)
  569. {
  570. PVOP_VCALL4(pv_cpu_ops.write_ldt_entry, dt, entry, low, high);
  571. }
  572. static inline void write_gdt_entry(void *dt, int entry, u32 low, u32 high)
  573. {
  574. PVOP_VCALL4(pv_cpu_ops.write_gdt_entry, dt, entry, low, high);
  575. }
  576. static inline void write_idt_entry(void *dt, int entry, u32 low, u32 high)
  577. {
  578. PVOP_VCALL4(pv_cpu_ops.write_idt_entry, dt, entry, low, high);
  579. }
  580. static inline void set_iopl_mask(unsigned mask)
  581. {
  582. PVOP_VCALL1(pv_cpu_ops.set_iopl_mask, mask);
  583. }
  584. /* The paravirtualized I/O functions */
  585. static inline void slow_down_io(void) {
  586. pv_cpu_ops.io_delay();
  587. #ifdef REALLY_SLOW_IO
  588. pv_cpu_ops.io_delay();
  589. pv_cpu_ops.io_delay();
  590. pv_cpu_ops.io_delay();
  591. #endif
  592. }
  593. #ifdef CONFIG_X86_LOCAL_APIC
  594. /*
  595. * Basic functions accessing APICs.
  596. */
  597. static inline void apic_write(unsigned long reg, unsigned long v)
  598. {
  599. PVOP_VCALL2(pv_apic_ops.apic_write, reg, v);
  600. }
  601. static inline void apic_write_atomic(unsigned long reg, unsigned long v)
  602. {
  603. PVOP_VCALL2(pv_apic_ops.apic_write_atomic, reg, v);
  604. }
  605. static inline unsigned long apic_read(unsigned long reg)
  606. {
  607. return PVOP_CALL1(unsigned long, pv_apic_ops.apic_read, reg);
  608. }
  609. static inline void setup_boot_clock(void)
  610. {
  611. PVOP_VCALL0(pv_apic_ops.setup_boot_clock);
  612. }
  613. static inline void setup_secondary_clock(void)
  614. {
  615. PVOP_VCALL0(pv_apic_ops.setup_secondary_clock);
  616. }
  617. #endif
  618. static inline void paravirt_post_allocator_init(void)
  619. {
  620. if (pv_init_ops.post_allocator_init)
  621. (*pv_init_ops.post_allocator_init)();
  622. }
  623. static inline void paravirt_pagetable_setup_start(pgd_t *base)
  624. {
  625. (*pv_mmu_ops.pagetable_setup_start)(base);
  626. }
  627. static inline void paravirt_pagetable_setup_done(pgd_t *base)
  628. {
  629. (*pv_mmu_ops.pagetable_setup_done)(base);
  630. }
  631. #ifdef CONFIG_SMP
  632. static inline void startup_ipi_hook(int phys_apicid, unsigned long start_eip,
  633. unsigned long start_esp)
  634. {
  635. PVOP_VCALL3(pv_apic_ops.startup_ipi_hook,
  636. phys_apicid, start_eip, start_esp);
  637. }
  638. #endif
  639. static inline void paravirt_activate_mm(struct mm_struct *prev,
  640. struct mm_struct *next)
  641. {
  642. PVOP_VCALL2(pv_mmu_ops.activate_mm, prev, next);
  643. }
  644. static inline void arch_dup_mmap(struct mm_struct *oldmm,
  645. struct mm_struct *mm)
  646. {
  647. PVOP_VCALL2(pv_mmu_ops.dup_mmap, oldmm, mm);
  648. }
  649. static inline void arch_exit_mmap(struct mm_struct *mm)
  650. {
  651. PVOP_VCALL1(pv_mmu_ops.exit_mmap, mm);
  652. }
  653. static inline void __flush_tlb(void)
  654. {
  655. PVOP_VCALL0(pv_mmu_ops.flush_tlb_user);
  656. }
  657. static inline void __flush_tlb_global(void)
  658. {
  659. PVOP_VCALL0(pv_mmu_ops.flush_tlb_kernel);
  660. }
  661. static inline void __flush_tlb_single(unsigned long addr)
  662. {
  663. PVOP_VCALL1(pv_mmu_ops.flush_tlb_single, addr);
  664. }
  665. static inline void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
  666. unsigned long va)
  667. {
  668. PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va);
  669. }
  670. static inline void paravirt_alloc_pt(struct mm_struct *mm, unsigned pfn)
  671. {
  672. PVOP_VCALL2(pv_mmu_ops.alloc_pt, mm, pfn);
  673. }
  674. static inline void paravirt_release_pt(unsigned pfn)
  675. {
  676. PVOP_VCALL1(pv_mmu_ops.release_pt, pfn);
  677. }
  678. static inline void paravirt_alloc_pd(unsigned pfn)
  679. {
  680. PVOP_VCALL1(pv_mmu_ops.alloc_pd, pfn);
  681. }
  682. static inline void paravirt_alloc_pd_clone(unsigned pfn, unsigned clonepfn,
  683. unsigned start, unsigned count)
  684. {
  685. PVOP_VCALL4(pv_mmu_ops.alloc_pd_clone, pfn, clonepfn, start, count);
  686. }
  687. static inline void paravirt_release_pd(unsigned pfn)
  688. {
  689. PVOP_VCALL1(pv_mmu_ops.release_pd, pfn);
  690. }
  691. #ifdef CONFIG_HIGHPTE
  692. static inline void *kmap_atomic_pte(struct page *page, enum km_type type)
  693. {
  694. unsigned long ret;
  695. ret = PVOP_CALL2(unsigned long, pv_mmu_ops.kmap_atomic_pte, page, type);
  696. return (void *)ret;
  697. }
  698. #endif
  699. static inline void pte_update(struct mm_struct *mm, unsigned long addr,
  700. pte_t *ptep)
  701. {
  702. PVOP_VCALL3(pv_mmu_ops.pte_update, mm, addr, ptep);
  703. }
  704. static inline void pte_update_defer(struct mm_struct *mm, unsigned long addr,
  705. pte_t *ptep)
  706. {
  707. PVOP_VCALL3(pv_mmu_ops.pte_update_defer, mm, addr, ptep);
  708. }
  709. #ifdef CONFIG_X86_PAE
  710. static inline pte_t __pte(unsigned long long val)
  711. {
  712. unsigned long long ret = PVOP_CALL2(unsigned long long,
  713. pv_mmu_ops.make_pte,
  714. val, val >> 32);
  715. return (pte_t) { ret, ret >> 32 };
  716. }
  717. static inline pmd_t __pmd(unsigned long long val)
  718. {
  719. return (pmd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pmd,
  720. val, val >> 32) };
  721. }
  722. static inline pgd_t __pgd(unsigned long long val)
  723. {
  724. return (pgd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pgd,
  725. val, val >> 32) };
  726. }
  727. static inline unsigned long long pte_val(pte_t x)
  728. {
  729. return PVOP_CALL2(unsigned long long, pv_mmu_ops.pte_val,
  730. x.pte_low, x.pte_high);
  731. }
  732. static inline unsigned long long pmd_val(pmd_t x)
  733. {
  734. return PVOP_CALL2(unsigned long long, pv_mmu_ops.pmd_val,
  735. x.pmd, x.pmd >> 32);
  736. }
  737. static inline unsigned long long pgd_val(pgd_t x)
  738. {
  739. return PVOP_CALL2(unsigned long long, pv_mmu_ops.pgd_val,
  740. x.pgd, x.pgd >> 32);
  741. }
  742. static inline void set_pte(pte_t *ptep, pte_t pteval)
  743. {
  744. PVOP_VCALL3(pv_mmu_ops.set_pte, ptep, pteval.pte_low, pteval.pte_high);
  745. }
  746. static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
  747. pte_t *ptep, pte_t pteval)
  748. {
  749. /* 5 arg words */
  750. pv_mmu_ops.set_pte_at(mm, addr, ptep, pteval);
  751. }
  752. static inline void set_pte_atomic(pte_t *ptep, pte_t pteval)
  753. {
  754. PVOP_VCALL3(pv_mmu_ops.set_pte_atomic, ptep,
  755. pteval.pte_low, pteval.pte_high);
  756. }
  757. static inline void set_pte_present(struct mm_struct *mm, unsigned long addr,
  758. pte_t *ptep, pte_t pte)
  759. {
  760. /* 5 arg words */
  761. pv_mmu_ops.set_pte_present(mm, addr, ptep, pte);
  762. }
  763. static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval)
  764. {
  765. PVOP_VCALL3(pv_mmu_ops.set_pmd, pmdp,
  766. pmdval.pmd, pmdval.pmd >> 32);
  767. }
  768. static inline void set_pud(pud_t *pudp, pud_t pudval)
  769. {
  770. PVOP_VCALL3(pv_mmu_ops.set_pud, pudp,
  771. pudval.pgd.pgd, pudval.pgd.pgd >> 32);
  772. }
  773. static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
  774. {
  775. PVOP_VCALL3(pv_mmu_ops.pte_clear, mm, addr, ptep);
  776. }
  777. static inline void pmd_clear(pmd_t *pmdp)
  778. {
  779. PVOP_VCALL1(pv_mmu_ops.pmd_clear, pmdp);
  780. }
  781. #else /* !CONFIG_X86_PAE */
  782. static inline pte_t __pte(unsigned long val)
  783. {
  784. return (pte_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pte, val) };
  785. }
  786. static inline pgd_t __pgd(unsigned long val)
  787. {
  788. return (pgd_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pgd, val) };
  789. }
  790. static inline unsigned long pte_val(pte_t x)
  791. {
  792. return PVOP_CALL1(unsigned long, pv_mmu_ops.pte_val, x.pte_low);
  793. }
  794. static inline unsigned long pgd_val(pgd_t x)
  795. {
  796. return PVOP_CALL1(unsigned long, pv_mmu_ops.pgd_val, x.pgd);
  797. }
  798. static inline void set_pte(pte_t *ptep, pte_t pteval)
  799. {
  800. PVOP_VCALL2(pv_mmu_ops.set_pte, ptep, pteval.pte_low);
  801. }
  802. static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
  803. pte_t *ptep, pte_t pteval)
  804. {
  805. PVOP_VCALL4(pv_mmu_ops.set_pte_at, mm, addr, ptep, pteval.pte_low);
  806. }
  807. static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval)
  808. {
  809. PVOP_VCALL2(pv_mmu_ops.set_pmd, pmdp, pmdval.pud.pgd.pgd);
  810. }
  811. #endif /* CONFIG_X86_PAE */
  812. /* Lazy mode for batching updates / context switch */
  813. enum paravirt_lazy_mode {
  814. PARAVIRT_LAZY_NONE,
  815. PARAVIRT_LAZY_MMU,
  816. PARAVIRT_LAZY_CPU,
  817. };
  818. enum paravirt_lazy_mode paravirt_get_lazy_mode(void);
  819. void paravirt_enter_lazy_cpu(void);
  820. void paravirt_leave_lazy_cpu(void);
  821. void paravirt_enter_lazy_mmu(void);
  822. void paravirt_leave_lazy_mmu(void);
  823. void paravirt_leave_lazy(enum paravirt_lazy_mode mode);
  824. #define __HAVE_ARCH_ENTER_LAZY_CPU_MODE
  825. static inline void arch_enter_lazy_cpu_mode(void)
  826. {
  827. PVOP_VCALL0(pv_cpu_ops.lazy_mode.enter);
  828. }
  829. static inline void arch_leave_lazy_cpu_mode(void)
  830. {
  831. PVOP_VCALL0(pv_cpu_ops.lazy_mode.leave);
  832. }
  833. static inline void arch_flush_lazy_cpu_mode(void)
  834. {
  835. if (unlikely(paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU)) {
  836. arch_leave_lazy_cpu_mode();
  837. arch_enter_lazy_cpu_mode();
  838. }
  839. }
  840. #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
  841. static inline void arch_enter_lazy_mmu_mode(void)
  842. {
  843. PVOP_VCALL0(pv_mmu_ops.lazy_mode.enter);
  844. }
  845. static inline void arch_leave_lazy_mmu_mode(void)
  846. {
  847. PVOP_VCALL0(pv_mmu_ops.lazy_mode.leave);
  848. }
  849. static inline void arch_flush_lazy_mmu_mode(void)
  850. {
  851. if (unlikely(paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU)) {
  852. arch_leave_lazy_mmu_mode();
  853. arch_enter_lazy_mmu_mode();
  854. }
  855. }
  856. void _paravirt_nop(void);
  857. #define paravirt_nop ((void *)_paravirt_nop)
  858. /* These all sit in the .parainstructions section to tell us what to patch. */
  859. struct paravirt_patch_site {
  860. u8 *instr; /* original instructions */
  861. u8 instrtype; /* type of this instruction */
  862. u8 len; /* length of original instruction */
  863. u16 clobbers; /* what registers you may clobber */
  864. };
  865. extern struct paravirt_patch_site __parainstructions[],
  866. __parainstructions_end[];
  867. static inline unsigned long __raw_local_save_flags(void)
  868. {
  869. unsigned long f;
  870. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  871. PARAVIRT_CALL
  872. "popl %%edx; popl %%ecx")
  873. : "=a"(f)
  874. : paravirt_type(pv_irq_ops.save_fl),
  875. paravirt_clobber(CLBR_EAX)
  876. : "memory", "cc");
  877. return f;
  878. }
  879. static inline void raw_local_irq_restore(unsigned long f)
  880. {
  881. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  882. PARAVIRT_CALL
  883. "popl %%edx; popl %%ecx")
  884. : "=a"(f)
  885. : "0"(f),
  886. paravirt_type(pv_irq_ops.restore_fl),
  887. paravirt_clobber(CLBR_EAX)
  888. : "memory", "cc");
  889. }
  890. static inline void raw_local_irq_disable(void)
  891. {
  892. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  893. PARAVIRT_CALL
  894. "popl %%edx; popl %%ecx")
  895. :
  896. : paravirt_type(pv_irq_ops.irq_disable),
  897. paravirt_clobber(CLBR_EAX)
  898. : "memory", "eax", "cc");
  899. }
  900. static inline void raw_local_irq_enable(void)
  901. {
  902. asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;"
  903. PARAVIRT_CALL
  904. "popl %%edx; popl %%ecx")
  905. :
  906. : paravirt_type(pv_irq_ops.irq_enable),
  907. paravirt_clobber(CLBR_EAX)
  908. : "memory", "eax", "cc");
  909. }
  910. static inline unsigned long __raw_local_irq_save(void)
  911. {
  912. unsigned long f;
  913. f = __raw_local_save_flags();
  914. raw_local_irq_disable();
  915. return f;
  916. }
  917. #define CLI_STRING \
  918. _paravirt_alt("pushl %%ecx; pushl %%edx;" \
  919. "call *%[paravirt_cli_opptr];" \
  920. "popl %%edx; popl %%ecx", \
  921. "%c[paravirt_cli_type]", "%c[paravirt_clobber]")
  922. #define STI_STRING \
  923. _paravirt_alt("pushl %%ecx; pushl %%edx;" \
  924. "call *%[paravirt_sti_opptr];" \
  925. "popl %%edx; popl %%ecx", \
  926. "%c[paravirt_sti_type]", "%c[paravirt_clobber]")
  927. #define CLI_STI_CLOBBERS , "%eax"
  928. #define CLI_STI_INPUT_ARGS \
  929. , \
  930. [paravirt_cli_type] "i" (PARAVIRT_PATCH(pv_irq_ops.irq_disable)), \
  931. [paravirt_cli_opptr] "m" (pv_irq_ops.irq_disable), \
  932. [paravirt_sti_type] "i" (PARAVIRT_PATCH(pv_irq_ops.irq_enable)), \
  933. [paravirt_sti_opptr] "m" (pv_irq_ops.irq_enable), \
  934. paravirt_clobber(CLBR_EAX)
  935. /* Make sure as little as possible of this mess escapes. */
  936. #undef PARAVIRT_CALL
  937. #undef __PVOP_CALL
  938. #undef __PVOP_VCALL
  939. #undef PVOP_VCALL0
  940. #undef PVOP_CALL0
  941. #undef PVOP_VCALL1
  942. #undef PVOP_CALL1
  943. #undef PVOP_VCALL2
  944. #undef PVOP_CALL2
  945. #undef PVOP_VCALL3
  946. #undef PVOP_CALL3
  947. #undef PVOP_VCALL4
  948. #undef PVOP_CALL4
  949. #else /* __ASSEMBLY__ */
  950. #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
  951. #define PARA_SITE(ptype, clobbers, ops) \
  952. 771:; \
  953. ops; \
  954. 772:; \
  955. .pushsection .parainstructions,"a"; \
  956. .long 771b; \
  957. .byte ptype; \
  958. .byte 772b-771b; \
  959. .short clobbers; \
  960. .popsection
  961. #define INTERRUPT_RETURN \
  962. PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_iret), CLBR_NONE, \
  963. jmp *%cs:pv_cpu_ops+PV_CPU_iret)
  964. #define DISABLE_INTERRUPTS(clobbers) \
  965. PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_disable), clobbers, \
  966. pushl %eax; pushl %ecx; pushl %edx; \
  967. call *%cs:pv_irq_ops+PV_IRQ_irq_disable; \
  968. popl %edx; popl %ecx; popl %eax) \
  969. #define ENABLE_INTERRUPTS(clobbers) \
  970. PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_enable), clobbers, \
  971. pushl %eax; pushl %ecx; pushl %edx; \
  972. call *%cs:pv_irq_ops+PV_IRQ_irq_enable; \
  973. popl %edx; popl %ecx; popl %eax)
  974. #define ENABLE_INTERRUPTS_SYSEXIT \
  975. PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), CLBR_NONE,\
  976. jmp *%cs:pv_cpu_ops+PV_CPU_irq_enable_sysexit)
  977. #define GET_CR0_INTO_EAX \
  978. push %ecx; push %edx; \
  979. call *pv_cpu_ops+PV_CPU_read_cr0; \
  980. pop %edx; pop %ecx
  981. #endif /* __ASSEMBLY__ */
  982. #endif /* CONFIG_PARAVIRT */
  983. #endif /* __ASM_PARAVIRT_H */