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