On Thu, Jun 14, 2012 at 10:12:23AM +0200, Kevin Wolf wrote:
Am 14.06.2012 02:52, schrieb Kevin O'Connor:
On Wed, Jun 13, 2012 at 04:51:04PM +0300, Gleb
I noticed that SeaBIOS fails to boot from virtio
disk smaller than 512K.
The attempt to access a disk fails at basic_access().
(cylinder >= nlc || head >= nlh || sector > nlspt) is true because nlc
is zero. The problem seams to be in how SeaBIOS calculates lchs from
pchs in get_translation(). Both QEMU and SeaBIOS fake disk geometry from
real disk size, but it seams that they do it differently and when they
disagree part of the disk may not be readable.
The LBA translation code comes from the original Bochs BIOS code.
Looking at this now, I think it's not rounding properly and thus
causing some sectors to get truncated.
This is probably the crucial point: What is "proper" rounding in this
context? Leaving aside the choice of concrete CHS values, you'll always
have to choose whether to round up or round down.
If you round down (which happens today in SeaBIOS and in most cases in
qemu), you make part of the image inaccessible. Usually only a problem
when you have something in /boot very close to the end of the image and
the bootloader can't read it. It gets problematic with small images
where everything is close to the end, and in Gleb's extreme case even
the MBR isn't accessible any more.
Agreed. Not a great choice.
If you round up (which qemu does in this case as for
some unknown reason
it always assumes a minimum of 2 cylinders), you pretend that the disk
is larger than the image really is and part of the virtual disk only
produces read/write errors. This is the only alternative implementation
I can see, and it's not a clear winner for me.
Maybe there is wisdom in setting a minimum of 2 cylinders. That way
the really tiny disks are still functional.