1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_X86_PARAVIRT_TYPES_H 3 #define _ASM_X86_PARAVIRT_TYPES_H 4 5 /* Bitmask of what can be clobbered: usually at least eax. */ 6 #define CLBR_EAX (1 << 0) 7 #define CLBR_ECX (1 << 1) 8 #define CLBR_EDX (1 << 2) 9 #define CLBR_EDI (1 << 3) 10 11 #ifdef CONFIG_X86_32 12 /* CLBR_ANY should match all regs platform has. For i386, that's just it */ 13 #define CLBR_ANY ((1 << 4) - 1) 14 15 #define CLBR_ARG_REGS (CLBR_EAX | CLBR_EDX | CLBR_ECX) 16 #define CLBR_RET_REG (CLBR_EAX | CLBR_EDX) 17 #else 18 #define CLBR_RAX CLBR_EAX 19 #define CLBR_RCX CLBR_ECX 20 #define CLBR_RDX CLBR_EDX 21 #define CLBR_RDI CLBR_EDI 22 #define CLBR_RSI (1 << 4) 23 #define CLBR_R8 (1 << 5) 24 #define CLBR_R9 (1 << 6) 25 #define CLBR_R10 (1 << 7) 26 #define CLBR_R11 (1 << 8) 27 28 #define CLBR_ANY ((1 << 9) - 1) 29 30 #define CLBR_ARG_REGS (CLBR_RDI | CLBR_RSI | CLBR_RDX | \ 31 CLBR_RCX | CLBR_R8 | CLBR_R9) 32 #define CLBR_RET_REG (CLBR_RAX) 33 34 #endif /* X86_64 */ 35 36 #ifndef __ASSEMBLY__ 37 38 #include <asm/desc_defs.h> 39 #include <asm/pgtable_types.h> 40 #include <asm/nospec-branch.h> 41 42 struct page; 43 struct thread_struct; 44 struct desc_ptr; 45 struct tss_struct; 46 struct mm_struct; 47 struct desc_struct; 48 struct task_struct; 49 struct cpumask; 50 struct flush_tlb_info; 51 struct mmu_gather; 52 struct vm_area_struct; 53 54 /* 55 * Wrapper type for pointers to code which uses the non-standard 56 * calling convention. See PV_CALL_SAVE_REGS_THUNK below. 57 */ 58 struct paravirt_callee_save { 59 void *func; 60 }; 61 62 /* general info */ 63 struct pv_info { 64 #ifdef CONFIG_PARAVIRT_XXL 65 u16 extra_user_64bit_cs; /* __USER_CS if none */ 66 #endif 67 68 const char *name; 69 }; 70 71 #ifdef CONFIG_PARAVIRT_XXL 72 struct pv_lazy_ops { 73 /* Set deferred update mode, used for batching operations. */ 74 void (*enter)(void); 75 void (*leave)(void); 76 void (*flush)(void); 77 } __no_randomize_layout; 78 #endif 79 80 struct pv_cpu_ops { 81 /* hooks for various privileged instructions */ 82 void (*io_delay)(void); 83 84 #ifdef CONFIG_PARAVIRT_XXL 85 unsigned long (*get_debugreg)(int regno); 86 void (*set_debugreg)(int regno, unsigned long value); 87 88 unsigned long (*read_cr0)(void); 89 void (*write_cr0)(unsigned long); 90 91 void (*write_cr4)(unsigned long); 92 93 /* Segment descriptor handling */ 94 void (*load_tr_desc)(void); 95 void (*load_gdt)(const struct desc_ptr *); 96 void (*load_idt)(const struct desc_ptr *); 97 void (*set_ldt)(const void *desc, unsigned entries); 98 unsigned long (*store_tr)(void); 99 void (*load_tls)(struct thread_struct *t, unsigned int cpu); 100 void (*load_gs_index)(unsigned int idx); 101 void (*write_ldt_entry)(struct desc_struct *ldt, int entrynum, 102 const void *desc); 103 void (*write_gdt_entry)(struct desc_struct *, 104 int entrynum, const void *desc, int size); 105 void (*write_idt_entry)(gate_desc *, 106 int entrynum, const gate_desc *gate); 107 void (*alloc_ldt)(struct desc_struct *ldt, unsigned entries); 108 void (*free_ldt)(struct desc_struct *ldt, unsigned entries); 109 110 void (*load_sp0)(unsigned long sp0); 111 112 #ifdef CONFIG_X86_IOPL_IOPERM 113 void (*invalidate_io_bitmap)(void); 114 void (*update_io_bitmap)(void); 115 #endif 116 117 void (*wbinvd)(void); 118 119 /* cpuid emulation, mostly so that caps bits can be disabled */ 120 void (*cpuid)(unsigned int *eax, unsigned int *ebx, 121 unsigned int *ecx, unsigned int *edx); 122 123 /* Unsafe MSR operations. These will warn or panic on failure. */ 124 u64 (*read_msr)(unsigned int msr); 125 void (*write_msr)(unsigned int msr, unsigned low, unsigned high); 126 127 /* 128 * Safe MSR operations. 129 * read sets err to 0 or -EIO. write returns 0 or -EIO. 130 */ 131 u64 (*read_msr_safe)(unsigned int msr, int *err); 132 int (*write_msr_safe)(unsigned int msr, unsigned low, unsigned high); 133 134 u64 (*read_pmc)(int counter); 135 136 void (*start_context_switch)(struct task_struct *prev); 137 void (*end_context_switch)(struct task_struct *next); 138 #endif 139 } __no_randomize_layout; 140 141 struct pv_irq_ops { 142 #ifdef CONFIG_PARAVIRT_XXL 143 /* 144 * Get/set interrupt state. save_fl is expected to use X86_EFLAGS_IF; 145 * all other bits returned from save_fl are undefined. 146 * 147 * NOTE: These functions callers expect the callee to preserve 148 * more registers than the standard C calling convention. 149 */ 150 struct paravirt_callee_save save_fl; 151 struct paravirt_callee_save irq_disable; 152 struct paravirt_callee_save irq_enable; 153 154 void (*safe_halt)(void); 155 void (*halt)(void); 156 #endif 157 } __no_randomize_layout; 158 159 struct pv_mmu_ops { 160 /* TLB operations */ 161 void (*flush_tlb_user)(void); 162 void (*flush_tlb_kernel)(void); 163 void (*flush_tlb_one_user)(unsigned long addr); 164 void (*flush_tlb_multi)(const struct cpumask *cpus, 165 const struct flush_tlb_info *info); 166 167 void (*tlb_remove_table)(struct mmu_gather *tlb, void *table); 168 169 /* Hook for intercepting the destruction of an mm_struct. */ 170 void (*exit_mmap)(struct mm_struct *mm); 171 void (*notify_page_enc_status_changed)(unsigned long pfn, int npages, bool enc); 172 173 #ifdef CONFIG_PARAVIRT_XXL 174 struct paravirt_callee_save read_cr2; 175 void (*write_cr2)(unsigned long); 176 177 unsigned long (*read_cr3)(void); 178 void (*write_cr3)(unsigned long); 179 180 /* Hooks for intercepting the creation/use of an mm_struct. */ 181 void (*activate_mm)(struct mm_struct *prev, 182 struct mm_struct *next); 183 void (*dup_mmap)(struct mm_struct *oldmm, 184 struct mm_struct *mm); 185 186 /* Hooks for allocating and freeing a pagetable top-level */ 187 int (*pgd_alloc)(struct mm_struct *mm); 188 void (*pgd_free)(struct mm_struct *mm, pgd_t *pgd); 189 190 /* 191 * Hooks for allocating/releasing pagetable pages when they're 192 * attached to a pagetable 193 */ 194 void (*alloc_pte)(struct mm_struct *mm, unsigned long pfn); 195 void (*alloc_pmd)(struct mm_struct *mm, unsigned long pfn); 196 void (*alloc_pud)(struct mm_struct *mm, unsigned long pfn); 197 void (*alloc_p4d)(struct mm_struct *mm, unsigned long pfn); 198 void (*release_pte)(unsigned long pfn); 199 void (*release_pmd)(unsigned long pfn); 200 void (*release_pud)(unsigned long pfn); 201 void (*release_p4d)(unsigned long pfn); 202 203 /* Pagetable manipulation functions */ 204 void (*set_pte)(pte_t *ptep, pte_t pteval); 205 void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval); 206 207 pte_t (*ptep_modify_prot_start)(struct vm_area_struct *vma, unsigned long addr, 208 pte_t *ptep); 209 void (*ptep_modify_prot_commit)(struct vm_area_struct *vma, unsigned long addr, 210 pte_t *ptep, pte_t pte); 211 212 struct paravirt_callee_save pte_val; 213 struct paravirt_callee_save make_pte; 214 215 struct paravirt_callee_save pgd_val; 216 struct paravirt_callee_save make_pgd; 217 218 void (*set_pud)(pud_t *pudp, pud_t pudval); 219 220 struct paravirt_callee_save pmd_val; 221 struct paravirt_callee_save make_pmd; 222 223 struct paravirt_callee_save pud_val; 224 struct paravirt_callee_save make_pud; 225 226 void (*set_p4d)(p4d_t *p4dp, p4d_t p4dval); 227 228 #if CONFIG_PGTABLE_LEVELS >= 5 229 struct paravirt_callee_save p4d_val; 230 struct paravirt_callee_save make_p4d; 231 232 void (*set_pgd)(pgd_t *pgdp, pgd_t pgdval); 233 #endif /* CONFIG_PGTABLE_LEVELS >= 5 */ 234 235 struct pv_lazy_ops lazy_mode; 236 237 /* dom0 ops */ 238 239 /* Sometimes the physical address is a pfn, and sometimes its 240 an mfn. We can tell which is which from the index. */ 241 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx, 242 phys_addr_t phys, pgprot_t flags); 243 #endif 244 } __no_randomize_layout; 245 246 struct arch_spinlock; 247 #ifdef CONFIG_SMP 248 #include <asm/spinlock_types.h> 249 #endif 250 251 struct qspinlock; 252 253 struct pv_lock_ops { 254 void (*queued_spin_lock_slowpath)(struct qspinlock *lock, u32 val); 255 struct paravirt_callee_save queued_spin_unlock; 256 257 void (*wait)(u8 *ptr, u8 val); 258 void (*kick)(int cpu); 259 260 struct paravirt_callee_save vcpu_is_preempted; 261 } __no_randomize_layout; 262 263 /* This contains all the paravirt structures: we get a convenient 264 * number for each function using the offset which we use to indicate 265 * what to patch. */ 266 struct paravirt_patch_template { 267 struct pv_cpu_ops cpu; 268 struct pv_irq_ops irq; 269 struct pv_mmu_ops mmu; 270 struct pv_lock_ops lock; 271 } __no_randomize_layout; 272 273 extern struct pv_info pv_info; 274 extern struct paravirt_patch_template pv_ops; 275 extern void (*paravirt_iret)(void); 276 277 #define PARAVIRT_PATCH(x) \ 278 (offsetof(struct paravirt_patch_template, x) / sizeof(void *)) 279 280 #define paravirt_type(op) \ 281 [paravirt_typenum] "i" (PARAVIRT_PATCH(op)), \ 282 [paravirt_opptr] "i" (&(pv_ops.op)) 283 #define paravirt_clobber(clobber) \ 284 [paravirt_clobber] "i" (clobber) 285 286 /* 287 * Generate some code, and mark it as patchable by the 288 * apply_paravirt() alternate instruction patcher. 289 */ 290 #define _paravirt_alt(insn_string, type, clobber) \ 291 "771:\n\t" insn_string "\n" "772:\n" \ 292 ".pushsection .parainstructions,\"a\"\n" \ 293 _ASM_ALIGN "\n" \ 294 _ASM_PTR " 771b\n" \ 295 " .byte " type "\n" \ 296 " .byte 772b-771b\n" \ 297 " .short " clobber "\n" \ 298 ".popsection\n" 299 300 /* Generate patchable code, with the default asm parameters. */ 301 #define paravirt_alt(insn_string) \ 302 _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") 303 304 /* Simple instruction patching code. */ 305 #define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t" 306 307 unsigned int paravirt_patch(u8 type, void *insn_buff, unsigned long addr, unsigned int len); 308 309 int paravirt_disable_iospace(void); 310 311 /* 312 * This generates an indirect call based on the operation type number. 313 * The type number, computed in PARAVIRT_PATCH, is derived from the 314 * offset into the paravirt_patch_template structure, and can therefore be 315 * freely converted back into a structure offset. 316 */ 317 #define PARAVIRT_CALL \ 318 ANNOTATE_RETPOLINE_SAFE \ 319 "call *%c[paravirt_opptr];" 320 321 /* 322 * These macros are intended to wrap calls through one of the paravirt 323 * ops structs, so that they can be later identified and patched at 324 * runtime. 325 * 326 * Normally, a call to a pv_op function is a simple indirect call: 327 * (pv_op_struct.operations)(args...). 328 * 329 * Unfortunately, this is a relatively slow operation for modern CPUs, 330 * because it cannot necessarily determine what the destination 331 * address is. In this case, the address is a runtime constant, so at 332 * the very least we can patch the call to e a simple direct call, or 333 * ideally, patch an inline implementation into the callsite. (Direct 334 * calls are essentially free, because the call and return addresses 335 * are completely predictable.) 336 * 337 * For i386, these macros rely on the standard gcc "regparm(3)" calling 338 * convention, in which the first three arguments are placed in %eax, 339 * %edx, %ecx (in that order), and the remaining arguments are placed 340 * on the stack. All caller-save registers (eax,edx,ecx) are expected 341 * to be modified (either clobbered or used for return values). 342 * X86_64, on the other hand, already specifies a register-based calling 343 * conventions, returning at %rax, with parameters going on %rdi, %rsi, 344 * %rdx, and %rcx. Note that for this reason, x86_64 does not need any 345 * special handling for dealing with 4 arguments, unlike i386. 346 * However, x86_64 also have to clobber all caller saved registers, which 347 * unfortunately, are quite a bit (r8 - r11) 348 * 349 * The call instruction itself is marked by placing its start address 350 * and size into the .parainstructions section, so that 351 * apply_paravirt() in arch/i386/kernel/alternative.c can do the 352 * appropriate patching under the control of the backend pv_init_ops 353 * implementation. 354 * 355 * Unfortunately there's no way to get gcc to generate the args setup 356 * for the call, and then allow the call itself to be generated by an 357 * inline asm. Because of this, we must do the complete arg setup and 358 * return value handling from within these macros. This is fairly 359 * cumbersome. 360 * 361 * There are 5 sets of PVOP_* macros for dealing with 0-4 arguments. 362 * It could be extended to more arguments, but there would be little 363 * to be gained from that. For each number of arguments, there are 364 * the two VCALL and CALL variants for void and non-void functions. 365 * 366 * When there is a return value, the invoker of the macro must specify 367 * the return type. The macro then uses sizeof() on that type to 368 * determine whether its a 32 or 64 bit value, and places the return 369 * in the right register(s) (just %eax for 32-bit, and %edx:%eax for 370 * 64-bit). For x86_64 machines, it just returns at %rax regardless of 371 * the return value size. 372 * 373 * 64-bit arguments are passed as a pair of adjacent 32-bit arguments 374 * i386 also passes 64-bit arguments as a pair of adjacent 32-bit arguments 375 * in low,high order 376 * 377 * Small structures are passed and returned in registers. The macro 378 * calling convention can't directly deal with this, so the wrapper 379 * functions must do this. 380 * 381 * These PVOP_* macros are only defined within this header. This 382 * means that all uses must be wrapped in inline functions. This also 383 * makes sure the incoming and outgoing types are always correct. 384 */ 385 #ifdef CONFIG_X86_32 386 #define PVOP_CALL_ARGS \ 387 unsigned long __eax = __eax, __edx = __edx, __ecx = __ecx; 388 389 #define PVOP_CALL_ARG1(x) "a" ((unsigned long)(x)) 390 #define PVOP_CALL_ARG2(x) "d" ((unsigned long)(x)) 391 #define PVOP_CALL_ARG3(x) "c" ((unsigned long)(x)) 392 393 #define PVOP_VCALL_CLOBBERS "=a" (__eax), "=d" (__edx), \ 394 "=c" (__ecx) 395 #define PVOP_CALL_CLOBBERS PVOP_VCALL_CLOBBERS 396 397 #define PVOP_VCALLEE_CLOBBERS "=a" (__eax), "=d" (__edx) 398 #define PVOP_CALLEE_CLOBBERS PVOP_VCALLEE_CLOBBERS 399 400 #define EXTRA_CLOBBERS 401 #define VEXTRA_CLOBBERS 402 #else /* CONFIG_X86_64 */ 403 /* [re]ax isn't an arg, but the return val */ 404 #define PVOP_CALL_ARGS \ 405 unsigned long __edi = __edi, __esi = __esi, \ 406 __edx = __edx, __ecx = __ecx, __eax = __eax; 407 408 #define PVOP_CALL_ARG1(x) "D" ((unsigned long)(x)) 409 #define PVOP_CALL_ARG2(x) "S" ((unsigned long)(x)) 410 #define PVOP_CALL_ARG3(x) "d" ((unsigned long)(x)) 411 #define PVOP_CALL_ARG4(x) "c" ((unsigned long)(x)) 412 413 #define PVOP_VCALL_CLOBBERS "=D" (__edi), \ 414 "=S" (__esi), "=d" (__edx), \ 415 "=c" (__ecx) 416 #define PVOP_CALL_CLOBBERS PVOP_VCALL_CLOBBERS, "=a" (__eax) 417 418 /* void functions are still allowed [re]ax for scratch */ 419 #define PVOP_VCALLEE_CLOBBERS "=a" (__eax) 420 #define PVOP_CALLEE_CLOBBERS PVOP_VCALLEE_CLOBBERS 421 422 #define EXTRA_CLOBBERS , "r8", "r9", "r10", "r11" 423 #define VEXTRA_CLOBBERS , "rax", "r8", "r9", "r10", "r11" 424 #endif /* CONFIG_X86_32 */ 425 426 #ifdef CONFIG_PARAVIRT_DEBUG 427 #define PVOP_TEST_NULL(op) BUG_ON(pv_ops.op == NULL) 428 #else 429 #define PVOP_TEST_NULL(op) ((void)pv_ops.op) 430 #endif 431 432 #define PVOP_RETVAL(rettype) \ 433 ({ unsigned long __mask = ~0UL; \ 434 BUILD_BUG_ON(sizeof(rettype) > sizeof(unsigned long)); \ 435 switch (sizeof(rettype)) { \ 436 case 1: __mask = 0xffUL; break; \ 437 case 2: __mask = 0xffffUL; break; \ 438 case 4: __mask = 0xffffffffUL; break; \ 439 default: break; \ 440 } \ 441 __mask & __eax; \ 442 }) 443 444 445 #define ____PVOP_CALL(ret, op, clbr, call_clbr, extra_clbr, ...) \ 446 ({ \ 447 PVOP_CALL_ARGS; \ 448 PVOP_TEST_NULL(op); \ 449 asm volatile(paravirt_alt(PARAVIRT_CALL) \ 450 : call_clbr, ASM_CALL_CONSTRAINT \ 451 : paravirt_type(op), \ 452 paravirt_clobber(clbr), \ 453 ##__VA_ARGS__ \ 454 : "memory", "cc" extra_clbr); \ 455 ret; \ 456 }) 457 458 #define ____PVOP_ALT_CALL(ret, op, alt, cond, clbr, call_clbr, \ 459 extra_clbr, ...) \ 460 ({ \ 461 PVOP_CALL_ARGS; \ 462 PVOP_TEST_NULL(op); \ 463 asm volatile(ALTERNATIVE(paravirt_alt(PARAVIRT_CALL), \ 464 alt, cond) \ 465 : call_clbr, ASM_CALL_CONSTRAINT \ 466 : paravirt_type(op), \ 467 paravirt_clobber(clbr), \ 468 ##__VA_ARGS__ \ 469 : "memory", "cc" extra_clbr); \ 470 ret; \ 471 }) 472 473 #define __PVOP_CALL(rettype, op, ...) \ 474 ____PVOP_CALL(PVOP_RETVAL(rettype), op, CLBR_ANY, \ 475 PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, ##__VA_ARGS__) 476 477 #define __PVOP_ALT_CALL(rettype, op, alt, cond, ...) \ 478 ____PVOP_ALT_CALL(PVOP_RETVAL(rettype), op, alt, cond, CLBR_ANY,\ 479 PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, \ 480 ##__VA_ARGS__) 481 482 #define __PVOP_CALLEESAVE(rettype, op, ...) \ 483 ____PVOP_CALL(PVOP_RETVAL(rettype), op.func, CLBR_RET_REG, \ 484 PVOP_CALLEE_CLOBBERS, , ##__VA_ARGS__) 485 486 #define __PVOP_ALT_CALLEESAVE(rettype, op, alt, cond, ...) \ 487 ____PVOP_ALT_CALL(PVOP_RETVAL(rettype), op.func, alt, cond, \ 488 CLBR_RET_REG, PVOP_CALLEE_CLOBBERS, , ##__VA_ARGS__) 489 490 491 #define __PVOP_VCALL(op, ...) \ 492 (void)____PVOP_CALL(, op, CLBR_ANY, PVOP_VCALL_CLOBBERS, \ 493 VEXTRA_CLOBBERS, ##__VA_ARGS__) 494 495 #define __PVOP_ALT_VCALL(op, alt, cond, ...) \ 496 (void)____PVOP_ALT_CALL(, op, alt, cond, CLBR_ANY, \ 497 PVOP_VCALL_CLOBBERS, VEXTRA_CLOBBERS, \ 498 ##__VA_ARGS__) 499 500 #define __PVOP_VCALLEESAVE(op, ...) \ 501 (void)____PVOP_CALL(, op.func, CLBR_RET_REG, \ 502 PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__) 503 504 #define __PVOP_ALT_VCALLEESAVE(op, alt, cond, ...) \ 505 (void)____PVOP_ALT_CALL(, op.func, alt, cond, CLBR_RET_REG, \ 506 PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__) 507 508 509 #define PVOP_CALL0(rettype, op) \ 510 __PVOP_CALL(rettype, op) 511 #define PVOP_VCALL0(op) \ 512 __PVOP_VCALL(op) 513 #define PVOP_ALT_CALL0(rettype, op, alt, cond) \ 514 __PVOP_ALT_CALL(rettype, op, alt, cond) 515 #define PVOP_ALT_VCALL0(op, alt, cond) \ 516 __PVOP_ALT_VCALL(op, alt, cond) 517 518 #define PVOP_CALLEE0(rettype, op) \ 519 __PVOP_CALLEESAVE(rettype, op) 520 #define PVOP_VCALLEE0(op) \ 521 __PVOP_VCALLEESAVE(op) 522 #define PVOP_ALT_CALLEE0(rettype, op, alt, cond) \ 523 __PVOP_ALT_CALLEESAVE(rettype, op, alt, cond) 524 #define PVOP_ALT_VCALLEE0(op, alt, cond) \ 525 __PVOP_ALT_VCALLEESAVE(op, alt, cond) 526 527 528 #define PVOP_CALL1(rettype, op, arg1) \ 529 __PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1)) 530 #define PVOP_VCALL1(op, arg1) \ 531 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1)) 532 #define PVOP_ALT_VCALL1(op, arg1, alt, cond) \ 533 __PVOP_ALT_VCALL(op, alt, cond, PVOP_CALL_ARG1(arg1)) 534 535 #define PVOP_CALLEE1(rettype, op, arg1) \ 536 __PVOP_CALLEESAVE(rettype, op, PVOP_CALL_ARG1(arg1)) 537 #define PVOP_VCALLEE1(op, arg1) \ 538 __PVOP_VCALLEESAVE(op, PVOP_CALL_ARG1(arg1)) 539 #define PVOP_ALT_CALLEE1(rettype, op, arg1, alt, cond) \ 540 __PVOP_ALT_CALLEESAVE(rettype, op, alt, cond, PVOP_CALL_ARG1(arg1)) 541 #define PVOP_ALT_VCALLEE1(op, arg1, alt, cond) \ 542 __PVOP_ALT_VCALLEESAVE(op, alt, cond, PVOP_CALL_ARG1(arg1)) 543 544 545 #define PVOP_CALL2(rettype, op, arg1, arg2) \ 546 __PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2)) 547 #define PVOP_VCALL2(op, arg1, arg2) \ 548 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2)) 549 550 #define PVOP_CALL3(rettype, op, arg1, arg2, arg3) \ 551 __PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1), \ 552 PVOP_CALL_ARG2(arg2), PVOP_CALL_ARG3(arg3)) 553 #define PVOP_VCALL3(op, arg1, arg2, arg3) \ 554 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), \ 555 PVOP_CALL_ARG2(arg2), PVOP_CALL_ARG3(arg3)) 556 557 #define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \ 558 __PVOP_CALL(rettype, op, \ 559 PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2), \ 560 PVOP_CALL_ARG3(arg3), PVOP_CALL_ARG4(arg4)) 561 #define PVOP_VCALL4(op, arg1, arg2, arg3, arg4) \ 562 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2), \ 563 PVOP_CALL_ARG3(arg3), PVOP_CALL_ARG4(arg4)) 564 565 /* Lazy mode for batching updates / context switch */ 566 enum paravirt_lazy_mode { 567 PARAVIRT_LAZY_NONE, 568 PARAVIRT_LAZY_MMU, 569 PARAVIRT_LAZY_CPU, 570 }; 571 572 enum paravirt_lazy_mode paravirt_get_lazy_mode(void); 573 void paravirt_start_context_switch(struct task_struct *prev); 574 void paravirt_end_context_switch(struct task_struct *next); 575 576 void paravirt_enter_lazy_mmu(void); 577 void paravirt_leave_lazy_mmu(void); 578 void paravirt_flush_lazy_mmu(void); 579 580 void _paravirt_nop(void); 581 void paravirt_BUG(void); 582 u64 _paravirt_ident_64(u64); 583 unsigned long paravirt_ret0(void); 584 585 #define paravirt_nop ((void *)_paravirt_nop) 586 587 /* These all sit in the .parainstructions section to tell us what to patch. */ 588 struct paravirt_patch_site { 589 u8 *instr; /* original instructions */ 590 u8 type; /* type of this instruction */ 591 u8 len; /* length of original instruction */ 592 }; 593 594 extern struct paravirt_patch_site __parainstructions[], 595 __parainstructions_end[]; 596 597 #endif /* __ASSEMBLY__ */ 598 599 #endif /* _ASM_X86_PARAVIRT_TYPES_H */ 600