Hey Kevin,

On 20.01.26 18:07, Kevin O'Connor wrote:
On Fri, Jan 16, 2026 at 10:51:39AM +0000, Alexander Graf via SeaBIOS wrote:
Implement catch-all mechanism to handle invalid boot loaders that execute
random instructions and reach the VGA hole at 0xa0000, which would lead to
VM crashes with KVM_INTERNAL_ERROR.

When a BIOS boot loader gets corrupted, it can end up jumping across
address space and execute stray code. The typical symptom of that is
that it executes 0x0 (addw) instructions until the code reaches an MMIO
region, such as the VGA window. When running in KVM, attempting to
execute code from the MMIO window results in KVM_INTERNAL_ERROR exits
which crash the VM.

To prevent VM crashes before we reach such an MMIO window, introduce an
internal int 0xf0 handler and call it at strategic locations that should
never get executed in the first place. When we now have stray code
executing, these int calls cause an emergency print of "BIOS failed to
boot volume" and cleanly shut down the machine.
Unless I'm missing something, "int 0xf0" isn't a standard.  I don't
think it is a good idea to introduce seabios specific real-mode
software interrupt handlers.  We've avoiding doing this in the past,
because of the confusion it can cause.  (In short, we never know if
some old dos-era program has its own expectations about unusual int
handlers.)

Ralph Brown's interrupt list has this to say about 0xf0:

INT F0 - BASICA.COM, GWBASIC, compiled BASIC - ORIGINAL INT 08 VECTOR
Note:   BASICA.COM does not restore vector on termination
SeeAlso: INT EF"BASIC"

If there is a well defined standard "panic" interrupt handler then we
could use that.  Otherwise, it should also be fine to load code into
the ebda/lowmem areas that somehow panics without relying on a new
interrupt handler.


I don't think there is a well defined panic handler as interrupt. I just picked f0 at random because it seemed unused. I do understand your argument that someone else may end up using and and could be getting confused if there is something present.

However, I managed to work around all of the interrupt logic by just doing a long jump instead. As bonus, I also managed to get rid of the hand crafted opcodes and instead everything is at least assembly code now. Turned out much nicer anyway :)


Thanks!

Alex





Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
_______________________________________________
SeaBIOS mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to