Skip to contentSkip to conversation

make build of vm_event/mem_access/monitor optional

PATCH Superseded Sergiy Kibrik 3 participants 11 messages Mar 11, 2025 – Mar 12, 2025 RISC-V

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover make build of vm_event/mem_access/monitor optional

This series aims to provide a possibility to build Xen without mem_access and related features. It is already largely covered by corresponding CONFIG_MEM_ACCESS option, yet there're still some parts remaining. Hopefully this would help to reduce dead code a bit.

As coverage of MEM_ACCESS config option begins to extend beyond actual mem_access code it has been suggested to rename it into VM_EVENT, as a more general option controlling mem_access, vm_event and monitor code.

One patch for automation from v2 series had been squashed into #1 patch in v3 series, v2 reference below:
https://lore.kernel.org/xen-devel/[email protected]/

-Sergiy

Sergiy Kibrik (2):
xen: kconfig: rename MEM_ACCESS -> VM_EVENT x86:monitor: control monitor.c build with CONFIG_VM_EVENT option

Stefano Stabellini (1):
xen: mem_access: conditionally compile vm_event.c & monitor.c

 automation/gitlab-ci/build.yaml         |  2 +-
 xen/arch/arm/Makefile                   |  6 +++---
 xen/arch/arm/configs/tiny64_defconfig   |  2 +-
 xen/arch/arm/include/asm/mem_access.h   |  4 ++--
 xen/arch/arm/vsmc.c                     |  3 ++-
 xen/arch/ppc/configs/ppc64_defconfig    |  2 +-
 xen/arch/riscv/configs/tiny64_defconfig |  2 +-
 xen/arch/x86/Kconfig                    |  2 +-
 xen/arch/x86/Makefile                   |  2 +-
 xen/arch/x86/mm/Makefile                |  2 +-
 xen/common/Kconfig                      |  2 +-
 xen/common/Makefile                     |  6 +++---
 xen/common/domctl.c                     |  2 +-
 xen/include/xen/mem_access.h            |  6 +++---
 xen/include/xen/monitor.h               |  9 +++++++++
 xen/include/xen/vm_event.h              | 14 +++++++++++---
 xen/include/xsm/dummy.h                 |  2 +-
 xen/include/xsm/xsm.h                   |  4 ++--
 xen/xsm/dummy.c                         |  2 +-
 xen/xsm/flask/hooks.c                   |  4 ++--
 20 files changed, 48 insertions(+), 30 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/3 xen: kconfig: rename MEM_ACCESS -> VM_EVENT

Use more generic CONFIG_VM_EVENT name throughout Xen code instead of CONFIG_MEM_ACCESS. This reflects the fact that vm_event is a higher level feature, with mem_access & monitor depending on it.

---
changes in v3:
- squash with automation patch
- tags & minor addition of blanks

---
 automation/gitlab-ci/build.yaml         | 2 +-
 xen/arch/arm/Makefile                   | 2 +-
 xen/arch/arm/configs/tiny64_defconfig   | 2 +-
 xen/arch/arm/include/asm/mem_access.h   | 4 ++--
 xen/arch/ppc/configs/ppc64_defconfig    | 2 +-
 xen/arch/riscv/configs/tiny64_defconfig | 2 +-
 xen/arch/x86/mm/Makefile                | 2 +-
 xen/common/Kconfig                      | 2 +-
 xen/common/Makefile                     | 2 +-
 xen/common/domctl.c                     | 2 +-
 xen/include/xen/mem_access.h            | 6 +++---
 xen/include/xsm/dummy.h                 | 2 +-
 xen/include/xsm/xsm.h                   | 4 ++--
 xen/xsm/dummy.c                         | 2 +-
 xen/xsm/flask/hooks.c                   | 4 ++--
 15 files changed, 20 insertions(+), 20 deletions(-)
automation/gitlab-ci/build.yaml +1 -1
index 034d6d9c3a..b6383c4fc8 100644
@@ -744,7 +744,7 @@ debian-12-riscv64-gcc:
       CONFIG_EXPERT=y
       CONFIG_GRANT_TABLE=n
       CONFIG_LIVEPATCH=n
-      CONFIG_MEM_ACCESS=n
+      CONFIG_VM_EVENT=n
       CONFIG_QEMU_PLATFORM=y
       CONFIG_XSM=n
 
xen/arch/arm/Makefile +1 -1
index fb0948f067..3bd5125e64 100644
@@ -38,7 +38,7 @@ obj-y += irq.o
 obj-y += kernel.init.o
 obj-$(CONFIG_LIVEPATCH) += livepatch.o
 obj-$(CONFIG_LLC_COLORING) += llc-coloring.o
-obj-$(CONFIG_MEM_ACCESS) += mem_access.o
+obj-$(CONFIG_VM_EVENT) += mem_access.o
 obj-y += mm.o
 obj-y += monitor.o
 obj-y += p2m.o
xen/arch/arm/configs/tiny64_defconfig +1 -1
index cc6d93f2f8..469a1eb9f9 100644
@@ -5,7 +5,7 @@ CONFIG_ARM=y
 # Architecture Features
 #
 # CONFIG_GICV3 is not set
-# CONFIG_MEM_ACCESS is not set
+# CONFIG_VM_EVENT is not set
 # CONFIG_SBSA_VUART_CONSOLE is not set
 
 #
xen/arch/arm/include/asm/mem_access.h +2 -2
index abac8032fc..d42f28e8b7 100644
@@ -37,7 +37,7 @@ static inline bool p2m_mem_access_sanity_check(struct domain *d)
  * Send mem event based on the access. Boolean return value indicates if trap
  * needs to be injected into guest.
  */
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
 bool p2m_mem_access_check(paddr_t gpa, vaddr_t gla, const struct npfec npfec);
 
 struct page_info*
@@ -58,7 +58,7 @@ p2m_mem_access_check_and_get_page(vaddr_t gva, unsigned long flag,
     return NULL;
 }
 
-#endif /*CONFIG_MEM_ACCESS*/
+#endif /* CONFIG_VM_EVENT */
 #endif /* _ASM_ARM_MEM_ACCESS_H */
 
 /*
xen/arch/ppc/configs/ppc64_defconfig +1 -1
index 4924d881a2..d6aaf772e7 100644
@@ -1,6 +1,6 @@
 # CONFIG_GRANT_TABLE is not set
 # CONFIG_SPECULATIVE_HARDEN_ARRAY is not set
-# CONFIG_MEM_ACCESS is not set
+# CONFIG_VM_EVENT is not set
 
 CONFIG_PPC64=y
 CONFIG_DEBUG=y
xen/arch/riscv/configs/tiny64_defconfig +1 -1
index bb3ae26a44..2399f7b918 100644
@@ -1,6 +1,6 @@
 # CONFIG_BOOT_TIME_CPUPOOLS is not set
 # CONFIG_GRANT_TABLE is not set
-# CONFIG_MEM_ACCESS is not set
+# CONFIG_VM_EVENT is not set
 # CONFIG_COVERAGE is not set
 # CONFIG_LIVEPATCH is not set
 # CONFIG_XSM is not set
xen/arch/x86/mm/Makefile +1 -1
index 0345388359..960f6e8409 100644
@@ -4,7 +4,7 @@ obj-$(CONFIG_HVM) += hap/
 obj-$(CONFIG_ALTP2M) += altp2m.o
 obj-$(CONFIG_HVM) += guest_walk_2.o guest_walk_3.o guest_walk_4.o
 obj-$(CONFIG_SHADOW_PAGING) += guest_walk_4.o
-obj-$(CONFIG_MEM_ACCESS) += mem_access.o
+obj-$(CONFIG_VM_EVENT) += mem_access.o
 obj-$(CONFIG_MEM_PAGING) += mem_paging.o
 obj-$(CONFIG_MEM_SHARING) += mem_sharing.o
 obj-$(CONFIG_HVM) += nested.o
xen/common/Kconfig +1 -1
index 6166327f4d..a6aa2c5c14 100644
@@ -92,7 +92,7 @@ config HAS_VMAP
 config MEM_ACCESS_ALWAYS_ON
 	bool
 
-config MEM_ACCESS
+config VM_EVENT
 	def_bool MEM_ACCESS_ALWAYS_ON
 	prompt "Memory Access and VM events" if !MEM_ACCESS_ALWAYS_ON
 	depends on HVM
xen/common/Makefile +1 -1
index cba3b32733..b71d4b3efa 100644
@@ -26,7 +26,7 @@ obj-$(CONFIG_KEXEC) += kexec.o
 obj-$(CONFIG_KEXEC) += kimage.o
 obj-$(CONFIG_LIVEPATCH) += livepatch.o livepatch_elf.o
 obj-$(CONFIG_LLC_COLORING) += llc-coloring.o
-obj-$(CONFIG_MEM_ACCESS) += mem_access.o
+obj-$(CONFIG_VM_EVENT) += mem_access.o
 obj-y += memory.o
 obj-y += multicall.o
 obj-y += notifier.o
xen/common/domctl.c +1 -1
index b897ca8723..bfe2e1f9f0 100644
@@ -809,7 +809,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
             copyback = true;
         break;
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
     case XEN_DOMCTL_set_access_required:
         if ( unlikely(current->domain == d) ) /* no domain_pause() */
             ret = -EPERM;
xen/include/xen/mem_access.h +3 -3
index 2231341b5d..4de651038d 100644
@@ -33,7 +33,7 @@
  */
 struct vm_event_st;
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
 #include <asm/mem_access.h>
 #endif
 
@@ -99,7 +99,7 @@ long p2m_set_mem_access_multi(struct domain *d,
 int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access,
                        unsigned int altp2m_idx);
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
 int mem_access_memop(unsigned long cmd,
                      XEN_GUEST_HANDLE_PARAM(xen_mem_access_op_t) arg);
 #else
@@ -109,7 +109,7 @@ int mem_access_memop(unsigned long cmd,
 {
     return -ENOSYS;
 }
-#endif /* CONFIG_MEM_ACCESS */
+#endif /* CONFIG_VM_EVENT */
 
 #endif /* _XEN_MEM_ACCESS_H */
 
xen/include/xsm/dummy.h +1 -1
index a8d06de6b0..9227205fcd 100644
@@ -647,7 +647,7 @@ static XSM_INLINE int cf_check xsm_vm_event_control(
     return xsm_default_action(action, current->domain, d);
 }
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
 static XSM_INLINE int cf_check xsm_mem_access(XSM_DEFAULT_ARG struct domain *d)
 {
     XSM_ASSERT_ACTION(XSM_DM_PRIV);
xen/include/xsm/xsm.h +2 -2
index 8c33b055fc..24acc16125 100644
@@ -153,7 +153,7 @@ struct xsm_ops {
 
     int (*vm_event_control)(struct domain *d, int mode, int op);
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
     int (*mem_access)(struct domain *d);
 #endif
 
@@ -637,7 +637,7 @@ static inline int xsm_vm_event_control(
     return alternative_call(xsm_ops.vm_event_control, d, mode, op);
 }
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
 static inline int xsm_mem_access(xsm_default_t def, struct domain *d)
 {
     return alternative_call(xsm_ops.mem_access, d);
xen/xsm/dummy.c +1 -1
index ce6fbdc6c5..93fbfc43cc 100644
@@ -111,7 +111,7 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
 
     .vm_event_control              = xsm_vm_event_control,
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
     .mem_access                    = xsm_mem_access,
 #endif
 
xen/xsm/flask/hooks.c +2 -2
index 389707a164..6a53487ea4 100644
@@ -1362,7 +1362,7 @@ static int cf_check flask_vm_event_control(struct domain *d, int mode, int op)
     return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__VM_EVENT);
 }
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
 static int cf_check flask_mem_access(struct domain *d)
 {
     return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__MEM_ACCESS);
@@ -1955,7 +1955,7 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
 
     .vm_event_control = flask_vm_event_control,
 
-#ifdef CONFIG_MEM_ACCESS
+#ifdef CONFIG_VM_EVENT
     .mem_access = flask_mem_access,
 #endif
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 1/3] xen: kconfig: rename MEM_ACCESS -> VM_EVENT

xen/common/Kconfig config HAS_VMAP · line 98

Quoted 11 lines · Sergiy Kibrik
xen/common/Kconfig +1 -1
@@ -92,7 +92,7 @@ config HAS_VMAP
 config MEM_ACCESS_ALWAYS_ON
 	bool
 
-config MEM_ACCESS
+config VM_EVENT
 	def_bool MEM_ACCESS_ALWAYS_ON
 	prompt "Memory Access and VM events" if !MEM_ACCESS_ALWAYS_ON
 	depends on HVM

I still don't see why we would then stick to MEM_ACCESS_ALWAYS_ON as a name for the sibling option.

Jan

#3 lore raw

Re: [PATCH v3 1/3] xen: kconfig: rename MEM_ACCESS -> VM_EVENT

Quoted 8 lines · Jan Beulich
Quoted 6 lines · Sergiy Kibrik
xen/common/Kconfig +0 -0
@@ -92,7 +92,7 @@ config HAS_VMAP
 config MEM_ACCESS_ALWAYS_ON
      bool
 
Quoted 8 lines

xen/common/Kconfig config HAS_VMAP · line 98

Quoted 5 lines
xen/common/Kconfig +1 -1
-config MEM_ACCESS
+config VM_EVENT
      def_bool MEM_ACCESS_ALWAYS_ON
      prompt "Memory Access and VM events" if !MEM_ACCESS_ALWAYS_ON
      depends on HVM

I still don't see why we would then stick to MEM_ACCESS_ALWAYS_ON as a name for the sibling option.

I'm not opposed to renaming it but it's also not something I see much value in doing. It's not used anywhere in the code, it's purely used in the config selector to mark that on x86 the vm_event/mem_access/monitor bits are not setup to be compiled-out.

Tamas

#4 lore raw

Re: [PATCH v3 1/3] xen: kconfig: rename MEM_ACCESS -> VM_EVENT

In reply to Jan Beulich

11.03.25 14:01, Jan Beulich:

Quoted 7 lines · Sergiy Kibrik
Quoted 6 lines
xen/common/Kconfig +0 -0
@@ -92,7 +92,7 @@ config HAS_VMAP
  config MEM_ACCESS_ALWAYS_ON
  	bool
 
Quoted 9 lines

xen/common/Kconfig config HAS_VMAP · line 98

Quoted 5 lines
xen/common/Kconfig +1 -1
-config MEM_ACCESS
+config VM_EVENT
  	def_bool MEM_ACCESS_ALWAYS_ON
  	prompt "Memory Access and VM events" if !MEM_ACCESS_ALWAYS_ON
  	depends on HVM

I still don't see why we would then stick to MEM_ACCESS_ALWAYS_ON as a name for the sibling option.

as HVM requires mem-access to be enabled I felt like it should be kept as is -- to hint that it is mem-access that ties vm_event to hvm.

-Sergiy

#5 lore raw

Re: [PATCH v3 1/3] xen: kconfig: rename MEM_ACCESS -> VM_EVENT

Quoted 17 lines · Sergiy Kibrik

11.03.25 14:01, Jan Beulich:

Quoted 7 lines · Sergiy Kibrik
Quoted 6 lines
xen/common/Kconfig +0 -0
@@ -92,7 +92,7 @@ config HAS_VMAP
  config MEM_ACCESS_ALWAYS_ON
  	bool
 
Quoted 8 lines

xen/common/Kconfig config HAS_VMAP · line 98

Quoted 5 lines
xen/common/Kconfig +1 -1
-config MEM_ACCESS
+config VM_EVENT
  	def_bool MEM_ACCESS_ALWAYS_ON
  	prompt "Memory Access and VM events" if !MEM_ACCESS_ALWAYS_ON
  	depends on HVM

I still don't see why we would then stick to MEM_ACCESS_ALWAYS_ON as a name for the sibling option.

Quoted 1 line

as HVM requires mem-access to be enabled

If that was indeed the case, ...

Quoted 2 lines

I felt like it should be kept
as is -- to hint that it is mem-access that ties vm_event to hvm.

... I'd agree. It was my understanding though that MEM_ACCESS_ALWAYS_ON only exists because when Arm support was added no-one wanted to take the time to make mem-access properly optional on x86.

Jan

#6 lore raw

PATCH v3 2/3 x86:monitor: control monitor.c build with CONFIG_VM_EVENT option

In reply to Sergiy Kibrik

Replace more general CONFIG_HVM option with CONFIG_VM_EVENT which is more relevant and specific to monitoring. This is only to clarify at build level to which subsystem this file belongs.

No functional change here, as VM_EVENT depends on HVM.

---
 xen/arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/Makefile +1 -1
index c763f80b0b..f59c9665fd 100644
@@ -49,7 +49,7 @@ obj-$(CONFIG_PV) += ioport_emulate.o
 obj-y += irq.o
 obj-$(CONFIG_KEXEC) += machine_kexec.o
 obj-y += mm.o x86_64/mm.o
-obj-$(CONFIG_HVM) += monitor.o
+obj-$(CONFIG_VM_EVENT) += monitor.o
 obj-y += mpparse.o
 obj-y += nmi.o
 obj-y += numa.o
Signature · 1 line
2.25.1
#7 lore raw

PATCH v3 3/3 xen: mem_access: conditionally compile vm_event.c & monitor.c

In reply to Sergiy Kibrik

From: Stefano Stabellini <[email protected]>

Extend coverage of CONFIG_VM_EVENT option and make the build of VM events and monitoring support optional. Also make MEM_PAGING option depend on VM_EVENT to document that mem_paging is relying on vm_event.
This is to reduce code size on Arm when this option isn't enabled.

---
changes in v3:
- add dependency MEM_PAGING -> VM_EVENT
- monitor_domctl() stub returns -EOPNOTSUPP
changes in v2:
- rename CONFIG_MEM_ACCESS -> CONFIG_VM_EVENT
- tags

---
 xen/arch/arm/Makefile      |  4 ++--
 xen/arch/arm/vsmc.c        |  3 ++-
 xen/arch/x86/Kconfig       |  2 +-
 xen/common/Makefile        |  4 ++--
 xen/include/xen/monitor.h  |  9 +++++++++
 xen/include/xen/vm_event.h | 14 +++++++++++---
 6 files changed, 27 insertions(+), 9 deletions(-)
xen/arch/arm/Makefile +2 -2
index 3bd5125e64..4837ad467a 100644
@@ -40,7 +40,7 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o
 obj-$(CONFIG_LLC_COLORING) += llc-coloring.o
 obj-$(CONFIG_VM_EVENT) += mem_access.o
 obj-y += mm.o
-obj-y += monitor.o
+obj-$(CONFIG_VM_EVENT) += monitor.o
 obj-y += p2m.o
 obj-y += platform.o
 obj-y += platform_hypercall.o
@@ -66,7 +66,7 @@ obj-$(CONFIG_VGICV2) += vgic-v2.o
 obj-$(CONFIG_GICV3) += vgic-v3.o
 obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o
 endif
-obj-y += vm_event.o
+obj-$(CONFIG_VM_EVENT) += vm_event.o
 obj-y += vtimer.o
 obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o
 obj-y += vsmc.o
xen/arch/arm/vsmc.c +2 -1
index e253865b6c..6081f14ed0 100644
@@ -330,7 +330,8 @@ void do_trap_smc(struct cpu_user_regs *regs, const union hsr hsr)
     }
 
     /* If monitor is enabled, let it handle the call. */
-    if ( current->domain->arch.monitor.privileged_call_enabled )
+    if ( IS_ENABLED(CONFIG_VM_EVENT) &&
+         current->domain->arch.monitor.privileged_call_enabled )
         rc = monitor_smc();
 
     if ( rc == 1 )
xen/arch/x86/Kconfig +1 -1
index 6e41bc0fb4..f086799594 100644
@@ -350,7 +350,7 @@ endif
 
 config MEM_PAGING
 	bool "Xen memory paging support (UNSUPPORTED)" if UNSUPPORTED
-	depends on HVM
+	depends on HVM && VM_EVENT
 
 config MEM_SHARING
 	bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED
xen/common/Makefile +2 -2
index b71d4b3efa..ac23120d7d 100644
@@ -54,7 +54,7 @@ obj-y += timer.o
 obj-$(CONFIG_TRACEBUFFER) += trace.o
 obj-y += version.o
 obj-y += virtual_region.o
-obj-y += vm_event.o
+obj-$(CONFIG_VM_EVENT) += vm_event.o
 obj-$(CONFIG_HAS_VMAP) += vmap.o
 obj-y += vsprintf.o
 obj-y += wait.o
@@ -68,7 +68,7 @@ obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o memory.o multicall.o xlat.o
 
 ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
 obj-y += domctl.o
-obj-y += monitor.o
+obj-$(CONFIG_VM_EVENT) += monitor.o
 obj-y += sysctl.o
 endif
 
xen/include/xen/monitor.h +9 -0
index 713d54f7c1..634b6cd2a1 100644
@@ -27,8 +27,17 @@
 struct domain;
 struct xen_domctl_monitor_op;
 
+#ifdef CONFIG_VM_EVENT
 int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop);
 void monitor_guest_request(void);
+#else
+static inline int monitor_domctl(struct domain *d,
+                                 struct xen_domctl_monitor_op *mop)
+{
+    return -EOPNOTSUPP;
+}
+static inline void monitor_guest_request(void) {}
+#endif
 
 int monitor_traps(struct vcpu *v, bool sync, vm_event_request_t *req);
 
xen/include/xen/vm_event.h +11 -3
index 9a86358b42..268c85fc4f 100644
@@ -50,9 +50,6 @@ struct vm_event_domain
     unsigned int last_vcpu_wake_up;
 };
 
-/* Clean up on domain destruction */
-void vm_event_cleanup(struct domain *d);
-
 /* Returns whether a ring has been set up */
 bool vm_event_check_ring(struct vm_event_domain *ved);
 
@@ -88,7 +85,18 @@ void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved);
 void vm_event_put_request(struct domain *d, struct vm_event_domain *ved,
                           vm_event_request_t *req);
 
+#ifdef CONFIG_VM_EVENT
+/* Clean up on domain destruction */
+void vm_event_cleanup(struct domain *d);
 int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec);
+#else
+static inline void vm_event_cleanup(struct domain *d) {}
+static inline int vm_event_domctl(struct domain *d,
+                                  struct xen_domctl_vm_event_op *vec)
+{
+    return -EINVAL;
+}
+#endif
 
 void vm_event_vcpu_pause(struct vcpu *v);
 void vm_event_vcpu_unpause(struct vcpu *v);
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH v3 3/3] xen: mem_access: conditionally compile vm_event.c & monitor.c

Quoted 7 lines · Sergiy Kibrik

From: Stefano Stabellini <[email protected]>

Extend coverage of CONFIG_VM_EVENT option and make the build of VM events and monitoring support optional. Also make MEM_PAGING option depend on VM_EVENT to document that mem_paging is relying on vm_event.
This is to reduce code size on Arm when this option isn't enabled.

Quoted 5 lines

Please can tags be kept in chronological order? It's impossible to review a patch that wasn't first signed-off on by the author(s).

Quoted 4 lines

---
changes in v3:
- add dependency MEM_PAGING -> VM_EVENT
- monitor_domctl() stub returns -EOPNOTSUPP

Seeing this, i.e. ...

Quoted 4 lines
xen/include/xen/monitor.h +0 -0
@@ -27,8 +27,17 @@
 struct domain;

xen/include/xen/monitor.h line 37

Quoted 10 lines
xen/include/xen/monitor.h +6 -0
 struct xen_domctl_monitor_op;
 
+#ifdef CONFIG_VM_EVENT
 int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop);
 void monitor_guest_request(void);
+#else
+static inline int monitor_domctl(struct domain *d,
+                                 struct xen_domctl_monitor_op *mop)
+{
+    return -EOPNOTSUPP;

... this, why ...

Quoted 4 lines
xen/include/xen/monitor.h +0 -0
@@ -88,7 +85,18 @@ void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved);
 void vm_event_put_request(struct domain *d, struct vm_event_domain *ved,
                           vm_event_request_t *req);
 

xen/include/xen/monitor.h void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved); · line 97

Quoted 10 lines
xen/include/xen/monitor.h +9 -0
+#ifdef CONFIG_VM_EVENT
+/* Clean up on domain destruction */
+void vm_event_cleanup(struct domain *d);
 int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec);
+#else
+static inline void vm_event_cleanup(struct domain *d) {}
+static inline int vm_event_domctl(struct domain *d,
+                                  struct xen_domctl_vm_event_op *vec)
+{
+    return -EINVAL;

... is it EINVAL here?

Jan

#9 lore raw

Re: [PATCH v3 3/3] xen: mem_access: conditionally compile vm_event.c & monitor.c

Quoted 9 lines · Jan Beulich
Quoted 7 lines · Sergiy Kibrik

From: Stefano Stabellini <[email protected]>

Extend coverage of CONFIG_VM_EVENT option and make the build of VM events and monitoring support optional. Also make MEM_PAGING option depend on VM_EVENT to document that mem_paging is relying on vm_event.
This is to reduce code size on Arm when this option isn't enabled.

Quoted 12 lines
Quoted 5 lines

Please can tags be kept in chronological order? It's impossible to review a patch that wasn't first signed-off on by the author(s).

Quoted 3 lines

---
changes in v3:
- add dependency MEM_PAGING -> VM_EVENT

This seems to be largely unnecessary since on x86 selecting HVM already selects it but I guess it also doesn't hurt to explicitly mark it like this either.

Quoted 25 lines
Quoted 1 line

- monitor_domctl() stub returns -EOPNOTSUPP

Seeing this, i.e. ...

Quoted 4 lines
xen/include/xen/monitor.h +0 -0
@@ -27,8 +27,17 @@
 struct domain;

xen/include/xen/monitor.h line 37

Quoted 10 lines
xen/include/xen/monitor.h +6 -0
 struct xen_domctl_monitor_op;
 
+#ifdef CONFIG_VM_EVENT
 int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop);
 void monitor_guest_request(void);
+#else
+static inline int monitor_domctl(struct domain *d,
+                                 struct xen_domctl_monitor_op *mop)
+{
+    return -EOPNOTSUPP;

... this, why ...

Quoted 4 lines
xen/include/xen/monitor.h +0 -0
@@ -88,7 +85,18 @@ void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved);
 void vm_event_put_request(struct domain *d, struct vm_event_domain *ved,
                           vm_event_request_t *req);
 
Quoted 12 lines

xen/include/xen/monitor.h void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved); · line 97

Quoted 10 lines
xen/include/xen/monitor.h +9 -0
+#ifdef CONFIG_VM_EVENT
+/* Clean up on domain destruction */
+void vm_event_cleanup(struct domain *d);
 int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec);
+#else
+static inline void vm_event_cleanup(struct domain *d) {}
+static inline int vm_event_domctl(struct domain *d,
+                                  struct xen_domctl_vm_event_op *vec)
+{
+    return -EINVAL;

... is it EINVAL here?

I would prefer if it was consistent too with -EOPNOTSUPP for both when the subsystems are compiled out.

Thanks,
Tamas

#10 lore raw

Re: [PATCH v3 3/3] xen: mem_access: conditionally compile vm_event.c & monitor.c

11.03.25 15:39, Tamas K Lengyel:

Quoted 17 lines · Jan Beulich
Quoted 16 lines · Sergiy Kibrik
Quoted 7 lines

From: Stefano Stabellini<[email protected]>

Extend coverage of CONFIG_VM_EVENT option and make the build of VM events and monitoring support optional. Also make MEM_PAGING option depend on VM_EVENT to document that mem_paging is relying on vm_event.
This is to reduce code size on Arm when this option isn't enabled.

Quoted 5 lines

Please can tags be kept in chronological order? It's impossible to review a patch that wasn't first signed-off on by the author(s).

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

---
changes in v3:
- add dependency MEM_PAGING -> VM_EVENT

This seems to be largely unnecessary since on x86 selecting HVM already selects it but I guess it also doesn't hurt to explicitly mark it like this either.

It's done just to highlight this dependency, more like a documentation hint (as Jan suggested in previous discussion).

-Sergiy