From nobody Fri Apr 26 12:03:36 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558417317; cv=none; d=zoho.com; s=zohoarc; b=T25LCthDm7RmtUDUuXQV6E5SalIEFyKTrtW4XZksy5bYR2HmKe9WGNtztOFg2JxljhgKjIFfLVdzjVPWcX96qq56TKwz+JGzJpQWfll2A3TNnDJeKTQsyCj7VmPuf0V6e9IOg4gGzeddoLrbiJIpzVh3ehiin9ynKEDHS0dUmDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558417317; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Subject:To:ARC-Authentication-Results; bh=uDo4CGa9i7fzM8+Xon4FRe+toDV95UPj0i24OxvamRc=; b=HASeh6rSsvB4SKpAqvequ+uG50maCRUJ2nY7IVMAsmzbUIl9N9aLeTu6RRyl3sZ01IEy1bddf3yqTF8rahH9iNcohMgsGQR+lvzSKH+QEdwhRjHpGPB2K+Apn0K2ovLy17G+ie1qQaJe4f7ZsJrNaGIexwvgTjnPPMLaIiXUNuw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1558417317890986.3095649301385; Mon, 20 May 2019 22:41:57 -0700 (PDT) Received: from [192.168.203.99] (mailu_mailman-core_1.mailu_default [192.168.203.99]) by coreboot.org (Postfix) with ESMTP id A4B9812E2E88; Tue, 21 May 2019 05:41:52 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by coreboot.org (Postfix) with ESMTP id 6F2D412E2E86 for ; Tue, 21 May 2019 05:41:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB8D1F74A6; Tue, 21 May 2019 05:41:41 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-74.ams2.redhat.com [10.36.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B8BB1001DE7; Tue, 21 May 2019 05:41:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5A9931747B; Tue, 21 May 2019 07:41:38 +0200 (CEST) From: Gerd Hoffmann To: seabios@seabios.org Date: Tue, 21 May 2019 07:41:33 +0200 Message-Id: <20190521054133.21986-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 21 May 2019 05:41:42 +0000 (UTC) Message-ID-Hash: F3KAZJHE7AW7KKWL7BV5ALWJZLB3KU67 X-Message-ID-Hash: F3KAZJHE7AW7KKWL7BV5ALWJZLB3KU67 X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.2.2 Precedence: list Subject: [SeaBIOS] [PATCH v3] optionrom: disallow int19 redirect for pnp roms. List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org Content-Type: text/plain; charset="utf-8" Check whenever pnp roms attempt to redirect int19, and in case it does log a message and undo the redirect. A pnp rom should not need this, we have BEVs and BCVs for that. Nevertheless there are roms in the wild which are redirecting int19. At least some BIOS implementations for physical hardware have a config option in the setup to allow/disallow int19 redirections, so just not allowing this seems to be the way to deal with this situation. Buglink: https://bugzilla.redhat.com//show_bug.cgi?id=3D1642135 Signed-off-by: Gerd Hoffmann --- src/optionroms.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/optionroms.c b/src/optionroms.c index fc992f649fe1..e906ab97f433 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -8,6 +8,7 @@ #include "bregs.h" // struct bregs #include "config.h" // CONFIG_* #include "farptr.h" // FLATPTR_TO_SEG +#include "biosvar.h" // GET_IVT #include "hw/pci.h" // pci_config_readl #include "hw/pcidevice.h" // foreachpci #include "hw/pci_ids.h" // PCI_CLASS_DISPLAY_VGA @@ -308,6 +309,19 @@ fail: return NULL; } =20 +static int boot_irq_captured(void) +{ + return GET_IVT(0x19).segoff !=3D FUNC16(entry_19_official).segoff; +} + +static void boot_irq_restore(void) +{ + struct segoff_s seabios; + + seabios =3D FUNC16(entry_19_official); + SET_IVT(0x19, seabios); +} + // Attempt to map and initialize the option rom on a given PCI device. static void init_pcirom(struct pci_device *pci, int isvga, u64 *sources) @@ -327,8 +341,18 @@ init_pcirom(struct pci_device *pci, int isvga, u64 *so= urces) if (! rom) // No ROM present. return; + int irq_was_captured =3D boot_irq_captured(); + struct pnp_data *pnp =3D get_pnp_rom(rom); setRomSource(sources, rom, RS_PCIROM | (u32)pci); init_optionrom(rom, pci->bdf, isvga); + if (boot_irq_captured() && !irq_was_captured && + !file && !isvga && pnp) { + // This PCI rom is misbehaving - recapture the boot irqs + char *desc =3D MAKE_FLATPTR(FLATPTR_TO_SEG(rom), pnp->productname); + dprintf(1, "PnP optionrom \"%s\" (bdf %pP) captured int19, restori= ng\n", + desc, pci); + boot_irq_restore(); + } } =20 =20 --=20 2.18.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org