paravirt.h 32 KB

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