git: ad4277c7250c - stable/12 - vt/vga: ignore ACPI_FADT_NO_VGA unless running virtualized

From: Roger Pau Monné <royger_at_FreeBSD.org>
Date: Wed, 23 Mar 2022 13:51:57 UTC
The branch stable/12 has been updated by royger:

URL: https://cgit.FreeBSD.org/src/commit/?id=ad4277c7250cc8d26b6acdbc2efa21cfe97c9b51

commit ad4277c7250cc8d26b6acdbc2efa21cfe97c9b51
Author:     Roger Pau Monné <royger@FreeBSD.org>
AuthorDate: 2022-02-24 15:53:30 +0000
Commit:     Roger Pau Monné <royger@FreeBSD.org>
CommitDate: 2022-03-23 13:50:33 +0000

    vt/vga: ignore ACPI_FADT_NO_VGA unless running virtualized
    
    There's too many broken hardware out there that wrongly has the
    ACPI_FADT_NO_VGA bit set. Ignore it unless running as a virtualized
    guest, as then the expectation would be that the hypervisor does
    provide correct ACPI tables.
    
    Reviewed by: emaste, 0mp, eugen
    Sponsored by: Citrix Systems R&D
    PR: 230172
    
    (cherry picked from commit 0518832011caba1e9dcee054d7884797ed8a74c2)
---
 share/man/man4/vt.4        | 5 ++++-
 sys/dev/vt/hw/vga/vt_vga.c | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4
index e057ca6e0351..9c8019925544 100644
--- a/share/man/man4/vt.4
+++ b/share/man/man4/vt.4
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 4, 2022
+.Dd March 17, 2022
 .Dt "VT" 4
 .Os
 .Sh NAME
@@ -204,6 +204,9 @@ graphics mode.
 Set to 1 to force the usage of the VGA driver regardless of whether
 ACPI IAPC_BOOT_ARCH signals no VGA support.
 Can be used to workaround firmware bugs in the ACPI tables.
+Note no VGA support is only acknowledged when running virtualized.
+There is too many broken firmware that wrongly reports no VGA support on
+physical hardware.
 .It Va kern.vty
 Set this value to
 .Ql vt
diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c
index bac8f3eb7b97..d457f8c7b31d 100644
--- a/sys/dev/vt/hw/vga/vt_vga.c
+++ b/sys/dev/vt/hw/vga/vt_vga.c
@@ -1261,7 +1261,11 @@ vga_acpi_disabled(void)
 	uint16_t flags;
 	int ignore;
 
-	ignore = 0;
+	/*
+	 * Ignore the flag on real hardware: there's a lot of buggy firmware
+	 * that will wrongly set it.
+	 */
+	ignore = (vm_guest == VM_GUEST_NO);
 	TUNABLE_INT_FETCH("hw.vga.acpi_ignore_no_vga", &ignore);
 	if (ignore || !acpi_get_fadt_bootflags(&flags))
  		return (false);