Skip to content

Commit

Permalink
x86/entry: Don't call error_entry() for XENPV
Browse files Browse the repository at this point in the history
XENPV guests enter already on the task stack and they can't fault for
native_iret() nor native_load_gs_index() since they use their own pvop
for IRET and load_gs_index(). A CR3 switch is not needed either.

So there is no reason to call error_entry() in XENPV.

  [ bp: Massage commit message. ]

Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20220503032107.680190-6-jiangshanlai@gmail.com
  • Loading branch information
Lai Jiangshan authored and Borislav Petkov committed May 3, 2022
1 parent c64cc28 commit 64cbd0a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions arch/x86/entry/entry_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,17 @@ SYM_CODE_END(push_and_clear_regs)
call push_and_clear_regs
UNWIND_HINT_REGS

call error_entry
movq %rax, %rsp /* switch to the task stack if from userspace */
/*
* Call error_entry() and switch to the task stack if from userspace.
*
* 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 the CR3. So it can skip invoking error_entry().
*/
ALTERNATIVE "call error_entry; movq %rax, %rsp", \
"", X86_FEATURE_XENPV

ENCODE_FRAME_POINTER
UNWIND_HINT_REGS

Expand Down

0 comments on commit 64cbd0a

Please sign in to comment.