diff mbox series

[XEN,v3,2/2] x86/hvm: introduce config option for stdvga emulation

Message ID b4163fe8957506d38294ba511c063c706cc1ac85.1731961652.git.Sergiy_Kibrik@epam.com (mailing list archive)
State New
Headers show
Series configurable stdvga & pmtimer emulation | expand

Commit Message

Sergiy Kibrik Nov. 18, 2024, 8:38 p.m. UTC
Introduce config option X86_HVM_STDVGA and make stdvga emulation driver
configurable so it can be disabled on systems that don't need it.

Suggested-by: Roger Pau Monné <roger.pau@citrix.com> # approach
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
CC: Jan Beulich <jbeulich@suse.com>
---
changes in v3:
 - changed config option's description
 - add build-time checks of X86_EMU_VGA vs XEN_X86_EMU_VGA
 - tags
changes in v2:
 - updated description
 - renamed config option X86_STDVGA -> X86_HVM_STDVGA & moved related
   Kconfig changes to this patch
 - reverted changes to has_vvga() macro
 - moved emulation_flags_ok() checks to this patch
---
 xen/arch/x86/Kconfig              | 10 ++++++++++
 xen/arch/x86/domain.c             |  7 +++++--
 xen/arch/x86/hvm/Makefile         |  2 +-
 xen/arch/x86/include/asm/domain.h |  8 ++++++--
 xen/arch/x86/include/asm/hvm/io.h |  4 ++++
 5 files changed, 26 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index d8f108a3ca..e2ba257fb3 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -155,6 +155,16 @@  config X86_HVM_PMTIMER
 	  Build driver that emulates ACPI PM timer for HVM guests.
 
 	  If unsure, say Y.
+
+config X86_HVM_STDVGA
+	bool "Standard VGA card emulation support"
+	default y
+	help
+	  Build driver that emulates standard VGA card with VESA BIOS
+	  Extensions for HVM guests.
+
+	  If unsure, say Y.
+
 endmenu
 
 config XEN_SHSTK
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index d867b4f046..e01759e2e5 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -744,12 +744,15 @@  static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
 {
 #ifdef CONFIG_HVM
     /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
-    BUILD_BUG_ON((X86_EMU_ALL & ~X86_EMU_PM) !=
-                 (XEN_X86_EMU_ALL & ~XEN_X86_EMU_PM));
+    BUILD_BUG_ON((X86_EMU_ALL & ~(X86_EMU_PM | X86_EMU_VGA)) !=
+                 (XEN_X86_EMU_ALL & ~(XEN_X86_EMU_PM | XEN_X86_EMU_VGA)));
 #endif
 #ifdef CONFIG_X86_HVM_PMTIMER
        BUILD_BUG_ON(X86_EMU_PM != XEN_X86_EMU_PM);
 #endif
+#ifdef CONFIG_X86_HVM_STDVGA
+       BUILD_BUG_ON(X86_EMU_VGA != XEN_X86_EMU_VGA);
+#endif
 
     /* emflags contain non-supported bits */
     if ( (emflags & X86_EMU_ALL) != emflags )
diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile
index 3af8963218..80ec425aa8 100644
--- a/xen/arch/x86/hvm/Makefile
+++ b/xen/arch/x86/hvm/Makefile
@@ -22,7 +22,7 @@  obj-$(CONFIG_X86_HVM_PMTIMER) += pmtimer.o
 obj-y += quirks.o
 obj-y += rtc.o
 obj-y += save.o
-obj-y += stdvga.o
+obj-$(CONFIG_X86_HVM_STDVGA) += stdvga.o
 obj-y += vioapic.o
 obj-y += vlapic.o
 obj-y += vm_event.o
diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
index 8550473997..106b438779 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -466,7 +466,6 @@  struct arch_domain
 #define X86_EMU_RTC      XEN_X86_EMU_RTC
 #define X86_EMU_IOAPIC   XEN_X86_EMU_IOAPIC
 #define X86_EMU_PIC      XEN_X86_EMU_PIC
-#define X86_EMU_VGA      XEN_X86_EMU_VGA
 #define X86_EMU_IOMMU    XEN_X86_EMU_IOMMU
 #define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ
 #define X86_EMU_VPCI     XEN_X86_EMU_VPCI
@@ -476,7 +475,6 @@  struct arch_domain
 #define X86_EMU_RTC      0
 #define X86_EMU_IOAPIC   0
 #define X86_EMU_PIC      0
-#define X86_EMU_VGA      0
 #define X86_EMU_IOMMU    0
 #define X86_EMU_USE_PIRQ 0
 #define X86_EMU_VPCI     0
@@ -488,6 +486,12 @@  struct arch_domain
 #define X86_EMU_PM       0
 #endif
 
+#ifdef CONFIG_X86_HVM_STDVGA
+#define X86_EMU_VGA      XEN_X86_EMU_VGA
+#else
+#define X86_EMU_VGA      0
+#endif
+
 #define X86_EMU_PIT     XEN_X86_EMU_PIT
 
 /* This must match XEN_X86_EMU_ALL in xen.h */
diff --git a/xen/arch/x86/include/asm/hvm/io.h b/xen/arch/x86/include/asm/hvm/io.h
index f2b8431fac..c02fad876c 100644
--- a/xen/arch/x86/include/asm/hvm/io.h
+++ b/xen/arch/x86/include/asm/hvm/io.h
@@ -108,7 +108,11 @@  struct vpci_arch_msix_entry {
     int pirq;
 };
 
+#ifdef CONFIG_X86_HVM_STDVGA
 void stdvga_init(struct domain *d);
+#else
+static inline void stdvga_init(struct domain *d) {}
+#endif
 
 extern void hvm_dpci_msi_eoi(struct domain *d, int vector);