* [Qemu-devel] [PATCHv2] linuxboot optionrom: do not jump into loaded kernel in a big real mode
@ 2013-01-06 13:09 Gleb Natapov
2013-01-06 13:18 ` Alexander Graf
2013-01-12 16:08 ` Blue Swirl
0 siblings, 2 replies; 3+ messages in thread
From: Gleb Natapov @ 2013-01-06 13:09 UTC (permalink / raw)
To: Alexander Graf; +Cc: qemu-devel
Big real mode is fully emulated by KVM now, so if control is passed to
the loaded kernel while one of the segment registers is in big real
mode all the real mode part of the Linux start up is emulated. This
slows boot process down. Fix that by resetting ES limit to 0xffff before
jumping into the kernel.
The patch also removes unused code segment definition from GDT and
changes
ES register to be 16bit in protected mode since CS stays 16bit too and
it is CS segment that determines effective operands and addresses
length.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
v1->v2
- add patch for binary linuxboot.bin
diff --git a/pc-bios/linuxboot.bin b/pc-bios/linuxboot.bin
index e7c36694f997c3c34f7f4af3c2923bd2ef6094e7..435cac4ebff3fcd83cab4bf74de11f7071ab5aa6 100644
GIT binary patch
delta 72
zcmZqRXyBNj#oWTwIZ^izW6s78X^grY3=9l?2hw%`DF%L}13f4D4!pei7sLaB|Nnu+
PBpBVlxtghlk#QmbUy&EH
delta 68
zcmZqRXyBNj#azSGI8pZyW6H)4X^g52K)|nbpyx#2ftL^ef_NbC|38qJbsj=bI={J@
NsfKa#1||;1e*hia7ytkO
diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S
index 748c831..afe39a5 100644
--- a/pc-bios/optionrom/linuxboot.S
+++ b/pc-bios/optionrom/linuxboot.S
@@ -101,18 +101,20 @@ copy_kernel:
mov $1, %eax
mov %eax, %cr0
- /* So we can set ES to a 32-bit segment */
+ /* So we can enlarge ES segment limit */
mov $0x10, %eax
mov %eax, %es
- /* We're now running in 16-bit CS, but 32-bit ES! */
-
/* Load kernel and initrd */
read_fw_blob_addr32(FW_CFG_KERNEL)
read_fw_blob_addr32(FW_CFG_INITRD)
read_fw_blob_addr32(FW_CFG_CMDLINE)
read_fw_blob_addr32(FW_CFG_SETUP)
+ /* Do not leave ES in big real mode */
+ mov $0x08, %eax
+ mov %eax, %es
+
/* And now jump into Linux! */
mov $0, %eax
mov %eax, %cr0
@@ -130,10 +132,10 @@ gdt:
/* 0x00 */
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- /* 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) */
-.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
+ /* 0x08: data segment (base=0, limit=0xffff, type=16bit data read/write, DPL=0, 4k) */
+.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00
- /* 0x10: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) */
-.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00
+ /* 0x10: data segment (base=0, limit=0xfffff, type=16bit data read/write, DPL=0, 4k) */
+.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x8f, 0x00
BOOT_ROM_END
--
Gleb.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCHv2] linuxboot optionrom: do not jump into loaded kernel in a big real mode
2013-01-06 13:09 [Qemu-devel] [PATCHv2] linuxboot optionrom: do not jump into loaded kernel in a big real mode Gleb Natapov
@ 2013-01-06 13:18 ` Alexander Graf
2013-01-12 16:08 ` Blue Swirl
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2013-01-06 13:18 UTC (permalink / raw)
To: Gleb Natapov; +Cc: qemu-devel
On 06.01.2013, at 14:09, Gleb Natapov wrote:
> Big real mode is fully emulated by KVM now, so if control is passed to
> the loaded kernel while one of the segment registers is in big real
> mode all the real mode part of the Linux start up is emulated. This
> slows boot process down. Fix that by resetting ES limit to 0xffff before
> jumping into the kernel.
>
> The patch also removes unused code segment definition from GDT and
> changes
> ES register to be 16bit in protected mode since CS stays 16bit too and
> it is CS segment that determines effective operands and addresses
> length.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Alex
> ---
> v1->v2
> - add patch for binary linuxboot.bin
>
> diff --git a/pc-bios/linuxboot.bin b/pc-bios/linuxboot.bin
> index e7c36694f997c3c34f7f4af3c2923bd2ef6094e7..435cac4ebff3fcd83cab4bf74de11f7071ab5aa6 100644
> GIT binary patch
> delta 72
> zcmZqRXyBNj#oWTwIZ^izW6s78X^grY3=9l?2hw%`DF%L}13f4D4!pei7sLaB|Nnu+
> PBpBVlxtghlk#QmbUy&EH
>
> delta 68
> zcmZqRXyBNj#azSGI8pZyW6H)4X^g52K)|nbpyx#2ftL^ef_NbC|38qJbsj=bI={J@
> NsfKa#1||;1e*hia7ytkO
>
> diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S
> index 748c831..afe39a5 100644
> --- a/pc-bios/optionrom/linuxboot.S
> +++ b/pc-bios/optionrom/linuxboot.S
> @@ -101,18 +101,20 @@ copy_kernel:
> mov $1, %eax
> mov %eax, %cr0
>
> - /* So we can set ES to a 32-bit segment */
> + /* So we can enlarge ES segment limit */
> mov $0x10, %eax
> mov %eax, %es
>
> - /* We're now running in 16-bit CS, but 32-bit ES! */
> -
> /* Load kernel and initrd */
> read_fw_blob_addr32(FW_CFG_KERNEL)
> read_fw_blob_addr32(FW_CFG_INITRD)
> read_fw_blob_addr32(FW_CFG_CMDLINE)
> read_fw_blob_addr32(FW_CFG_SETUP)
>
> + /* Do not leave ES in big real mode */
> + mov $0x08, %eax
> + mov %eax, %es
> +
> /* And now jump into Linux! */
> mov $0, %eax
> mov %eax, %cr0
> @@ -130,10 +132,10 @@ gdt:
> /* 0x00 */
> .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
>
> - /* 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) */
> -.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
> + /* 0x08: data segment (base=0, limit=0xffff, type=16bit data read/write, DPL=0, 4k) */
> +.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00
>
> - /* 0x10: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) */
> -.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00
> + /* 0x10: data segment (base=0, limit=0xfffff, type=16bit data read/write, DPL=0, 4k) */
> +.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x8f, 0x00
>
> BOOT_ROM_END
> --
> Gleb.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCHv2] linuxboot optionrom: do not jump into loaded kernel in a big real mode
2013-01-06 13:09 [Qemu-devel] [PATCHv2] linuxboot optionrom: do not jump into loaded kernel in a big real mode Gleb Natapov
2013-01-06 13:18 ` Alexander Graf
@ 2013-01-12 16:08 ` Blue Swirl
1 sibling, 0 replies; 3+ messages in thread
From: Blue Swirl @ 2013-01-12 16:08 UTC (permalink / raw)
To: Gleb Natapov; +Cc: Alexander Graf, qemu-devel
Thanks, applied.
On Sun, Jan 6, 2013 at 1:09 PM, Gleb Natapov <gleb@redhat.com> wrote:
> Big real mode is fully emulated by KVM now, so if control is passed to
> the loaded kernel while one of the segment registers is in big real
> mode all the real mode part of the Linux start up is emulated. This
> slows boot process down. Fix that by resetting ES limit to 0xffff before
> jumping into the kernel.
>
> The patch also removes unused code segment definition from GDT and
> changes
> ES register to be 16bit in protected mode since CS stays 16bit too and
> it is CS segment that determines effective operands and addresses
> length.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
> v1->v2
> - add patch for binary linuxboot.bin
>
> diff --git a/pc-bios/linuxboot.bin b/pc-bios/linuxboot.bin
> index e7c36694f997c3c34f7f4af3c2923bd2ef6094e7..435cac4ebff3fcd83cab4bf74de11f7071ab5aa6 100644
> GIT binary patch
> delta 72
> zcmZqRXyBNj#oWTwIZ^izW6s78X^grY3=9l?2hw%`DF%L}13f4D4!pei7sLaB|Nnu+
> PBpBVlxtghlk#QmbUy&EH
>
> delta 68
> zcmZqRXyBNj#azSGI8pZyW6H)4X^g52K)|nbpyx#2ftL^ef_NbC|38qJbsj=bI={J@
> NsfKa#1||;1e*hia7ytkO
>
> diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S
> index 748c831..afe39a5 100644
> --- a/pc-bios/optionrom/linuxboot.S
> +++ b/pc-bios/optionrom/linuxboot.S
> @@ -101,18 +101,20 @@ copy_kernel:
> mov $1, %eax
> mov %eax, %cr0
>
> - /* So we can set ES to a 32-bit segment */
> + /* So we can enlarge ES segment limit */
> mov $0x10, %eax
> mov %eax, %es
>
> - /* We're now running in 16-bit CS, but 32-bit ES! */
> -
> /* Load kernel and initrd */
> read_fw_blob_addr32(FW_CFG_KERNEL)
> read_fw_blob_addr32(FW_CFG_INITRD)
> read_fw_blob_addr32(FW_CFG_CMDLINE)
> read_fw_blob_addr32(FW_CFG_SETUP)
>
> + /* Do not leave ES in big real mode */
> + mov $0x08, %eax
> + mov %eax, %es
> +
> /* And now jump into Linux! */
> mov $0, %eax
> mov %eax, %cr0
> @@ -130,10 +132,10 @@ gdt:
> /* 0x00 */
> .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
>
> - /* 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) */
> -.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
> + /* 0x08: data segment (base=0, limit=0xffff, type=16bit data read/write, DPL=0, 4k) */
> +.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00
>
> - /* 0x10: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) */
> -.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00
> + /* 0x10: data segment (base=0, limit=0xfffff, type=16bit data read/write, DPL=0, 4k) */
> +.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x8f, 0x00
>
> BOOT_ROM_END
> --
> Gleb.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-12 16:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-06 13:09 [Qemu-devel] [PATCHv2] linuxboot optionrom: do not jump into loaded kernel in a big real mode Gleb Natapov
2013-01-06 13:18 ` Alexander Graf
2013-01-12 16:08 ` Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).