Skip to contentSkip to conversation

xen: introduce CONFIG_SYSCTL

PATCH In review Penny Zheng 4 participants 22 messages Jul 11, 2025 – Jul 22, 2025 RISC-V

lore
Share & tools
lore
#0 lore raw

v8 cover xen: introduce CONFIG_SYSCTL

It can be beneficial for some dom0less systems to further reduce Xen footprint via disabling some hypercalls handling code, which may not to be used & required in such systems. Each hypercall has a separate option to keep configuration flexible.

Options to disable hypercalls:
- sysctl
- domctl
- hvm
- physdev
- platform

This patch serie is only focusing on introducing CONFIG_SYSCTL. Different options will be covered in different patch serie.

Features, like LIVEPATCH, Overlay DTB, which fully rely on sysctl op, will be wrapped with CONFIG_SYSCTL, to reduce Xen footprint as much as possible.

It is derived from Stefano Stabellini's commit "xen: introduce kconfig options to disable hypercalls"(
https://lore.kernel.org/xen-devel/[email protected])

---
Commit "xen/x86: remove "depends on !PV_SHIM_EXCLUSIVE"" and commit " xen/sysctl: wrap around sysctl hypercall" shall be commited together.
---
Penny Zheng (6):
xen/xsm: wrap around xsm_sysctl with CONFIG_SYSCTL xen/sysctl: wrap around XEN_SYSCTL_readconsole xen/sysctl: wrap around XEN_SYSCTL_page_offline_op xen/sysctl: wrap around XEN_SYSCTL_scheduler_op xen/sysctl: wrap around arch-specific arch_do_sysctl xen/x86: remove "depends on !PV_SHIM_EXCLUSIVE"

Stefano Stabellini (1):
xen/sysctl: wrap around sysctl hypercall

 xen/arch/arm/Kconfig                  |  1 +
 xen/arch/arm/Makefile                 |  2 +-
 xen/arch/arm/sysctl.c                 |  2 --
 xen/arch/riscv/stubs.c                |  2 +-
 xen/arch/x86/Kconfig                  |  4 ----
 xen/arch/x86/Makefile                 |  2 +-
 xen/arch/x86/configs/pvshim_defconfig |  5 +----
 xen/arch/x86/hvm/Kconfig              |  1 -
 xen/arch/x86/psr.c                    | 18 ++++++++++++++++++
 xen/arch/x86/sysctl.c                 |  2 --
 xen/common/Kconfig                    |  6 +++++-
 xen/common/Makefile                   |  2 +-
 xen/common/page_alloc.c               |  2 ++
 xen/common/sched/arinc653.c           |  6 ++++++
 xen/common/sched/core.c               |  2 ++
 xen/common/sched/credit.c             |  4 ++++
 xen/common/sched/credit2.c            |  4 ++++
 xen/common/sched/private.h            |  4 ++++
 xen/drivers/char/console.c            |  2 ++
 xen/drivers/video/Kconfig             |  2 +-
 xen/include/hypercall-defs.c          |  8 ++++++--
 xen/include/xsm/xsm.h                 | 18 ++++++++++++++++++
 xen/xsm/dummy.c                       |  6 ++++++
 xen/xsm/flask/hooks.c                 | 14 ++++++++++++++
 24 files changed, 98 insertions(+), 21 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v8 1/7 xen/xsm: wrap around xsm_sysctl with CONFIG_SYSCTL

As function xsm_sysctl() is solely invoked in sysctl.c, we need to wrap around it with CONFIG_SYSCTL

---
 xen/include/xsm/xsm.h | 4 ++++
 xen/xsm/dummy.c       | 2 ++
 xen/xsm/flask/hooks.c | 4 ++++
 3 files changed, 10 insertions(+)
xen/include/xsm/xsm.h +4 -0
index 24acc16125..22e2429f52 100644
@@ -261,7 +261,11 @@ static inline int xsm_domctl(xsm_default_t def, struct domain *d,
 
 static inline int xsm_sysctl(xsm_default_t def, int cmd)
 {
+#ifdef CONFIG_SYSCTL
     return alternative_call(xsm_ops.sysctl, cmd);
+#else
+    return -EOPNOTSUPP;
+#endif
 }
 
 static inline int xsm_readconsole(xsm_default_t def, uint32_t clear)
xen/xsm/dummy.c +2 -0
index 93fbfc43cc..93a0665ecc 100644
@@ -22,7 +22,9 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
     .sysctl_scheduler_op           = xsm_sysctl_scheduler_op,
     .set_target                    = xsm_set_target,
     .domctl                        = xsm_domctl,
+#ifdef CONFIG_SYSCTL
     .sysctl                        = xsm_sysctl,
+#endif
     .readconsole                   = xsm_readconsole,
 
     .evtchn_unbound                = xsm_evtchn_unbound,
xen/xsm/flask/hooks.c +4 -0
index 6a53487ea4..3a43e5a1d6 100644
@@ -856,6 +856,7 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,
     }
 }
 
+#ifdef CONFIG_SYSCTL
 static int cf_check flask_sysctl(int cmd)
 {
     switch ( cmd )
@@ -933,6 +934,7 @@ static int cf_check flask_sysctl(int cmd)
         return avc_unknown_permission("sysctl", cmd);
     }
 }
+#endif /* CONFIG_SYSCTL */
 
 static int cf_check flask_readconsole(uint32_t clear)
 {
@@ -1884,7 +1886,9 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
     .sysctl_scheduler_op = flask_sysctl_scheduler_op,
     .set_target = flask_set_target,
     .domctl = flask_domctl,
+#ifdef CONFIG_SYSCTL
     .sysctl = flask_sysctl,
+#endif
     .readconsole = flask_readconsole,
 
     .evtchn_unbound = flask_evtchn_unbound,
Signature · 1 line
2.34.1
#3 lore raw

PATCH v8 2/7 xen/sysctl: wrap around XEN_SYSCTL_readconsole

In reply to Penny Zheng

The following functions is to deal with XEN_SYSCTL_readconsole sub-op, and shall be wrapped:
- xsm_readconsole()
- read_console_ring()

---
v2 -> v3:
- move #endif up ahead of the blank line
---
v3 -> v4:
- remove transient "#ifdef CONFIG_SYSCTL"

---
 xen/drivers/char/console.c | 2 ++
 xen/include/xsm/xsm.h      | 4 ++++
 xen/xsm/dummy.c            | 2 +-
 xen/xsm/flask/hooks.c      | 4 ++--
 4 files changed, 9 insertions(+), 3 deletions(-)
xen/drivers/char/console.c +2 -0
index ba5a809a99..c5afac9f72 100644
@@ -368,6 +368,7 @@ static void conring_puts(const char *str, size_t len)
         conringc = conringp - conring_size;
 }
 
+#ifdef CONFIG_SYSCTL
 long read_console_ring(struct xen_sysctl_readconsole *op)
 {
     XEN_GUEST_HANDLE_PARAM(char) str;
@@ -410,6 +411,7 @@ long read_console_ring(struct xen_sysctl_readconsole *op)
 
     return 0;
 }
+#endif /* CONFIG_SYSCTL */
 
 
 /*
xen/include/xsm/xsm.h +4 -0
index 22e2429f52..042a99449f 100644
@@ -270,7 +270,11 @@ static inline int xsm_sysctl(xsm_default_t def, int cmd)
 
 static inline int xsm_readconsole(xsm_default_t def, uint32_t clear)
 {
+#ifdef CONFIG_SYSCTL
     return alternative_call(xsm_ops.readconsole, clear);
+#else
+    return -EOPNOTSUPP;
+#endif
 }
 
 static inline int xsm_evtchn_unbound(
xen/xsm/dummy.c +1 -1
index 93a0665ecc..cd0e844fcf 100644
@@ -24,8 +24,8 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
     .domctl                        = xsm_domctl,
 #ifdef CONFIG_SYSCTL
     .sysctl                        = xsm_sysctl,
-#endif
     .readconsole                   = xsm_readconsole,
+#endif
 
     .evtchn_unbound                = xsm_evtchn_unbound,
     .evtchn_interdomain            = xsm_evtchn_interdomain,
xen/xsm/flask/hooks.c +2 -2
index 3a43e5a1d6..df7e10775b 100644
@@ -934,7 +934,6 @@ static int cf_check flask_sysctl(int cmd)
         return avc_unknown_permission("sysctl", cmd);
     }
 }
-#endif /* CONFIG_SYSCTL */
 
 static int cf_check flask_readconsole(uint32_t clear)
 {
@@ -945,6 +944,7 @@ static int cf_check flask_readconsole(uint32_t clear)
 
     return domain_has_xen(current->domain, perms);
 }
+#endif /* CONFIG_SYSCTL */
 
 static inline uint32_t resource_to_perm(uint8_t access)
 {
@@ -1888,8 +1888,8 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
     .domctl = flask_domctl,
 #ifdef CONFIG_SYSCTL
     .sysctl = flask_sysctl,
-#endif
     .readconsole = flask_readconsole,
+#endif
 
     .evtchn_unbound = flask_evtchn_unbound,
     .evtchn_interdomain = flask_evtchn_interdomain,
Signature · 1 line
2.34.1
Acked-by on v8 2/7
#4 lore raw

Re: [PATCH v8 2/7] xen/sysctl: wrap around XEN_SYSCTL_readconsole

Quoted 7 lines · Penny Zheng

The following functions is to deal with XEN_SYSCTL_readconsole sub-op, and shall be wrapped:
- xsm_readconsole()
- read_console_ring()

Quoted 7 lines

---
v2 -> v3:
- move #endif up ahead of the blank line
---
v3 -> v4:
- remove transient "#ifdef CONFIG_SYSCTL"
---

#5 lore raw

PATCH v8 3/7 xen/sysctl: wrap around XEN_SYSCTL_page_offline_op

In reply to Penny Zheng

The following functions are only to deal with XEN_SYSCTL_page_offline_op, then shall be wrapped:
- xsm_page_offline()
- online_page()
- query_page_offline()

---
v1 -> v2:
- add transient #ifdef in sysctl.c for correct compilation
- no need to wrap declarations
- place the #ifdef inside the function body to have less redundancy
---
v3 -> v4:
- remove transient "#ifdef CONFIG_SYSCTL"

---
 xen/common/page_alloc.c | 2 ++
 xen/include/xsm/xsm.h   | 6 ++++++
 xen/xsm/dummy.c         | 2 ++
 xen/xsm/flask/hooks.c   | 6 ++++++
 4 files changed, 16 insertions(+)
xen/common/page_alloc.c +2 -0
index 8f93a4c354..8177d12f50 100644
@@ -1781,6 +1781,7 @@ int offline_page(mfn_t mfn, int broken, uint32_t *status)
     return 0;
 }
 
+#ifdef CONFIG_SYSCTL
 /*
  * Online the memory.
  *   The caller should make sure end_pfn <= max_page,
@@ -1865,6 +1866,7 @@ int query_page_offline(mfn_t mfn, uint32_t *status)
 
     return 0;
 }
+#endif /* CONFIG_SYSCTL */
 
 /*
  * This function should only be called with valid pages from the same NUMA
xen/include/xsm/xsm.h +6 -0
index 042a99449f..5ac99904c4 100644
@@ -138,7 +138,9 @@ struct xsm_ops {
     int (*resource_setup_gsi)(int gsi);
     int (*resource_setup_misc)(void);
 
+#ifdef CONFIG_SYSCTL
     int (*page_offline)(uint32_t cmd);
+#endif
     int (*hypfs_op)(void);
 
     long (*do_xsm_op)(XEN_GUEST_HANDLE_PARAM(void) op);
@@ -597,7 +599,11 @@ static inline int xsm_resource_setup_misc(xsm_default_t def)
 
 static inline int xsm_page_offline(xsm_default_t def, uint32_t cmd)
 {
+#ifdef CONFIG_SYSCTL
     return alternative_call(xsm_ops.page_offline, cmd);
+#else
+    return -EOPNOTSUPP;
+#endif
 }
 
 static inline int xsm_hypfs_op(xsm_default_t def)
xen/xsm/dummy.c +2 -0
index cd0e844fcf..d46413ad8c 100644
@@ -96,7 +96,9 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
     .resource_setup_gsi            = xsm_resource_setup_gsi,
     .resource_setup_misc           = xsm_resource_setup_misc,
 
+#ifdef CONFIG_SYSCTL
     .page_offline                  = xsm_page_offline,
+#endif
     .hypfs_op                      = xsm_hypfs_op,
     .hvm_param                     = xsm_hvm_param,
     .hvm_param_altp2mhvm           = xsm_hvm_param_altp2mhvm,
xen/xsm/flask/hooks.c +6 -0
index df7e10775b..45c12aa662 100644
@@ -1206,10 +1206,12 @@ static int cf_check flask_resource_unplug_core(void)
     return avc_current_has_perm(SECINITSID_DOMXEN, SECCLASS_RESOURCE, RESOURCE__UNPLUG, NULL);
 }
 
+#ifdef CONFIG_SYSCTL
 static int flask_resource_use_core(void)
 {
     return avc_current_has_perm(SECINITSID_DOMXEN, SECCLASS_RESOURCE, RESOURCE__USE, NULL);
 }
+#endif /* CONFIG_SYSCTL */
 
 static int cf_check flask_resource_plug_pci(uint32_t machine_bdf)
 {
@@ -1274,6 +1276,7 @@ static int cf_check flask_resource_setup_misc(void)
     return avc_current_has_perm(SECINITSID_XEN, SECCLASS_RESOURCE, RESOURCE__SETUP, NULL);
 }
 
+#ifdef CONFIG_SYSCTL
 static inline int cf_check flask_page_offline(uint32_t cmd)
 {
     switch ( cmd )
@@ -1288,6 +1291,7 @@ static inline int cf_check flask_page_offline(uint32_t cmd)
         return avc_unknown_permission("page_offline", cmd);
     }
 }
+#endif /* CONFIG_SYSCTL */
 
 static inline int cf_check flask_hypfs_op(void)
 {
@@ -1948,7 +1952,9 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
     .resource_setup_gsi = flask_resource_setup_gsi,
     .resource_setup_misc = flask_resource_setup_misc,
 
+#ifdef CONFIG_SYSCTL
     .page_offline = flask_page_offline,
+#endif
     .hypfs_op = flask_hypfs_op,
     .hvm_param = flask_hvm_param,
     .hvm_param_altp2mhvm = flask_hvm_param_altp2mhvm,
Signature · 1 line
2.34.1
Acked-by on v8 3/7
#6 lore raw

Re: [PATCH v8 3/7] xen/sysctl: wrap around XEN_SYSCTL_page_offline_op

Quoted 8 lines · Penny Zheng

The following functions are only to deal with XEN_SYSCTL_page_offline_op, then shall be wrapped:
- xsm_page_offline()
- online_page()
- query_page_offline()

Quoted 9 lines

---
v1 -> v2:
- add transient #ifdef in sysctl.c for correct compilation
- no need to wrap declarations
- place the #ifdef inside the function body to have less redundancy
---
v3 -> v4:
- remove transient "#ifdef CONFIG_SYSCTL"
---

#7 lore raw

PATCH v8 4/7 xen/sysctl: wrap around XEN_SYSCTL_scheduler_op

In reply to Penny Zheng

Function sched_adjust_global is designed for XEN_SYSCTL_scheduler_op, so itself and its calling flow, like .adjust_global, shall all be wrapped.

---
v1 -> v2:
- no need to wrap declarations
- add transient #ifdef in sysctl.c for correct compilation
---
v2 -> v3:
- move #endif up ahead of the blank line
---
v3 -> v4:
- remove transient "#ifdef CONFIG_SYSCTL"

---
 xen/common/sched/arinc653.c | 6 ++++++
 xen/common/sched/core.c     | 2 ++
 xen/common/sched/credit.c   | 4 ++++
 xen/common/sched/credit2.c  | 4 ++++
 xen/common/sched/private.h  | 4 ++++
 xen/include/xsm/xsm.h       | 4 ++++
 xen/xsm/dummy.c             | 2 ++
 xen/xsm/flask/hooks.c       | 4 ++++
 8 files changed, 30 insertions(+)
xen/common/sched/arinc653.c +6 -0
index 432ccfe662..3c014c9934 100644
@@ -220,6 +220,7 @@ static void update_schedule_units(const struct scheduler *ops)
                       SCHED_PRIV(ops)->schedule[i].unit_id);
 }
 
+#ifdef CONFIG_SYSCTL
 /**
  * This function is called by the adjust_global scheduler hook to put
  * in place a new ARINC653 schedule.
@@ -334,6 +335,7 @@ arinc653_sched_get(
 
     return 0;
 }
+#endif /* CONFIG_SYSCTL */
 
 /**************************************************************************
  * Scheduler callback functions                                           *
@@ -653,6 +655,7 @@ a653_switch_sched(struct scheduler *new_ops, unsigned int cpu,
     return &sr->_lock;
 }
 
+#ifdef CONFIG_SYSCTL
 /**
  * Xen scheduler callback function to perform a global (not domain-specific)
  * adjustment. It is used by the ARINC 653 scheduler to put in place a new
@@ -692,6 +695,7 @@ a653sched_adjust_global(const struct scheduler *ops,
 
     return rc;
 }
+#endif /* CONFIG_SYSCTL */
 
 /**
  * This structure defines our scheduler for Xen.
@@ -726,7 +730,9 @@ static const struct scheduler sched_arinc653_def = {
     .switch_sched   = a653_switch_sched,
 
     .adjust         = NULL,
+#ifdef CONFIG_SYSCTL
     .adjust_global  = a653sched_adjust_global,
+#endif
 
     .dump_settings  = NULL,
     .dump_cpu_state = NULL,
xen/common/sched/core.c +2 -0
index 13fdf57e57..ea95dea65a 100644
@@ -2112,6 +2112,7 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)
     return ret;
 }
 
+#ifdef CONFIG_SYSCTL
 long sched_adjust_global(struct xen_sysctl_scheduler_op *op)
 {
     struct cpupool *pool;
@@ -2140,6 +2141,7 @@ long sched_adjust_global(struct xen_sysctl_scheduler_op *op)
 
     return rc;
 }
+#endif /* CONFIG_SYSCTL */
 
 static void vcpu_periodic_timer_work_locked(struct vcpu *v)
 {
xen/common/sched/credit.c +4 -0
index a6bb321e7d..6dcf6b2c8b 100644
@@ -1256,6 +1256,7 @@ __csched_set_tslice(struct csched_private *prv, unsigned int timeslice_ms)
     prv->credit = prv->credits_per_tslice * prv->ncpus;
 }
 
+#ifdef CONFIG_SYSCTL
 static int cf_check
 csched_sys_cntl(const struct scheduler *ops,
                         struct xen_sysctl_scheduler_op *sc)
@@ -1298,6 +1299,7 @@ csched_sys_cntl(const struct scheduler *ops,
     out:
     return rc;
 }
+#endif /* CONFIG_SYSCTL */
 
 static void *cf_check
 csched_alloc_domdata(const struct scheduler *ops, struct domain *dom)
@@ -2288,7 +2290,9 @@ static const struct scheduler sched_credit_def = {
 
     .adjust         = csched_dom_cntl,
     .adjust_affinity= csched_aff_cntl,
+#ifdef CONFIG_SYSCTL
     .adjust_global  = csched_sys_cntl,
+#endif
 
     .pick_resource  = csched_res_pick,
     .do_schedule    = csched_schedule,
xen/common/sched/credit2.c +4 -0
index 0a83f23725..0b3b61df57 100644
@@ -3131,6 +3131,7 @@ csched2_aff_cntl(const struct scheduler *ops, struct sched_unit *unit,
         __clear_bit(__CSFLAG_pinned, &svc->flags);
 }
 
+#ifdef CONFIG_SYSCTL
 static int cf_check csched2_sys_cntl(
     const struct scheduler *ops, struct xen_sysctl_scheduler_op *sc)
 {
@@ -3162,6 +3163,7 @@ static int cf_check csched2_sys_cntl(
 
     return 0;
 }
+#endif /* CONFIG_SYSCTL */
 
 static void *cf_check
 csched2_alloc_domdata(const struct scheduler *ops, struct domain *dom)
@@ -4232,7 +4234,9 @@ static const struct scheduler sched_credit2_def = {
 
     .adjust         = csched2_dom_cntl,
     .adjust_affinity= csched2_aff_cntl,
+#ifdef CONFIG_SYSCTL
     .adjust_global  = csched2_sys_cntl,
+#endif
 
     .pick_resource  = csched2_res_pick,
     .migrate        = csched2_unit_migrate,
xen/common/sched/private.h +4 -0
index c0e7c96d24..d6884550cd 100644
@@ -356,8 +356,10 @@ struct scheduler {
                                     struct sched_unit *unit,
                                     const struct cpumask *hard,
                                     const struct cpumask *soft);
+#ifdef CONFIG_SYSCTL
     int          (*adjust_global)  (const struct scheduler *ops,
                                     struct xen_sysctl_scheduler_op *sc);
+#endif
     void         (*dump_settings)  (const struct scheduler *ops);
     void         (*dump_cpu_state) (const struct scheduler *ops, int cpu);
     void         (*move_timers)    (const struct scheduler *ops,
@@ -510,11 +512,13 @@ static inline int sched_adjust_dom(const struct scheduler *s, struct domain *d,
     return s->adjust ? s->adjust(s, d, op) : 0;
 }
 
+#ifdef CONFIG_SYSCTL
 static inline int sched_adjust_cpupool(const struct scheduler *s,
                                        struct xen_sysctl_scheduler_op *op)
 {
     return s->adjust_global ? s->adjust_global(s, op) : 0;
 }
+#endif
 
 static inline void sched_move_timers(const struct scheduler *s,
                                      struct sched_resource *sr)
xen/include/xsm/xsm.h +4 -0
index 5ac99904c4..6e1789c314 100644
@@ -57,7 +57,9 @@ struct xsm_ops {
     int (*domain_create)(struct domain *d, uint32_t ssidref);
     int (*getdomaininfo)(struct domain *d);
     int (*domctl_scheduler_op)(struct domain *d, int op);
+#ifdef CONFIG_SYSCTL
     int (*sysctl_scheduler_op)(int op);
+#endif
     int (*set_target)(struct domain *d, struct domain *e);
     int (*domctl)(struct domain *d, unsigned int cmd, uint32_t ssidref);
     int (*sysctl)(int cmd);
@@ -244,10 +246,12 @@ static inline int xsm_domctl_scheduler_op(
     return alternative_call(xsm_ops.domctl_scheduler_op, d, cmd);
 }
 
+#ifdef CONFIG_SYSCTL
 static inline int xsm_sysctl_scheduler_op(xsm_default_t def, int cmd)
 {
     return alternative_call(xsm_ops.sysctl_scheduler_op, cmd);
 }
+#endif
 
 static inline int xsm_set_target(
     xsm_default_t def, struct domain *d, struct domain *e)
xen/xsm/dummy.c +2 -0
index d46413ad8c..8d44f5bfb6 100644
@@ -19,7 +19,9 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
     .domain_create                 = xsm_domain_create,
     .getdomaininfo                 = xsm_getdomaininfo,
     .domctl_scheduler_op           = xsm_domctl_scheduler_op,
+#ifdef CONFIG_SYSCTL
     .sysctl_scheduler_op           = xsm_sysctl_scheduler_op,
+#endif
     .set_target                    = xsm_set_target,
     .domctl                        = xsm_domctl,
 #ifdef CONFIG_SYSCTL
xen/xsm/flask/hooks.c +4 -0
index 45c12aa662..a7cb33a718 100644
@@ -626,6 +626,7 @@ static int cf_check flask_domctl_scheduler_op(struct domain *d, int op)
     }
 }
 
+#ifdef CONFIG_SYSCTL
 static int cf_check flask_sysctl_scheduler_op(int op)
 {
     switch ( op )
@@ -640,6 +641,7 @@ static int cf_check flask_sysctl_scheduler_op(int op)
         return avc_unknown_permission("sysctl_scheduler_op", op);
     }
 }
+#endif /* CONFIG_SYSCTL */
 
 static int cf_check flask_set_target(struct domain *d, struct domain *t)
 {
@@ -1887,7 +1889,9 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
     .domain_create = flask_domain_create,
     .getdomaininfo = flask_getdomaininfo,
     .domctl_scheduler_op = flask_domctl_scheduler_op,
+#ifdef CONFIG_SYSCTL
     .sysctl_scheduler_op = flask_sysctl_scheduler_op,
+#endif
     .set_target = flask_set_target,
     .domctl = flask_domctl,
 #ifdef CONFIG_SYSCTL
Signature · 1 line
2.34.1
Acked-by on v8 4/7
#9 lore raw

Re: [PATCH v8 4/7] xen/sysctl: wrap around XEN_SYSCTL_scheduler_op

In reply to Penny Zheng
Quoted 6 lines · Penny Zheng

Function sched_adjust_global is designed for XEN_SYSCTL_scheduler_op, so itself and its calling flow, like .adjust_global, shall all be wrapped.

Quoted 11 lines

---
v1 -> v2:
- no need to wrap declarations
- add transient #ifdef in sysctl.c for correct compilation
---
v2 -> v3:
- move #endif up ahead of the blank line
---
v3 -> v4:
- remove transient "#ifdef CONFIG_SYSCTL"
---

#10 lore raw

PATCH v8 5/7 xen/sysctl: wrap around arch-specific arch_do_sysctl

In reply to Penny Zheng

Function arch_do_sysctl is to perform arch-specific sysctl op. Some functions, like psr_get_info() for x86, DTB overlay support for arm, are solely available through sysctl op, then they all shall be wrapped with CONFIG_SYSCTL

Also, remove all #ifdef CONFIG_SYSCTL-s in arch-specific sysctl.c, as we put the guardian in Makefile for the whole file.
Since PV_SHIM_EXCLUSIVE needs sorting in the future, we move obj-$(CONFIG_SYSCTL) += sysctl.o out of PV_SHIM_EXCLUSIVE condition.

---
v1 -> v2:
- use "depends on" for config OVERLAY_DTB
- no need to wrap declaration
- add transient #ifdef in sysctl.c for correct compilation
---
v2 -> v3:
- move obj-$(CONFIG_SYSCTL) += sysctl.o out of PV_SHIM_EXCLUSIVE condition
- move copyback out of #ifdef
- add #else process for default label
---
v3 -> v4:
- remove transient "#ifdef CONFIG_SYSCTL"
- move #ifdef ahead of the comment

---
 xen/arch/arm/Kconfig   |  1 +
 xen/arch/arm/Makefile  |  2 +-
 xen/arch/arm/sysctl.c  |  2 --
 xen/arch/riscv/stubs.c |  2 +-
 xen/arch/x86/Makefile  |  2 +-
 xen/arch/x86/psr.c     | 18 ++++++++++++++++++
 xen/arch/x86/sysctl.c  |  2 --
 7 files changed, 22 insertions(+), 7 deletions(-)
xen/arch/arm/Kconfig +1 -0
index 3f25da3ca5..e076419d5e 100644
@@ -139,6 +139,7 @@ config HAS_ITS
 
 config OVERLAY_DTB
 	bool "DTB overlay support (UNSUPPORTED)" if UNSUPPORTED
+	depends on SYSCTL
 	help
 	  Dynamic addition/removal of Xen device tree nodes using a dtbo.
 
xen/arch/arm/Makefile +1 -1
index ab0a0c2be6..f833cdf207 100644
@@ -51,7 +51,7 @@ obj-y += setup.o
 obj-y += shutdown.o
 obj-y += smp.o
 obj-y += smpboot.o
-obj-y += sysctl.o
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += time.o
 obj-y += traps.o
 obj-y += vcpreg.o
xen/arch/arm/sysctl.c +0 -2
index 2d350b700a..32cab4feff 100644
@@ -15,7 +15,6 @@
 #include <asm/arm64/sve.h>
 #include <public/sysctl.h>
 
-#ifdef CONFIG_SYSCTL
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
 {
     pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm | XEN_SYSCTL_PHYSCAP_hap;
@@ -23,7 +22,6 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
     pi->arch_capabilities |= MASK_INSR(sve_encode_vl(get_sys_vl_len()),
                                        XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK);
 }
-#endif
 
 long arch_do_sysctl(struct xen_sysctl *sysctl,
                     XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
xen/arch/riscv/stubs.c +1 -1
index f86a1c17cb..8918cebf35 100644
@@ -302,6 +302,7 @@ unsigned long raw_copy_from_guest(void *to, const void __user *from,
     BUG_ON("unimplemented");
 }
 
+#ifdef CONFIG_SYSCTL
 /* sysctl.c */
 
 long arch_do_sysctl(struct xen_sysctl *sysctl,
@@ -310,7 +311,6 @@ long arch_do_sysctl(struct xen_sysctl *sysctl,
     BUG_ON("unimplemented");
 }
 
-#ifdef CONFIG_SYSCTL
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
 {
     BUG_ON("unimplemented");
xen/arch/x86/Makefile +1 -1
index ce724a9daa..96d63219e7 100644
@@ -63,6 +63,7 @@ obj-y += smpboot.o
 obj-y += spec_ctrl.o
 obj-y += srat.o
 obj-y += string.o
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += time.o
 obj-y += traps-setup.o
 obj-y += traps.o
@@ -78,7 +79,6 @@ ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
 obj-y += domctl.o
 obj-y += platform_hypercall.o
 obj-$(CONFIG_COMPAT) += x86_64/platform_hypercall.o
-obj-y += sysctl.o
 endif
 
 extra-y += asm-macros.i
xen/arch/x86/psr.c +18 -0
index 5815a35335..499d320e61 100644
@@ -133,9 +133,11 @@ static const struct feat_props {
      */
     enum psr_type alt_type;
 
+#ifdef CONFIG_SYSCTL
     /* get_feat_info is used to return feature HW info through sysctl. */
     bool (*get_feat_info)(const struct feat_node *feat,
                           uint32_t data[], unsigned int array_len);
+#endif
 
     /* write_msr is used to write out feature MSR register. */
     void (*write_msr)(unsigned int cos, uint32_t val, enum psr_type type);
@@ -418,6 +420,7 @@ static bool mba_init_feature(const struct cpuid_leaf *regs,
     return true;
 }
 
+#ifdef CONFIG_SYSCTL
 static bool cf_check cat_get_feat_info(
     const struct feat_node *feat, uint32_t data[], unsigned int array_len)
 {
@@ -430,6 +433,7 @@ static bool cf_check cat_get_feat_info(
 
     return true;
 }
+#endif /* CONFIG_SYSCTL */
 
 /* L3 CAT props */
 static void cf_check l3_cat_write_msr(
@@ -442,11 +446,14 @@ static const struct feat_props l3_cat_props = {
     .cos_num = 1,
     .type[0] = PSR_TYPE_L3_CBM,
     .alt_type = PSR_TYPE_UNKNOWN,
+#ifdef CONFIG_SYSCTL
     .get_feat_info = cat_get_feat_info,
+#endif
     .write_msr = l3_cat_write_msr,
     .sanitize = cat_check_cbm,
 };
 
+#ifdef CONFIG_SYSCTL
 /* L3 CDP props */
 static bool cf_check l3_cdp_get_feat_info(
     const struct feat_node *feat, uint32_t data[], uint32_t array_len)
@@ -458,6 +465,7 @@ static bool cf_check l3_cdp_get_feat_info(
 
     return true;
 }
+#endif /* CONFIG_SYSCTL */
 
 static void cf_check l3_cdp_write_msr(
     unsigned int cos, uint32_t val, enum psr_type type)
@@ -473,7 +481,9 @@ static const struct feat_props l3_cdp_props = {
     .type[0] = PSR_TYPE_L3_DATA,
     .type[1] = PSR_TYPE_L3_CODE,
     .alt_type = PSR_TYPE_L3_CBM,
+#ifdef CONFIG_SYSCTL
     .get_feat_info = l3_cdp_get_feat_info,
+#endif
     .write_msr = l3_cdp_write_msr,
     .sanitize = cat_check_cbm,
 };
@@ -489,11 +499,14 @@ static const struct feat_props l2_cat_props = {
     .cos_num = 1,
     .type[0] = PSR_TYPE_L2_CBM,
     .alt_type = PSR_TYPE_UNKNOWN,
+#ifdef CONFIG_SYSCTL
     .get_feat_info = cat_get_feat_info,
+#endif
     .write_msr = l2_cat_write_msr,
     .sanitize = cat_check_cbm,
 };
 
+#ifdef CONFIG_SYSCTL
 /* MBA props */
 static bool cf_check mba_get_feat_info(
     const struct feat_node *feat, uint32_t data[], unsigned int array_len)
@@ -508,6 +521,7 @@ static bool cf_check mba_get_feat_info(
 
     return true;
 }
+#endif /* CONFIG_SYSCTL */
 
 static void cf_check mba_write_msr(
     unsigned int cos, uint32_t val, enum psr_type type)
@@ -545,7 +559,9 @@ static const struct feat_props mba_props = {
     .cos_num = 1,
     .type[0] = PSR_TYPE_MBA_THRTL,
     .alt_type = PSR_TYPE_UNKNOWN,
+#ifdef CONFIG_SYSCTL
     .get_feat_info = mba_get_feat_info,
+#endif
     .write_msr = mba_write_msr,
     .sanitize = mba_sanitize_thrtl,
 };
@@ -808,6 +824,7 @@ static struct psr_socket_info *get_socket_info(unsigned int socket)
     return socket_info + socket;
 }
 
+#ifdef CONFIG_SYSCTL
 int psr_get_info(unsigned int socket, enum psr_type type,
                  uint32_t data[], unsigned int array_len)
 {
@@ -839,6 +856,7 @@ int psr_get_info(unsigned int socket, enum psr_type type,
 
     return -EINVAL;
 }
+#endif /* CONFIG_SYSCTL */
 
 int psr_get_val(struct domain *d, unsigned int socket,
                 uint32_t *val, enum psr_type type)
xen/arch/x86/sysctl.c +0 -2
index f64addbe2b..1b04947516 100644
@@ -91,7 +91,6 @@ static long cf_check smt_up_down_helper(void *data)
     return ret;
 }
 
-#ifdef CONFIG_SYSCTL
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
 {
     memcpy(pi->hw_cap, boot_cpu_data.x86_capability,
@@ -105,7 +104,6 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
     if ( IS_ENABLED(CONFIG_SHADOW_PAGING) )
         pi->capabilities |= XEN_SYSCTL_PHYSCAP_shadow;
 }
-#endif /* CONFIG_SYSCTL */
 
 long arch_do_sysctl(
     struct xen_sysctl *sysctl, XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
Signature · 1 line
2.34.1
#11 lore raw

PATCH v8 6/7 xen/x86: remove "depends on !PV_SHIM_EXCLUSIVE"

In reply to Penny Zheng

Remove all "depends on !PV_SHIM_EXCLUSIVE" (also the functionally equivalent "if !...") in Kconfig file, since negative dependancy will badly affect allyesconfig. Although "if !PV_SHIM_EXCLUSIVE" for CONFIG_VGA is not truly a dependency, setting PV_SHIM_EXCLUSIVE y still makes it unconfigurable. So we remove it here too

Add "#CONFIG_xxx is not set" for above options in presets for x86 PV shim, as the explicit declaration is to ephasize setting for the shim is different from the general default.

---
This commit shall be commited together with the next one, which is also the last commit.
---
v2 -> v3:
- remove comment for PV_SHIM_EXCLUSIVE
---
v3 -> v4:
- explicitly state "CONFIG_xxx is not set" in "pvshim_defconfig"
- Add "default y" for SHADOW_PAGING and TBOOT
- refactor commit message
---
v4 -> v5:
- For not breaking allyesconfig, changes to defaults are actually not needed. So remove them all
- Leave one blank lines
---
v5 -> v6
- add description for change: removing "if !PV_SHIM_EXCLUSIVE" for CONFIG_VGA

---
 xen/arch/x86/Kconfig      | 4 ----
 xen/arch/x86/hvm/Kconfig  | 1 -
 xen/drivers/video/Kconfig | 2 +-
 3 files changed, 1 insertion(+), 6 deletions(-)
xen/arch/x86/Kconfig +0 -4
index 9ec0fb0bed..a45ce106e2 100644
@@ -303,8 +303,6 @@ config PV_SHIM_EXCLUSIVE
 
 	  If unsure, say N.
 
-if !PV_SHIM_EXCLUSIVE
-
 config HYPERV_GUEST
 	bool "Hyper-V Guest"
 	select GUEST
@@ -313,8 +311,6 @@ config HYPERV_GUEST
 
 	  If unsure, say N.
 
-endif
-
 config REQUIRE_NX
 	bool "Require NX (No eXecute) support"
 	help
xen/arch/x86/hvm/Kconfig +0 -1
index 2def0f98e2..b903764bda 100644
@@ -1,6 +1,5 @@
 menuconfig HVM
 	bool "HVM support"
-	depends on !PV_SHIM_EXCLUSIVE
 	default !PV_SHIM
 	select COMPAT
 	select IOREQ_SERVER
xen/drivers/video/Kconfig +1 -1
index 245030beea..0a51e87eb2 100644
@@ -3,7 +3,7 @@ config VIDEO
 	bool
 
 config VGA
-	bool "VGA support" if !PV_SHIM_EXCLUSIVE
+	bool "VGA support"
 	select VIDEO
 	depends on X86
 	default y if !PV_SHIM_EXCLUSIVE
Signature · 1 line
2.34.1
#12 lore raw

PATCH v8 7/7 xen/sysctl: wrap around sysctl hypercall

In reply to Penny Zheng

From: Stefano Stabellini <[email protected]>

Wrap sysctl hypercall def and sysctl.o with CONFIG_SYSCTL, and since PV_SHIM_EXCLUSIVE needs sorting in the future, we move them out of PV_SHIM_EXCLUSIVE condition at the same time.

We need to make SYSCTL with prompt back, add help info and set default value as y. We shall at least provide "# CONFIG_SYSCTL is not set" in preset configs for PV shim on x86. With that, all dependent option get covered and could be deleted.

---
v1 -> v2:
- remove all transient "#ifdef CONFIG_SYSCTL"-s in sysctl.c
---
v2 -> v3:
- move out of CONFIG_PV_SHIM_EXCLUSIVE condition
---
v3 -> v4:
- make SYSCTL with prompt
- state unsetting SYSCTL in pvshim_defconfig
---
v4 -> v5:
- adapt to the new changes in commit "xen: introduce CONFIG_SYSCTL"
- expand help info also for PV shim
- refactor commit message
---
v7 -> v8
- remove TRACEBUFFER, PM_OP, PM_STATS, LIVEPATCH entry in pvshim_defconfig

---
 xen/arch/x86/configs/pvshim_defconfig | 5 +----
 xen/common/Kconfig                    | 6 +++++-
 xen/common/Makefile                   | 2 +-
 xen/include/hypercall-defs.c          | 8 ++++++--
 4 files changed, 13 insertions(+), 8 deletions(-)
xen/arch/x86/configs/pvshim_defconfig +1 -4
index 9dc91c33e3..c58c29adb0 100644
@@ -19,12 +19,9 @@ CONFIG_EXPERT=y
 # CONFIG_SCHED_CREDIT2 is not set
 # CONFIG_SCHED_RTDS is not set
 # CONFIG_SCHED_ARINC653 is not set
-# CONFIG_LIVEPATCH is not set
 # CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS is not set
-# CONFIG_TRACEBUFFER is not set
 # CONFIG_AMD_IOMMU is not set
 # CONFIG_INTEL_IOMMU is not set
 # CONFIG_DEBUG is not set
 # CONFIG_GDBSX is not set
-# CONFIG_PM_OP is not set
-# CONFIG_PM_STATS is not set
+# CONFIG_SYSCTL is not set
xen/common/Kconfig +5 -1
index 65f07289dd..64865112a1 100644
@@ -616,7 +616,11 @@ menu "Supported hypercall interfaces"
 	visible if EXPERT
 
 config SYSCTL
-	def_bool y
+	bool "Enable sysctl hypercall"
+	default y
+	help
+	  This option shall only be disabled on some dom0less systems, or
+	  PV shim on x86, to reduce Xen footprint.
 
 endmenu
 
xen/common/Makefile +1 -1
index 98f0873056..15ab048244 100644
@@ -49,6 +49,7 @@ obj-y += spinlock.o
 obj-$(CONFIG_STACK_PROTECTOR) += stack-protector.o
 obj-y += stop_machine.o
 obj-y += symbols.o
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o
@@ -70,7 +71,6 @@ obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o memory.o multicall.o xlat.o
 ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
 obj-y += domctl.o
 obj-$(CONFIG_VM_EVENT) += monitor.o
-obj-y += sysctl.o
 endif
 
 extra-y := symbols-dummy.o
xen/include/hypercall-defs.c +6 -2
index 7720a29ade..c1081d87a2 100644
@@ -194,8 +194,10 @@ kexec_op(unsigned long op, void *uarg)
 #ifdef CONFIG_IOREQ_SERVER
 dm_op(domid_t domid, unsigned int nr_bufs, xen_dm_op_buf_t *bufs)
 #endif
-#ifndef CONFIG_PV_SHIM_EXCLUSIVE
+#ifdef CONFIG_SYSCTL
 sysctl(xen_sysctl_t *u_sysctl)
+#endif
+#ifndef CONFIG_PV_SHIM_EXCLUSIVE
 domctl(xen_domctl_t *u_domctl)
 paging_domctl_cont(xen_domctl_t *u_domctl)
 platform_op(xen_platform_op_t *u_xenpf_op)
@@ -273,8 +275,10 @@ physdev_op                         compat   do       hvm      hvm      do_arm
 #ifdef CONFIG_HVM
 hvm_op                             do       do       do       do       do
 #endif
-#ifndef CONFIG_PV_SHIM_EXCLUSIVE
+#ifdef CONFIG_SYSCTL
 sysctl                             do       do       do       do       do
+#endif
+#ifndef CONFIG_PV_SHIM_EXCLUSIVE
 domctl                             do       do       do       do       do
 #endif
 #ifdef CONFIG_KEXEC
Signature · 1 line
2.34.1
Reviewed-by on v8 7/7
#13 lore raw

Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 11 lines · Penny Zheng

From: Stefano Stabellini <[email protected]>

Wrap sysctl hypercall def and sysctl.o with CONFIG_SYSCTL, and since PV_SHIM_EXCLUSIVE needs sorting in the future, we move them out of PV_SHIM_EXCLUSIVE condition at the same time.

We need to make SYSCTL with prompt back, add help info and set default value as y. We shall at least provide "# CONFIG_SYSCTL is not set" in preset configs for PV shim on x86. With that, all dependent option get covered and could be deleted.

Quoted 4 lines
#14 lore raw

Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

In reply to Penny Zheng
Quoted 11 lines · Penny Zheng
xen/common/Makefile +1 -0
@@ -49,6 +49,7 @@ obj-y += spinlock.o
 obj-$(CONFIG_STACK_PROTECTOR) += stack-protector.o
 obj-y += stop_machine.o
 obj-y += symbols.o
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o

xen/common/Makefile obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o memory.o multicall.o xlat.o · line 76

Quoted 7 lines
xen/common/Makefile +0 -1
@@ -70,7 +71,6 @@ obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o memory.o multicall.o xlat.o
 ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
 obj-y += domctl.o
 obj-$(CONFIG_VM_EVENT) += monitor.o
-obj-y += sysctl.o
 endif
 
 extra-y := symbols-dummy.o

CI demonstrates that this combination of changes is wrong. The job that failed (debian-12-x86_64-gcc-ibt) is a randconfig one, and ended up picking both SYSCTL=y and PV_SHIM_EXCLUSIVE=y. Which results in sysctl.c being built, but domctl.c not being built. Which leaves getdomaininfo() undefined, causing linking to fail. In case the next pipeline also ends up failing, I'll simply revert that change. In case it succeeds, not reverting may be an option, as long as a proper fix shows up pretty quickly.

Jan

#15 lore raw

RE: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

[Public]

Quoted 30 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Thursday, July 17, 2025 4:55 PM
To: Penny, Zheng <[email protected]>; Stabellini, Stefano <[email protected]>
Cc: Huang, Ray <[email protected]>; Stefano Stabellini <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Sergiy Kibrik <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 16 lines · Penny Zheng
xen/common/Makefile +0 -0
@@ -49,6 +49,7 @@ obj-y += spinlock.o
 obj-$(CONFIG_STACK_PROTECTOR) += stack-protector.o  obj-y +=

stop_machine.o obj-y += symbols.o

xen/common/Makefile +1 -0
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o
@@ -70,7 +71,6 @@ obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o
 memory.o multicall.o xlat.o  ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)

obj-y += domctl.o
obj-$(CONFIG_VM_EVENT) += monitor.o
-obj-y += sysctl.o
endif

Quoted 10 lines
Quoted 1 line

extra-y := symbols-dummy.o

CI demonstrates that this combination of changes is wrong. The job that failed (debian-12-x86_64-gcc-ibt) is a randconfig one, and ended up picking both SYSCTL=y and PV_SHIM_EXCLUSIVE=y. Which results in sysctl.c being built, but domctl.c not being built. Which leaves getdomaininfo() undefined, causing linking to fail. In case the next pipeline also ends up failing, I'll simply revert that change. In case it succeeds, not reverting may be an option, as long as a proper fix shows up pretty quickly.

I've push commit of " xen: move getdomaininfo() to domain.c " to try to fix the error.

Quoted 1 line

Jan

#16 lore raw

Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 42 lines · Zheng

[Public]

Quoted 30 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Thursday, July 17, 2025 4:55 PM
To: Penny, Zheng <[email protected]>; Stabellini, Stefano <[email protected]>
Cc: Huang, Ray <[email protected]>; Stefano Stabellini <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Sergiy Kibrik <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 16 lines · Penny Zheng
xen/common/Makefile +0 -0
@@ -49,6 +49,7 @@ obj-y += spinlock.o
 obj-$(CONFIG_STACK_PROTECTOR) += stack-protector.o  obj-y +=

stop_machine.o obj-y += symbols.o

xen/common/Makefile +1 -0
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o
@@ -70,7 +71,6 @@ obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o
 memory.o multicall.o xlat.o  ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)

obj-y += domctl.o
obj-$(CONFIG_VM_EVENT) += monitor.o
-obj-y += sysctl.o
endif

Quoted 9 lines
Quoted 1 line

extra-y := symbols-dummy.o

CI demonstrates that this combination of changes is wrong. The job that failed (debian-12-x86_64-gcc-ibt) is a randconfig one, and ended up picking both SYSCTL=y and PV_SHIM_EXCLUSIVE=y. Which results in sysctl.c being built, but domctl.c not being built. Which leaves getdomaininfo() undefined, causing linking to fail. In case the next pipeline also ends up failing, I'll simply revert that change. In case it succeeds, not reverting may be an option, as long as a proper fix shows up pretty quickly.

Quoted 1 line

I've push commit of " xen: move getdomaininfo() to domain.c " to try to fix the error.

And you're reasonably certain that's the only issue? I ask because it is the nature of randconfig to pick random combinations of settings; on a later pipeline I had seen a different failure. I didn't look at that in detail (it may have had to do with the domctl lock or something vaguely similar), which perhaps was a mistake.

Jan

#17 lore raw

RE: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

[Public]

Quoted 55 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Tuesday, July 22, 2025 1:33 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; Stefano Stabellini <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Sergiy Kibrik <[email protected]>; xen- [email protected]; Stabellini, Stefano <[email protected]>
Subject: Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 40 lines · Zheng

[Public]

Quoted 38 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Thursday, July 17, 2025 4:55 PM
To: Penny, Zheng <[email protected]>; Stabellini, Stefano <[email protected]>
Cc: Huang, Ray <[email protected]>; Stefano Stabellini <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Sergiy Kibrik <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 14 lines · Penny Zheng
xen/common/Makefile +0 -0
@@ -49,6 +49,7 @@ obj-y += spinlock.o
 obj-$(CONFIG_STACK_PROTECTOR) += stack-protector.o  obj-y +=

stop_machine.o obj-y += symbols.o

xen/common/Makefile +1 -0
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o
@@ -70,7 +71,6 @@ obj-$(CONFIG_COMPAT) += $(addprefix

compat/,domain.o memory.o multicall.o xlat.o ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) obj-y += domctl.o
obj-$(CONFIG_VM_EVENT) += monitor.o -obj-y += sysctl.o endif

Quoted 1 line

extra-y := symbols-dummy.o

CI demonstrates that this combination of changes is wrong. The job that failed
(debian-12-x86_64-gcc-ibt) is a randconfig one, and ended up picking both SYSCTL=y and PV_SHIM_EXCLUSIVE=y. Which results in sysctl.c being built, but domctl.c not being built. Which leaves getdomaininfo() undefined, causing linking to fail. In case the next pipeline also ends up failing, I'll simply revert that change. In case it succeeds, not reverting may be an option, as long as a proper fix shows

up pretty quickly.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

I've push commit of " xen: move getdomaininfo() to domain.c " to try to fix the

error.

And you're reasonably certain that's the only issue? I ask because it is the nature of randconfig to pick random combinations of settings; on a later pipeline I had seen a different failure. I didn't look at that in detail (it may have had to do with the domctl lock or something vaguely similar), which perhaps was a mistake.

I turned on HVM, HYPERV_GUEST, and VGA when PV_SHIM_EXCLUSIVE is on to track down more linking issues
All undefined link failure is due to removing PV_SHIM_EXCLUSIVE dependency for CONFIG_HVM, like monitor_traps, domctl_lock_acquire/domctl_lock_release, etc I suggest to move domctl_lock_acquire/domctl_lock_release out of domctl.c too, and also "obj-$(CONFIG_VM_EVENT) += monitor.o" out of PV_SHIM_EXCLUSIVE guard And above change, fwit, is to fix commit of " xen/x86: remove "depends on !PV_SHIM_EXCLUSIVE" "

Quoted 1 line

Jan

#18 lore raw

Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 60 lines · Zheng

[Public]

Quoted 58 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Tuesday, July 22, 2025 1:33 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; Stefano Stabellini <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Sergiy Kibrik <[email protected]>; xen- [email protected]; Stabellini, Stefano <[email protected]>
Subject: Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 40 lines · Zheng

[Public]

Quoted 38 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Thursday, July 17, 2025 4:55 PM
To: Penny, Zheng <[email protected]>; Stabellini, Stefano <[email protected]>
Cc: Huang, Ray <[email protected]>; Stefano Stabellini <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Sergiy Kibrik <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v8 7/7] xen/sysctl: wrap around sysctl hypercall

Quoted 14 lines · Penny Zheng
xen/common/Makefile +0 -0
@@ -49,6 +49,7 @@ obj-y += spinlock.o
 obj-$(CONFIG_STACK_PROTECTOR) += stack-protector.o  obj-y +=

stop_machine.o obj-y += symbols.o

xen/common/Makefile +1 -0
+obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o
@@ -70,7 +71,6 @@ obj-$(CONFIG_COMPAT) += $(addprefix

compat/,domain.o memory.o multicall.o xlat.o ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) obj-y += domctl.o
obj-$(CONFIG_VM_EVENT) += monitor.o -obj-y += sysctl.o endif

Quoted 1 line

extra-y := symbols-dummy.o

CI demonstrates that this combination of changes is wrong. The job that failed
(debian-12-x86_64-gcc-ibt) is a randconfig one, and ended up picking both SYSCTL=y and PV_SHIM_EXCLUSIVE=y. Which results in sysctl.c being built, but domctl.c not being built. Which leaves getdomaininfo() undefined, causing linking to fail. In case the next pipeline also ends up failing, I'll simply revert that change. In case it succeeds, not reverting may be an option, as long as a proper fix shows

up pretty quickly.

Quoted 2 lines

I've push commit of " xen: move getdomaininfo() to domain.c " to try to fix the

error.

Quoted 8 lines
Quoted 4 lines

And you're reasonably certain that's the only issue? I ask because it is the nature of randconfig to pick random combinations of settings; on a later pipeline I had seen a different failure. I didn't look at that in detail (it may have had to do with the domctl lock or something vaguely similar), which perhaps was a mistake.

I turned on HVM, HYPERV_GUEST, and VGA when PV_SHIM_EXCLUSIVE is on to track down more linking issues
All undefined link failure is due to removing PV_SHIM_EXCLUSIVE dependency for CONFIG_HVM, like monitor_traps, domctl_lock_acquire/domctl_lock_release, etc I suggest to move domctl_lock_acquire/domctl_lock_release out of domctl.c too, and also "obj-$(CONFIG_VM_EVENT) += monitor.o" out of PV_SHIM_EXCLUSIVE guard

I'm not convinced of that approach; I'm curious what others think. One alternative would appear to be to have SYSCTL depend on DOMCTL (the latter yet to be introduced). As it stands, my vote would go towards reverting the final one or two patches. It's not entirely clear to me though why you say ...

Quoted 1 line

And above change, fwit, is to fix commit of " xen/x86: remove "depends on !PV_SHIM_EXCLUSIVE" "

... this. My understanding is that the issue became manifest with "xen/sysctl: wrap around sysctl hypercall", i.e. reverting just that one would suffice at least for the getdomaininfo() issue. Yet then "above" is ambiguous here, and hence may mean the domctl lock issue. Which then would indeed suggest we need to revert both.

Jan

#19 lore raw
In reply to Penny Zheng

Heads up, I intend to commit this series shortly as it has been thoroughly reviewed by multiple people and has been on the list for a long time now.

Quoted 66 lines · Penny Zheng

It can be beneficial for some dom0less systems to further reduce Xen footprint via disabling some hypercalls handling code, which may not to be used & required in such systems. Each hypercall has a separate option to keep configuration flexible.

Options to disable hypercalls:
- sysctl
- domctl
- hvm
- physdev
- platform

This patch serie is only focusing on introducing CONFIG_SYSCTL. Different options will be covered in different patch serie.

Features, like LIVEPATCH, Overlay DTB, which fully rely on sysctl op, will be wrapped with CONFIG_SYSCTL, to reduce Xen footprint as much as possible.

It is derived from Stefano Stabellini's commit "xen: introduce kconfig options to disable hypercalls"(
https://lore.kernel.org/xen-devel/[email protected])

---
Commit "xen/x86: remove "depends on !PV_SHIM_EXCLUSIVE"" and commit " xen/sysctl: wrap around sysctl hypercall" shall be commited together.
---
Penny Zheng (6):
xen/xsm: wrap around xsm_sysctl with CONFIG_SYSCTL xen/sysctl: wrap around XEN_SYSCTL_readconsole xen/sysctl: wrap around XEN_SYSCTL_page_offline_op xen/sysctl: wrap around XEN_SYSCTL_scheduler_op xen/sysctl: wrap around arch-specific arch_do_sysctl xen/x86: remove "depends on !PV_SHIM_EXCLUSIVE"

Stefano Stabellini (1):
xen/sysctl: wrap around sysctl hypercall

 xen/arch/arm/Kconfig                  |  1 +
 xen/arch/arm/Makefile                 |  2 +-
 xen/arch/arm/sysctl.c                 |  2 --
 xen/arch/riscv/stubs.c                |  2 +-
 xen/arch/x86/Kconfig                  |  4 ----
 xen/arch/x86/Makefile                 |  2 +-
 xen/arch/x86/configs/pvshim_defconfig |  5 +----
 xen/arch/x86/hvm/Kconfig              |  1 -
 xen/arch/x86/psr.c                    | 18 ++++++++++++++++++
 xen/arch/x86/sysctl.c                 |  2 --
 xen/common/Kconfig                    |  6 +++++-
 xen/common/Makefile                   |  2 +-
 xen/common/page_alloc.c               |  2 ++
 xen/common/sched/arinc653.c           |  6 ++++++
 xen/common/sched/core.c               |  2 ++
 xen/common/sched/credit.c             |  4 ++++
 xen/common/sched/credit2.c            |  4 ++++
 xen/common/sched/private.h            |  4 ++++
 xen/drivers/char/console.c            |  2 ++
 xen/drivers/video/Kconfig             |  2 +-
 xen/include/hypercall-defs.c          |  8 ++++++--
 xen/include/xsm/xsm.h                 | 18 ++++++++++++++++++
 xen/xsm/dummy.c                       |  6 ++++++
 xen/xsm/flask/hooks.c                 | 14 ++++++++++++++
 24 files changed, 98 insertions(+), 21 deletions(-)
Signature · 1 line
2.34.1
#20 lore raw
Quoted 3 lines · Stefano Stabellini

Heads up, I intend to commit this series shortly as it has been thoroughly reviewed by multiple people and has been on the list for a long time now.

I would have already committed it if it had all necessary acks. XSM ones in particular are missing.

Jan

#21 lore raw
Quoted 7 lines · Jan Beulich
Quoted 3 lines · Stefano Stabellini

Heads up, I intend to commit this series shortly as it has been thoroughly reviewed by multiple people and has been on the list for a long time now.

I would have already committed it if it had all necessary acks. XSM ones in particular are missing.

While the XSM acks did arrive, you still committed part of this series not fully ack-ed. As much as I can understand your eagerness, I think chasing all necessary acks is important. If nothing else, then to avoid after-the- fact discussions (as I could see happening for the second to last patch of the series).

Jan