x86/boot: Simplify BSS zeroing
diff mbox series

Message ID 20200108132241.8564-1-andrew.cooper3@citrix.com
State New
Headers show
Series
  • x86/boot: Simplify BSS zeroing
Related show

Commit Message

Andrew Cooper Jan. 8, 2020, 1:22 p.m. UTC
There is no need to load a non-flat %es to zero the BSS.  Use sym_esi()
instead, which is easier to follow, faster (avoids two segment loads) and
doesn't require use of the stack.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>

Looking through the code, almost everything that uses sym_fs() would be better
using sym_esi().  It is unnecessary extra instruction stream bytes, and AGU
hit for every memory operand.

Most importantly however, the code is far more simple to reason about when it
is consitent about being flat, rather than mixing and matching between flat
and non-flat views of the same memory.
---
 xen/arch/x86/boot/head.S | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Jan Beulich Jan. 8, 2020, 1:29 p.m. UTC | #1
On 08.01.2020 14:22, Andrew Cooper wrote:
> There is no need to load a non-flat %es to zero the BSS.  Use sym_esi()
> instead, which is easier to follow, faster (avoids two segment loads) and
> doesn't require use of the stack.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Patch
diff mbox series

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 82395e91dd..1b729c37f8 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -617,16 +617,12 @@  trampoline_setup:
         jnz     1f
 
         /* Initialize BSS (no nasty surprises!). */
-        mov     $sym_offs(__bss_start),%edi
-        mov     $sym_offs(__bss_end),%ecx
-        push    %fs
-        pop     %es
+        lea     sym_esi(__bss_start), %edi
+        lea     sym_esi(__bss_end), %ecx
         sub     %edi,%ecx
         xor     %eax,%eax
         shr     $2,%ecx
         rep stosl
-        push    %ds
-        pop     %es
 
 1:
         /* Interrogate CPU extended features via CPUID. */