Reduce assembly code size of exception entry points
PATCH 4/5 Reduce assembly code size of exception entry points
We just pushed a 8-bytes zero and exception constants are small so we can just write a single byte saving 3 bytes for instruction.
With ENDBR64 this reduces the size of the entry point from 32 to 16 bytes (due to alignment).
--- xen/arch/x86/x86_64/entry.S | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
xen/arch/x86/x86_64/entry.S +8 -8
@@ -898,28 +898,28 @@ END(handle_exception) FUNC(entry_DE) ENDBR64 pushq $0 - movl $X86_EXC_DE, 4(%rsp) + movb $X86_EXC_DE, 4(%rsp) jmp handle_exception END(entry_DE) FUNC(entry_MF) ENDBR64 pushq $0 - movl $X86_EXC_MF, 4(%rsp) + movb $X86_EXC_MF, 4(%rsp) jmp handle_exception END(entry_MF) FUNC(entry_XM) ENDBR64 pushq $0 - movl $X86_EXC_XM, 4(%rsp) + movb $X86_EXC_XM, 4(%rsp) jmp handle_exception END(entry_XM) FUNC(entry_NM) ENDBR64 pushq $0 - movl $X86_EXC_NM, 4(%rsp) + movb $X86_EXC_NM, 4(%rsp) jmp handle_exception END(entry_NM)
@@ -933,28 +933,28 @@ END(entry_DB) FUNC(entry_BP) ENDBR64 pushq $0 - movl $X86_EXC_BP, 4(%rsp) + movb $X86_EXC_BP, 4(%rsp) jmp handle_exception END(entry_BP) FUNC(entry_OF) ENDBR64 pushq $0 - movl $X86_EXC_OF, 4(%rsp) + movb $X86_EXC_OF, 4(%rsp) jmp handle_exception END(entry_OF) FUNC(entry_BR) ENDBR64 pushq $0 - movl $X86_EXC_BR, 4(%rsp) + movb $X86_EXC_BR, 4(%rsp) jmp handle_exception END(entry_BR) FUNC(entry_UD) ENDBR64 pushq $0 - movl $X86_EXC_UD, 4(%rsp) + movb $X86_EXC_UD, 4(%rsp) jmp handle_exception END(entry_UD)
Signature · 1 line
2.34.1
Quoted 5 lines · Frediano Ziglio
We just pushed a 8-bytes zero and exception constants are small so we can just write a single byte saving 3 bytes for instruction.
With ENDBR64 this reduces the size of the entry point from 32 to 16 bytes (due to alignment).
Oh, good - when recently touching these entry points, I was thinking of doing exactly this. Just didn't get to it, yet. However
- since using different size stores can raise performance concerns, I'd like to suggest that you mention the fact that we actually already have cases of this, in autogen_stubs,
- I'd further like to ask that this conversion then be done consistently everywhere, perhaps even including the storing of TRAP_syscall. I find it particularly puzzling that you ...
xen/arch/x86/x86_64/entry.S END(entry_DB)
Quoted 36 lines
xen/arch/x86/x86_64/entry.S +4
-4@@ -898,28 +898,28 @@ END(handle_exception) FUNC(entry_DE) ENDBR64 pushq $0 - movl $X86_EXC_DE, 4(%rsp) + movb $X86_EXC_DE, 4(%rsp) jmp handle_exception END(entry_DE) FUNC(entry_MF) ENDBR64 pushq $0 - movl $X86_EXC_MF, 4(%rsp) + movb $X86_EXC_MF, 4(%rsp) jmp handle_exception END(entry_MF) FUNC(entry_XM) ENDBR64 pushq $0 - movl $X86_EXC_XM, 4(%rsp) + movb $X86_EXC_XM, 4(%rsp) jmp handle_exception END(entry_XM) FUNC(entry_NM) ENDBR64 pushq $0 - movl $X86_EXC_NM, 4(%rsp) + movb $X86_EXC_NM, 4(%rsp) jmp handle_exception END(entry_NM)@@ -933,28 +933,28 @@ END(entry_DB)
... skip entry_DB here. And even ...
Quoted 21 lines
xen/arch/x86/x86_64/entry.S +3
-3FUNC(entry_BP) ENDBR64 pushq $0 - movl $X86_EXC_BP, 4(%rsp) + movb $X86_EXC_BP, 4(%rsp) jmp handle_exception END(entry_BP) FUNC(entry_OF) ENDBR64 pushq $0 - movl $X86_EXC_OF, 4(%rsp) + movb $X86_EXC_OF, 4(%rsp) jmp handle_exception END(entry_OF) FUNC(entry_BR) ENDBR64 pushq $0 - movl $X86_EXC_BR, 4(%rsp) + movb $X86_EXC_BR, 4(%rsp)
xen/arch/x86/x86_64/entry.S END(entry_DB) · line 959
Quoted 10 lines
xen/arch/x86/x86_64/entry.S +1
-1jmp handle_exception END(entry_BR) FUNC(entry_UD) ENDBR64 pushq $0 - movl $X86_EXC_UD, 4(%rsp) + movb $X86_EXC_UD, 4(%rsp) jmp handle_exception END(entry_UD)
... entry points below here, where an error code is pushed, will have zero in the respective field, so these can be converted too. And entry_NMI isn't any different either. Whereas entry_MC even exactly matches the pattern you have been following, afaict.
Jan