diff mbox

Boot order problem and disable iPXE/gPXE

Message ID 20120106020539.GB25140@morn.localdomain
State New
Headers show

Commit Message

Kevin O'Connor Jan. 6, 2012, 2:05 a.m. UTC
On Thu, Jan 05, 2012 at 11:20:37AM +0200, Gleb Natapov wrote:
> On Thu, Jan 05, 2012 at 10:09:44AM +0100, Gerhard Wiesinger wrote:
> > But as far as I remember therefore the option ROM registers through
> > BIOS for INT 19h booting. So Seabios should know it that this is a
> > harddisk.
> It registers BEV. Otherwise you wouldn't be able to boot at all. In fact
> it registers multiple BEVs (one for each attached scsi device). But BIOS
> knows nothing about the device behind the BEV. It just jumps to BEV
> address to boot from it when INT 19h is called. There may be scsi cdrom
> there or even tape.

Gerhard's option rom is actually registering a BCV, and SeaBIOS can
know that is likely a hard drive.  So, I think Gerhard has a point.
SeaBIOS could probably fall back to the harddrive priority if it finds
a BCV without an explicit bootindex priority.

Gerhard - does the patch below improve things for you?

-Kevin

Comments

Gleb Natapov Jan. 6, 2012, 5:27 a.m. UTC | #1
On Thu, Jan 05, 2012 at 09:05:39PM -0500, Kevin O'Connor wrote:
> On Thu, Jan 05, 2012 at 11:20:37AM +0200, Gleb Natapov wrote:
> > On Thu, Jan 05, 2012 at 10:09:44AM +0100, Gerhard Wiesinger wrote:
> > > But as far as I remember therefore the option ROM registers through
> > > BIOS for INT 19h booting. So Seabios should know it that this is a
> > > harddisk.
> > It registers BEV. Otherwise you wouldn't be able to boot at all. In fact
> > it registers multiple BEVs (one for each attached scsi device). But BIOS
> > knows nothing about the device behind the BEV. It just jumps to BEV
> > address to boot from it when INT 19h is called. There may be scsi cdrom
> > there or even tape.
> 
> Gerhard's option rom is actually registering a BCV, and SeaBIOS can
> know that is likely a hard drive.  So, I think Gerhard has a point.
Ah, yeah. I see now that pnp rom can register either bev or bcv. But non
of them tell us what device it actually is.

> SeaBIOS could probably fall back to the harddrive priority if it finds
> a BCV without an explicit bootindex priority.
The same option rom probably will register bcv for SCSI CD/DVD too. Also
are you sure pxe roms do not register bcv for network booting?

> 
> Gerhard - does the patch below improve things for you?
> 
> -Kevin
> 
> 
> --- a/src/boot.c
> +++ b/src/boot.c
> @@ -326,7 +326,7 @@ boot_add_bev(u16 seg, u16 bev, u16 desc, int prio)
>  void
>  boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio)
>  {
> -    bootentry_add(IPL_TYPE_BCV, defPrio(prio, DEFAULT_PRIO)
> +    bootentry_add(IPL_TYPE_BCV, defPrio(prio, DefaultHDPrio)
>                    , SEGOFF(seg, ip).segoff
>                    , desc ? MAKE_FLATPTR(seg, desc) : "Legacy option rom");
>  }

--
			Gleb.
Kevin O'Connor Jan. 7, 2012, 1:53 a.m. UTC | #2
On Fri, Jan 06, 2012 at 07:27:25AM +0200, Gleb Natapov wrote:
> On Thu, Jan 05, 2012 at 09:05:39PM -0500, Kevin O'Connor wrote:
> > SeaBIOS could probably fall back to the harddrive priority if it finds
> > a BCV without an explicit bootindex priority.
> The same option rom probably will register bcv for SCSI CD/DVD too. Also
> are you sure pxe roms do not register bcv for network booting?

BCV is just for drives - network cards would use a BEV.  The BBS spec
isn't clear on whether BCV is just for harddrives (as opposed to
floppy/cd), but it seems to imply that.

I'm not sure what a SCSI rom would do with a CD drive.  My guess is
that it wouldn't map it to a BIOS visible drive id at all, as there's
no way to select an id with any assurance that it wont conflict with
one chosen by the BIOS or another rom.  If QEMU can simulate this (and
someone knows the command-line to do such) it would be an interesting
test to see what the rom does.

-Kevin
Gerhard Wiesinger Jan. 7, 2012, 8:35 a.m. UTC | #3
On Thu, 5 Jan 2012, Kevin O'Connor wrote:

> On Thu, Jan 05, 2012 at 11:20:37AM +0200, Gleb Natapov wrote:
>> On Thu, Jan 05, 2012 at 10:09:44AM +0100, Gerhard Wiesinger wrote:
>>> But as far as I remember therefore the option ROM registers through
>>> BIOS for INT 19h booting. So Seabios should know it that this is a
>>> harddisk.
>> It registers BEV. Otherwise you wouldn't be able to boot at all. In fact
>> it registers multiple BEVs (one for each attached scsi device). But BIOS
>> knows nothing about the device behind the BEV. It just jumps to BEV
>> address to boot from it when INT 19h is called. There may be scsi cdrom
>> there or even tape.
>
> Gerhard's option rom is actually registering a BCV, and SeaBIOS can
> know that is likely a hard drive.  So, I think Gerhard has a point.
> SeaBIOS could probably fall back to the harddrive priority if it finds
> a BCV without an explicit bootindex priority.
>
> Gerhard - does the patch below improve things for you?

Can confirm, that it works now as expected and boots from SCSI harddisk. 
(boot order=cad,menu=on). Also boot=dca,menu=on boots from CDROM as 
expected. Also when legacy option rom is selected boots from harddisk.

Boot menu looks like
1. #18 ID 00 LUN0 QEMU    QEMU HARDDSISK
2. #18 ID 00 LUN1 QEMU    QEMU HARDDSISK
3. #18 ID 00 LUN2 QEMU    QEMU HARDDSISK
4. #18 ID 00 LUN3 QEMU    QEMU HARDDSISK
5. Legacy option rom
6. DVD/CD [ata1-0: QEMU DVD-ROM ATAPI-4 DVD/CD]
7. iPXE (PCI 00:00.0)

But there is still the iPXE ROM there (I think I didn't see iPXE because 
it is last one displayed and boot screen is fast and will be cleared 
afterwards). So something must be wrong. @Gerd: any ideas?

command line:
/root/download/qemu/git/qemu-kvm/x86_64-softmmu/qemu-system-x86_64
-drive file=1.img,media=disk,if=scsi,bus=0,unit=0
-drive file=2.img,media=disk,if=scsi,bus=0,unit=1
-drive file=3.img,media=disk,if=scsi,bus=0,unit=2
-drive file=4.img,media=disk,if=scsi,bus=0,unit=3 
-cdrom KNOPPIX_V6.2CD-2009-11-18-DE.iso
-boot order=cad,menu=on -m 256 -k de 
-vga vmware -vnc :0 -bios /root/download/seabios/git/seabios/out/bios.bin 
-option-rom 8xx_64.rom
-device rtl8139,mac=1a:46:0b:ca:bc:7c,vlan=0,romfile=
-net tap,ifname=tap0,script=no,downscript=no,vlan=0
-device pcnet,mac=1a:46:0b:ca:bc:7e,vlan=1,romfile=
-net tap,ifname=tap1,script=no,downscript=no,vlan=1

Relevant logs below.

Ciao,
Gerhard

--
http://www.wiesinger.com/

|0ffdf000| Searching bootorder for: /pci@i0cf8/*@1,1/drive@1/disk@0
|0ffdf000| pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe15b0 (detail=0x0ffe15d0)
|0ffdf000| Registering bootable: DVD/CD [ata1-0: QEMU DVD-ROM ATAPI-4 DVD/CD] (type:3 prio:103 data:fd940)
Searching bootorder for: /rom@genroms/8xx_64.rom
pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe1560 (detail=0x0ffe1580)
Registering bootable: #18 ID00 LUN0 QEMU     QEMU HARDDISK    (type:129 prio:101 data:ca003d4e)
Searching bootorder for: /rom@genroms/8xx_64.rom:rom1
pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe1510 (detail=0x0ffe1530)
Registering bootable: #18 ID01 LUN0 QEMU     QEMU HARDDISK    (type:129 prio:101 data:ca003da2)
Searching bootorder for: /rom@genroms/8xx_64.rom:rom2
pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe14c0 (detail=0x0ffe14e0)
Registering bootable: #18 ID02 LUN0 QEMU     QEMU HARDDISK    (type:129 prio:101 data:ca003df6)
Searching bootorder for: /rom@genroms/8xx_64.rom:rom3
pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe1470 (detail=0x0ffe1490)
Registering bootable: #18 ID03 LUN0 QEMU     QEMU HARDDISK    (type:129 prio:101 data:ca003e4a)
Checking rom 0x000ce000 (sig aa55 size 17)
Searching bootorder for: /rom@genroms/vapic.bin
pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe1420 (detail=0x0ffe1440)
Registering bootable: Legacy option rom (type:129 prio:101 data:ce000003)
Checking rom 0x000d0800 (sig aa55 size 5)
Searching bootorder for: /rom@genroms/pxe-pcnet.rom
pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe13d0 (detail=0x0ffe13f0)
Registering bootable: iPXE (PCI 00:00.0) (type:128 prio:9999 data:d0800372)
Press F12 for boot menu.

Checking for bootsplash
Gerhard Wiesinger Jan. 7, 2012, 9 a.m. UTC | #4
On Fri, 6 Jan 2012, Kevin O'Connor wrote:
> I'm not sure what a SCSI rom would do with a CD drive.  My guess is
> that it wouldn't map it to a BIOS visible drive id at all, as there's
> no way to select an id with any assurance that it wont conflict with
> one chosen by the BIOS or another rom.  If QEMU can simulate this (and
> someone knows the command-line to do such) it would be an interesting
> test to see what the rom does.

As far as I remember from SCSI only systems one can just boot from CD 
drives, too. Order is SCSI id (starting with SCSI id 0, up to 7, 15, etc. 
depending on host adapeter).

Tried:
-drive file=KNOPPIX_V6.2CD-2009-11-18-DE.iso,media=cdrom,if=scsi,bus=0,unit=0
all other drives are afterwards.

Registers as CDROM, selecting Legacy Option ROM from boot menu, but can't 
boot:
Screen:
Booting from DVD/CD...
Boot failed: Could not read from CDROM (code 0003)

Log:
Booting from DVD/CD...
scsi_is_ready (drive=0x000fd920)
ata_pio_transfer id=0x000fd920 write=0 count=1 bs=18 buf=0x00006746
Read sector id=0x000fd920 dest=0x00006746
Device reports MEDIUM NOT PRESENT
scsi_is_ready returned -1
Boot failed: Could not read from CDROM (code 0003)

Ciao,
Gerhard

--
http://www.wiesinger.com/
Kevin O'Connor Jan. 7, 2012, 4:20 p.m. UTC | #5
On Sat, Jan 07, 2012 at 09:35:55AM +0100, Gerhard Wiesinger wrote:
[...]
> 5. Legacy option rom
> 6. DVD/CD [ata1-0: QEMU DVD-ROM ATAPI-4 DVD/CD]
> 7. iPXE (PCI 00:00.0)
> 
> But there is still the iPXE ROM there (I think I didn't see iPXE
> because it is last one displayed and boot screen is fast and will be
> cleared afterwards). So something must be wrong. @Gerd: any ideas?
[...]
> Checking rom 0x000ce000 (sig aa55 size 17)
> Searching bootorder for: /rom@genroms/vapic.bin
> pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe1420 (detail=0x0ffe1440)
> Registering bootable: Legacy option rom (type:129 prio:101 data:ce000003)
> Checking rom 0x000d0800 (sig aa55 size 5)
> Searching bootorder for: /rom@genroms/pxe-pcnet.rom
> pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe13d0 (detail=0x0ffe13f0)
> Registering bootable: iPXE (PCI 00:00.0) (type:128 prio:9999 data:d0800372)

The iPXE rom is coming from the "genroms" fw_cfg interface instead of
via the pci rom bar interface.  Also, the "legacy option rom" is from
the vapic.bin file (comfing from the same fw_cfg interface) - this rom
is something KVM sets up.

-Kevin
Kevin O'Connor Jan. 7, 2012, 4:28 p.m. UTC | #6
On Sat, Jan 07, 2012 at 10:00:56AM +0100, Gerhard Wiesinger wrote:
> On Fri, 6 Jan 2012, Kevin O'Connor wrote:
> >I'm not sure what a SCSI rom would do with a CD drive.  My guess is
> >that it wouldn't map it to a BIOS visible drive id at all, as there's
> >no way to select an id with any assurance that it wont conflict with
> >one chosen by the BIOS or another rom.  If QEMU can simulate this (and
> >someone knows the command-line to do such) it would be an interesting
> >test to see what the rom does.
> 
> As far as I remember from SCSI only systems one can just boot from
> CD drives, too. Order is SCSI id (starting with SCSI id 0, up to 7,
> 15, etc. depending on host adapeter).
> 
> Tried:
> -drive file=KNOPPIX_V6.2CD-2009-11-18-DE.iso,media=cdrom,if=scsi,bus=0,unit=0
> all other drives are afterwards.
> 
> Registers as CDROM, selecting Legacy Option ROM from boot menu, but
> can't boot:
> Screen:
> Booting from DVD/CD...

This is SeaBIOS attempting to boot from its internal CD code which
wont work for SCSI.  (The "Legacy Option ROM" seletion is probably the
KVM vapic.bin rom.)  The question is, what will the 8xx_64.rom do with
a cdrom on a scsi adapter...

I downloaded 8xx_64.rom and tried the above command line.
Interestingly, it will register a BEV for a CD drive - which confirms
my suspicion that it wont use a BCV.  Also interesting is that if both
a harddrive and a CD are found, both a BEV and a BCV will be present -
SeaBIOS doesn't support this, but I don't see any reason it couldn't.

-Kevin
Gerhard Wiesinger Jan. 7, 2012, 10:46 p.m. UTC | #7
On Sat, 7 Jan 2012, Kevin O'Connor wrote:

> On Sat, Jan 07, 2012 at 09:35:55AM +0100, Gerhard Wiesinger wrote:
> [...]
>> 5. Legacy option rom
>> 6. DVD/CD [ata1-0: QEMU DVD-ROM ATAPI-4 DVD/CD]
>> 7. iPXE (PCI 00:00.0)
>>
>> But there is still the iPXE ROM there (I think I didn't see iPXE
>> because it is last one displayed and boot screen is fast and will be
>> cleared afterwards). So something must be wrong. @Gerd: any ideas?
> [...]
>> Checking rom 0x000ce000 (sig aa55 size 17)
>> Searching bootorder for: /rom@genroms/vapic.bin
>> pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe1420 (detail=0x0ffe1440)
>> Registering bootable: Legacy option rom (type:129 prio:101 data:ce000003)
>> Checking rom 0x000d0800 (sig aa55 size 5)
>> Searching bootorder for: /rom@genroms/pxe-pcnet.rom
>> pmm_malloc zone=0x0ffefe30 handle=ffffffff size=20 align=10 ret=0x0ffe13d0 (detail=0x0ffe13f0)
>> Registering bootable: iPXE (PCI 00:00.0) (type:128 prio:9999 data:d0800372)
>
> The iPXE rom is coming from the "genroms" fw_cfg interface instead of
> via the pci rom bar interface.  Also, the "legacy option rom" is from
> the vapic.bin file (comfing from the same fw_cfg interface) - this rom
> is something KVM sets up.

No NIC:
-net none
=> No iPXE ROM (correct).

but with the previously listed config no iPXE ROM should be there. Saw 
this is done through paravirtualization from Seabios/QEMU or KVM. So there
must be a bug with the empty romfile options with net or device (I guess) 
in QEMU/KVM.

The vapic.bin is ok.

BTW: Will you integrate the boot one liner?

Ciao,
Gerhard

--
http://www.wiesinger.com/
Gerhard Wiesinger Jan. 7, 2012, 10:47 p.m. UTC | #8
On Sat, 7 Jan 2012, Kevin O'Connor wrote:

> On Sat, Jan 07, 2012 at 10:00:56AM +0100, Gerhard Wiesinger wrote:
>> On Fri, 6 Jan 2012, Kevin O'Connor wrote:
>>> I'm not sure what a SCSI rom would do with a CD drive.  My guess is
>>> that it wouldn't map it to a BIOS visible drive id at all, as there's
>>> no way to select an id with any assurance that it wont conflict with
>>> one chosen by the BIOS or another rom.  If QEMU can simulate this (and
>>> someone knows the command-line to do such) it would be an interesting
>>> test to see what the rom does.
>>
>> As far as I remember from SCSI only systems one can just boot from
>> CD drives, too. Order is SCSI id (starting with SCSI id 0, up to 7,
>> 15, etc. depending on host adapeter).
>>
>> Tried:
>> -drive file=KNOPPIX_V6.2CD-2009-11-18-DE.iso,media=cdrom,if=scsi,bus=0,unit=0
>> all other drives are afterwards.
>>
>> Registers as CDROM, selecting Legacy Option ROM from boot menu, but
>> can't boot:
>> Screen:
>> Booting from DVD/CD...
>
> This is SeaBIOS attempting to boot from its internal CD code which
> wont work for SCSI.  (The "Legacy Option ROM" seletion is probably the
> KVM vapic.bin rom.)  The question is, what will the 8xx_64.rom do with
> a cdrom on a scsi adapter...
>
> I downloaded 8xx_64.rom and tried the above command line.
> Interestingly, it will register a BEV for a CD drive - which confirms
> my suspicion that it wont use a BCV.  Also interesting is that if both
> a harddrive and a CD are found, both a BEV and a BCV will be present -
> SeaBIOS doesn't support this, but I don't see any reason it couldn't.

Any plans to implement it?

BTW: Where is the "Spec" about BEVs and BCVs?

Thnx.

Ciao,
Gerhard

--
http://www.wiesinger.com/
Kevin O'Connor Jan. 7, 2012, 10:53 p.m. UTC | #9
On Sat, Jan 07, 2012 at 11:47:29PM +0100, Gerhard Wiesinger wrote:
> On Sat, 7 Jan 2012, Kevin O'Connor wrote:
> >I downloaded 8xx_64.rom and tried the above command line.
> >Interestingly, it will register a BEV for a CD drive - which confirms
> >my suspicion that it wont use a BCV.  Also interesting is that if both
> >a harddrive and a CD are found, both a BEV and a BCV will be present -
> >SeaBIOS doesn't support this, but I don't see any reason it couldn't.
> 
> Any plans to implement it?

It's on my queue, as is the change to have BCV inherit from
DefaultHDPrio.

> 
> BTW: Where is the "Spec" about BEVs and BCVs?

Google for "specsbbs101.pdf".

-Kevin
Gerhard Wiesinger Jan. 7, 2012, 10:59 p.m. UTC | #10
On Sat, 7 Jan 2012, Gerhard Wiesinger wrote:
> No NIC:
> -net none
> => No iPXE ROM (correct).
>
> but with the previously listed config no iPXE ROM should be there. Saw this 
> is done through paravirtualization from Seabios/QEMU or KVM. So there
> must be a bug with the empty romfile options with net or device (I guess) in 
> QEMU/KVM.

I think I found the bug:
pcnet-pci.c
static int pci_pcnet_init(PCIDevice *pci_dev)
{
...
     if (!pci_dev->qdev.hotplugged) {
         static int loaded = 0;
         if (!loaded) {
             rom_add_option("pxe-pcnet.rom", -1);
             loaded = 1;
         }
     }

Option rom is added unconditionally regardless of command line options 
due to hot plug feature ...

grep -ir rom_add_option .
./ne2000.c:            rom_add_option("pxe-ne2k_pci.rom", -1);
NE2000 also has the same problem.

RTL8139 and all others are done through romfile which are working 
correct:
./rtl8139.c:    .romfile    = "pxe-rtl8139.rom",

Ciao,
Gerhard

--
http://www.wiesinger.com/
Gleb Natapov Jan. 8, 2012, 8:31 a.m. UTC | #11
On Sat, Jan 07, 2012 at 11:28:44AM -0500, Kevin O'Connor wrote:
> On Sat, Jan 07, 2012 at 10:00:56AM +0100, Gerhard Wiesinger wrote:
> > On Fri, 6 Jan 2012, Kevin O'Connor wrote:
> > >I'm not sure what a SCSI rom would do with a CD drive.  My guess is
> > >that it wouldn't map it to a BIOS visible drive id at all, as there's
> > >no way to select an id with any assurance that it wont conflict with
> > >one chosen by the BIOS or another rom.  If QEMU can simulate this (and
> > >someone knows the command-line to do such) it would be an interesting
> > >test to see what the rom does.
> > 
> > As far as I remember from SCSI only systems one can just boot from
> > CD drives, too. Order is SCSI id (starting with SCSI id 0, up to 7,
> > 15, etc. depending on host adapeter).
> > 
> > Tried:
> > -drive file=KNOPPIX_V6.2CD-2009-11-18-DE.iso,media=cdrom,if=scsi,bus=0,unit=0
> > all other drives are afterwards.
> > 
> > Registers as CDROM, selecting Legacy Option ROM from boot menu, but
> > can't boot:
> > Screen:
> > Booting from DVD/CD...
> 
> This is SeaBIOS attempting to boot from its internal CD code which
> wont work for SCSI.  (The "Legacy Option ROM" seletion is probably the
> KVM vapic.bin rom.)  The question is, what will the 8xx_64.rom do with
> a cdrom on a scsi adapter...
> 
> I downloaded 8xx_64.rom and tried the above command line.
> Interestingly, it will register a BEV for a CD drive - which confirms
> my suspicion that it wont use a BCV.  Also interesting is that if both
> a harddrive and a CD are found, both a BEV and a BCV will be present -
> SeaBIOS doesn't support this, but I don't see any reason it couldn't.
> 
Cool! What about non pnp roms that also register bcv? Should we use HD
priority for those too?

--
			Gleb.
Gerhard Wiesinger Jan. 8, 2012, 11:59 a.m. UTC | #12
On Sat, 7 Jan 2012, Gerhard Wiesinger wrote:

> On Sat, 7 Jan 2012, Gerhard Wiesinger wrote:
>> No NIC:
>> -net none
>> => No iPXE ROM (correct).
>> 
>> but with the previously listed config no iPXE ROM should be there. Saw this 
>> is done through paravirtualization from Seabios/QEMU or KVM. So there
>> must be a bug with the empty romfile options with net or device (I guess) 
>> in QEMU/KVM.
>
> I think I found the bug:
> pcnet-pci.c
> static int pci_pcnet_init(PCIDevice *pci_dev)
> {
> ...
>    if (!pci_dev->qdev.hotplugged) {
>        static int loaded = 0;
>        if (!loaded) {
>            rom_add_option("pxe-pcnet.rom", -1);
>            loaded = 1;
>        }
>    }
>
> Option rom is added unconditionally regardless of command line options due to 
> hot plug feature ...
>
> grep -ir rom_add_option .
> ./ne2000.c:            rom_add_option("pxe-ne2k_pci.rom", -1);
> NE2000 also has the same problem.
>
> RTL8139 and all others are done through romfile which are working correct:
> ./rtl8139.c:    .romfile    = "pxe-rtl8139.rom",

I finally submitted a patch for fixing the issue:
[PATCH] network: Added option to disable NIC option roms

Ciao,
Gerhard

--
http://www.wiesinger.com/
Kevin O'Connor Jan. 8, 2012, 2:58 p.m. UTC | #13
On Sun, Jan 08, 2012 at 10:31:05AM +0200, Gleb Natapov wrote:
> On Sat, Jan 07, 2012 at 11:28:44AM -0500, Kevin O'Connor wrote:
> > I downloaded 8xx_64.rom and tried the above command line.
> > Interestingly, it will register a BEV for a CD drive - which confirms
> > my suspicion that it wont use a BCV.  Also interesting is that if both
> > a harddrive and a CD are found, both a BEV and a BCV will be present -
> > SeaBIOS doesn't support this, but I don't see any reason it couldn't.
> > 
> Cool! What about non pnp roms that also register bcv? Should we use HD
> priority for those too?

A non-pnp rom can't register a BCV, but it can hook int13 (or hook
int19 or do a direct boot).  Right now, if a user selects a "legacy
option rom" from the boot menu, SeaBIOS will still prioritize HD
booting even if the rom doesn't hook int13.  It's an open question
whether that is the right thing to do.  In practice, though, there
aren't many legacy option roms, so it's probably not a big deal.  The
"vapic.bin" should probably be upgraded to use a PNP header just so it
doesn't show up in the boot menu.

-Kevin
Gleb Natapov Jan. 8, 2012, 3:17 p.m. UTC | #14
On Sun, Jan 08, 2012 at 09:58:53AM -0500, Kevin O'Connor wrote:
> On Sun, Jan 08, 2012 at 10:31:05AM +0200, Gleb Natapov wrote:
> > On Sat, Jan 07, 2012 at 11:28:44AM -0500, Kevin O'Connor wrote:
> > > I downloaded 8xx_64.rom and tried the above command line.
> > > Interestingly, it will register a BEV for a CD drive - which confirms
> > > my suspicion that it wont use a BCV.  Also interesting is that if both
> > > a harddrive and a CD are found, both a BEV and a BCV will be present -
> > > SeaBIOS doesn't support this, but I don't see any reason it couldn't.
> > > 
> > Cool! What about non pnp roms that also register bcv? Should we use HD
> > priority for those too?
> 
> A non-pnp rom can't register a BCV, but it can hook int13 (or hook
> int19 or do a direct boot).  Right now, if a user selects a "legacy
> option rom" from the boot menu, SeaBIOS will still prioritize HD
> booting even if the rom doesn't hook int13.  It's an open question
> whether that is the right thing to do.  In practice, though, there
> aren't many legacy option roms, so it's probably not a big deal.  The
> "vapic.bin" should probably be upgraded to use a PNP header just so it
> doesn't show up in the boot menu.
> 
I was talking about this code in optionroms.c:

        if (! pnp) {
            // Legacy rom.
            boot_add_bcv(FLATPTR_TO_SEG(rom), OPTION_ROM_INITVECTOR, 0
                         , getRomPriority(sources, rom, 0));
            continue;
        }

Isn't it register bcv for each non pnp option rom found? As far as I
understand this is done in order to postpone executing such rom until
it is absolutely clear that user wants to use it for booting. If
boot_add_bcv() will unconditionally give HD boot priority to such bcv it
will have higher priority than CD or pxe boot option, no?

Yes, we should fix vapic.bin to not show up in boot menu.

--
			Gleb.
Kevin O'Connor Jan. 8, 2012, 3:47 p.m. UTC | #15
On Sun, Jan 08, 2012 at 05:17:45PM +0200, Gleb Natapov wrote:
> On Sun, Jan 08, 2012 at 09:58:53AM -0500, Kevin O'Connor wrote:
> > On Sun, Jan 08, 2012 at 10:31:05AM +0200, Gleb Natapov wrote:
> > > Cool! What about non pnp roms that also register bcv? Should we use HD
> > > priority for those too?
> > 
> > A non-pnp rom can't register a BCV, but it can hook int13 (or hook
> > int19 or do a direct boot).  Right now, if a user selects a "legacy
> > option rom" from the boot menu, SeaBIOS will still prioritize HD
> > booting even if the rom doesn't hook int13.  It's an open question
> > whether that is the right thing to do.  In practice, though, there
> > aren't many legacy option roms, so it's probably not a big deal.  The
> > "vapic.bin" should probably be upgraded to use a PNP header just so it
> > doesn't show up in the boot menu.
> > 
> I was talking about this code in optionroms.c:
> 
>         if (! pnp) {
>             // Legacy rom.
>             boot_add_bcv(FLATPTR_TO_SEG(rom), OPTION_ROM_INITVECTOR, 0
>                          , getRomPriority(sources, rom, 0));
>             continue;
>         }
> 
> Isn't it register bcv for each non pnp option rom found?

Yes.

>As far as I
> understand this is done in order to postpone executing such rom until
> it is absolutely clear that user wants to use it for booting.

No - the option rom will always be executed.  The purpose of placing
it in the BCV list is to order its execution with respect to other
BCVs so that if the legacy option rom hooks int13 it will do so after
other drives have had a chance.

Should a legacy rom do direct boot or hook int19 it will take priority
over everything else - irrespective of seabios priorities or what the
user selects in the boot menu.  This lack of control is what spawned
the whole PNP rom stuff.

>If
> boot_add_bcv() will unconditionally give HD boot priority to such bcv it
> will have higher priority than CD or pxe boot option, no?

As above, the BCV priorities are only relevant when compared to the
priority of other BCVs.  So, no - it should have no impact on CD/PXE.

As I mentioned in my previous post, SeaBIOS does currently prioritizes
hard drive booting when the user selects "Legacy option rom" from the
boot menu - it's unclear if this is the right thing to do.

To be honest, this wasn't all that clear to me yesterday - I had to
think on it a bit.  This legacy boot stuff is crazy.

-Kevin
Gerd Hoffmann Jan. 9, 2012, 9:10 a.m. UTC | #16
Hi,

> I'm not sure what a SCSI rom would do with a CD drive.  My guess is
> that it wouldn't map it to a BIOS visible drive id at all, as there's
> no way to select an id with any assurance that it wont conflict with
> one chosen by the BIOS or another rom.  If QEMU can simulate this (and
> someone knows the command-line to do such) it would be an interesting
> test to see what the rom does.

The lsi rom (8xx_64.rom) seems to prioritize cdroms.  Maybe that is
something configurable in the option rom setup.  When a cdrom drive with
a bootable cd inserted is present the boot looks like this:

=======================================================================
SeaBIOS (version 0.6.1.2-20120105_124702-rincewind.home.kraxel.org)


iPXE v1.0.0-591-g7aee315
iPXE (http://ipxe.org) 00:03.0 CB00 PCI2.10 PnP PMM+1FFD9190+1FF99190 CB00



LSI Logic Corp. Symbios SDMS (TM) V4.0 PCI SCSI BIOS, PCI Rev. 2.0, 2.1
Copyright 1995-2001 LSI Logic Corp.
PCI-4.19.00

HBA ID LUN VENDOR   PRODUCT          REV  SYNC  WIDE  CYL/ HD/SEC
--- -- --- -------- ---------------- ---- ----- ---- ------------
 0   0  0  QEMU     QEMU HARDDISK    1.0.   NO    8  1024/255/63
 0   1  0  QEMU     QEMU HARDDISK    1.0.   NO    8  1008/ 33/63
 0   4  0  QEMU     QEMU CD-ROM      1.0.   NO    8
 0   7  0  LSILogic 53C895A          0000  10.0   8

LSI Logic Corp. PCI boot ROM successfully installed!
Press F12 for boot menu.

Select boot device:

1. #28 ID04 LUN0 QEMU     QEMU CD-ROM
2. USB Drive USB      Flash Disk       2.00
3. iPXE (PCI 00:03.0)
=======================================================================

whereas without bootable cd (drive still present but no disk inserted)
the boot menu looks like this:

=======================================================================
Select boot device:

1. #28 ID00 LUN0 QEMU     QEMU HARDDISK
2. USB Drive USB      Flash Disk       2.00
3. iPXE (PCI 00:03.0)
4. #28 ID01 LUN0 QEMU     QEMU HARDDISK
=======================================================================

cheers,
  Gerd
Gerhard Wiesinger Jan. 25, 2012, 8:30 p.m. UTC | #17
On Sun, 8 Jan 2012, Kevin O'Connor wrote:
> On Sun, Jan 08, 2012 at 05:17:45PM +0200, Gleb Natapov wrote:
> No - the option rom will always be executed.  The purpose of placing
> it in the BCV list is to order its execution with respect to other
> BCVs so that if the legacy option rom hooks int13 it will do so after
> other drives have had a chance.
>
> Should a legacy rom do direct boot or hook int19 it will take priority
> over everything else - irrespective of seabios priorities or what the
> user selects in the boot menu.  This lack of control is what spawned
> the whole PNP rom stuff.
>
>> If
>> boot_add_bcv() will unconditionally give HD boot priority to such bcv it
>> will have higher priority than CD or pxe boot option, no?
>
> As above, the BCV priorities are only relevant when compared to the
> priority of other BCVs.  So, no - it should have no impact on CD/PXE.
>
> As I mentioned in my previous post, SeaBIOS does currently prioritizes
> hard drive booting when the user selects "Legacy option rom" from the
> boot menu - it's unclear if this is the right thing to do.
>
> To be honest, this wasn't all that clear to me yesterday - I had to
> think on it a bit.  This legacy boot stuff is crazy.

Thanx for applying the patch/adding SCSI boot order feature to Seabios 
and supporting the LSI option ROM. (For the records: 
88e745e11242bbe13fa4f22093029ccf04087472 and
1e15725c92858a0cb1dd5c76bd44af1fec09fee3)

I think we have added even more compliance to QEMU/KVM and Seabios 
regarding option ROMs and SCSI boot order support.

Sometimes lateral thinking is necessary to achieve good results :-)

Ciao,
Gerhard

--
http://www.wiesinger.com/
diff mbox

Patch

--- a/src/boot.c
+++ b/src/boot.c
@@ -326,7 +326,7 @@  boot_add_bev(u16 seg, u16 bev, u16 desc, int prio)
 void
 boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio)
 {
-    bootentry_add(IPL_TYPE_BCV, defPrio(prio, DEFAULT_PRIO)
+    bootentry_add(IPL_TYPE_BCV, defPrio(prio, DefaultHDPrio)
                   , SEGOFF(seg, ip).segoff
                   , desc ? MAKE_FLATPTR(seg, desc) : "Legacy option rom");
 }