[SeaBIOS] [PATCH] fix two issues with virtio-blk

Sebastian Herbszt herbszt at gmx.de
Sun May 16 14:59:19 CEST 2010


Kevin O'Connor wrote:
> On Sat, May 15, 2010 at 10:08:54PM +0200, Sebastian Herbszt wrote:
>> Kevin O'Connor wrote:
>> >On Sat, May 15, 2010 at 05:17:31PM +0200, Sebastian Herbszt wrote:
>> >>Doing a read emulation
>> >>in BIOS shouldn't be too bad, but a write emulation will need a "physical
>> >>sector size" RMW buffer (no clue where the BIOS could steal those 4KB from).
>> >SeaBIOS has a "malloc_low" function which obtains permanent memory in
>> >the first 1Meg.  Currently, it grabs memory at the end of 640K (it
>> >moves the ebda down if needed).  It's probably possible to use memory
>> >in the c/d/e/f segments - though that's tricky because parts of that
>> >area are likely to be read-only.
>> >
>> >Right now SeaBIOS allocates a 2K buffer to support cdrom emulation
>> >(this is different from what bochs bios does).  So, going to a 4K
>> >buffer is probably reasonable.
>> This explains why i see 2 KB less free memory with SeaBIOS.
>> With current SeaBIOS i get 511 KB free memory running MS-DOS 6.22
>> with CDROM support. Sure you can grab another 4 KB for a RMW buffer,
> 
> It's only 2KB more - the buffer could be shared.

Even if you want to be able to copy from CDROM emulation to a disk with 4 KB
physical sectors? I assume you need 2 KB for CDROM emulation and 4 KB for RMW.

>> but sooner or later there won't be enough memory free to play your favorite
>> game from the 90s. And i didn't even load an option ROM which also wants
>> 1-2 KB EBDA or some useful TSR program.
>> 
>> Why is a 4 KB physical sector size needed in a VM anyway?
> 
> It isn't - I was just describing where one could get the memory.  I'm
> not planning on implementing this.
> 
> There may come a point where drives require a bigger sector size.
> (SeaBIOS can also run on real hardware.)  In that case, it may be
> necessary to add support - after all, one can't run old games if their
> computer doesn't boot.  However, I think we can cross that bridge when
> we get to it.
> 
> -Kevin

Even if drives use a bigger physical sector size they can still use a logical sector
size of 512 bytes. This is what those drives with the Advanced Format Technology
do. The drive does the emulation/RMW and the BIOS gets its 512 byte logical sectors
and nothing changes for the software.

I assume the drive manufacturers and BIOS vendors will fix this if the emulation is
a real problem. Maybe a new ATA command can be introduced to ask the drive to
use a larger logical sector size. This way all drives could start up in compatibility
mode with emulation enabled. All legacy applications (BIOS, option ROMS, boot
loaders) will still work and if some advanced OS can use larger logical sectors it
could ask the drive to deliver those.

Sebastian




More information about the SeaBIOS mailing list