mirror of
https://github.com/0xAX/linux-insides.git
synced 2025-01-09 15:20:57 +00:00
fix boot-4
This commit is contained in:
parent
4382670c38
commit
e735b508d1
@ -151,7 +151,7 @@ Bit 6 (write): KEEP_SEGMENTS
|
|||||||
So, if the `KEEP_SEGMENTS` bit is not set in the `loadflags`, we need to set `ds`, `ss` and `es` segment registers to the index of data segment with base `0`. That we do:
|
So, if the `KEEP_SEGMENTS` bit is not set in the `loadflags`, we need to set `ds`, `ss` and `es` segment registers to the index of data segment with base `0`. That we do:
|
||||||
|
|
||||||
```C
|
```C
|
||||||
testb $(1 << 6), BP_loadflags(%esi)
|
testb $KEEP_SEGMENTS, BP_loadflags(%esi)
|
||||||
jnz 1f
|
jnz 1f
|
||||||
|
|
||||||
cli
|
cli
|
||||||
@ -337,8 +337,6 @@ When we are using position-independent code an address is obtained by adding the
|
|||||||
jge 1f
|
jge 1f
|
||||||
#endif
|
#endif
|
||||||
movl $LOAD_PHYSICAL_ADDR, %ebx
|
movl $LOAD_PHYSICAL_ADDR, %ebx
|
||||||
1:
|
|
||||||
addl $z_extract_offset, %ebx
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Remember that the value of the `ebp` register is the physical address of the `startup_32` label. If the `CONFIG_RELOCATABLE` kernel configuration option is enabled during kernel configuration, we put this address in the `ebx` register, align it to a multiple of `2MB` and compare it with the `LOAD_PHYSICAL_ADDR` value. The `LOAD_PHYSICAL_ADDR` macro is defined in the [arch/x86/include/asm/boot.h](https://github.com/torvalds/linux/blob/16f73eb02d7e1765ccab3d2018e0bd98eb93d973/arch/x86/include/asm/boot.h) header file and it looks like this:
|
Remember that the value of the `ebp` register is the physical address of the `startup_32` label. If the `CONFIG_RELOCATABLE` kernel configuration option is enabled during kernel configuration, we put this address in the `ebx` register, align it to a multiple of `2MB` and compare it with the `LOAD_PHYSICAL_ADDR` value. The `LOAD_PHYSICAL_ADDR` macro is defined in the [arch/x86/include/asm/boot.h](https://github.com/torvalds/linux/blob/16f73eb02d7e1765ccab3d2018e0bd98eb93d973/arch/x86/include/asm/boot.h) header file and it looks like this:
|
||||||
@ -354,6 +352,7 @@ As we can see it just expands to the aligned `CONFIG_PHYSICAL_ALIGN` value which
|
|||||||
After all of these calculations, we will have `ebp` which contains the address where we loaded it and `ebx` set to the address of where kernel will be moved after decompression. But that is not the end. The compressed kernel image should be moved to the end of the decompression buffer to simplify calculations where kernel will be located later. For this:
|
After all of these calculations, we will have `ebp` which contains the address where we loaded it and `ebx` set to the address of where kernel will be moved after decompression. But that is not the end. The compressed kernel image should be moved to the end of the decompression buffer to simplify calculations where kernel will be located later. For this:
|
||||||
|
|
||||||
```assembly
|
```assembly
|
||||||
|
1:
|
||||||
movl BP_init_size(%esi), %eax
|
movl BP_init_size(%esi), %eax
|
||||||
subl $_end, %eax
|
subl $_end, %eax
|
||||||
addl %eax, %ebx
|
addl %eax, %ebx
|
||||||
@ -377,6 +376,11 @@ To understand the magic with `gdt` offsets we need to look at the definition of
|
|||||||
|
|
||||||
```assembly
|
```assembly
|
||||||
.data
|
.data
|
||||||
|
gdt64:
|
||||||
|
.word gdt_end - gdt
|
||||||
|
.long 0
|
||||||
|
.word 0
|
||||||
|
.quad 0
|
||||||
gdt:
|
gdt:
|
||||||
.word gdt_end - gdt
|
.word gdt_end - gdt
|
||||||
.long gdt
|
.long gdt
|
||||||
|
Loading…
Reference in New Issue
Block a user