Skip to contentSkip to conversation

configurable stdvga & pmtimer emulation

PATCH Superseded Sergiy Kibrik 3 participants 12 messages Nov 6, 2024 – Nov 15, 2024

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover configurable stdvga & pmtimer emulation

Introduce build options for stdvga and ACPI PM timer emulation drivers to make them configurable with possibility to be disabled for finer-tuned setups that don't need this code.

New config options reside in separate sub-menu, checks of emulation flags are added so that domain can't be created if it requires devices that had been disabled.
Since previous series one patch merged into 2 others and review comments have been addressed (details are in per-patch changelogs).

v1 series here:
https://lore.kernel.org/xen-devel/[email protected]/

-Sergiy

Sergiy Kibrik (2):
x86/hvm: introduce config option for ACPI PM timer x86/hvm: introduce config option for stdvga emulation

 xen/arch/x86/Kconfig                  | 23 +++++++++++++++++++++++
 xen/arch/x86/domain.c                 |  7 ++++++-
 xen/arch/x86/hvm/Makefile             |  4 ++--
 xen/arch/x86/include/asm/acpi.h       |  5 +++++
 xen/arch/x86/include/asm/domain.h     | 16 ++++++++++++----
 xen/arch/x86/include/asm/hvm/domain.h |  2 ++
 xen/arch/x86/include/asm/hvm/io.h     |  4 ++++
 xen/arch/x86/include/asm/hvm/vpt.h    | 10 ++++++++++
 8 files changed, 64 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/2 x86/hvm: introduce config option for ACPI PM timer

Introduce config option X86_HVM_PMTIMER and make pmtimer emulation driver configurable and possible to disable on systems that don't need it. Option X86_X86_HVM_PMTIMER depends on HVM option, because this driver is part of HVM support code.

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 pmtimer or any other emulated device are disabled.

---
changes in v2:
- updated description
- renamed config option X86_PMTIMER -> X86_HVM_PMTIMER & moved related Kconfig changes to this patch
- define X86_EMU_PM to 0 when !X86_HVM_PMTIMER
- reverted changes to has_vpm() macro
- moved emulation_flags_ok() checks to this patch
- guard struct hvm_hw_acpi acpi attribute of struct domain

---
 xen/arch/x86/Kconfig                  | 13 +++++++++++++
 xen/arch/x86/domain.c                 |  7 ++++++-
 xen/arch/x86/hvm/Makefile             |  2 +-
 xen/arch/x86/include/asm/acpi.h       |  5 +++++
 xen/arch/x86/include/asm/domain.h     |  8 ++++++--
 xen/arch/x86/include/asm/hvm/domain.h |  2 ++
 xen/arch/x86/include/asm/hvm/vpt.h    | 10 ++++++++++
 7 files changed, 43 insertions(+), 4 deletions(-)
xen/arch/x86/Kconfig +13 -0
index 9cdd04721a..ed0ece85c7 100644
@@ -144,6 +144,19 @@ config INTEL_VMX
 	  If your system includes a processor with Intel VT-x support, say Y.
 	  If in doubt, say Y.
 
+menu "Emulated HVM devices support"
+       visible if EXPERT
+       depends on HVM
+
+config X86_HVM_PMTIMER
+	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.
+endmenu
+
 config XEN_SHSTK
 	bool "Supervisor Shadow Stacks"
 	depends on HAS_AS_CET_SS
xen/arch/x86/domain.c +6 -1
index 78a13e6812..b340818ee2 100644
@@ -742,11 +742,16 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
 
 static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
 {
-#ifdef CONFIG_HVM
+    const uint32_t disabled_emu_mask = X86_EMU_PM;
+
+#if defined(CONFIG_X86_HVM_PMTIMER)
     /* 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) &&
xen/arch/x86/hvm/Makefile +1 -1
index 4c1fa5c6c2..3af8963218 100644
@@ -18,7 +18,7 @@ obj-y += irq.o
 obj-y += monitor.o
 obj-y += mtrr.o
 obj-y += nestedhvm.o
-obj-y += pmtimer.o
+obj-$(CONFIG_X86_HVM_PMTIMER) += pmtimer.o
 obj-y += quirks.o
 obj-y += rtc.o
 obj-y += save.o
xen/arch/x86/include/asm/acpi.h +5 -0
index 217819dd61..eb2e4a1ede 100644
@@ -150,8 +150,13 @@ void acpi_mmcfg_init(void);
 /* Incremented whenever we transition through S3. Value is 1 during boot. */
 extern uint32_t system_reset_counter;
 
+#ifdef CONFIG_X86_HVM_PMTIMER
 void hvm_acpi_power_button(struct domain *d);
 void hvm_acpi_sleep_button(struct domain *d);
+#else
+static inline void hvm_acpi_power_button(struct domain *d) {}
+static inline void hvm_acpi_sleep_button(struct domain *d) {}
+#endif
 
 /* suspend/resume */
 void save_rest_processor_state(void);
xen/arch/x86/include/asm/domain.h +6 -2
index b79d6badd7..8550473997 100644
@@ -463,7 +463,6 @@ struct arch_domain
 #ifdef CONFIG_HVM
 #define X86_EMU_LAPIC    XEN_X86_EMU_LAPIC
 #define X86_EMU_HPET     XEN_X86_EMU_HPET
-#define X86_EMU_PM       XEN_X86_EMU_PM
 #define X86_EMU_RTC      XEN_X86_EMU_RTC
 #define X86_EMU_IOAPIC   XEN_X86_EMU_IOAPIC
 #define X86_EMU_PIC      XEN_X86_EMU_PIC
@@ -474,7 +473,6 @@ struct arch_domain
 #else
 #define X86_EMU_LAPIC    0
 #define X86_EMU_HPET     0
-#define X86_EMU_PM       0
 #define X86_EMU_RTC      0
 #define X86_EMU_IOAPIC   0
 #define X86_EMU_PIC      0
@@ -484,6 +482,12 @@ struct arch_domain
 #define X86_EMU_VPCI     0
 #endif
 
+#ifdef CONFIG_X86_HVM_PMTIMER
+#define X86_EMU_PM       XEN_X86_EMU_PM
+#else
+#define X86_EMU_PM       0
+#endif
+
 #define X86_EMU_PIT     XEN_X86_EMU_PIT
 
 /* This must match XEN_X86_EMU_ALL in xen.h */
xen/arch/x86/include/asm/hvm/domain.h +2 -0
index 333501d5f2..a4fddf7754 100644
@@ -80,8 +80,10 @@ struct hvm_domain {
      * in public header files.
      * Internally, however, we will be using hvm_hw_acpi.
      */
+#ifdef CONFIG_X86_HVM_PMTIMER
 #define hvm_hw_acpi hvm_hw_pmtimer
     struct hvm_hw_acpi     acpi;
+#endif
 
     /* VCPU which is current target for 8259 interrupts. */
     struct vcpu           *i8259_target;
xen/arch/x86/include/asm/hvm/vpt.h +10 -0
index 0b92b28625..f24ef08925 100644
@@ -187,10 +187,20 @@ void rtc_deinit(struct domain *d);
 void rtc_reset(struct domain *d);
 void rtc_update_clock(struct domain *d);
 
+#ifdef CONFIG_X86_HVM_PMTIMER
 void pmtimer_init(struct vcpu *v);
 void pmtimer_deinit(struct domain *d);
 void pmtimer_reset(struct domain *d);
 int pmtimer_change_ioport(struct domain *d, uint64_t version);
+#else
+static inline void pmtimer_init(struct vcpu *v) {}
+static inline void pmtimer_deinit(struct domain *d) {}
+static inline void pmtimer_reset(struct domain *d) {}
+static inline int pmtimer_change_ioport(struct domain *d, uint64_t version)
+{
+    return -ENODEV;
+}
+#endif
 
 void hpet_init(struct domain *d);
 void hpet_deinit(struct domain *d);
Signature · 1 line
2.25.1
#2 lore raw

Re: [XEN PATCH v2 1/2] x86/hvm: introduce config option for ACPI PM timer

06.11.24 12:14, Sergiy Kibrik:

Quoted 9 lines
xen/arch/x86/domain.c +0 -1
index 78a13e6812..b340818ee2 100644
@@ -742,11 +742,16 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
 
  static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
  {
-#ifdef CONFIG_HVM

xen/arch/x86/domain.c int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) · line 754

Quoted 10 lines
xen/arch/x86/domain.c +6 -0
+    const uint32_t disabled_emu_mask = X86_EMU_PM;
+
+#if defined(CONFIG_X86_HVM_PMTIMER)
      /* 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;
+

oops, disregard this chunk please, it should be:

if ( (emflags & X86_EMU_ALL) != emflags )

     return false;

with disabled_emu_mask completely removed.

xen/arch/x86/domain.c int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) · line 757

Quoted 3 lines
xen/arch/x86/domain.c +0 -0
      if ( is_hvm_domain(d) )
      {
          if ( is_hardware_domain(d) &&

-Sergiy

Reviewed-by
#3 lore raw

Re: [XEN PATCH v2 1/2] x86/hvm: introduce config option for ACPI PM timer

Quoted 23 lines · Sergiy Kibrik

06.11.24 12:14, Sergiy Kibrik:

Quoted 9 lines
xen/arch/x86/domain.c +0 -1
index 78a13e6812..b340818ee2 100644
@@ -742,11 +742,16 @@ int arch_sanitise_domain_config(struct
 xen_domctl_createdomain *config)
    static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
  {
-#ifdef CONFIG_HVM

xen/arch/x86/domain.c int arch_sanitise_domain_config(struct · line 754

Quoted 10 lines
xen/arch/x86/domain.c +5 -0
+    const uint32_t disabled_emu_mask = X86_EMU_PM;
+
+#if defined(CONFIG_X86_HVM_PMTIMER)
      /* 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;
+

oops, disregard this chunk please, it should be:

Quoted 4 lines

if ( (emflags & X86_EMU_ALL) != emflags )

     return false;

with disabled_emu_mask completely removed.

With this change:

#4 lore raw

Re: [XEN PATCH v2 1/2] x86/hvm: introduce config option for ACPI PM timer

In reply to Sergiy Kibrik
Quoted 5 lines · Sergiy Kibrik

Introduce config option X86_HVM_PMTIMER and make pmtimer emulation driver configurable and possible to disable on systems that don't need it. Option X86_X86_HVM_PMTIMER depends on HVM option, because this driver is part of HVM support code.

Quoted 7 lines

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 pmtimer or any other emulated device are disabled.

What exactly was it that Roger suggested? I don't think it was what the patch does overall, but just _how_ it is being done? That makes quite a bit of a difference, as the former could be read as kind of an implicit ack to what is being done here (and also in the other patch). Issue is: I remain unconvinced that this conditionalizing is actually something we really want/need.

Quoted 5 lines
xen/arch/x86/Kconfig +0 -0
@@ -144,6 +144,19 @@ config INTEL_VMX
 	  If your system includes a processor with Intel VT-x support, say Y.
 	  If in doubt, say Y.

xen/arch/x86/Kconfig config INTEL_VMX · line 155

Quoted 10 lines
xen/arch/x86/Kconfig +9 -0
 
+menu "Emulated HVM devices support"
+       visible if EXPERT
+       depends on HVM
+
+config X86_HVM_PMTIMER
+	bool "ACPI PM timer emulation support"
+	default y
+	help
+	  Build pmtimer driver that emulates ACPI PM timer for HVM/PVH guests.

Does this really affect PVH guests? Isn't the whole point of the change that in a PVH-only environment this wouldn't be needed in Xen?

I wonder how meaningful "pmtimer" is to someone reading this help test in isolation. I'd just drop the word.

Quoted 10 lines
xen/arch/x86/domain.c +3 -1
@@ -742,11 +742,16 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
 
 static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
 {
-#ifdef CONFIG_HVM
+    const uint32_t disabled_emu_mask = X86_EMU_PM;
+
+#if defined(CONFIG_X86_HVM_PMTIMER)

xen/arch/x86/domain.c int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) · line 757

Quoted 10 lines
xen/arch/x86/domain.c +3 -0
     /* 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) &&

While you commented on this hunk, it didn't become clear what exactly the resulting new hunk would be. I question in particular the change to the #ifdef: If that's changed and the BUILD_BUG_ON() kept as is, the comment also needs adjusting. Yet it would perhaps be better of the BUILD_BUG_ON() was split accordingly.

Jan

#5 lore raw

Re: [XEN PATCH v2 1/2] x86/hvm: introduce config option for ACPI PM timer

11.11.24 11:51, Jan Beulich:

Quoted 12 lines · Sergiy Kibrik
Quoted 11 lines

Introduce config option X86_HVM_PMTIMER and make pmtimer emulation driver configurable and possible to disable on systems that don't need it. Option X86_X86_HVM_PMTIMER depends on HVM option, because this driver is part of HVM support code.

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 pmtimer or any other emulated device are disabled.

Quoted 7 lines
Quoted 1 line

What exactly was it that Roger suggested? I don't think it was what the patch does overall, but just _how_ it is being done? That makes quite a bit of a difference, as the former could be read as kind of an implicit ack to what is being done here (and also in the other patch). Issue is: I remain unconvinced that this conditionalizing is actually something we really want/need.

about a half of this patch is what Roger suggested. These changes were in a separate patch, which Roger suggested to be merged into other patches. What tag should be put in this case then?

Quoted 6 lines
Quoted 6 lines
xen/arch/x86/Kconfig +0 -0
@@ -144,6 +144,19 @@ config INTEL_VMX
  	  If your system includes a processor with Intel VT-x support, say Y.
  	  If in doubt, say Y.
 
Quoted 12 lines

xen/arch/x86/Kconfig config INTEL_VMX · line 155

Quoted 9 lines
xen/arch/x86/Kconfig +9 -0
+menu "Emulated HVM devices support"
+       visible if EXPERT
+       depends on HVM
+
+config X86_HVM_PMTIMER
+	bool "ACPI PM timer emulation support"
+	default y
+	help
+	  Build pmtimer driver that emulates ACPI PM timer for HVM/PVH guests.

Does this really affect PVH guests? Isn't the whole point of the change that in a PVH-only environment this wouldn't be needed in Xen?

PVH guest may (depending on its configuration) still use PM timer, so I'd say the point is in a PVH-only environment this driver becomes optional.

Quoted 2 lines

I wonder how meaningful "pmtimer" is to someone reading this help test in isolation. I'd just drop the word.

sure, the word is rarely mentioned anywhere, I'll remove it.

Quoted 15 lines
Quoted 15 lines
xen/arch/x86/domain.c +3 -1
@@ -742,11 +742,16 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
 
  static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
  {
-#ifdef CONFIG_HVM
+    const uint32_t disabled_emu_mask = X86_EMU_PM;
+
+#if defined(CONFIG_X86_HVM_PMTIMER)
      /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
      BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
  #endif
 
Quoted 13 lines

xen/arch/x86/domain.c int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) · line 757

Quoted 6 lines
xen/arch/x86/domain.c +3 -0
+    if ( emflags & disabled_emu_mask )
+        return false;
+
      if ( is_hvm_domain(d) )
      {
          if ( is_hardware_domain(d) &&

While you commented on this hunk, it didn't become clear what exactly the resulting new hunk would be. I question in particular the change to the #ifdef: If that's changed and the BUILD_BUG_ON() kept as is, the comment also needs adjusting. Yet it would perhaps be better of the BUILD_BUG_ON() was split accordingly.

This #ifdef definitely wants nicer change. How would you suggest BUILD_BUG_ON() be split?

-Sergiy

#6 lore raw

Re: [XEN PATCH v2 1/2] x86/hvm: introduce config option for ACPI PM timer

Quoted 21 lines · Sergiy Kibrik

11.11.24 11:51, Jan Beulich:

Quoted 12 lines · Sergiy Kibrik
Quoted 11 lines

Introduce config option X86_HVM_PMTIMER and make pmtimer emulation driver configurable and possible to disable on systems that don't need it. Option X86_X86_HVM_PMTIMER depends on HVM option, because this driver is part of HVM support code.

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 pmtimer or any other emulated device are disabled.

Quoted 7 lines
Quoted 1 line

What exactly was it that Roger suggested? I don't think it was what the patch does overall, but just _how_ it is being done? That makes quite a bit of a difference, as the former could be read as kind of an implicit ack to what is being done here (and also in the other patch). Issue is: I remain unconvinced that this conditionalizing is actually something we really want/need.

Quoted 3 lines

about a half of this patch is what Roger suggested. These changes were in a separate patch, which Roger suggested to be merged into other patches. What tag should be put in this case then?

The tag itself is fine, but could do with clarifying by way of attaching "# <brief>", like we also permit for R-b and A-b. Alternatively a post- commit-message remark would help during review (but notably not once the change would have been committed, e.g. for archaeologists).

Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
xen/arch/x86/Kconfig +0 -0
@@ -144,6 +144,19 @@ config INTEL_VMX
  	  If your system includes a processor with Intel VT-x support, say Y.
  	  If in doubt, say Y.
 
Quoted 12 lines

xen/arch/x86/Kconfig config INTEL_VMX · line 155

Quoted 9 lines
xen/arch/x86/Kconfig +9 -0
+menu "Emulated HVM devices support"
+       visible if EXPERT
+       depends on HVM
+
+config X86_HVM_PMTIMER
+	bool "ACPI PM timer emulation support"
+	default y
+	help
+	  Build pmtimer driver that emulates ACPI PM timer for HVM/PVH guests.

Does this really affect PVH guests? Isn't the whole point of the change that in a PVH-only environment this wouldn't be needed in Xen?

Quoted 2 lines

PVH guest may (depending on its configuration) still use PM timer, so I'd say the point is in a PVH-only environment this driver becomes optional.

Hmm, the way I look at emulation_flags_ok() it doesn't look to permit this as optional. The PVH case is "emflags == X86_EMU_LAPIC".

Quoted 28 lines
Quoted 14 lines
Quoted 14 lines
xen/arch/x86/domain.c +3 -1
@@ -742,11 +742,16 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
 
  static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
  {
-#ifdef CONFIG_HVM
+    const uint32_t disabled_emu_mask = X86_EMU_PM;
+
+#if defined(CONFIG_X86_HVM_PMTIMER)
      /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
      BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
  #endif
 
Quoted 13 lines

xen/arch/x86/domain.c int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) · line 757

Quoted 6 lines
xen/arch/x86/domain.c +3 -0
+    if ( emflags & disabled_emu_mask )
+        return false;
+
      if ( is_hvm_domain(d) )
      {
          if ( is_hardware_domain(d) &&

While you commented on this hunk, it didn't become clear what exactly the resulting new hunk would be. I question in particular the change to the #ifdef: If that's changed and the BUILD_BUG_ON() kept as is, the comment also needs adjusting. Yet it would perhaps be better of the BUILD_BUG_ON() was split accordingly.

Quoted 2 lines

This #ifdef definitely wants nicer change. How would you suggest BUILD_BUG_ON() be split?

#ifdef CONFIG_HVM
       BUILD_BUG_ON(X86_EMU_ALL & ~X86_EMU_PM !=
                    XEN_X86_EMU_ALL & ~XEN_X86_EMU_PM);
#endif
#ifdef CONFIG_X86_HVM_PMTIMER
       BUILD_BUG_ON(X86_EMU_PM != XEN_X86_EMU_PM);

#endif

Jan

#7 lore raw

Re: [XEN PATCH v2 1/2] x86/hvm: introduce config option for ACPI PM timer

11.11.24 14:05, Jan Beulich:
[..]>>> What exactly was it that Roger suggested? I don't think it was what the patch

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

does overall, but just _how_ it is being done? That makes quite a bit of a difference, as the former could be read as kind of an implicit ack to what is being done here (and also in the other patch). Issue is: I remain unconvinced that this conditionalizing is actually something we really want/need.

Quoted 8 lines
Quoted 3 lines

about a half of this patch is what Roger suggested. These changes were in a separate patch, which Roger suggested to be merged into other patches. What tag should be put in this case then?

The tag itself is fine, but could do with clarifying by way of attaching "# <brief>", like we also permit for R-b and A-b. Alternatively a post- commit-message remark would help during review (but notably not once the change would have been committed, e.g. for archaeologists).

can the tag look like the following?:

Suggested-by Name <email> # domain.h,domain.c
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 6 lines
xen/arch/x86/Kconfig +0 -0
@@ -144,6 +144,19 @@ config INTEL_VMX
   	  If your system includes a processor with Intel VT-x support, say Y.
   	  If in doubt, say Y.

xen/arch/x86/Kconfig config INTEL_VMX · line 155

Quoted 10 lines
xen/arch/x86/Kconfig +9 -0
 
+menu "Emulated HVM devices support"
+       visible if EXPERT
+       depends on HVM
+
+config X86_HVM_PMTIMER
+	bool "ACPI PM timer emulation support"
+	default y
+	help
+	  Build pmtimer driver that emulates ACPI PM timer for HVM/PVH guests.

Does this really affect PVH guests? Isn't the whole point of the change that in a PVH-only environment this wouldn't be needed in Xen?

Quoted 5 lines
Quoted 2 lines

PVH guest may (depending on its configuration) still use PM timer, so I'd say the point is in a PVH-only environment this driver becomes optional.

Hmm, the way I look at emulation_flags_ok() it doesn't look to permit this as optional. The PVH case is "emflags == X86_EMU_LAPIC".

I see, will drop PVH mentioning then

-Sergiy

#8 lore raw

Re: [XEN PATCH v2 1/2] x86/hvm: introduce config option for ACPI PM timer

Quoted 12 lines · Sergiy Kibrik

11.11.24 14:05, Jan Beulich:
[..]>>> What exactly was it that Roger suggested? I don't think it was what the patch

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

does overall, but just _how_ it is being done? That makes quite a bit of a difference, as the former could be read as kind of an implicit ack to what is being done here (and also in the other patch). Issue is: I remain unconvinced that this conditionalizing is actually something we really want/need.

about a half of this patch is what Roger suggested. These changes were in a separate patch, which Roger suggested to be merged into other patches. What tag should be put in this case then?

Quoted 8 lines
Quoted 4 lines

The tag itself is fine, but could do with clarifying by way of attaching "# <brief>", like we also permit for R-b and A-b. Alternatively a post- commit-message remark would help during review (but notably not once the change would have been committed, e.g. for archaeologists).

can the tag look like the following?:

Suggested-by Name <email> # domain.h,domain.c

Not sure what people would derive from that. How about

Suggested-by Name <email> # approach

or

Suggested-by Name <email> # how, but not what

or some such?

Jan

#9 lore raw

PATCH v2 2/2 x86/hvm: introduce config option for stdvga emulation

In reply to Sergiy Kibrik

Introduce config option X86_HVM_STDVGA and make stdvga emulation driver configurable so it can be disabled on systems that don't need it.

---
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             |  4 ++--
 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, 23 insertions(+), 5 deletions(-)
xen/arch/x86/Kconfig +10 -0
index ed0ece85c7..35c8ace8ef 100644
@@ -155,6 +155,16 @@ config X86_HVM_PMTIMER
 	  Build pmtimer driver that emulates ACPI PM timer for HVM/PVH guests.
 
 	  If unsure, say Y.
+
+config X86_HVM_STDVGA
+	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
xen/arch/x86/domain.c +2 -2
index b340818ee2..aefa1fc136 100644
@@ -742,9 +742,9 @@ 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 = X86_EMU_PM;
+    const uint32_t disabled_emu_mask = X86_EMU_PM | X86_EMU_VGA;
 
-#if defined(CONFIG_X86_HVM_PMTIMER)
+#if defined(CONFIG_X86_HVM_PMTIMER) && defined(CONFIG_X86_HVM_STDVGA)
     /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
     BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
 #endif
xen/arch/x86/hvm/Makefile +1 -1
index 3af8963218..80ec425aa8 100644
@@ -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
xen/arch/x86/include/asm/domain.h +6 -2
index 8550473997..106b438779 100644
@@ -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 */
xen/arch/x86/include/asm/hvm/io.h +4 -0
index f2b8431fac..c02fad876c 100644
@@ -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);
 
Signature · 1 line
2.25.1
Reviewed-by on v2 2/2
#10 lore raw

Re: [XEN PATCH v2 2/2] x86/hvm: introduce config option for stdvga emulation

Quoted 48 lines · Sergiy Kibrik

Introduce config option X86_HVM_STDVGA and make stdvga emulation driver configurable so it can be disabled on systems that don't need it.

---
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             |  4 ++--
 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, 23 insertions(+), 5 deletions(-)
xen/arch/x86/Kconfig +10 -0
index ed0ece85c7..35c8ace8ef 100644
@@ -155,6 +155,16 @@ config X86_HVM_PMTIMER
 	  Build pmtimer driver that emulates ACPI PM timer for HVM/PVH guests.
 
 	  If unsure, say Y.
+
+config X86_HVM_STDVGA
+	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
xen/arch/x86/domain.c +0 -0
index b340818ee2..aefa1fc136 100644
@@ -742,9 +742,9 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
 

xen/arch/x86/domain.c int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) · line 750

Quoted 10 lines
xen/arch/x86/domain.c +2 -2
 static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
 {
-    const uint32_t disabled_emu_mask = X86_EMU_PM;
+    const uint32_t disabled_emu_mask = X86_EMU_PM | X86_EMU_VGA;
 
-#if defined(CONFIG_X86_HVM_PMTIMER)
+#if defined(CONFIG_X86_HVM_PMTIMER) && defined(CONFIG_X86_HVM_STDVGA)
     /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
     BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
 #endif

You need to remove this part, following your reply to the previous patch

With that modification:

Quoted 65 lines
xen/arch/x86/hvm/Makefile +1 -1
index 3af8963218..80ec425aa8 100644
@@ -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
xen/arch/x86/include/asm/domain.h +6 -2
index 8550473997..106b438779 100644
@@ -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 */
xen/arch/x86/include/asm/hvm/io.h +4 -0
index f2b8431fac..c02fad876c 100644
@@ -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);
 
Signature · 1 line
2.25.1