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 276 #define PARAVIRT_PATCH(x) \ 277 (offsetof(struct paravirt_patch_template, x) / sizeof(void *)) 278 279 #define paravirt_type(op) \ 280 [paravirt_typenum] "i" (PARAVIRT_PATCH(op)), \ 281 [paravirt_opptr] "m" (pv_ops.op) 282 #define paravirt_clobber(clobber) \ 283 [paravirt_clobber] "i" (clobber) 284 285 /* 286 * Generate some code, and mark it as patchable by the 287 * apply_paravirt() alternate instruction patcher. 288 */ 289 #define _paravirt_alt(insn_string, type, clobber) \ 290 "771:\n\t" insn_string "\n" "772:\n" \ 291 ".pushsection .parainstructions,\"a\"\n" \ 292 _ASM_ALIGN "\n" \ 293 _ASM_PTR " 771b\n" \ 294 " .byte " type "\n" \ 295 " .byte 772b-771b\n" \ 296 " .short " clobber "\n" \ 297 _ASM_ALIGN "\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 *%[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 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 in %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 has 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 * 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 it's 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 in %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 it. 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 /* 419 * void functions are still allowed [re]ax for scratch. 420 * 421 * The ZERO_CALL_USED REGS feature may end up zeroing out callee-saved 422 * registers. Make sure we model this with the appropriate clobbers. 423 */ 424 #ifdef CONFIG_ZERO_CALL_USED_REGS 425 #define PVOP_VCALLEE_CLOBBERS "=a" (__eax), PVOP_VCALL_CLOBBERS 426 #else 427 #define PVOP_VCALLEE_CLOBBERS "=a" (__eax) 428 #endif 429 #define PVOP_CALLEE_CLOBBERS PVOP_VCALLEE_CLOBBERS 430 431 #define EXTRA_CLOBBERS , "r8", "r9", "r10", "r11" 432 #define VEXTRA_CLOBBERS , "rax", "r8", "r9", "r10", "r11" 433 #endif /* CONFIG_X86_32 */ 434 435 #ifdef CONFIG_PARAVIRT_DEBUG 436 #define PVOP_TEST_NULL(op) BUG_ON(pv_ops.op == NULL) 437 #else 438 #define PVOP_TEST_NULL(op) ((void)pv_ops.op) 439 #endif 440 441 #define PVOP_RETVAL(rettype) \ 442 ({ unsigned long __mask = ~0UL; \ 443 BUILD_BUG_ON(sizeof(rettype) > sizeof(unsigned long)); \ 444 switch (sizeof(rettype)) { \ 445 case 1: __mask = 0xffUL; break; \ 446 case 2: __mask = 0xffffUL; break; \ 447 case 4: __mask = 0xffffffffUL; break; \ 448 default: break; \ 449 } \ 450 __mask & __eax; \ 451 }) 452 453 454 #define ____PVOP_CALL(ret, op, clbr, call_clbr, extra_clbr, ...) \ 455 ({ \ 456 PVOP_CALL_ARGS; \ 457 PVOP_TEST_NULL(op); \ 458 asm volatile(paravirt_alt(PARAVIRT_CALL) \ 459 : call_clbr, ASM_CALL_CONSTRAINT \ 460 : paravirt_type(op), \ 461 paravirt_clobber(clbr), \ 462 ##__VA_ARGS__ \ 463 : "memory", "cc" extra_clbr); \ 464 ret; \ 465 }) 466 467 #define ____PVOP_ALT_CALL(ret, op, alt, cond, clbr, call_clbr, \ 468 extra_clbr, ...) \ 469 ({ \ 470 PVOP_CALL_ARGS; \ 471 PVOP_TEST_NULL(op); \ 472 asm volatile(ALTERNATIVE(paravirt_alt(PARAVIRT_CALL), \ 473 alt, cond) \ 474 : call_clbr, ASM_CALL_CONSTRAINT \ 475 : paravirt_type(op), \ 476 paravirt_clobber(clbr), \ 477 ##__VA_ARGS__ \ 478 : "memory", "cc" extra_clbr); \ 479 ret; \ 480 }) 481 482 #define __PVOP_CALL(rettype, op, ...) \ 483 ____PVOP_CALL(PVOP_RETVAL(rettype), op, CLBR_ANY, \ 484 PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, ##__VA_ARGS__) 485 486 #define __PVOP_ALT_CALL(rettype, op, alt, cond, ...) \ 487 ____PVOP_ALT_CALL(PVOP_RETVAL(rettype), op, alt, cond, CLBR_ANY,\ 488 PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, \ 489 ##__VA_ARGS__) 490 491 #define __PVOP_CALLEESAVE(rettype, op, ...) \ 492 ____PVOP_CALL(PVOP_RETVAL(rettype), op.func, CLBR_RET_REG, \ 493 PVOP_CALLEE_CLOBBERS, , ##__VA_ARGS__) 494 495 #define __PVOP_ALT_CALLEESAVE(rettype, op, alt, cond, ...) \ 496 ____PVOP_ALT_CALL(PVOP_RETVAL(rettype), op.func, alt, cond, \ 497 CLBR_RET_REG, PVOP_CALLEE_CLOBBERS, , ##__VA_ARGS__) 498 499 500 #define __PVOP_VCALL(op, ...) \ 501 (void)____PVOP_CALL(, op, CLBR_ANY, PVOP_VCALL_CLOBBERS, \ 502 VEXTRA_CLOBBERS, ##__VA_ARGS__) 503 504 #define __PVOP_ALT_VCALL(op, alt, cond, ...) \ 505 (void)____PVOP_ALT_CALL(, op, alt, cond, CLBR_ANY, \ 506 PVOP_VCALL_CLOBBERS, VEXTRA_CLOBBERS, \ 507 ##__VA_ARGS__) 508 509 #define __PVOP_VCALLEESAVE(op, ...) \ 510 (void)____PVOP_CALL(, op.func, CLBR_RET_REG, \ 511 PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__) 512 513 #define __PVOP_ALT_VCALLEESAVE(op, alt, cond, ...) \ 514 (void)____PVOP_ALT_CALL(, op.func, alt, cond, CLBR_RET_REG, \ 515 PVOP_VCALLEE_CLOBBERS, , ##__VA_ARGS__) 516 517 518 #define PVOP_CALL0(rettype, op) \ 519 __PVOP_CALL(rettype, op) 520 #define PVOP_VCALL0(op) \ 521 __PVOP_VCALL(op) 522 #define PVOP_ALT_CALL0(rettype, op, alt, cond) \ 523 __PVOP_ALT_CALL(rettype, op, alt, cond) 524 #define PVOP_ALT_VCALL0(op, alt, cond) \ 525 __PVOP_ALT_VCALL(op, alt, cond) 526 527 #define PVOP_CALLEE0(rettype, op) \ 528 __PVOP_CALLEESAVE(rettype, op) 529 #define PVOP_VCALLEE0(op) \ 530 __PVOP_VCALLEESAVE(op) 531 #define PVOP_ALT_CALLEE0(rettype, op, alt, cond) \ 532 __PVOP_ALT_CALLEESAVE(rettype, op, alt, cond) 533 #define PVOP_ALT_VCALLEE0(op, alt, cond) \ 534 __PVOP_ALT_VCALLEESAVE(op, alt, cond) 535 536 537 #define PVOP_CALL1(rettype, op, arg1) \ 538 __PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1)) 539 #define PVOP_VCALL1(op, arg1) \ 540 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1)) 541 #define PVOP_ALT_VCALL1(op, arg1, alt, cond) \ 542 __PVOP_ALT_VCALL(op, alt, cond, PVOP_CALL_ARG1(arg1)) 543 544 #define PVOP_CALLEE1(rettype, op, arg1) \ 545 __PVOP_CALLEESAVE(rettype, op, PVOP_CALL_ARG1(arg1)) 546 #define PVOP_VCALLEE1(op, arg1) \ 547 __PVOP_VCALLEESAVE(op, PVOP_CALL_ARG1(arg1)) 548 #define PVOP_ALT_CALLEE1(rettype, op, arg1, alt, cond) \ 549 __PVOP_ALT_CALLEESAVE(rettype, op, alt, cond, PVOP_CALL_ARG1(arg1)) 550 #define PVOP_ALT_VCALLEE1(op, arg1, alt, cond) \ 551 __PVOP_ALT_VCALLEESAVE(op, alt, cond, PVOP_CALL_ARG1(arg1)) 552 553 554 #define PVOP_CALL2(rettype, op, arg1, arg2) \ 555 __PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2)) 556 #define PVOP_VCALL2(op, arg1, arg2) \ 557 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2)) 558 559 #define PVOP_CALL3(rettype, op, arg1, arg2, arg3) \ 560 __PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1), \ 561 PVOP_CALL_ARG2(arg2), PVOP_CALL_ARG3(arg3)) 562 #define PVOP_VCALL3(op, arg1, arg2, arg3) \ 563 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), \ 564 PVOP_CALL_ARG2(arg2), PVOP_CALL_ARG3(arg3)) 565 566 #define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \ 567 __PVOP_CALL(rettype, op, \ 568 PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2), \ 569 PVOP_CALL_ARG3(arg3), PVOP_CALL_ARG4(arg4)) 570 #define PVOP_VCALL4(op, arg1, arg2, arg3, arg4) \ 571 __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2), \ 572 PVOP_CALL_ARG3(arg3), PVOP_CALL_ARG4(arg4)) 573 574 /* Lazy mode for batching updates / context switch */ 575 enum paravirt_lazy_mode { 576 PARAVIRT_LAZY_NONE, 577 PARAVIRT_LAZY_MMU, 578 PARAVIRT_LAZY_CPU, 579 }; 580 581 enum paravirt_lazy_mode paravirt_get_lazy_mode(void); 582 void paravirt_start_context_switch(struct task_struct *prev); 583 void paravirt_end_context_switch(struct task_struct *next); 584 585 void paravirt_enter_lazy_mmu(void); 586 void paravirt_leave_lazy_mmu(void); 587 void paravirt_flush_lazy_mmu(void); 588 589 void _paravirt_nop(void); 590 void paravirt_BUG(void); 591 u64 _paravirt_ident_64(u64); 592 unsigned long paravirt_ret0(void); 593 594 #define paravirt_nop ((void *)_paravirt_nop) 595 596 /* These all sit in the .parainstructions section to tell us what to patch. */ 597 struct paravirt_patch_site { 598 u8 *instr; /* original instructions */ 599 u8 type; /* type of this instruction */ 600 u8 len; /* length of original instruction */ 601 }; 602 603 extern struct paravirt_patch_site __parainstructions[], 604 __parainstructions_end[]; 605 606 #endif /* __ASSEMBLY__ */ 607 608 #endif /* _ASM_X86_PARAVIRT_TYPES_H */ 609