paravirt.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. #include <linux/stringify.h>
  6. #include <asm/page.h>
  7. #ifdef CONFIG_PARAVIRT
  8. /* These are the most performance critical ops, so we want to be able to patch
  9. * callers */
  10. #define PARAVIRT_IRQ_DISABLE 0
  11. #define PARAVIRT_IRQ_ENABLE 1
  12. #define PARAVIRT_RESTORE_FLAGS 2
  13. #define PARAVIRT_SAVE_FLAGS 3
  14. #define PARAVIRT_SAVE_FLAGS_IRQ_DISABLE 4
  15. #define PARAVIRT_INTERRUPT_RETURN 5
  16. #define PARAVIRT_STI_SYSEXIT 6
  17. /* Bitmask of what can be clobbered: usually at least eax. */
  18. #define CLBR_NONE 0x0
  19. #define CLBR_EAX 0x1
  20. #define CLBR_ECX 0x2
  21. #define CLBR_EDX 0x4
  22. #define CLBR_ANY 0x7
  23. #ifndef __ASSEMBLY__
  24. #include <linux/types.h>
  25. struct thread_struct;
  26. struct Xgt_desc_struct;
  27. struct tss_struct;
  28. struct mm_struct;
  29. struct desc_struct;
  30. struct paravirt_ops
  31. {
  32. unsigned int kernel_rpl;
  33. int paravirt_enabled;
  34. const char *name;
  35. /*
  36. * Patch may replace one of the defined code sequences with arbitrary
  37. * code, subject to the same register constraints. This generally
  38. * means the code is not free to clobber any registers other than EAX.
  39. * The patch function should return the number of bytes of code
  40. * generated, as we nop pad the rest in generic code.
  41. */
  42. unsigned (*patch)(u8 type, u16 clobber, void *firstinsn, unsigned len);
  43. void (*arch_setup)(void);
  44. char *(*memory_setup)(void);
  45. void (*init_IRQ)(void);
  46. void (*banner)(void);
  47. unsigned long (*get_wallclock)(void);
  48. int (*set_wallclock)(unsigned long);
  49. void (*time_init)(void);
  50. void (*cpuid)(unsigned int *eax, unsigned int *ebx,
  51. unsigned int *ecx, unsigned int *edx);
  52. unsigned long (*get_debugreg)(int regno);
  53. void (*set_debugreg)(int regno, unsigned long value);
  54. void (*clts)(void);
  55. unsigned long (*read_cr0)(void);
  56. void (*write_cr0)(unsigned long);
  57. unsigned long (*read_cr2)(void);
  58. void (*write_cr2)(unsigned long);
  59. unsigned long (*read_cr3)(void);
  60. void (*write_cr3)(unsigned long);
  61. unsigned long (*read_cr4_safe)(void);
  62. unsigned long (*read_cr4)(void);
  63. void (*write_cr4)(unsigned long);
  64. unsigned long (*save_fl)(void);
  65. void (*restore_fl)(unsigned long);
  66. void (*irq_disable)(void);
  67. void (*irq_enable)(void);
  68. void (*safe_halt)(void);
  69. void (*halt)(void);
  70. void (*wbinvd)(void);
  71. /* err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */
  72. u64 (*read_msr)(unsigned int msr, int *err);
  73. int (*write_msr)(unsigned int msr, u64 val);
  74. u64 (*read_tsc)(void);
  75. u64 (*read_pmc)(void);
  76. u64 (*get_scheduled_cycles)(void);
  77. unsigned long (*get_cpu_khz)(void);
  78. void (*load_tr_desc)(void);
  79. void (*load_gdt)(const struct Xgt_desc_struct *);
  80. void (*load_idt)(const struct Xgt_desc_struct *);
  81. void (*store_gdt)(struct Xgt_desc_struct *);
  82. void (*store_idt)(struct Xgt_desc_struct *);
  83. void (*set_ldt)(const void *desc, unsigned entries);
  84. unsigned long (*store_tr)(void);
  85. void (*load_tls)(struct thread_struct *t, unsigned int cpu);
  86. void (*write_ldt_entry)(struct desc_struct *,
  87. int entrynum, u32 low, u32 high);
  88. void (*write_gdt_entry)(struct desc_struct *,
  89. int entrynum, u32 low, u32 high);
  90. void (*write_idt_entry)(struct desc_struct *,
  91. int entrynum, u32 low, u32 high);
  92. void (*load_esp0)(struct tss_struct *tss, struct thread_struct *t);
  93. void (*set_iopl_mask)(unsigned mask);
  94. void (*io_delay)(void);
  95. #ifdef CONFIG_X86_LOCAL_APIC
  96. void (*apic_write)(unsigned long reg, unsigned long v);
  97. void (*apic_write_atomic)(unsigned long reg, unsigned long v);
  98. unsigned long (*apic_read)(unsigned long reg);
  99. void (*setup_boot_clock)(void);
  100. void (*setup_secondary_clock)(void);
  101. #endif
  102. void (*flush_tlb_user)(void);
  103. void (*flush_tlb_kernel)(void);
  104. void (*flush_tlb_single)(u32 addr);
  105. void (*map_pt_hook)(int type, pte_t *va, u32 pfn);
  106. void (*alloc_pt)(u32 pfn);
  107. void (*alloc_pd)(u32 pfn);
  108. void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
  109. void (*release_pt)(u32 pfn);
  110. void (*release_pd)(u32 pfn);
  111. void (*set_pte)(pte_t *ptep, pte_t pteval);
  112. void (*set_pte_at)(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval);
  113. void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval);
  114. void (*pte_update)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  115. void (*pte_update_defer)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  116. pte_t (*ptep_get_and_clear)(pte_t *ptep);
  117. #ifdef CONFIG_X86_PAE
  118. void (*set_pte_atomic)(pte_t *ptep, pte_t pteval);
  119. void (*set_pte_present)(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte);
  120. void (*set_pud)(pud_t *pudp, pud_t pudval);
  121. void (*pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  122. void (*pmd_clear)(pmd_t *pmdp);
  123. unsigned long long (*pte_val)(pte_t);
  124. unsigned long long (*pmd_val)(pmd_t);
  125. unsigned long long (*pgd_val)(pgd_t);
  126. pte_t (*make_pte)(unsigned long long pte);
  127. pmd_t (*make_pmd)(unsigned long long pmd);
  128. pgd_t (*make_pgd)(unsigned long long pgd);
  129. #else
  130. unsigned long (*pte_val)(pte_t);
  131. unsigned long (*pgd_val)(pgd_t);
  132. pte_t (*make_pte)(unsigned long pte);
  133. pgd_t (*make_pgd)(unsigned long pgd);
  134. #endif
  135. void (*set_lazy_mode)(int mode);
  136. /* These two are jmp to, not actually called. */
  137. void (*irq_enable_sysexit)(void);
  138. void (*iret)(void);
  139. void (*startup_ipi_hook)(int phys_apicid, unsigned long start_eip, unsigned long start_esp);
  140. };
  141. /* Mark a paravirt probe function. */
  142. #define paravirt_probe(fn) \
  143. static asmlinkage void (*__paravirtprobe_##fn)(void) __attribute_used__ \
  144. __attribute__((__section__(".paravirtprobe"))) = fn
  145. extern struct paravirt_ops paravirt_ops;
  146. #define paravirt_enabled() (paravirt_ops.paravirt_enabled)
  147. static inline void load_esp0(struct tss_struct *tss,
  148. struct thread_struct *thread)
  149. {
  150. paravirt_ops.load_esp0(tss, thread);
  151. }
  152. #define ARCH_SETUP paravirt_ops.arch_setup();
  153. static inline unsigned long get_wallclock(void)
  154. {
  155. return paravirt_ops.get_wallclock();
  156. }
  157. static inline int set_wallclock(unsigned long nowtime)
  158. {
  159. return paravirt_ops.set_wallclock(nowtime);
  160. }
  161. static inline void (*choose_time_init(void))(void)
  162. {
  163. return paravirt_ops.time_init;
  164. }
  165. /* The paravirtualized CPUID instruction. */
  166. static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
  167. unsigned int *ecx, unsigned int *edx)
  168. {
  169. paravirt_ops.cpuid(eax, ebx, ecx, edx);
  170. }
  171. /*
  172. * These special macros can be used to get or set a debugging register
  173. */
  174. #define get_debugreg(var, reg) var = paravirt_ops.get_debugreg(reg)
  175. #define set_debugreg(val, reg) paravirt_ops.set_debugreg(reg, val)
  176. #define clts() paravirt_ops.clts()
  177. #define read_cr0() paravirt_ops.read_cr0()
  178. #define write_cr0(x) paravirt_ops.write_cr0(x)
  179. #define read_cr2() paravirt_ops.read_cr2()
  180. #define write_cr2(x) paravirt_ops.write_cr2(x)
  181. #define read_cr3() paravirt_ops.read_cr3()
  182. #define write_cr3(x) paravirt_ops.write_cr3(x)
  183. #define read_cr4() paravirt_ops.read_cr4()
  184. #define read_cr4_safe(x) paravirt_ops.read_cr4_safe()
  185. #define write_cr4(x) paravirt_ops.write_cr4(x)
  186. #define raw_ptep_get_and_clear(xp) (paravirt_ops.ptep_get_and_clear(xp))
  187. static inline void raw_safe_halt(void)
  188. {
  189. paravirt_ops.safe_halt();
  190. }
  191. static inline void halt(void)
  192. {
  193. paravirt_ops.safe_halt();
  194. }
  195. #define wbinvd() paravirt_ops.wbinvd()
  196. #define get_kernel_rpl() (paravirt_ops.kernel_rpl)
  197. /* These should all do BUG_ON(_err), but our headers are too tangled. */
  198. #define rdmsr(msr,val1,val2) do { \
  199. int _err; \
  200. u64 _l = paravirt_ops.read_msr(msr,&_err); \
  201. val1 = (u32)_l; \
  202. val2 = _l >> 32; \
  203. } while(0)
  204. #define wrmsr(msr,val1,val2) do { \
  205. u64 _l = ((u64)(val2) << 32) | (val1); \
  206. paravirt_ops.write_msr((msr), _l); \
  207. } while(0)
  208. #define rdmsrl(msr,val) do { \
  209. int _err; \
  210. val = paravirt_ops.read_msr((msr),&_err); \
  211. } while(0)
  212. #define wrmsrl(msr,val) (paravirt_ops.write_msr((msr),(val)))
  213. #define wrmsr_safe(msr,a,b) ({ \
  214. u64 _l = ((u64)(b) << 32) | (a); \
  215. paravirt_ops.write_msr((msr),_l); \
  216. })
  217. /* rdmsr with exception handling */
  218. #define rdmsr_safe(msr,a,b) ({ \
  219. int _err; \
  220. u64 _l = paravirt_ops.read_msr(msr,&_err); \
  221. (*a) = (u32)_l; \
  222. (*b) = _l >> 32; \
  223. _err; })
  224. #define rdtsc(low,high) do { \
  225. u64 _l = paravirt_ops.read_tsc(); \
  226. low = (u32)_l; \
  227. high = _l >> 32; \
  228. } while(0)
  229. #define rdtscl(low) do { \
  230. u64 _l = paravirt_ops.read_tsc(); \
  231. low = (int)_l; \
  232. } while(0)
  233. #define rdtscll(val) (val = paravirt_ops.read_tsc())
  234. #define get_scheduled_cycles(val) (val = paravirt_ops.get_scheduled_cycles())
  235. #define calculate_cpu_khz() (paravirt_ops.get_cpu_khz())
  236. #define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
  237. #define rdpmc(counter,low,high) do { \
  238. u64 _l = paravirt_ops.read_pmc(); \
  239. low = (u32)_l; \
  240. high = _l >> 32; \
  241. } while(0)
  242. #define load_TR_desc() (paravirt_ops.load_tr_desc())
  243. #define load_gdt(dtr) (paravirt_ops.load_gdt(dtr))
  244. #define load_idt(dtr) (paravirt_ops.load_idt(dtr))
  245. #define set_ldt(addr, entries) (paravirt_ops.set_ldt((addr), (entries)))
  246. #define store_gdt(dtr) (paravirt_ops.store_gdt(dtr))
  247. #define store_idt(dtr) (paravirt_ops.store_idt(dtr))
  248. #define store_tr(tr) ((tr) = paravirt_ops.store_tr())
  249. #define load_TLS(t,cpu) (paravirt_ops.load_tls((t),(cpu)))
  250. #define write_ldt_entry(dt, entry, low, high) \
  251. (paravirt_ops.write_ldt_entry((dt), (entry), (low), (high)))
  252. #define write_gdt_entry(dt, entry, low, high) \
  253. (paravirt_ops.write_gdt_entry((dt), (entry), (low), (high)))
  254. #define write_idt_entry(dt, entry, low, high) \
  255. (paravirt_ops.write_idt_entry((dt), (entry), (low), (high)))
  256. #define set_iopl_mask(mask) (paravirt_ops.set_iopl_mask(mask))
  257. #define __pte(x) paravirt_ops.make_pte(x)
  258. #define __pgd(x) paravirt_ops.make_pgd(x)
  259. #define pte_val(x) paravirt_ops.pte_val(x)
  260. #define pgd_val(x) paravirt_ops.pgd_val(x)
  261. #ifdef CONFIG_X86_PAE
  262. #define __pmd(x) paravirt_ops.make_pmd(x)
  263. #define pmd_val(x) paravirt_ops.pmd_val(x)
  264. #endif
  265. /* The paravirtualized I/O functions */
  266. static inline void slow_down_io(void) {
  267. paravirt_ops.io_delay();
  268. #ifdef REALLY_SLOW_IO
  269. paravirt_ops.io_delay();
  270. paravirt_ops.io_delay();
  271. paravirt_ops.io_delay();
  272. #endif
  273. }
  274. #ifdef CONFIG_X86_LOCAL_APIC
  275. /*
  276. * Basic functions accessing APICs.
  277. */
  278. static inline void apic_write(unsigned long reg, unsigned long v)
  279. {
  280. paravirt_ops.apic_write(reg,v);
  281. }
  282. static inline void apic_write_atomic(unsigned long reg, unsigned long v)
  283. {
  284. paravirt_ops.apic_write_atomic(reg,v);
  285. }
  286. static inline unsigned long apic_read(unsigned long reg)
  287. {
  288. return paravirt_ops.apic_read(reg);
  289. }
  290. static inline void setup_boot_clock(void)
  291. {
  292. paravirt_ops.setup_boot_clock();
  293. }
  294. static inline void setup_secondary_clock(void)
  295. {
  296. paravirt_ops.setup_secondary_clock();
  297. }
  298. #endif
  299. #ifdef CONFIG_SMP
  300. static inline void startup_ipi_hook(int phys_apicid, unsigned long start_eip,
  301. unsigned long start_esp)
  302. {
  303. return paravirt_ops.startup_ipi_hook(phys_apicid, start_eip, start_esp);
  304. }
  305. #endif
  306. #define __flush_tlb() paravirt_ops.flush_tlb_user()
  307. #define __flush_tlb_global() paravirt_ops.flush_tlb_kernel()
  308. #define __flush_tlb_single(addr) paravirt_ops.flush_tlb_single(addr)
  309. #define paravirt_map_pt_hook(type, va, pfn) paravirt_ops.map_pt_hook(type, va, pfn)
  310. #define paravirt_alloc_pt(pfn) paravirt_ops.alloc_pt(pfn)
  311. #define paravirt_release_pt(pfn) paravirt_ops.release_pt(pfn)
  312. #define paravirt_alloc_pd(pfn) paravirt_ops.alloc_pd(pfn)
  313. #define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) \
  314. paravirt_ops.alloc_pd_clone(pfn, clonepfn, start, count)
  315. #define paravirt_release_pd(pfn) paravirt_ops.release_pd(pfn)
  316. static inline void set_pte(pte_t *ptep, pte_t pteval)
  317. {
  318. paravirt_ops.set_pte(ptep, pteval);
  319. }
  320. static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
  321. pte_t *ptep, pte_t pteval)
  322. {
  323. paravirt_ops.set_pte_at(mm, addr, ptep, pteval);
  324. }
  325. static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval)
  326. {
  327. paravirt_ops.set_pmd(pmdp, pmdval);
  328. }
  329. static inline void pte_update(struct mm_struct *mm, u32 addr, pte_t *ptep)
  330. {
  331. paravirt_ops.pte_update(mm, addr, ptep);
  332. }
  333. static inline void pte_update_defer(struct mm_struct *mm, u32 addr, pte_t *ptep)
  334. {
  335. paravirt_ops.pte_update_defer(mm, addr, ptep);
  336. }
  337. #ifdef CONFIG_X86_PAE
  338. static inline void set_pte_atomic(pte_t *ptep, pte_t pteval)
  339. {
  340. paravirt_ops.set_pte_atomic(ptep, pteval);
  341. }
  342. static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
  343. {
  344. paravirt_ops.set_pte_present(mm, addr, ptep, pte);
  345. }
  346. static inline void set_pud(pud_t *pudp, pud_t pudval)
  347. {
  348. paravirt_ops.set_pud(pudp, pudval);
  349. }
  350. static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
  351. {
  352. paravirt_ops.pte_clear(mm, addr, ptep);
  353. }
  354. static inline void pmd_clear(pmd_t *pmdp)
  355. {
  356. paravirt_ops.pmd_clear(pmdp);
  357. }
  358. #endif
  359. /* Lazy mode for batching updates / context switch */
  360. #define PARAVIRT_LAZY_NONE 0
  361. #define PARAVIRT_LAZY_MMU 1
  362. #define PARAVIRT_LAZY_CPU 2
  363. #define PARAVIRT_LAZY_FLUSH 3
  364. #define __HAVE_ARCH_ENTER_LAZY_CPU_MODE
  365. #define arch_enter_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_CPU)
  366. #define arch_leave_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_NONE)
  367. #define arch_flush_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_FLUSH)
  368. #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
  369. #define arch_enter_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_MMU)
  370. #define arch_leave_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_NONE)
  371. #define arch_flush_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_FLUSH)
  372. void _paravirt_nop(void);
  373. #define paravirt_nop ((void *)_paravirt_nop)
  374. /* These all sit in the .parainstructions section to tell us what to patch. */
  375. struct paravirt_patch {
  376. u8 *instr; /* original instructions */
  377. u8 instrtype; /* type of this instruction */
  378. u8 len; /* length of original instruction */
  379. u16 clobbers; /* what registers you may clobber */
  380. };
  381. #define paravirt_alt(insn_string, typenum, clobber) \
  382. "771:\n\t" insn_string "\n" "772:\n" \
  383. ".pushsection .parainstructions,\"a\"\n" \
  384. " .long 771b\n" \
  385. " .byte " __stringify(typenum) "\n" \
  386. " .byte 772b-771b\n" \
  387. " .short " __stringify(clobber) "\n" \
  388. ".popsection"
  389. static inline unsigned long __raw_local_save_flags(void)
  390. {
  391. unsigned long f;
  392. __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
  393. "call *%1;"
  394. "popl %%edx; popl %%ecx",
  395. PARAVIRT_SAVE_FLAGS, CLBR_NONE)
  396. : "=a"(f): "m"(paravirt_ops.save_fl)
  397. : "memory", "cc");
  398. return f;
  399. }
  400. static inline void raw_local_irq_restore(unsigned long f)
  401. {
  402. __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
  403. "call *%1;"
  404. "popl %%edx; popl %%ecx",
  405. PARAVIRT_RESTORE_FLAGS, CLBR_EAX)
  406. : "=a"(f) : "m" (paravirt_ops.restore_fl), "0"(f)
  407. : "memory", "cc");
  408. }
  409. static inline void raw_local_irq_disable(void)
  410. {
  411. __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
  412. "call *%0;"
  413. "popl %%edx; popl %%ecx",
  414. PARAVIRT_IRQ_DISABLE, CLBR_EAX)
  415. : : "m" (paravirt_ops.irq_disable)
  416. : "memory", "eax", "cc");
  417. }
  418. static inline void raw_local_irq_enable(void)
  419. {
  420. __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
  421. "call *%0;"
  422. "popl %%edx; popl %%ecx",
  423. PARAVIRT_IRQ_ENABLE, CLBR_EAX)
  424. : : "m" (paravirt_ops.irq_enable)
  425. : "memory", "eax", "cc");
  426. }
  427. static inline unsigned long __raw_local_irq_save(void)
  428. {
  429. unsigned long f;
  430. __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
  431. "call *%1; pushl %%eax;"
  432. "call *%2; popl %%eax;"
  433. "popl %%edx; popl %%ecx",
  434. PARAVIRT_SAVE_FLAGS_IRQ_DISABLE,
  435. CLBR_NONE)
  436. : "=a"(f)
  437. : "m" (paravirt_ops.save_fl),
  438. "m" (paravirt_ops.irq_disable)
  439. : "memory", "cc");
  440. return f;
  441. }
  442. #define CLI_STRING paravirt_alt("pushl %%ecx; pushl %%edx;" \
  443. "call *paravirt_ops+%c[irq_disable];" \
  444. "popl %%edx; popl %%ecx", \
  445. PARAVIRT_IRQ_DISABLE, CLBR_EAX)
  446. #define STI_STRING paravirt_alt("pushl %%ecx; pushl %%edx;" \
  447. "call *paravirt_ops+%c[irq_enable];" \
  448. "popl %%edx; popl %%ecx", \
  449. PARAVIRT_IRQ_ENABLE, CLBR_EAX)
  450. #define CLI_STI_CLOBBERS , "%eax"
  451. #define CLI_STI_INPUT_ARGS \
  452. , \
  453. [irq_disable] "i" (offsetof(struct paravirt_ops, irq_disable)), \
  454. [irq_enable] "i" (offsetof(struct paravirt_ops, irq_enable))
  455. #else /* __ASSEMBLY__ */
  456. #define PARA_PATCH(ptype, clobbers, ops) \
  457. 771:; \
  458. ops; \
  459. 772:; \
  460. .pushsection .parainstructions,"a"; \
  461. .long 771b; \
  462. .byte ptype; \
  463. .byte 772b-771b; \
  464. .short clobbers; \
  465. .popsection
  466. #define INTERRUPT_RETURN \
  467. PARA_PATCH(PARAVIRT_INTERRUPT_RETURN, CLBR_ANY, \
  468. jmp *%cs:paravirt_ops+PARAVIRT_iret)
  469. #define DISABLE_INTERRUPTS(clobbers) \
  470. PARA_PATCH(PARAVIRT_IRQ_DISABLE, clobbers, \
  471. pushl %ecx; pushl %edx; \
  472. call *paravirt_ops+PARAVIRT_irq_disable; \
  473. popl %edx; popl %ecx) \
  474. #define ENABLE_INTERRUPTS(clobbers) \
  475. PARA_PATCH(PARAVIRT_IRQ_ENABLE, clobbers, \
  476. pushl %ecx; pushl %edx; \
  477. call *%cs:paravirt_ops+PARAVIRT_irq_enable; \
  478. popl %edx; popl %ecx)
  479. #define ENABLE_INTERRUPTS_SYSEXIT \
  480. PARA_PATCH(PARAVIRT_STI_SYSEXIT, CLBR_ANY, \
  481. jmp *%cs:paravirt_ops+PARAVIRT_irq_enable_sysexit)
  482. #define GET_CR0_INTO_EAX \
  483. call *paravirt_ops+PARAVIRT_read_cr0
  484. #endif /* __ASSEMBLY__ */
  485. #endif /* CONFIG_PARAVIRT */
  486. #endif /* __ASM_PARAVIRT_H */