mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/entry: Use PUSH_AND_CLEAR_GPRS and drop SAVE_ALL
PUSH_AND_CLEAR_GPRS is shorter than SAVE_ALL in terms of emitted code. lstar_enter() and cstar_enter() do not need CLD. The SYSCALL instruction sanitises flags based on MSR_SYSCALL_MASK. For all other cases, place the CLD instruction next to STAC/CLAC so the flag handling is together. Get rid of the compat=1 special case for PV32. It's not obviously a win, and PV32 is getting increasingly rare these days. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
8af337dfb8
commit
c4bf5bc5f0
3 files changed
+19
-55
No files matched your search
@@ -219,51 +219,6 @@ static always_inline void stac(void)
|
||||
#endif
|
||||
|
||||
#ifdef __ASSEMBLER__
|
||||
.macro SAVE_ALL compat=0
|
||||
addq $-(UREGS_error_code-UREGS_r15), %rsp
|
||||
cld
|
||||
movq %rdi,UREGS_rdi(%rsp)
|
||||
xor %edi, %edi
|
||||
movq %rsi,UREGS_rsi(%rsp)
|
||||
xor %esi, %esi
|
||||
movq %rdx,UREGS_rdx(%rsp)
|
||||
xor %edx, %edx
|
||||
movq %rcx,UREGS_rcx(%rsp)
|
||||
xor %ecx, %ecx
|
||||
movq %rax,UREGS_rax(%rsp)
|
||||
xor %eax, %eax
|
||||
.if !\compat
|
||||
movq %r8,UREGS_r8(%rsp)
|
||||
movq %r9,UREGS_r9(%rsp)
|
||||
movq %r10,UREGS_r10(%rsp)
|
||||
movq %r11,UREGS_r11(%rsp)
|
||||
.endif
|
||||
xor %r8d, %r8d
|
||||
xor %r9d, %r9d
|
||||
xor %r10d, %r10d
|
||||
xor %r11d, %r11d
|
||||
movq %rbx,UREGS_rbx(%rsp)
|
||||
xor %ebx, %ebx
|
||||
movq %rbp,UREGS_rbp(%rsp)
|
||||
#ifdef CONFIG_FRAME_POINTER
|
||||
/* Indicate special exception stack frame by inverting the frame pointer. */
|
||||
leaq UREGS_rbp(%rsp), %rbp
|
||||
notq %rbp
|
||||
#else
|
||||
xor %ebp, %ebp
|
||||
#endif
|
||||
.if !\compat
|
||||
movq %r12,UREGS_r12(%rsp)
|
||||
movq %r13,UREGS_r13(%rsp)
|
||||
movq %r14,UREGS_r14(%rsp)
|
||||
movq %r15,UREGS_r15(%rsp)
|
||||
.endif
|
||||
xor %r12d, %r12d
|
||||
xor %r13d, %r13d
|
||||
xor %r14d, %r14d
|
||||
xor %r15d, %r15d
|
||||
.endm
|
||||
|
||||
/*
|
||||
* Push and clear GPRs
|
||||
*/
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
#include <asm/desc.h>
|
||||
#include <public/xen.h>
|
||||
|
||||
/* DPL1 gate, restricted to 32bit PV guest kernels only. */
|
||||
FUNC(entry_int82)
|
||||
ENDBR64
|
||||
cld
|
||||
ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
|
||||
pushq $0
|
||||
movb $HYPERCALL_VECTOR, EFRAME_entry_vector(%rsp)
|
||||
SAVE_ALL compat=1 /* DPL1 gate, restricted to 32bit PV guests only. */
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ FUNC(lstar_enter)
|
||||
pushq $0
|
||||
BUILD_BUG_ON(TRAP_syscall & 0xff)
|
||||
movb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
@@ -345,7 +345,7 @@ FUNC(cstar_enter)
|
||||
pushq $0
|
||||
BUILD_BUG_ON(TRAP_syscall & 0xff)
|
||||
movb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
@@ -383,13 +383,14 @@ FUNC(sysenter_entry)
|
||||
pushq $0
|
||||
pushfq
|
||||
LABEL(sysenter_eflags_saved, 0)
|
||||
cld
|
||||
ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
|
||||
pushq $3 /* ring 3 null cs */
|
||||
pushq $0 /* null rip */
|
||||
pushq $0
|
||||
BUILD_BUG_ON(TRAP_syscall & 0xff)
|
||||
movb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
@@ -442,10 +443,11 @@ END(sysenter_entry)
|
||||
|
||||
FUNC(entry_int80)
|
||||
ENDBR64
|
||||
cld
|
||||
ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
|
||||
pushq $0
|
||||
movb $0x80, EFRAME_entry_vector(%rsp)
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
@@ -722,8 +724,9 @@ END(ret_from_intr)
|
||||
.section .init.text, "ax", @progbits
|
||||
FUNC(early_page_fault)
|
||||
ENDBR64
|
||||
cld
|
||||
movb $X86_EXC_PF, EFRAME_entry_vector(%rsp)
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
movq %rsp, %rdi
|
||||
call do_early_page_fault
|
||||
jmp restore_all_xen
|
||||
@@ -769,8 +772,9 @@ UNLIKELY_END(exit_cr3)
|
||||
END(restore_all_xen)
|
||||
|
||||
FUNC(common_interrupt)
|
||||
cld
|
||||
ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
@@ -805,8 +809,9 @@ FUNC(entry_PF)
|
||||
END(entry_PF)
|
||||
/* No special register assumptions. */
|
||||
FUNC(handle_exception, 0)
|
||||
cld
|
||||
ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
@@ -1103,9 +1108,10 @@ END(entry_CP)
|
||||
FUNC(entry_DF)
|
||||
ENDBR64
|
||||
movb $X86_EXC_DF, EFRAME_entry_vector(%rsp)
|
||||
cld
|
||||
/* Set AC to reduce chance of further SMAP faults */
|
||||
ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
@@ -1132,8 +1138,9 @@ FUNC(entry_NMI)
|
||||
END(entry_NMI)
|
||||
|
||||
FUNC(handle_ist_exception)
|
||||
cld
|
||||
ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
|
||||
SAVE_ALL
|
||||
PUSH_AND_CLEAR_GPRS
|
||||
|
||||
GET_STACK_END(14)
|
||||
|
||||
|
||||