lkml.org 
[lkml]   [2022]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V3 6/7] x86/entry: Don't call error_entry for XENPV
On Tue, Mar 15, 2022 at 03:39:48PM +0800, Lai Jiangshan wrote:
> +++ b/arch/x86/entry/entry_64.S
> @@ -328,8 +328,17 @@ SYM_CODE_END(ret_from_fork)
> PUSH_AND_CLEAR_REGS
> ENCODE_FRAME_POINTER
>
> - call error_entry
> - movq %rax, %rsp /* switch stack settled by sync_regs() */
> + /*
> + * Call error_entry and switch stack settled by sync_regs().
> + *
> + * When in XENPV, it is already in the task stack, and it can't fault
> + * for native_iret() nor native_load_gs_index() since XENPV uses its
> + * own pvops for iret and load_gs_index(). And it doesn't need to
> + * switch CR3. So it can skip invoking error_entry().
> + */
> + ALTERNATIVE "call error_entry; movq %rax, %rsp", \
> + "", X86_FEATURE_XENPV
> +
> ENCODE_FRAME_POINTER
> UNWIND_HINT_REGS

The second ENCODE_FRAME_POINTER is only needed for the stack-switching
(non-XENPV) case. The second UNWIND_HINT_REGS shouldn't be needed at
all, since the first one still applies after the call.

How about something more readable like this?

.macro idtentry_body cfunc has_error_code:req

PUSH_AND_CLEAR_REGS
ENCODE_FRAME_POINTER

#ifdef CONFIG_XEN_PV
/*
* When in XENPV, it is already in the task stack, and it can't fault
* for native_iret() nor native_load_gs_index() since XENPV uses its
* own pvops for iret and load_gs_index(). And it doesn't need to
* switch CR3. So it can skip invoking error_entry().
*/
ALTERNATIVE "", "jmp 1f", X86_FEATURE_XENPV
#endif

call error_entry
movq %rax, %rsp
ENCODE_FRAME_POINTER
1:
movq %rsp, %rdi /* pt_regs pointer into 1st argument*/

--
Josh

\
 
 \ /
  Last update: 2022-03-16 04:00    [W:0.155 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site