Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/paravirt: Move thunk macros to paravirt_types.h

The macros for generating PV-thunks are part of the generic paravirt
infrastructure, so they should be in paravirt_types.h.

Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260105110520.21356-5-jgross@suse.com

authored by

Juergen Gross and committed by
Borislav Petkov (AMD)
b49c63ee d73298f0

+68 -68
-68
arch/x86/include/asm/paravirt.h
··· 581 581 582 582 #endif /* SMP && PARAVIRT_SPINLOCKS */ 583 583 584 - #ifdef CONFIG_X86_32 585 - /* save and restore all caller-save registers, except return value */ 586 - #define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;" 587 - #define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;" 588 - #else 589 - /* save and restore all caller-save registers, except return value */ 590 - #define PV_SAVE_ALL_CALLER_REGS \ 591 - "push %rcx;" \ 592 - "push %rdx;" \ 593 - "push %rsi;" \ 594 - "push %rdi;" \ 595 - "push %r8;" \ 596 - "push %r9;" \ 597 - "push %r10;" \ 598 - "push %r11;" 599 - #define PV_RESTORE_ALL_CALLER_REGS \ 600 - "pop %r11;" \ 601 - "pop %r10;" \ 602 - "pop %r9;" \ 603 - "pop %r8;" \ 604 - "pop %rdi;" \ 605 - "pop %rsi;" \ 606 - "pop %rdx;" \ 607 - "pop %rcx;" 608 - #endif 609 - 610 - /* 611 - * Generate a thunk around a function which saves all caller-save 612 - * registers except for the return value. This allows C functions to 613 - * be called from assembler code where fewer than normal registers are 614 - * available. It may also help code generation around calls from C 615 - * code if the common case doesn't use many registers. 616 - * 617 - * When a callee is wrapped in a thunk, the caller can assume that all 618 - * arg regs and all scratch registers are preserved across the 619 - * call. The return value in rax/eax will not be saved, even for void 620 - * functions. 621 - */ 622 - #define PV_THUNK_NAME(func) "__raw_callee_save_" #func 623 - #define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \ 624 - extern typeof(func) __raw_callee_save_##func; \ 625 - \ 626 - asm(".pushsection " section ", \"ax\";" \ 627 - ".globl " PV_THUNK_NAME(func) ";" \ 628 - ".type " PV_THUNK_NAME(func) ", @function;" \ 629 - ASM_FUNC_ALIGN \ 630 - PV_THUNK_NAME(func) ":" \ 631 - ASM_ENDBR \ 632 - FRAME_BEGIN \ 633 - PV_SAVE_ALL_CALLER_REGS \ 634 - "call " #func ";" \ 635 - PV_RESTORE_ALL_CALLER_REGS \ 636 - FRAME_END \ 637 - ASM_RET \ 638 - ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \ 639 - ".popsection") 640 - 641 - #define PV_CALLEE_SAVE_REGS_THUNK(func) \ 642 - __PV_CALLEE_SAVE_REGS_THUNK(func, ".text") 643 - 644 - /* Get a reference to a callee-save function */ 645 - #define PV_CALLEE_SAVE(func) \ 646 - ((struct paravirt_callee_save) { __raw_callee_save_##func }) 647 - 648 - /* Promise that "func" already uses the right calling convention */ 649 - #define __PV_IS_CALLEE_SAVE(func) \ 650 - ((struct paravirt_callee_save) { func }) 651 - 652 584 #ifdef CONFIG_PARAVIRT_XXL 653 585 static __always_inline unsigned long arch_local_save_flags(void) 654 586 {
+68
arch/x86/include/asm/paravirt_types.h
··· 512 512 513 513 #define ALT_NOT_XEN ALT_NOT(X86_FEATURE_XENPV) 514 514 515 + #ifdef CONFIG_X86_32 516 + /* save and restore all caller-save registers, except return value */ 517 + #define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;" 518 + #define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;" 519 + #else 520 + /* save and restore all caller-save registers, except return value */ 521 + #define PV_SAVE_ALL_CALLER_REGS \ 522 + "push %rcx;" \ 523 + "push %rdx;" \ 524 + "push %rsi;" \ 525 + "push %rdi;" \ 526 + "push %r8;" \ 527 + "push %r9;" \ 528 + "push %r10;" \ 529 + "push %r11;" 530 + #define PV_RESTORE_ALL_CALLER_REGS \ 531 + "pop %r11;" \ 532 + "pop %r10;" \ 533 + "pop %r9;" \ 534 + "pop %r8;" \ 535 + "pop %rdi;" \ 536 + "pop %rsi;" \ 537 + "pop %rdx;" \ 538 + "pop %rcx;" 539 + #endif 540 + 541 + /* 542 + * Generate a thunk around a function which saves all caller-save 543 + * registers except for the return value. This allows C functions to 544 + * be called from assembler code where fewer than normal registers are 545 + * available. It may also help code generation around calls from C 546 + * code if the common case doesn't use many registers. 547 + * 548 + * When a callee is wrapped in a thunk, the caller can assume that all 549 + * arg regs and all scratch registers are preserved across the 550 + * call. The return value in rax/eax will not be saved, even for void 551 + * functions. 552 + */ 553 + #define PV_THUNK_NAME(func) "__raw_callee_save_" #func 554 + #define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \ 555 + extern typeof(func) __raw_callee_save_##func; \ 556 + \ 557 + asm(".pushsection " section ", \"ax\";" \ 558 + ".globl " PV_THUNK_NAME(func) ";" \ 559 + ".type " PV_THUNK_NAME(func) ", @function;" \ 560 + ASM_FUNC_ALIGN \ 561 + PV_THUNK_NAME(func) ":" \ 562 + ASM_ENDBR \ 563 + FRAME_BEGIN \ 564 + PV_SAVE_ALL_CALLER_REGS \ 565 + "call " #func ";" \ 566 + PV_RESTORE_ALL_CALLER_REGS \ 567 + FRAME_END \ 568 + ASM_RET \ 569 + ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \ 570 + ".popsection") 571 + 572 + #define PV_CALLEE_SAVE_REGS_THUNK(func) \ 573 + __PV_CALLEE_SAVE_REGS_THUNK(func, ".text") 574 + 575 + /* Get a reference to a callee-save function */ 576 + #define PV_CALLEE_SAVE(func) \ 577 + ((struct paravirt_callee_save) { __raw_callee_save_##func }) 578 + 579 + /* Promise that "func" already uses the right calling convention */ 580 + #define __PV_IS_CALLEE_SAVE(func) \ 581 + ((struct paravirt_callee_save) { func }) 582 + 515 583 #endif /* CONFIG_PARAVIRT */ 516 584 #endif /* _ASM_X86_PARAVIRT_TYPES_H */