paravirt.h 33 KB

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