diff mbox series

[XEN,v1,3/3] x86/hvm: make ACPI PM & stdvga emulation optional

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

Commit Message

Sergiy Kibrik Oct. 4, 2024, 9:35 a.m. UTC
Make it possible to build a configuration without code for PM timer or stdvga
drivers. This may help to reduce code's footprint a bit for systems that don't
run HVM guests and also don't need these devices emulated.

Introduced additional check of domain's emulation flags, to cover the case
when user explicitly states the requirement of emulated devices that are
disabled in the build. HVM always require these devices to be present so domains
of this type can't be created when stdvga or pmtimer are disabled.

Options X86_STDVGA & X86_PMTIMER are dependant on HVM option, because these
drivers are part of HVM support code.

Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
---
 xen/arch/x86/Kconfig  | 21 +++++++++++++++++++--
 xen/arch/x86/domain.c |  6 ++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

Comments

Jan Beulich Oct. 4, 2024, 1:36 p.m. UTC | #1
On 04.10.2024 11:35, Sergiy Kibrik wrote:
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -742,11 +742,17 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
>  
>  static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
>  {
> +    const uint32_t disabled_emu_mask =
> +        (IS_ENABLED(CONFIG_X86_PMTIMER) ? 0 : X86_EMU_PM) |
> +        (IS_ENABLED(CONFIG_X86_STDVGA)  ? 0 : X86_EMU_VGA);
>  #ifdef CONFIG_HVM
>      /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
>      BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);

Nit: Blank line between declaration(s) and statement(s) please.

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 89c42ff6da..05551bd722 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -144,11 +144,28 @@  config INTEL_VMX
 	  If your system includes a processor with Intel VT-x support, say Y.
 	  If in doubt, say Y.
 
+menu "Emulated devices support"
+	visible if EXPERT
+	depends on HVM
+
 config X86_PMTIMER
-	def_bool HVM
+	bool "ACPI PM timer emulation support"
+	default y
+	help
+	  Build pmtimer driver that emulates ACPI PM timer for HVM/PVH guests.
+
+	  If unsure, say Y.
 
 config X86_STDVGA
-	def_bool HVM
+	bool "Standard VGA card emulation support"
+	default y
+	help
+	  Build stdvga driver that emulates standard VGA card with VESA BIOS
+	  Extensions for HVM/PVH guests.
+
+	  If unsure, say Y.
+
+endmenu
 
 config XEN_SHSTK
 	bool "Supervisor Shadow Stacks"
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 89aad7e897..32dd3f84cd 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -742,11 +742,17 @@  int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
 
 static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
 {
+    const uint32_t disabled_emu_mask =
+        (IS_ENABLED(CONFIG_X86_PMTIMER) ? 0 : X86_EMU_PM) |
+        (IS_ENABLED(CONFIG_X86_STDVGA)  ? 0 : X86_EMU_VGA);
 #ifdef CONFIG_HVM
     /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
     BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
 #endif
 
+    if ( emflags & disabled_emu_mask )
+        return false;
+
     if ( is_hvm_domain(d) )
     {
         if ( is_hardware_domain(d) &&