Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 390

kvm-83-270.el5_11.src.rpm

From 550a844c025a975ea1a097e48ce509795e8fafbe Mon Sep 17 00:00:00 2001
From: Glauber Costa <glommer@redhat.com>
Date: Mon, 22 Nov 2010 12:51:27 -0200
Subject: [PATCH] implement dummy PnP support

RH-Author: Glauber Costa <glommer@redhat.com>
Message-id: <1290430287-736-1-git-send-email-glommer@redhat.com>
Patchwork-id: 13751
O-Subject: [RHEL5.6 PATCH] implement dummy PnP support
Bugzilla: 652671
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>

For a while now, people are complaining that trying to pxe-boot a guest
and then fallback to local storage boot won't work. The reason is that the pxe
Option Roms will register an int19 handler that subscribe the bios default one.

Analyzing that, I found out that gpxe (at least) will, more specifically,
fail in two tests:

 1. It will test to see if the PnP string is at a 16-byte boundary, which it is
    not. The spec requires this alignment, but bochs forcibly skip it to show it
    is a "Fake" PnP bios.
 2. Forcing the alignment right, gpxe will try to ask for a version service,
    that the bios does not implement.

This upstream commit from bochs, implements a fake PnP structure, that extends
the notion of a "fake PnP" further. It aligns the PnP string that lives in the
beginning of the structure, and implement a service routine, that only answers
to the function gpxe is interested at.

With that, gpxe works flawlessly.
Etherboot, on the other hand, does not work due to a configuration option in our
default build (described at BZ655266). It does, however, experiment a nice
improvement in functionality:

 * When pressing F12 and selecting local, we will now succeed where previously
   failing. Again, we used to fail because we would not run our int19 handler,
   even after pressing F12.

 * -boot cn goes directly to the hard disk sector, without trying to boot the
    network first.

Bugzilla: 652671
Upstream: bochs commit 1.244

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 bios/rombios.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 6 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 bios/rombios.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/bios/rombios.c b/bios/rombios.c
index df8dbe8..d153a46 100644
--- a/bios/rombios.c
+++ b/bios/rombios.c
@@ -143,6 +143,7 @@
 #define BX_FLOPPY_ON_CNT 37   /* 2 seconds */
 #define BX_PCIBIOS       1
 #define BX_APM           1
+#define BX_PNPBIOS       1
 
 #define BX_USE_ATADRV    1
 #define BX_ELTORITO_BOOT 1
@@ -1938,6 +1939,9 @@ print_bios_banner()
 #if BX_PCIBIOS
   "pcibios "
 #endif
+#if BX_PNPBIOS
+  "pnpbios "
+#endif
 #if BX_ELTORITO_BOOT
   "eltorito "
 #endif
@@ -10246,13 +10250,53 @@ checksum_out:
   ret
 
 
-;; We need a copy of this string, but we are not actually a PnP BIOS,
-;; so make sure it is *not* aligned, so OSes will not see it if they scan.
 .align 16
+#if !BX_PNPBIOS
+;; Make sure the pnpbios structure is *not* aligned, so OSes will not see it if
+;; they scan.
   db 0
-pnp_string:
+#endif
+pnpbios_structure:
   .ascii "$PnP"
-
+  db 0x10 ;; version
+  db 0x21 ;; length
+  dw 0x0 ;; control field
+  db 0xd1 ;; checksum
+  dd 0xf0000 ;; event notification flag address
+  dw pnpbios_real ;; real mode 16 bit offset
+  dw 0xf000 ;; real mode 16 bit segment
+  dw pnpbios_prot ;; 16 bit protected mode offset
+  dd 0xf0000 ;; 16 bit protected mode segment base
+  dd 0x0 ;; OEM device identifier
+  dw 0xf000 ;; real mode 16 bit data segment
+  dd 0xf0000 ;; 16 bit protected mode segment base
+
+pnpbios_prot:
+  push ebp
+  mov  ebp, esp
+  jmp  pnpbios_code
+pnpbios_real:
+  push ebp
+  movzx ebp, sp
+pnpbios_code:
+  mov  ax, 8[ebp]
+  cmp  ax, #0x60 ;; Get Version and Installation Check
+  jnz  pnpbios_fail
+  push ds
+  push di
+  mov  ds, 12[bp]
+  mov  di, 10[bp]
+  mov  ax, #0x0101
+  mov  [di], ax
+  pop  di
+  pop  ds
+  xor  ax, ax ;; SUCCESS
+  jmp  pnpbios_exit
+pnpbios_fail:
+  mov  ax, #0x82 ;; FUNCTION_NOT_SUPPORTED
+pnpbios_exit:
+  pop ebp
+  retf
 
 rom_scan:
   ;; Scan for existence of valid expansion ROMS.
@@ -10309,7 +10353,7 @@ fetch_bdf:
   ;; That should stop it grabbing INT 19h; we will use its BEV instead.
   mov  bx, #0xf000
   mov  es, bx
-  lea  di, pnp_string
+  lea  di, pnpbios_structure
 
   mov  bp, sp   ;; Call ROM init routine using seg:off on stack
   db   0xff     ;; call_far ss:[bp+0]
@@ -10342,7 +10386,7 @@ fetch_bdf:
   ;; Point ES:DI at "$PnP", which tells the ROM that we are a PnP BIOS.
   mov  bx, #0xf000
   mov  es, bx
-  lea  di, pnp_string
+  lea  di, pnpbios_structure
   /* jump to BCV function entry pointer */
   mov  bp, sp   ;; Call ROM BCV routine using seg:off on stack
   db   0xff     ;; call_far ss:[bp+0]
-- 
1.7.3.2