Borislav Petkov
2023-Mar-09 13:39 UTC
[PATCH] x86/paravirt: convert simple paravirt functions to asm
On Wed, Mar 08, 2023 at 04:42:10PM +0100, Juergen Gross wrote:> All functions referenced via __PV_IS_CALLEE_SAVE() need to be assembler > functions, as those functions calls are hidden from gcc. In case the > kernel is compiled with "-fzero-call-used-regs" the compiler will > clobber caller-saved registers at the end of C functions, which will > result in unexpectedly zeroed registers at the call site of the > related paravirt functions. > > Replace the C functions with DEFINE_PARAVIRT_ASM() constructs using > the same instructions as the related paravirt calls in the > PVOP_ALT_[V]CALLEE*() macros. > > Signed-off-by: Juergen Gross <jgross at suse.com> > --- > arch/x86/include/asm/paravirt_types.h | 8 +++++++- > arch/x86/kernel/paravirt.c | 27 ++++++--------------------- > 2 files changed, 13 insertions(+), 22 deletions(-)Right, works with my particular reproducer. Turning them into asm prevents the compiler from doing the callee-clobbered zeroing and that's fine as this whole paravirt gunk is hiding the "CALL" insn from it and you putting them in asm is in line with this. And a negative diffstat.. So yeah, I'll queue it soon unless someone objects. Long term, I think we should continue switching all that pv stuff to using the alternatives. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
Juergen Gross
2023-Mar-10 06:24 UTC
[PATCH] x86/paravirt: convert simple paravirt functions to asm
On 09.03.23 14:39, Borislav Petkov wrote:> On Wed, Mar 08, 2023 at 04:42:10PM +0100, Juergen Gross wrote: >> All functions referenced via __PV_IS_CALLEE_SAVE() need to be assembler >> functions, as those functions calls are hidden from gcc. In case the >> kernel is compiled with "-fzero-call-used-regs" the compiler will >> clobber caller-saved registers at the end of C functions, which will >> result in unexpectedly zeroed registers at the call site of the >> related paravirt functions. >> >> Replace the C functions with DEFINE_PARAVIRT_ASM() constructs using >> the same instructions as the related paravirt calls in the >> PVOP_ALT_[V]CALLEE*() macros. >> >> Signed-off-by: Juergen Gross <jgross at suse.com> >> --- >> arch/x86/include/asm/paravirt_types.h | 8 +++++++- >> arch/x86/kernel/paravirt.c | 27 ++++++--------------------- >> 2 files changed, 13 insertions(+), 22 deletions(-) > > Right, works with my particular reproducer. > > Turning them into asm prevents the compiler from doing the > callee-clobbered zeroing and that's fine as this whole paravirt gunk is > hiding the "CALL" insn from it and you putting them in asm is in line > with this. > > And a negative diffstat.. > > So yeah, I'll queue it soon unless someone objects.Thanks.> Long term, I think we should continue switching all that pv stuff to > using the alternatives.The "normal" cases not using alternatives should rather be switched to static calls. Whether it is possible to mix a static call with alternatives needs to be evaluated. Juergen -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_0xB0DE9DD628BF132F.asc Type: application/pgp-keys Size: 3098 bytes Desc: OpenPGP public key URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20230310/679d21bc/attachment.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 495 bytes Desc: OpenPGP digital signature URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20230310/679d21bc/attachment.sig>
Maybe Matching Threads
- [PATCH] x86/paravirt: convert simple paravirt functions to asm
- [PATCH v2] x86/paravirt: convert simple paravirt functions to asm
- [RFC PATCH 0/3] x86/paravirt: Get rid of paravirt patching
- [PATCH v2] x86/paravirt: merge activate_mm and dup_mmap callbacks
- [PATCH RFC 13/43] x86/paravirt: Use relative reference for original instruction