From nobody Wed Feb 4 03:47:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass(p=reject dis=none) header.from=seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1768560735; cv=none; d=zohomail.com; s=zohoarc; b=Vmwm/WsXF46pciz1wx9DWB989PsPAbfoatwvtxKnv6WQATE8dftTiu7fnOEhhBvjcttkSxbZGCl58gVJ0D29ZmFSZi8rZ+g+hUSsK/X17Ie2kkdtbhvf3ZiqpTxmHdWPGh0pQji6YAt+0qMU8ixrhLLnfy2TrevRTAyqi3JDcg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768560735; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=7kHtZDDt9/sbZMWTymGq7+nKFJWg4zPt2Z6Nhk1DVZs=; b=Gz/SxRjRslOZZIKmQF2/IVxyz4xSmkZuKTDb6xJ+VT5LXp3HBiic7m0/X8gGbl1Q7BHh5nnFLnUG5y7N4kDS8dAu0+N6KVxkakg7CLY8eOPNxkRSd73HxdoNHZnLuk1hlDryTl0sdfRazNLfEddkomEeyRwKZSiu4jvn8Cgxb9E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from coreboot.org (mail.coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1768560735183727.3252220999168; Fri, 16 Jan 2026 02:52:15 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id EB81781791; Fri, 16 Jan 2026 10:52:09 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com [44.246.1.125]) by coreboot.org (Postfix) with ESMTP id 364F781721 for ; Fri, 16 Jan 2026 10:51:51 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2026 10:51:42 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.14.244:2525] with esmtp (Farcaster) id 74f0092e-58ba-47a0-9341-e78a72a3cb88; Fri, 16 Jan 2026 10:51:42 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX19MTAUWA001.ant.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 16 Jan 2026 10:51:41 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX19D020UWC004.ant.amazon.com (10.13.138.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 16 Jan 2026 10:51:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seabios.org; s=dkim; t=1768560730; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:list-id:list-owner:list-unsubscribe:list-subscribe:list-post; bh=7kHtZDDt9/sbZMWTymGq7+nKFJWg4zPt2Z6Nhk1DVZs=; b=FuyxJTxzAhs488Fwd1uDJEAAleS1jOdNjbsN0694Q4cRRWnnmvjRAnf9d4p+aGUxsHD0ho Vad/kIpiXALCohqO/ECnU2lsRdrMj1racyL1EzTcXfy3QKfa85Nc5Xb3KhSnSU+lyCEpmD c6lz5bpEzOGPcdY0qOv5kzFRBRXHLXw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1768560711; x=1800096711; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ke/gKCPbFVyRHUq3PXBE4OLhPf8wdG0A/q3EIgd2RBA=; b=BKnezvduEcjQ/EkYkwjzNeB1WZT1RpVXXaaz82qU8eYt2U8a/eyc3a8P VZc9iYaOhWMzQfGlNHAjhv9o3YNJCnGvIeKKh096Nhs/4dh2hDEFt/CcO 4pO9w7p0oP6g3Gea/S7GMAk+XfLesG95qUBu5wIna0tITR1rbbUcdB9A6 EA/gq9NPCMCNyz+2ws7/CEpbUPTMdgPkqvNpzWKj5fWGsZ8YQwZ23wtYJ cmJc19UAvdqKZLtepDkO4mmloNRmf8Psbn6b0Wh4WNRRjauXFIlnB8+s0 VztbIpLeNIm1Sm2bsPqlN8hI4tTALHCRm/GfUr44UaGKeD+EobvAE6pqE Q==; X-CSE-ConnectionGUID: 3+3gyS2MQu2UTMgt5AlHXA== X-CSE-MsgGUID: aUbGdvyYQlikymx2d4CwFw== X-IronPort-AV: E=Sophos;i="6.21,230,1763424000"; d="scan'208";a="10988036" X-Farcaster-Flow-ID: 74f0092e-58ba-47a0-9341-e78a72a3cb88 To: Date: Fri, 16 Jan 2026 10:51:39 +0000 Message-ID: <20260116105139.39323-1-graf@amazon.com> MIME-Version: 1.0 X-ClientProxiedBy: EX19D046UWA003.ant.amazon.com (10.13.139.18) To EX19D020UWC004.ant.amazon.com (10.13.138.149) Message-ID-Hash: WD42E7RO3O4QJRORH7QQKZ4NUYKDXRVV X-Message-ID-Hash: WD42E7RO3O4QJRORH7QQKZ4NUYKDXRVV X-MailFrom: prvs=4692a63b9=graf@amazon.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Gerd Hoffmann , nh-open-source@amazon.com X-Mailman-Version: 3.3.11b1 Precedence: list Subject: [SeaBIOS] [PATCH v2] boot: Add boot failure catch-all handler to prevent VM crashes List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Alexander Graf via SeaBIOS Reply-To: Alexander Graf Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: pass (identity @seabios.org) X-ZM-MESSAGEID: 1768560736299158500 Content-Type: text/plain; charset="utf-8" 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. This is a nicer experience for users as it prints out why their system broke and in addition it avoids KVM_INTERNAL_ERROR calls when a virtual machine attempts to execute from MMIO because of a broken boot loader. Signed-off-by: Alexander Graf --- v1 -> v2: - Clarify error message - Move 32bit handler entry to similar other interrupt code --- src/boot.c | 36 ++++++++++++++++++++++++++++++++++++ src/post.c | 4 ++++ src/romlayout.S | 4 ++++ src/util.h | 1 + 4 files changed, 45 insertions(+) diff --git a/src/boot.c b/src/boot.c index 5c37dafd..fd8bdf01 100644 --- a/src/boot.c +++ b/src/boot.c @@ -1044,3 +1044,39 @@ handle_19(void) BootSequence =3D 0; do_boot(0); } + +// INT f0h Boot Failure Service Entry Point +void VISIBLE32FLAT +handle_f0(void) +{ + printf("\n\nBIOS failed to boot volume. The boot loader may be corrupt= ed.\n\n "); + + /* Try to shut down. Will busy loop on failure to shut down. */ + apm_shutdown(); +} + +static const u8 catchall[0x10] =3D { + 0xcd, // INT + 0xf0, // interrupt number 0xF0 + 0xeb, // JMP short + 0xfc, // -3 (jump back to INT) +}; + +static void +install_bootfail_catchall_one(u8 *catchall_addr) +{ + memcpy(catchall_addr, catchall, sizeof(catchall)); +} + +/* + * Install the catch-all code just before VGA hole at 0xa0000 and at the e= nd + * of the PMM zero region. + */ +void +install_bootfail_catchall(void) +{ + /* Install just before the VGA hole */ + install_bootfail_catchall_one((u8*)BUILD_LOWRAM_END - sizeof(catchall)= ); + /* and after the PMM zero region */ + install_bootfail_catchall_one((u8*)BUILD_EBDA_MINIMUM); +} diff --git a/src/post.c b/src/post.c index f93106a1..bdacbdb8 100644 --- a/src/post.c +++ b/src/post.c @@ -68,6 +68,9 @@ ivt_init(void) // set vector 0x79 to zero // this is used by 'gardian angel' protection system SET_IVT(0x79, SEGOFF(0, 0)); + + // Boot failure catch-all interrupt (INT 0xF0) + SET_IVT(0xf0, FUNC16(entry_f0)); } =20 static void @@ -115,6 +118,7 @@ interface_init(void) =20 // Other interfaces boot_init(); + install_bootfail_catchall(); bios32_init(); pmm_init(); pnp_init(); diff --git a/src/romlayout.S b/src/romlayout.S index c4a4635e..e8feae9c 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -580,6 +580,10 @@ entry_19: entry_18: ENTRY_INTO32 _cfunc32flat_handle_18 =20 + // int f0 is SeaBIOS specific and used to handle early boot breaka= ge +entry_f0: + ENTRY_INTO32 _cfunc32flat_handle_f0 + =20 /**************************************************************** * Fixed position entry points diff --git a/src/util.h b/src/util.h index aff8e888..3c5d075c 100644 --- a/src/util.h +++ b/src/util.h @@ -47,6 +47,7 @@ int boot_lchs_find_scsi_device(struct pci_device *pci, in= t target, int lun, struct chs_s *chs); int boot_lchs_find_ata_device(struct pci_device *pci, int chanid, int slav= e, struct chs_s *chs); +void install_bootfail_catchall(void); =20 // bootsplash.c void enable_vga_console(void); --=20 2.47.1 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 -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org