Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/arch/amd64
On Sat, Jan 04, 2020 at 08:43:16AM +0100, Maxime Villard wrote:
> +.section multiboot,"",@note
> Why @note? It will be in the .text anyway. Also why no dot in the section
> name? That's supposed to be the naming convention.
The idea is that one day if ld gets more reasonable, it could go in
non-loading note ection at the beginning of the binary, but if you
prefer .text, let us go with that.
On the section name, ELF specification says "Section names with a dot (.)
prefix are reserved for the system" (TIS ELF specification version 1.2),
section names without a dot are allowed, and we use plenty of them in
our kernels (e.g.: link_set_* sections). Our naming convention is not
obvious to me, nor what the specification means by "the system" here.
My hunch would be to avoid using an abitratry name inside a reserved
namespace, althought we already did it. If you have a strong opinion
on it, I can stand a leading dot in the multiboot section name.
> I don't know if you realize, but you landed a huge pile
> of crap in the middle of the amd64 locore
I have been working on this, but the priority was obviously the
boot problem. Attached is my latest change set, including the
locore cleanup you asked for.
--
Emmanuel Dreyfus
manu%netbsd.org@localhost
Index: sys/arch/amd64/amd64/locore.S
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
retrieving revision 1.195
diff -U4 -r1.195 locore.S
--- sys/arch/amd64/amd64/locore.S 15 Dec 2019 02:58:21 -0000 1.195
+++ sys/arch/amd64/amd64/locore.S 5 Jan 2020 00:41:18 -0000
@@ -431,10 +431,10 @@
.size tmpstk, tmpstk - .
.space 512
tmpstk:
-.section multiboot,"a"
#if defined(MULTIBOOT)
+.section multiboot
.align 8
.globl Multiboot2_Header
_C_LABEL(Multiboot2_Header):
.int MULTIBOOT2_HEADER_MAGIC
@@ -473,9 +473,9 @@
.int 8 /* sizeof(struct multiboot_tag) */
.align 8
.globl Multiboot2_Header_end
_C_LABEL(Multiboot2_Header_end):
-#endif /* MULTIBOOT */
+#endif /* MULTIBOOT */
/*
* Some hackage to deal with 64bit symbols in 32 bit mode.
* This may not be needed if things are cleaned up a little.
@@ -544,109 +544,13 @@
mov $(KERNTEXTOFF - KERNBASE), %rdi /* dest */
mov %r8, %rsi
sub $(start - kernel_text), %rsi /* src */
mov $(__kernel_end - kernel_text), %rcx /* size */
- mov %rcx, %r12
- movq %rdi, %r11 /* for misaligned check */
-
-#if !defined(NO_OVERLAP)
- movq %rdi, %r13
- subq %rsi, %r13
-#endif
-
- shrq $3, %rcx /* count for copy by words */
- jz 8f /* j if less than 8 bytes */
-
- lea -8(%rdi, %r12), %r14 /* target address of last 8 */
- mov -8(%rsi, %r12), %r15 /* get last word */
-#if !defined(NO_OVERLAP)
- cmpq %r12, %r13 /* overlapping? */
- jb 10f
-#endif
-
-/*
- * Non-overlaping, copy forwards.
- * Newer Intel cpus (Nehalem) will do 16byte read/write transfers
- * if %ecx is more than 76.
- * AMD might do something similar some day.
- */
- and $7, %r11 /* destination misaligned ? */
- jnz 12f
- rep
- movsq
- mov %r15, (%r14) /* write last word */
- jmp .Lcopy_done
-/*
- * Destination misaligned
- * AMD say it is better to align the destination (not the source).
- * This will also re-align copies if the source and dest are both
- * misaligned by the same amount)
- * (I think Nehalem will use its accelerated copy if the source
- * and destination have the same alignment.)
- */
-12:
- lea -9(%r11, %r12), %rcx /* post re-alignment count */
- neg %r11 /* now -1 .. -7 */
- mov (%rsi), %r12 /* get first word */
- mov %rdi, %r13 /* target for first word */
- lea 8(%rsi, %r11), %rsi
- lea 8(%rdi, %r11), %rdi
- shr $3, %rcx
- rep
- movsq
- mov %r12, (%r13) /* write first word */
- mov %r15, (%r14) /* write last word */
- jmp .Lcopy_done
-
-#if !defined(NO_OVERLAP)
-/* Must copy backwards.
- * Reverse copy is probably easy to code faster than 'rep movds'
- * since that requires (IIRC) an extra clock every 3 iterations (AMD).
- * However I don't suppose anything cares that much!
- * The big cost is the std/cld pair - reputedly 50+ cycles on Netburst P4.
- * The copy is aligned with the buffer start (more likely to
- * be a multiple of 8 than the end).
- */
-10:
- lea -8(%rsi, %rcx, 8), %rsi
- lea -8(%rdi, %rcx, 8), %rdi
- std
+ /* Assume non overlap and aligned size */
+ shrq $3, %rcx
rep
movsq
- cld
- mov %r15, (%r14) /* write last bytes */
- jmp .Lcopy_done
-#endif
-
-/* Less than 8 bytes to copy, copy by bytes */
-/* Intel Nehalem optimise 'rep movsb' for <= 7 bytes (9-15 clocks).
- * For longer transfers it is 50+ !
- */
-8: mov %r12, %rcx
-
-#if !defined(NO_OVERLAP)
- cmpq %r12, %r13 /* overlapping? */
- jb 81f
-#endif
-
- /* nope, copy forwards. */
- rep
- movsb
- jmp .Lcopy_done
-
-#if !defined(NO_OVERLAP)
-/* Must copy backwards */
-81:
- lea -1(%rsi, %rcx), %rsi
- lea -1(%rdi, %rcx), %rdi
- std
- rep
- movsb
- cld
-#endif
- /* End of copy kernel */
-.Lcopy_done:
mov %r8, %rdi /* %rdi: loaded start address */
mov %r9, %rsi /* %rsi: kernel entry address */
@@ -691,10 +595,10 @@
multiboot2_loader32b:
xor %eax, %eax
/*
- * Reload multiboot info from target location
- */
+ * Reload multiboot info from target location
+ */
movl _RELOC(multiboot2_info_ptr), %ebx
call *%esi
.align 16
@@ -712,9 +616,9 @@
.quad 0
multiboot2_info_ptr:
.long 0
-
+
.align 16
multiboot2_loader:
/*
* Here we would like to call multiboot2_pre_reloc() but
@@ -724,9 +628,8 @@
* does not work. As a result, we need to do the job
* of multiboot2_pre_reloc() here in assembly.
*/
#if multiboot2_pre_reloc_would_be_built_as_ia32
- movl $_RELOC(tmpstk),%esp
mov %ebx,%edi /* Address of Multiboot information */
call _C_LABEL(multiboot2_pre_reloc)
#else
/*
@@ -741,10 +644,10 @@
/*
* Set multiboot2_enabled
*/
- movl $1,%eax
- movl %eax,RELOC(multiboot2_enabled)
+ movb $1,%al
+ movb %al,RELOC(multiboot2_enabled)
/*
* Look for MULTIBOOT_TAG_TYPE_ELF_SECTIONS
*/
@@ -776,408 +679,19 @@
push %ebp /* int **esymp */
push $_RELOC(has_syms) /* bool *has_symsp */
push $_RELOC(Multiboot_Symbols)/* struct multiboot_symbol *ms */
push %esi /* struct multiboot_tag_elf_sections *mbt_elf */
- call multiboot2_copy_syms32
+ call _C_LABEL(multiboot2_copy_syms32)
- /* Asjust esym as a 64 bit pointer if esymp was set */
+ /* Adjust esym as a 64 bit pointer if esymp was set */
movl (%ebp),%eax
testl %eax,%eax /* esymp = NULL? */
jz elf_sections_done
movl $RELOC(esym),%ebp
movl %eax,(%ebp)
movl $KERNBASE_HI,4(%ebp)
- jmp elf_sections_done
-
- /*
- * This is multiboot2_copy_syms() from
- * src/sys/arch/x86/x86/multiboot2.c
- * built with -m32 -mcmodel=32 -D_LOCORE_64
- */
-multiboot2_copy_syms32:
- push %ebp
- mov %esp,%ebp
- push %edi
- push %esi
- push %ebx
- sub $0x20,%esp
- mov 0x8(%ebp),%esi
- /* for (i = 0; i < mbt_elf->num && symtabp == NULL && */
- mov 0x8(%esi),%ebx
- test %ebx,%ebx
- je copy_syms_4ce
- add $0x14,%esi
- mov %esi,%eax
- xor %edx,%edx
- jmp copy_syms_3a0
-copy_syms_395:
- cmp %edx,%ebx
- jbe copy_syms_4ce
-copy_syms_39d:
- add $0x40,%eax
-copy_syms_3a0:
- add $0x1,%edx
- /* if ((shdrp->sh_type == SHT_SYMTAB) && */
- cmpl $0x2,0x4(%eax)
- jne copy_syms_395
- /* shdrp->sh_link != SHN_UNDEF) { */
- mov 0x28(%eax),%ecx
- /* if ((shdrp->sh_type == SHT_SYMTAB) && */
- test %ecx,%ecx
- je copy_syms_395
- /* [shdrp->sh_link]; */
- shl $0x6,%ecx
- /* shdrp2 = &((locore_Elf_Shdr *)mbt_elf->sections) */
- add %esi,%ecx
- /* if (shdrp2->sh_type == SHT_STRTAB) { */
- cmpl $0x3,0x4(%ecx)
- jne copy_syms_395
- /* for (i = 0; i < mbt_elf->num && symtabp == NULL && */
- cmp %ebx,%edx
- jae copy_syms_6d1
- test %eax,%eax
- je copy_syms_608
- /* if (symtabp == NULL || strtabp == NULL) */
-copy_syms_3cb:
- test %ecx,%ecx
- lea 0x0(%esi),%esi
- je copy_syms_4ce
- /* symaddr = symtabp->sh_addr; */
- mov 0x10(%eax),%edi
- mov %edi,-0x10(%ebp)
- mov 0x14(%eax),%ebx
- mov %ebx,-0x18(%ebp)
- /* straddr = strtabp->sh_addr; */
- mov 0x10(%ecx),%esi
- mov %esi,-0x14(%ebp)
- mov 0x14(%ecx),%ebx
- mov %ebx,-0x20(%ebp)
- /* symsize = symtabp->sh_size; */
- mov 0x20(%eax),%ebx
- /* strsize = strtabp->sh_size; */
- mov 0x20(%ecx),%eax
- mov %eax,-0x1c(%ebp)
- cmp 0x18(%ebp),%edi
- jae copy_syms_4d6
- cmp %esi,0x18(%ebp)
- ja copy_syms_4e0
- jae copy_syms_54d
- /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
-copy_syms_40f:
- mov -0x1c(%ebp),%ecx
- mov %ecx,%eax
- xor %edx,%edx
- /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
- mov 0x18(%ebp),%esi
- xor %edi,%edi
- /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
- add %esi,%eax
- adc %edi,%edx
- mov %eax,-0x2c(%ebp)
- mov %edx,-0x28(%ebp)
- /* (void)memcpy((void *)(uintptr_t)cp1dst, */
- mov %ecx,%eax
- mov 0x18(%ebp),%edi
- mov -0x14(%ebp),%esi
- cmp $0x4,%ecx
- jae copy_syms_5e8
-copy_syms_436:
- test $0x2,%al
- je copy_syms_43c
- movsw %ds:(%esi),%es:(%edi)
-copy_syms_43c:
- test $0x1,%al
- je copy_syms_441
- movsb %ds:(%esi),%es:(%edi)
- /* (void)memcpy((void *)(uintptr_t)cp2dst, */
-copy_syms_441:
- mov %ebx,%eax
- mov 0x18(%ebp),%edi
- mov -0x1c(%ebp),%esi
- add %esi,%edi
- mov -0x10(%ebp),%esi
- cmp $0x4,%ebx
- jae copy_syms_5c4
-copy_syms_457:
- test $0x2,%al
- je copy_syms_45d
- movsw %ds:(%esi),%es:(%edi)
-copy_syms_45d:
- test $0x1,%al
- je copy_syms_462
- movsb %ds:(%esi),%es:(%edi)
- /* symstart = (cp1src == symaddr) ? cp1dst : cp2dst; */
-copy_syms_462:
- mov -0x18(%ebp),%edx
- mov -0x20(%ebp),%edi
- xor %edi,%edx
- mov -0x10(%ebp),%eax
- mov -0x14(%ebp),%ecx
- xor %ecx,%eax
- or %eax,%edx
- je copy_syms_6ba
- mov -0x2c(%ebp),%eax
- mov %eax,-0x24(%ebp)
- mov %ecx,-0x10(%ebp)
- mov %edi,-0x18(%ebp)
- /* strstart = (cp1src == straddr) ? cp1dst : cp2dst; */
-copy_syms_486:
- mov -0x20(%ebp),%edx
- xor -0x18(%ebp),%edx
- mov -0x14(%ebp),%eax
- xor -0x10(%ebp),%eax
- or %eax,%edx
- je copy_syms_545
-copy_syms_49a:
- mov -0x2c(%ebp),%esi
- /* ms->s_symstart = symstart + kernbase; */
-copy_syms_49d:
- mov -0x24(%ebp),%eax
- add 0x1c(%ebp),%eax
- mov 0xc(%ebp),%edi
- mov %eax,(%edi)
- /* ms->s_symsize = symsize; */
- mov %edi,%eax
- mov %ebx,0x4(%edi)
- /* ms->s_strstart = strstart + kernbase; */
- add 0x1c(%ebp),%esi
- mov %esi,0x8(%edi)
- /* ms->s_strsize = strsize; */
- mov -0x1c(%ebp),%edi
- mov %edi,0xc(%eax)
- /* *has_symsp = true; */
- mov 0x10(%ebp),%eax
- movb $0x1,(%eax)
- /* *esymp = (int *)((uintptr_t)endp + symsize + strsize + kernbase); */
- mov 0x18(%ebp),%eax
- add 0x1c(%ebp),%eax
- add %eax,%ebx
- add %edi,%ebx
- mov 0x14(%ebp),%eax
- mov %ebx,(%eax)
-copy_syms_4ce:
- add $0x20,%esp
- pop %ebx
- pop %esi
- pop %edi
- pop %ebp
- ret
-copy_syms_4d6:
- jbe copy_syms_54d
- mov -0x14(%ebp),%eax
- cmp %eax,0x18(%ebp)
- jbe copy_syms_54d
- /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
-copy_syms_4e0:
- mov 0x18(%ebp),%eax
- mov %eax,-0x24(%ebp)
- /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
- mov %ebx,%eax
- xor %edx,%edx
- /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
- mov 0x18(%ebp),%esi
- xor %edi,%edi
- /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
- add %esi,%eax
- adc %edi,%edx
- mov %eax,-0x2c(%ebp)
- mov %edx,-0x28(%ebp)
- /* (void)memcpy((void *)(uintptr_t)cp1dst, */
- mov %ebx,%eax
- mov 0x18(%ebp),%edi
- mov -0x10(%ebp),%esi
- cmp $0x4,%ebx
- jae copy_syms_5a8
-copy_syms_50a:
- test $0x2,%al
- jne copy_syms_57b
- test $0x1,%al
- jne copy_syms_578
- /* (void)memcpy((void *)(uintptr_t)cp2dst, */
-copy_syms_512:
- mov -0x1c(%ebp),%ecx
- mov %ecx,%eax
- mov 0x18(%ebp),%edi
- add %ebx,%edi
- mov -0x14(%ebp),%esi
- cmp $0x4,%ecx
- jae copy_syms_584
-copy_syms_524:
- test $0x2,%al
- jne copy_syms_56c
- test $0x1,%al
- je copy_syms_486
-copy_syms_530:
- movsb %ds:(%esi),%es:(%edi)
- /* strstart = (cp1src == straddr) ? cp1dst : cp2dst; */
- mov -0x20(%ebp),%edx
- xor -0x18(%ebp),%edx
- mov -0x14(%ebp),%eax
- xor -0x10(%ebp),%eax
- or %eax,%edx
- jne copy_syms_49a
-copy_syms_545:
- mov 0x18(%ebp),%esi
- jmp copy_syms_49d
- /* if (symaddr < straddr) { */
-copy_syms_54d:
- mov -0x20(%ebp),%edi
- cmp %edi,-0x18(%ebp)
- jb copy_syms_4e0
- ja copy_syms_40f
- mov -0x14(%ebp),%edi
- cmp %edi,-0x10(%ebp)
- jb copy_syms_4e0
- jmp copy_syms_40f
- /* (void)memcpy((void *)(uintptr_t)cp2dst, */
-copy_syms_56c:
- movsw %ds:(%esi),%es:(%edi)
- test $0x1,%al
- je copy_syms_486
- jmp copy_syms_530
- /* (void)memcpy((void *)(uintptr_t)cp1dst, */
-copy_syms_578:
- movsb %ds:(%esi),%es:(%edi)
- jmp copy_syms_512
-copy_syms_57b:
- movsw %ds:(%esi),%es:(%edi)
- test $0x1,%al
- nop
- je copy_syms_512
- jmp copy_syms_578
- /* (void)memcpy((void *)(uintptr_t)cp2dst, */
-copy_syms_584:
- test $0x1,%edi
- jne copy_syms_650
-copy_syms_590:
- test $0x2,%edi
- jne copy_syms_63c
-copy_syms_59c:
- mov %eax,%ecx
- shr $0x2,%ecx
- rep movsl %ds:(%esi),%es:(%edi)
- jmp copy_syms_524
- /* (void)memcpy((void *)(uintptr_t)cp1dst, */
-copy_syms_5a8:
- test $0x1,%edi
- jne copy_syms_626
-copy_syms_5b0:
- test $0x2,%edi
- jne copy_syms_615
-copy_syms_5b8:
- mov %eax,%ecx
- shr $0x2,%ecx
- rep movsl %ds:(%esi),%es:(%edi)
- jmp copy_syms_50a
- /* (void)memcpy((void *)(uintptr_t)cp2dst, */
-copy_syms_5c4:
- test $0x1,%edi
- jne copy_syms_666
-copy_syms_5d0:
- test $0x2,%edi
- jne copy_syms_6a6
-copy_syms_5dc:
- mov %eax,%ecx
- shr $0x2,%ecx
- rep movsl %ds:(%esi),%es:(%edi)
- jmp copy_syms_457
- /* (void)memcpy((void *)(uintptr_t)cp1dst, */
-copy_syms_5e8:
- test $0x1,%edi
- jne copy_syms_68d
-copy_syms_5f4:
- test $0x2,%edi
- jne copy_syms_679
-copy_syms_5fc:
- mov %eax,%ecx
- shr $0x2,%ecx
- rep movsl %ds:(%esi),%es:(%edi)
- jmp copy_syms_436
- /* for (i = 0; i < mbt_elf->num && symtabp == NULL && */
-copy_syms_608:
- test %ecx,%ecx
- jne copy_syms_4ce
- jmp copy_syms_39d
- /* (void)memcpy((void *)(uintptr_t)cp1dst, */
-copy_syms_615:
- movzwl (%esi),%edx
- mov %dx,(%edi)
- add $0x2,%edi
- add $0x2,%esi
- sub $0x2,%eax
- jmp copy_syms_5b8
-copy_syms_626:
- movzbl (%esi),%eax
- mov %al,(%edi)
- mov 0x18(%ebp),%eax
- lea 0x1(%eax),%edi
- add $0x1,%esi
- lea -0x1(%ebx),%eax
- jmp copy_syms_5b0
- /* (void)memcpy((void *)(uintptr_t)cp2dst, */
-copy_syms_63c:
- movzwl (%esi),%edx
- mov %dx,(%edi)
- add $0x2,%edi
- add $0x2,%esi
- sub $0x2,%eax
- jmp copy_syms_59c
-copy_syms_650:
- movzbl (%esi),%eax
- mov %al,(%edi)
- add $0x1,%edi
- add $0x1,%esi
- mov -0x1c(%ebp),%eax
- sub $0x1,%eax
- jmp copy_syms_590
-copy_syms_666:
- movzbl (%esi),%eax
- mov %al,(%edi)
- add $0x1,%edi
- add $0x1,%esi
- lea -0x1(%ebx),%eax
- jmp copy_syms_5d0
- /* (void)memcpy((void *)(uintptr_t)cp1dst, */
-copy_syms_679:
- movzwl (%esi),%edx
- mov %dx,(%edi)
- add $0x2,%edi
- add $0x2,%esi
- sub $0x2,%eax
- jmp copy_syms_5fc
-copy_syms_68d:
- movzbl (%esi),%eax
- mov %al,(%edi)
- mov 0x18(%ebp),%eax
- lea 0x1(%eax),%edi
- add $0x1,%esi
- mov -0x1c(%ebp),%eax
- sub $0x1,%eax
- jmp copy_syms_5f4
- /* (void)memcpy((void *)(uintptr_t)cp2dst, */
-copy_syms_6a6:
- movzwl (%esi),%edx
- mov %dx,(%edi)
- add $0x2,%edi
- add $0x2,%esi
- sub $0x2,%eax
- jmp copy_syms_5dc
-copy_syms_6ba:
- mov -0x14(%ebp),%eax
- mov %eax,-0x10(%ebp)
- mov -0x20(%ebp),%eax
- mov %eax,-0x18(%ebp)
- /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
- mov 0x18(%ebp),%eax
- mov %eax,-0x24(%ebp)
- jmp copy_syms_486
- /* if (symtabp == NULL || strtabp == NULL) */
-copy_syms_6d1:
- test %eax,%eax
- jne copy_syms_3cb
- jmp copy_syms_4ce
elf_sections_done:
#endif
jmp .Lbegin
@@ -1629,11 +1143,15 @@
* we saved before from C code. Note that we cannot delay its
* parsing any more because initgdt (called below) needs to make
* use of this information.
*/
+ movb _C_LABEL(multiboot2_enabled),%al
+ cmpb $0,%al
+ je no_multiboot2_post_reloc
pushq %rsi
call _C_LABEL(multiboot2_post_reloc)
popq %rsi
+no_multiboot2_post_reloc:
#endif
xorw %ax,%ax
movw %ax,%gs
movw %ax,%fs
Index: sys/arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.551
diff -U4 -r1.551 GENERIC
--- sys/arch/amd64/conf/GENERIC 14 Dec 2019 07:45:20 -0000 1.551
+++ sys/arch/amd64/conf/GENERIC 5 Jan 2020 00:41:18 -0000
@@ -25,9 +25,9 @@
#ident "GENERIC-$Revision: 1.551 $"
maxusers 64 # estimated number of users
-#options MULTIBOOT # Multiboot support (see multiboot(8))
+options MULTIBOOT # Multiboot support (see multiboot(8))
# delay between "rebooting ..." message and hardware reset, in milliseconds
#options CPURESET_DELAY=2000
Index: sys/arch/amd64/conf/Makefile.amd64
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/Makefile.amd64,v
retrieving revision 1.80
diff -U4 -r1.80 Makefile.amd64
--- sys/arch/amd64/conf/Makefile.amd64 14 Nov 2019 16:23:52 -0000 1.80
+++ sys/arch/amd64/conf/Makefile.amd64 5 Jan 2020 00:41:18 -0000
@@ -93,9 +93,9 @@
.if defined(KASLR)
EXTRA_LINKFLAGS= --split-by-file=0x100000 -r -d
KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
.else
-EXTRA_LINKFLAGS= -z max-page-size=0x200000
+EXTRA_LINKFLAGS= -z max-page-size=0x1000
KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
.endif
LINKFLAGS_NORMAL= -X
Index: sys/arch/amd64/conf/files.amd64
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/files.amd64,v
retrieving revision 1.114
diff -U4 -r1.114 files.amd64
--- sys/arch/amd64/conf/files.amd64 10 Dec 2019 02:06:07 -0000 1.114
+++ sys/arch/amd64/conf/files.amd64 5 Jan 2020 00:41:18 -0000
@@ -32,8 +32,9 @@
# Multiboot support
defflag opt_multiboot.h MULTIBOOT
file arch/x86/x86/multiboot2.c multiboot
+file arch/amd64/amd64/copy_syms32.S multiboot
# Start code
file arch/amd64/amd64/locore.S machdep
file arch/amd64/amd64/vector.S machdep
Index: sys/arch/amd64/conf/kern.ldscript
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/kern.ldscript,v
retrieving revision 1.30
diff -U4 -r1.30 kern.ldscript
--- sys/arch/amd64/conf/kern.ldscript 15 Dec 2019 02:56:40 -0000 1.30
+++ sys/arch/amd64/conf/kern.ldscript 5 Jan 2020 00:41:18 -0000
@@ -12,20 +12,11 @@
ENTRY(_start)
SECTIONS
{
- /*
- * multiboot (file_offset) : AT (load_address)
- * file_offset must be below 32k for multiboot 2 specification
- * BIOS boot requires load_address above 0x200000
- */
- multiboot 0x1000 : AT (0x200000)
+ .text : AT (ADDR(.text) & 0x0fffffff)
{
- . = ALIGN(8);
KEEP(*(multiboot));
- }
- .text : AT (0x200000 + SIZEOF(multiboot))
- {
. = ALIGN(__PAGE_SIZE);
__text_user_start = . ;
*(.text.user)
. = ALIGN(__PAGE_SIZE);
--- /dev/null 2020-01-04 05:33:25.257148725 +0100
+++ sys/arch/amd64/amd64/copy_syms32.S 2019-12-31 03:02:13.628539586 +0100
@@ -0,0 +1,391 @@
+#include <machine/asm.h>
+
+ .code32
+ .globl _C_LABEL(multiboot2_copy_syms32)
+/*
+ * This is multiboot2_copy_syms() from
+ * src/sys/arch/x86/x86/multiboot2.c
+ * built with -m32 -mcmodel=32 -D_LOCORE_64
+ */
+_C_LABEL(multiboot2_copy_syms32):
+ push %ebp
+ mov %esp,%ebp
+ push %edi
+ push %esi
+ push %ebx
+ sub $0x20,%esp
+ mov 0x8(%ebp),%esi
+ /* for (i = 0; i < mbt_elf->num && symtabp == NULL && */
+ mov 0x8(%esi),%ebx
+ test %ebx,%ebx
+ je copy_syms_4ce
+ add $0x14,%esi
+ mov %esi,%eax
+ xor %edx,%edx
+ jmp copy_syms_3a0
+copy_syms_395:
+ cmp %edx,%ebx
+ jbe copy_syms_4ce
+copy_syms_39d:
+ add $0x40,%eax
+copy_syms_3a0:
+ add $0x1,%edx
+ /* if ((shdrp->sh_type == SHT_SYMTAB) && */
+ cmpl $0x2,0x4(%eax)
+ jne copy_syms_395
+ /* shdrp->sh_link != SHN_UNDEF) { */
+ mov 0x28(%eax),%ecx
+ /* if ((shdrp->sh_type == SHT_SYMTAB) && */
+ test %ecx,%ecx
+ je copy_syms_395
+ /* [shdrp->sh_link]; */
+ shl $0x6,%ecx
+ /* shdrp2 = &((locore_Elf_Shdr *)mbt_elf->sections) */
+ add %esi,%ecx
+ /* if (shdrp2->sh_type == SHT_STRTAB) { */
+ cmpl $0x3,0x4(%ecx)
+ jne copy_syms_395
+ /* for (i = 0; i < mbt_elf->num && symtabp == NULL && */
+ cmp %ebx,%edx
+ jae copy_syms_6d1
+ test %eax,%eax
+ je copy_syms_608
+ /* if (symtabp == NULL || strtabp == NULL) */
+copy_syms_3cb:
+ test %ecx,%ecx
+ lea 0x0(%esi),%esi
+ je copy_syms_4ce
+ /* symaddr = symtabp->sh_addr; */
+ mov 0x10(%eax),%edi
+ mov %edi,-0x10(%ebp)
+ mov 0x14(%eax),%ebx
+ mov %ebx,-0x18(%ebp)
+ /* straddr = strtabp->sh_addr; */
+ mov 0x10(%ecx),%esi
+ mov %esi,-0x14(%ebp)
+ mov 0x14(%ecx),%ebx
+ mov %ebx,-0x20(%ebp)
+ /* symsize = symtabp->sh_size; */
+ mov 0x20(%eax),%ebx
+ /* strsize = strtabp->sh_size; */
+ mov 0x20(%ecx),%eax
+ mov %eax,-0x1c(%ebp)
+ cmp 0x18(%ebp),%edi
+ jae copy_syms_4d6
+ cmp %esi,0x18(%ebp)
+ ja copy_syms_4e0
+ jae copy_syms_54d
+ /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
+copy_syms_40f:
+ mov -0x1c(%ebp),%ecx
+ mov %ecx,%eax
+ xor %edx,%edx
+ /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
+ mov 0x18(%ebp),%esi
+ xor %edi,%edi
+ /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
+ add %esi,%eax
+ adc %edi,%edx
+ mov %eax,-0x2c(%ebp)
+ mov %edx,-0x28(%ebp)
+ /* (void)memcpy((void *)(uintptr_t)cp1dst, */
+ mov %ecx,%eax
+ mov 0x18(%ebp),%edi
+ mov -0x14(%ebp),%esi
+ cmp $0x4,%ecx
+ jae copy_syms_5e8
+copy_syms_436:
+ test $0x2,%al
+ je copy_syms_43c
+ movsw %ds:(%esi),%es:(%edi)
+copy_syms_43c:
+ test $0x1,%al
+ je copy_syms_441
+ movsb %ds:(%esi),%es:(%edi)
+ /* (void)memcpy((void *)(uintptr_t)cp2dst, */
+copy_syms_441:
+ mov %ebx,%eax
+ mov 0x18(%ebp),%edi
+ mov -0x1c(%ebp),%esi
+ add %esi,%edi
+ mov -0x10(%ebp),%esi
+ cmp $0x4,%ebx
+ jae copy_syms_5c4
+copy_syms_457:
+ test $0x2,%al
+ je copy_syms_45d
+ movsw %ds:(%esi),%es:(%edi)
+copy_syms_45d:
+ test $0x1,%al
+ je copy_syms_462
+ movsb %ds:(%esi),%es:(%edi)
+ /* symstart = (cp1src == symaddr) ? cp1dst : cp2dst; */
+copy_syms_462:
+ mov -0x18(%ebp),%edx
+ mov -0x20(%ebp),%edi
+ xor %edi,%edx
+ mov -0x10(%ebp),%eax
+ mov -0x14(%ebp),%ecx
+ xor %ecx,%eax
+ or %eax,%edx
+ je copy_syms_6ba
+ mov -0x2c(%ebp),%eax
+ mov %eax,-0x24(%ebp)
+ mov %ecx,-0x10(%ebp)
+ mov %edi,-0x18(%ebp)
+ /* strstart = (cp1src == straddr) ? cp1dst : cp2dst; */
+copy_syms_486:
+ mov -0x20(%ebp),%edx
+ xor -0x18(%ebp),%edx
+ mov -0x14(%ebp),%eax
+ xor -0x10(%ebp),%eax
+ or %eax,%edx
+ je copy_syms_545
+copy_syms_49a:
+ mov -0x2c(%ebp),%esi
+ /* ms->s_symstart = symstart + kernbase; */
+copy_syms_49d:
+ mov -0x24(%ebp),%eax
+ add 0x1c(%ebp),%eax
+ mov 0xc(%ebp),%edi
+ mov %eax,(%edi)
+ /* ms->s_symsize = symsize; */
+ mov %edi,%eax
+ mov %ebx,0x4(%edi)
+ /* ms->s_strstart = strstart + kernbase; */
+ add 0x1c(%ebp),%esi
+ mov %esi,0x8(%edi)
+ /* ms->s_strsize = strsize; */
+ mov -0x1c(%ebp),%edi
+ mov %edi,0xc(%eax)
+ /* *has_symsp = true; */
+ mov 0x10(%ebp),%eax
+ movb $0x1,(%eax)
+ /* *esymp = (int *)((uintptr_t)endp + symsize + strsize + kernbase); */
+ mov 0x18(%ebp),%eax
+ add 0x1c(%ebp),%eax
+ add %eax,%ebx
+ add %edi,%ebx
+ mov 0x14(%ebp),%eax
+ mov %ebx,(%eax)
+copy_syms_4ce:
+ add $0x20,%esp
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ ret
+copy_syms_4d6:
+ jbe copy_syms_54d
+ mov -0x14(%ebp),%eax
+ cmp %eax,0x18(%ebp)
+ jbe copy_syms_54d
+ /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
+copy_syms_4e0:
+ mov 0x18(%ebp),%eax
+ mov %eax,-0x24(%ebp)
+ /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
+ mov %ebx,%eax
+ xor %edx,%edx
+ /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
+ mov 0x18(%ebp),%esi
+ xor %edi,%edi
+ /* cp2dst = (locore_Elf_Addr)(uintptr_t)endp + cp1size; */
+ add %esi,%eax
+ adc %edi,%edx
+ mov %eax,-0x2c(%ebp)
+ mov %edx,-0x28(%ebp)
+ /* (void)memcpy((void *)(uintptr_t)cp1dst, */
+ mov %ebx,%eax
+ mov 0x18(%ebp),%edi
+ mov -0x10(%ebp),%esi
+ cmp $0x4,%ebx
+ jae copy_syms_5a8
+copy_syms_50a:
+ test $0x2,%al
+ jne copy_syms_57b
+ test $0x1,%al
+ jne copy_syms_578
+ /* (void)memcpy((void *)(uintptr_t)cp2dst, */
+copy_syms_512:
+ mov -0x1c(%ebp),%ecx
+ mov %ecx,%eax
+ mov 0x18(%ebp),%edi
+ add %ebx,%edi
+ mov -0x14(%ebp),%esi
+ cmp $0x4,%ecx
+ jae copy_syms_584
+copy_syms_524:
+ test $0x2,%al
+ jne copy_syms_56c
+ test $0x1,%al
+ je copy_syms_486
+copy_syms_530:
+ movsb %ds:(%esi),%es:(%edi)
+ /* strstart = (cp1src == straddr) ? cp1dst : cp2dst; */
+ mov -0x20(%ebp),%edx
+ xor -0x18(%ebp),%edx
+ mov -0x14(%ebp),%eax
+ xor -0x10(%ebp),%eax
+ or %eax,%edx
+ jne copy_syms_49a
+copy_syms_545:
+ mov 0x18(%ebp),%esi
+ jmp copy_syms_49d
+ /* if (symaddr < straddr) { */
+copy_syms_54d:
+ mov -0x20(%ebp),%edi
+ cmp %edi,-0x18(%ebp)
+ jb copy_syms_4e0
+ ja copy_syms_40f
+ mov -0x14(%ebp),%edi
+ cmp %edi,-0x10(%ebp)
+ jb copy_syms_4e0
+ jmp copy_syms_40f
+ /* (void)memcpy((void *)(uintptr_t)cp2dst, */
+copy_syms_56c:
+ movsw %ds:(%esi),%es:(%edi)
+ test $0x1,%al
+ je copy_syms_486
+ jmp copy_syms_530
+ /* (void)memcpy((void *)(uintptr_t)cp1dst, */
+copy_syms_578:
+ movsb %ds:(%esi),%es:(%edi)
+ jmp copy_syms_512
+copy_syms_57b:
+ movsw %ds:(%esi),%es:(%edi)
+ test $0x1,%al
+ nop
+ je copy_syms_512
+ jmp copy_syms_578
+ /* (void)memcpy((void *)(uintptr_t)cp2dst, */
+copy_syms_584:
+ test $0x1,%edi
+ jne copy_syms_650
+copy_syms_590:
+ test $0x2,%edi
+ jne copy_syms_63c
+copy_syms_59c:
+ mov %eax,%ecx
+ shr $0x2,%ecx
+ rep movsl %ds:(%esi),%es:(%edi)
+ jmp copy_syms_524
+ /* (void)memcpy((void *)(uintptr_t)cp1dst, */
+copy_syms_5a8:
+ test $0x1,%edi
+ jne copy_syms_626
+copy_syms_5b0:
+ test $0x2,%edi
+ jne copy_syms_615
+copy_syms_5b8:
+ mov %eax,%ecx
+ shr $0x2,%ecx
+ rep movsl %ds:(%esi),%es:(%edi)
+ jmp copy_syms_50a
+ /* (void)memcpy((void *)(uintptr_t)cp2dst, */
+copy_syms_5c4:
+ test $0x1,%edi
+ jne copy_syms_666
+copy_syms_5d0:
+ test $0x2,%edi
+ jne copy_syms_6a6
+copy_syms_5dc:
+ mov %eax,%ecx
+ shr $0x2,%ecx
+ rep movsl %ds:(%esi),%es:(%edi)
+ jmp copy_syms_457
+ /* (void)memcpy((void *)(uintptr_t)cp1dst, */
+copy_syms_5e8:
+ test $0x1,%edi
+ jne copy_syms_68d
+copy_syms_5f4:
+ test $0x2,%edi
+ jne copy_syms_679
+copy_syms_5fc:
+ mov %eax,%ecx
+ shr $0x2,%ecx
+ rep movsl %ds:(%esi),%es:(%edi)
+ jmp copy_syms_436
+ /* for (i = 0; i < mbt_elf->num && symtabp == NULL && */
+copy_syms_608:
+ test %ecx,%ecx
+ jne copy_syms_4ce
+ jmp copy_syms_39d
+ /* (void)memcpy((void *)(uintptr_t)cp1dst, */
+copy_syms_615:
+ movzwl (%esi),%edx
+ mov %dx,(%edi)
+ add $0x2,%edi
+ add $0x2,%esi
+ sub $0x2,%eax
+ jmp copy_syms_5b8
+copy_syms_626:
+ movzbl (%esi),%eax
+ mov %al,(%edi)
+ mov 0x18(%ebp),%eax
+ lea 0x1(%eax),%edi
+ add $0x1,%esi
+ lea -0x1(%ebx),%eax
+ jmp copy_syms_5b0
+ /* (void)memcpy((void *)(uintptr_t)cp2dst, */
+copy_syms_63c:
+ movzwl (%esi),%edx
+ mov %dx,(%edi)
+ add $0x2,%edi
+ add $0x2,%esi
+ sub $0x2,%eax
+ jmp copy_syms_59c
+copy_syms_650:
+ movzbl (%esi),%eax
+ mov %al,(%edi)
+ add $0x1,%edi
+ add $0x1,%esi
+ mov -0x1c(%ebp),%eax
+ sub $0x1,%eax
+ jmp copy_syms_590
+copy_syms_666:
+ movzbl (%esi),%eax
+ mov %al,(%edi)
+ add $0x1,%edi
+ add $0x1,%esi
+ lea -0x1(%ebx),%eax
+ jmp copy_syms_5d0
+ /* (void)memcpy((void *)(uintptr_t)cp1dst, */
+copy_syms_679:
+ movzwl (%esi),%edx
+ mov %dx,(%edi)
+ add $0x2,%edi
+ add $0x2,%esi
+ sub $0x2,%eax
+ jmp copy_syms_5fc
+copy_syms_68d:
+ movzbl (%esi),%eax
+ mov %al,(%edi)
+ mov 0x18(%ebp),%eax
+ lea 0x1(%eax),%edi
+ add $0x1,%esi
+ mov -0x1c(%ebp),%eax
+ sub $0x1,%eax
+ jmp copy_syms_5f4
+ /* (void)memcpy((void *)(uintptr_t)cp2dst, */
+copy_syms_6a6:
+ movzwl (%esi),%edx
+ mov %dx,(%edi)
+ add $0x2,%edi
+ add $0x2,%esi
+ sub $0x2,%eax
+ jmp copy_syms_5dc
+copy_syms_6ba:
+ mov -0x14(%ebp),%eax
+ mov %eax,-0x10(%ebp)
+ mov -0x20(%ebp),%eax
+ mov %eax,-0x18(%ebp)
+ /* cp1dst = (locore_Elf_Addr)(uintptr_t)endp; */
+ mov 0x18(%ebp),%eax
+ mov %eax,-0x24(%ebp)
+ jmp copy_syms_486
+ /* if (symtabp == NULL || strtabp == NULL) */
+copy_syms_6d1:
+ test %eax,%eax
+ jne copy_syms_3cb
+ jmp copy_syms_4ce
Home |
Main Index |
Thread Index |
Old Index