Patchwork [master,stable-0.12] linuxboot: fix gdt address calculation

login
register
mail settings
Submitter Avi Kivity
Date Dec. 24, 2009, 1:38 p.m.
Message ID <1261661930-11888-1-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/41777/
State New
Headers show

Comments

Avi Kivity - Dec. 24, 2009, 1:38 p.m.
The gdt address calculation in linuxboot.bin is broken in two ways: first
it loads %cs into %eax, but that instruction leaves the high bits of %eax
undefined and we did not clear them.  Secondly, we completely ignore the
incorrect %eax, and use the undefined %ebx instead.

With these issues fixed, linuxboot works again.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 pc-bios/optionrom/linuxboot.S |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Paolo Bonzini - Dec. 24, 2009, 1:56 p.m.
On 12/24/2009 02:38 PM, Avi Kivity wrote:
> The gdt address calculation in linuxboot.bin is broken in two ways: first
> it loads %cs into %eax, but that instruction leaves the high bits of %eax
> undefined and we did not clear them.  Secondly, we completely ignore the
> incorrect %eax, and use the undefined %ebx instead.
>
> With these issues fixed, linuxboot works again.

Wow, I wonder how it worked for me...

Paolo
Anthony Liguori - Jan. 8, 2010, 4:41 p.m.
On 12/24/2009 07:38 AM, Avi Kivity wrote:
> The gdt address calculation in linuxboot.bin is broken in two ways: first
> it loads %cs into %eax, but that instruction leaves the high bits of %eax
> undefined and we did not clear them.  Secondly, we completely ignore the
> incorrect %eax, and use the undefined %ebx instead.
>
> With these issues fixed, linuxboot works again.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   pc-bios/optionrom/linuxboot.S |    5 +++--
>   1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S
> index c4c9109..8aebe51 100644
> --- a/pc-bios/optionrom/linuxboot.S
> +++ b/pc-bios/optionrom/linuxboot.S
> @@ -86,9 +86,10 @@ copy_kernel:
>   	/* Now create the GDT descriptor */
>   	movw		$((3 * 8) - 1), -16(%bp)
>   	mov		%cs, %eax
> +	movzwl		%ax, %eax
>   	shl		$4, %eax
> -	addl		$gdt, %ebx
> -	movl		%ebx, -14(%bp)
> +	addl		$gdt, %eax
> +	movl		%eax, -14(%bp)
>
>   	/* And load the GDT */
>   	data32 lgdt	-16(%bp)
>

Patch

diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S
index c4c9109..8aebe51 100644
--- a/pc-bios/optionrom/linuxboot.S
+++ b/pc-bios/optionrom/linuxboot.S
@@ -86,9 +86,10 @@  copy_kernel:
 	/* Now create the GDT descriptor */
 	movw		$((3 * 8) - 1), -16(%bp)
 	mov		%cs, %eax
+	movzwl		%ax, %eax
 	shl		$4, %eax
-	addl		$gdt, %ebx
-	movl		%ebx, -14(%bp)
+	addl		$gdt, %eax
+	movl		%eax, -14(%bp)
 
 	/* And load the GDT */
 	data32 lgdt	-16(%bp)