Borislav Petkov
2020-Dec-02 12:32 UTC
[PATCH v2 04/12] x86/xen: drop USERGS_SYSRET64 paravirt call
On Fri, Nov 20, 2020 at 12:46:22PM +0100, Juergen Gross wrote:> @@ -123,12 +115,15 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_hwframe, SYM_L_GLOBAL) > * Try to use SYSRET instead of IRET if we're returning to > * a completely clean 64-bit userspace context. If we're not, > * go to the slow exit path. > + * In the Xen PV case we must use iret anyway. > */ > - movq RCX(%rsp), %rcx > - movq RIP(%rsp), %r11 > > - cmpq %rcx, %r11 /* SYSRET requires RCX == RIP */ > - jne swapgs_restore_regs_and_return_to_usermode > + ALTERNATIVE __stringify( \ > + movq RCX(%rsp), %rcx; \ > + movq RIP(%rsp), %r11; \ > + cmpq %rcx, %r11; /* SYSRET requires RCX == RIP */ \ > + jne swapgs_restore_regs_and_return_to_usermode), \ > + "jmp swapgs_restore_regs_and_return_to_usermode", X86_FEATURE_XENPVWhy such a big ALTERNATIVE when you can simply do: /* * Try to use SYSRET instead of IRET if we're returning to * a completely clean 64-bit userspace context. If we're not, * go to the slow exit path. * In the Xen PV case we must use iret anyway. */ ALTERNATIVE "", "jmp swapgs_restore_regs_and_return_to_usermode", X86_FEATURE_XENPV movq RCX(%rsp), %rcx; movq RIP(%rsp), %r11; cmpq %rcx, %r11; /* SYSRET requires RCX == RIP */ \ jne swapgs_restore_regs_and_return_to_usermode ? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
Jürgen Groß
2020-Dec-02 14:48 UTC
[PATCH v2 04/12] x86/xen: drop USERGS_SYSRET64 paravirt call
On 02.12.20 13:32, Borislav Petkov wrote:> On Fri, Nov 20, 2020 at 12:46:22PM +0100, Juergen Gross wrote: >> @@ -123,12 +115,15 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_hwframe, SYM_L_GLOBAL) >> * Try to use SYSRET instead of IRET if we're returning to >> * a completely clean 64-bit userspace context. If we're not, >> * go to the slow exit path. >> + * In the Xen PV case we must use iret anyway. >> */ >> - movq RCX(%rsp), %rcx >> - movq RIP(%rsp), %r11 >> >> - cmpq %rcx, %r11 /* SYSRET requires RCX == RIP */ >> - jne swapgs_restore_regs_and_return_to_usermode >> + ALTERNATIVE __stringify( \ >> + movq RCX(%rsp), %rcx; \ >> + movq RIP(%rsp), %r11; \ >> + cmpq %rcx, %r11; /* SYSRET requires RCX == RIP */ \ >> + jne swapgs_restore_regs_and_return_to_usermode), \ >> + "jmp swapgs_restore_regs_and_return_to_usermode", X86_FEATURE_XENPV > > Why such a big ALTERNATIVE when you can simply do: > > /* > * Try to use SYSRET instead of IRET if we're returning to > * a completely clean 64-bit userspace context. If we're not, > * go to the slow exit path. > * In the Xen PV case we must use iret anyway. > */ > ALTERNATIVE "", "jmp swapgs_restore_regs_and_return_to_usermode", X86_FEATURE_XENPV > > movq RCX(%rsp), %rcx; > movq RIP(%rsp), %r11; > cmpq %rcx, %r11; /* SYSRET requires RCX == RIP */ \ > jne swapgs_restore_regs_and_return_to_usermode > > ? >I wanted to avoid the additional NOPs for the bare metal case. If you don't mind them I can do as you are suggesting. Juergen -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_0xB0DE9DD628BF132F.asc Type: application/pgp-keys Size: 3091 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20201202/08b0284f/attachment-0001.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/20201202/08b0284f/attachment-0001.sig>