Disable domctl-op via CONFIG_MGMT_HYPERCALLS
v4 cover Disable domctl-op via CONFIG_MGMT_HYPERCALLS
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.
We are introducing a new single Kconfig CONFIG_MGMT_HYPERCALLS to manage such hypercalls.
We are trying to disable hypercalls in the following aspects:
- sysctl
- domctl
- hvm
- physdev
- platform
This patch serie is only focusing on domctl-op. Different aspects will be covered in different patch serie.
Features, like VM event, or paging log-dirty support, which fully rely on domctl-op, will be wrapped with CONFIG_MGMT_HYPERCALLS, 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])
---
This patch serie is based on two patch serie, one is
"[XEN][PATCH v4] xen: make VMTRACE support optional" and "
[PATCH v3 0/7] consolidate vm event subsystem"
---
Penny Zheng (24):
xen/xsm: remove redundant xsm_iomem_mapping()
xen: consolidate cpuid library
xen/sysctl: replace CONFIG_SYSCTL with CONFIG_MGMT_HYPERCALLS xen/domctl: make MGMT_HYPERCALLS transiently def_bool xen/vm_event: make VM_EVENT depend on CONFIG_MGMT_HYPERCALLS xen/domctl: consolidate domain.c with MGMT_HYPERCALLS xen/mem_sharing: make memory sharing depend on MGMT_HYPERCALLS xen/domctl: wrap domain_kill() with CONFIG_MGMT_HYPERCALLS xen/domctl: wrap vcpu_affinity_domctl() with CONFIG_MGMT_HYPERCALLS xen/domctl: wrap sched_adjust() with CONFIG_MGMT_HYPERCALLS xen/domctl: wrap xsm_irq_permission with CONFIG_MGMT_HYPERCALLS xen/domctl: wrap arch-specific domain_set_time_offset() with
CONFIG_MGMT_HYPERCALLS
xen/domctl: wrap xsm_set_target() with CONFIG_MGMT_HYPERCALLS xen/domctl: wrap pci-subset iommu-related domctl op with
CONFIG_MGMT_HYPERCALLS
xen/domctl: wrap device-tree-subset iommu-related domctl op with
CONFIG_MGMT_HYPERCALLS
xen/domctl: wrap iommu-related domctl op with CONFIG_MGMT_HYPERCALLS xen/domctl: wrap arch_{get,set}_paging_mempool_size() with
CONFIG_MGMT_HYPERCALLS
xen/domctl: make CONFIG_X86_PSR depend on CONFIG_MGMT_HYPERCALLS xen/domctl: wrap hvm_save{,load} with CONFIG_MGMT_HYPERCALLS xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS xen/arm: wrap arm-specific domctl-op with CONFIG_MGMT_HYPERCALLS xen/domctl: domctl_lock synchronization only when MGMT_HYPERCALLS=y xen/domctl: wrap common/domctl.c with CONFIG_MGMT_HYPERCALLS
xen: move MGMT_HYPERCALLS out of PV_SHIM_EXCLUSIVE
tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/Kconfig.debug | 3 +- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/Makefile | 4 +- xen/arch/arm/arm32/Makefile | 2 +- xen/arch/arm/arm64/Makefile | 2 +- xen/arch/arm/domain.c | 3 + xen/arch/arm/include/asm/tee/tee.h | 2 + xen/arch/arm/mmu/p2m.c | 8 + xen/arch/arm/mpu/p2m.c | 2 + xen/arch/arm/tee/ffa.c | 4 + xen/arch/arm/tee/optee.c | 4 + xen/arch/arm/tee/tee.c | 2 + xen/arch/arm/time.c | 2 + xen/arch/ppc/stubs.c | 2 + xen/arch/riscv/stubs.c | 8 +- xen/arch/x86/Kconfig | 3 +- xen/arch/x86/Makefile | 4 +- xen/arch/x86/configs/pvshim_defconfig | 2 +- xen/arch/x86/domain.c | 2 + xen/arch/x86/emul-i8254.c | 2 + xen/arch/x86/hvm/Kconfig | 3 +- xen/arch/x86/hvm/hvm.c | 7 +- xen/arch/x86/hvm/pmtimer.c | 2 + xen/arch/x86/hvm/save.c | 154 +++++------ xen/arch/x86/include/asm/p2m.h | 2 +- xen/arch/x86/include/asm/paging.h | 2 +- xen/arch/x86/mm/p2m-pod.c | 2 + xen/arch/x86/mm/p2m.c | 2 + xen/arch/x86/mm/paging.c | 4 + xen/arch/x86/psr.c | 18 -- xen/arch/x86/time.c | 2 + xen/common/Kconfig | 28 +- xen/common/Makefile | 7 +- xen/common/device-tree/device-tree.c | 2 + xen/common/domain.c | 116 ++++---- xen/common/domctl.c | 2 +- xen/common/page_alloc.c | 8 +- xen/common/perfc.c | 4 +- xen/common/sched/arinc653.c | 11 +- xen/common/sched/core.c | 8 +- xen/common/sched/cpupool.c | 16 +- xen/common/sched/credit.c | 10 +- xen/common/sched/credit2.c | 10 +- xen/common/sched/private.h | 10 +- xen/common/sched/rt.c | 4 + xen/common/spinlock.c | 4 +- xen/drivers/char/console.c | 4 +- xen/drivers/passthrough/amd/pci_amd_iommu.c | 20 +- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 26 +- xen/drivers/passthrough/arm/smmu-v3.c | 4 + xen/drivers/passthrough/arm/smmu.c | 55 ++-- xen/drivers/passthrough/device_tree.c | 108 ++++---- xen/drivers/passthrough/iommu.c | 2 + xen/drivers/passthrough/pci.c | 52 ++-- xen/drivers/passthrough/vtd/iommu.c | 6 +- xen/drivers/vpci/header.c | 2 +- xen/include/hypercall-defs.c | 14 +- xen/include/xen/domain.h | 4 - xen/include/xsm/dummy.h | 29 +- xen/include/xsm/xsm.h | 60 ++-- xen/lib/x86/Makefile | 7 +- xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ xen/xsm/dummy.c | 21 +- xen/xsm/flask/hooks.c | 54 ++-- 70 files changed, 812 insertions(+), 708 deletions(-) create mode 100644 xen/lib/x86/cpuid-generic.c
Signature · 1 line
2.34.1
PATCH v4 1/24 xen/xsm: remove redundant xsm_iomem_mapping()
Function xsm_iomem_mapping() seems redundant, and in flask policy, it just directly calls xsm_iomem_permission().
Remove it and use xsm_iomem_permission() instead, with the benefit of a cf_check disappearing too.
---
v2 -> v3:
- new commit
--- xen/common/domctl.c | 2 +- xen/drivers/vpci/header.c | 2 +- xen/include/xsm/dummy.h | 7 ------- xen/include/xsm/xsm.h | 8 -------- xen/xsm/dummy.c | 1 - xen/xsm/flask/hooks.c | 6 ------ 6 files changed, 2 insertions(+), 24 deletions(-)
xen/common/domctl.c +1 -1
@@ -707,7 +707,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) !iomem_access_permitted(d, mfn, mfn_end) )break ; - ret =xsm_iomem_mapping (XSM_HOOK , d, mfn, mfn_end, add); + ret =xsm_iomem_permission (XSM_HOOK , d, mfn, mfn_end, add);if ( ret )break ;
xen/drivers/vpci/header.c +1 -1
@@ -67,7 +67,7 @@ static int cf_check map_range(return -EPERM ; } - rc =xsm_iomem_mapping (XSM_HOOK , map->d, map_mfn, m_end, map->map); + rc =xsm_iomem_permission (XSM_HOOK , map->d, map_mfn, m_end, map->map);if ( rc ) { printk(XENLOG_G_WARNING
xen/include/xsm/dummy.h +0 -7
@@ -570,13 +570,6 @@ static XSM_INLINE int cf_check xsm_iomem_permission(return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int cf_check xsm_iomem_mapping( - XSM_DEFAULT_ARG struct domain *d, uint64_t s, uint64_t e, uint8_t allow) -{ -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); -} - static XSM_INLINE int cf_check xsm_pci_config_permission( XSM_DEFAULT_ARG struct domain *d, uint32_t machine_bdf, uint16_t start,uint16_t end,uint8_t access)
xen/include/xsm/xsm.h +0 -8
@@ -116,8 +116,6 @@ struct xsm_ops {int (*irq_permission)(struct domain *d,int pirq,uint8_t allow);int (*iomem_permission)(struct domain *d,uint64_t s,uint64_t e,uint8_t allow); -int (*iomem_mapping)(struct domain *d,uint64_t s,uint64_t e, -uint8_t allow);int (*pci_config_permission)(struct domain *d,uint32_t machine_bdf,uint16_t start,uint16_t end,uint8_t access);
@@ -517,12 +515,6 @@ static inline int xsm_iomem_permission(return alternative_call (xsm_ops.iomem_permission, d, s, e, allow); } -static inline int xsm_iomem_mapping ( -xsm_default_t def,struct domain *d,uint64_t s,uint64_t e,uint8_t allow) -{ -return alternative_call (xsm_ops.iomem_mapping, d, s, e, allow); -} -static inline int xsm_pci_config_permission (xsm_default_t def,struct domain *d,uint32_t machine_bdf,uint16_t start,uint16_t end,uint8_t access)
xen/xsm/dummy.c +0 -1
@@ -75,7 +75,6 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .unbind_pt_irq = xsm_unbind_pt_irq, .irq_permission = xsm_irq_permission, .iomem_permission = xsm_iomem_permission, - .iomem_mapping = xsm_iomem_mapping, .pci_config_permission = xsm_pci_config_permission, .get_vnumainfo = xsm_get_vnumainfo,
xen/xsm/flask/hooks.c +0 -6
@@ -1167,11 +1167,6 @@ static int cf_check flask_iomem_permission(return security_iterate_iomem_sids (start, end, _iomem_has_perm, &data); } -static int cf_check flask_iomem_mapping(struct domain *d, uint64_t start, uint64_t end, uint8_t access) -{ -return flask_iomem_permission (d, start, end, access); -} - static int cf_check flask_pci_config_permission(struct domain *d,uint32_t machine_bdf,uint16_t start,uint16_t end,uint8_t access)
@@ -1945,7 +1940,6 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .unbind_pt_irq = flask_unbind_pt_irq, .irq_permission = flask_irq_permission, .iomem_permission = flask_iomem_permission, - .iomem_mapping = flask_iomem_mapping, .pci_config_permission = flask_pci_config_permission, .resource_plug_core = flask_resource_plug_core,
Signature · 1 line
2.34.1
Re: [PATCH v4 01/24] xen/xsm: remove redundant xsm_iomem_mapping()
Quoted 7 lines · Penny Zheng
Function
xsm_iomem_mapping()seems redundant, and in flask policy, it just directly callsxsm_iomem_permission().
Remove it and usexsm_iomem_permission()instead, with the benefit of acf_checkdisappearing too.Signed-off-by Penny Zheng <[email protected]>Cc Daniel De Graaf <[email protected]>
Any reason for this Cc?
Quoted 3 lines
---
v2 -> v3:
- new commit
So in v4 you dropped the Suggested-by: but kept the code as is. I would have expected it the other way around, in the absence of Daniel having voiced any opinion.
Jan
PATCH v4 2/24 xen: consolidate cpuid library
In reply to Penny ZhengThere are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with CONFIG_MGMT_HYPERCALLS later, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
- x86_cpu_policy_clear_out_of_range_leaves
- zero_leaves
- x86_cpuid_copy_to_buffer
- copy_leaf_to_buffer
- x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file named cpuid-generic.c, and modify related Makefile-s to retain same behavior.
---
v3 -> v4:
- new commit
--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-) create mode 100644 xen/lib/x86/cpuid-generic.c
tools/fuzz/cpu-policy/Makefile +1 -1
@@ -22,7 +22,7 @@ CFLAGS += $(APPEND_CFLAGS) -Og vpath %.c ../../../xen/lib/x86 -afl-policy-fuzzer: afl-policy-fuzzer.o msr.o cpuid.o +afl-policy-fuzzer: afl-policy-fuzzer.o msr.o cpuid.o cpuid-generic.o $(CC) $(CFLAGS) $^ -o $@ -include $(DEPS_INCLUDE)
tools/fuzz/x86_instruction_emulator/Makefile +5 -5
@@ -25,7 +25,7 @@ x86_emulate/%.h: x86_emulate ; ln -nsf $< $@ CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -iquote . -cpuid.o: CFLAGS += -iquote $(XEN_ROOT)/xen/lib/x86 +cpuid.o cpuid-generic.o: CFLAGS += -iquote $(XEN_ROOT)/xen/lib/x86 GCOV_FLAGS := --coverage %-cov.o: %.c
@@ -49,16 +49,16 @@ $(filter x86_emulate/%.o,$(OBJS)): x86_emulate/%.o: x86_emulate/%.c $(private.h) $(patsubst %.o,%-cov.o,$(filter x86_emulate/%.o,$(OBJS))): x86_emulate/%-cov.o: x86_emulate/%.c $(private.h) $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) $(GCOV_FLAGS) -c -o $@ $< $(APPEND_CFLAGS) -x86-insn-fuzzer.a: $(OBJS) cpuid.o +x86-insn-fuzzer.a: $(OBJS) cpuid.o cpuid-generic.o $(AR) rc $@ $^ -afl-harness: afl-harness.o $(OBJS) cpuid.o wrappers.o +afl-harness: afl-harness.o $(OBJS) cpuid.o cpuid-generic.o wrappers.o $(CC) $(CFLAGS) $(addprefix -Wl$(comma)--wrap=,$(WRAPPED)) $^ -o $@ -afl-harness-cov: afl-harness-cov.o $(patsubst %.o,%-cov.o,$(OBJS)) cpuid.o wrappers.o +afl-harness-cov: afl-harness-cov.o $(patsubst %.o,%-cov.o,$(OBJS)) cpuid.o cpuid-generic.o wrappers.o $(CC) $(CFLAGS) $(GCOV_FLAGS) $(addprefix -Wl$(comma)--wrap=,$(WRAPPED)) $^ -o $@ -libfuzzer-harness: $(OBJS) cpuid.o wrappers.o +libfuzzer-harness: $(OBJS) cpuid.o cpuid-generic.o wrappers.o $(CC) $(CFLAGS) $(LIB_FUZZING_ENGINE) -fsanitize=fuzzer $(addprefix -Wl$(comma)--wrap=,$(WRAPPED)) $^ -o $@ # Common targets
tools/libs/guest/Makefile.common +1 -1
@@ -35,7 +35,7 @@ OBJS-y += $(LIBELF_OBJS) ifeq ($(CONFIG_X86),y) # Add libx86 to the build vpath %.c ../../../xen/lib/x86 -OBJS-y += cpuid.o msr.o policy.o +OBJS-y += cpuid.o cpuid-generic.o msr.o policy.o endif # new domain builder
tools/tests/cpu-policy/Makefile +1 -1
@@ -46,7 +46,7 @@ vpath %.c ../../../xen/lib/x86 %.o: Makefile -test-cpu-policy: test-cpu-policy.o msr.o cpuid.o policy.o +test-cpu-policy: test-cpu-policy.o msr.o cpuid.o cpuid-generic.o policy.o $(CC) $^ -o $@ $(LDFLAGS) -include $(DEPS_INCLUDE)
tools/tests/x86_emulator/Makefile +1 -1
@@ -248,7 +248,7 @@ xop.h avx512f.h avx512fp16.h: simd-fma.c endif # 32-bit override -OBJS := x86-emulate.o cpuid.o test_x86_emulator.o evex-disp8.o predicates.o wrappers.o +OBJS := x86-emulate.o cpuid.o cpuid-generic.o test_x86_emulator.o evex-disp8.o predicates.o wrappers.o OBJS += x86_emulate/0f01.o x86_emulate/0fae.o x86_emulate/0fc7.o OBJS += x86_emulate/blk.o x86_emulate/decode.o x86_emulate/fpu.o x86_emulate/util.o
xen/lib/x86/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-y += cpuid.o +obj-y += cpuid-generic.o obj-y += msr.o obj-y += policy.o
xen/lib/x86/cpuid-generic.c new file +273 -0
273 lines not on this page · raw message
xen/lib/x86/cpuid.c +0 -260
272 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v4 02/24] xen: consolidate cpuid library
Quoted 16 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit
Quoted 11 lines
--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-) create mode 100644 xen/lib/x86/cpuid-generic.c
Andrew - what's your take on such a split? Personally I'm not overly happy to see related functions be scattered across two files. The separation also feels pretty random, posing the risk that later some of the code may need to move back.
Penny, I also don't think "consolidate" is what is happening here. Perhaps "split" would be getting closer?
Jan
RE: [PATCH v4 02/24] xen: consolidate cpuid library
[Public]
Quoted 40 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Tuesday, November 25, 2025 2:39 PM
To: Penny, Zheng <[email protected]>; Andrew Cooper <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Juergen Gross <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v4 02/24] xen: consolidate cpuid libraryQuoted 26 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-) create modeQuoted 1 line
100644
xen/lib/x86/cpuid-generic.c
Quoted 7 lines
Andrew - what's your take on such a split? Personally I'm not overly happy to see related functions be scattered across two files. The separation also feels pretty random, posing the risk that later some of the code may need to move back.
Penny, I also don't think "consolidate" is what is happening here. Perhaps "split" would be getting closer?
I'll change it to split, thx
Quoted 1 line
Jan
RE: [PATCH v4 02/24] xen: consolidate cpuid library
In reply to Jan Beulich[Public]
Quoted 40 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Tuesday, November 25, 2025 2:39 PM
To: Penny, Zheng <[email protected]>; Andrew Cooper <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Juergen Gross <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v4 02/24] xen: consolidate cpuid libraryQuoted 26 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-) create modeQuoted 1 line
100644
xen/lib/x86/cpuid-generic.c
Quoted 4 lines
Andrew - what's your take on such a split? Personally I'm not overly happy to see related functions be scattered across two files. The separation also feels pretty random, posing the risk that later some of the code may need to move back.
Right now, I could not think a better way to guard x86_cpuid_copy_from{,to}_buffer with MGMT_HYPERCALLS without split, any better suggestion? Or maybe I could add up some explanations on the file cpuid_generic.c head note to explain the diffs between itself and cpuid.c, something like:
``` The difference between cpuid.c and cpuid_generic.c is that the former contains library functions that has only been referenced in management hypercalls, such as sysctl, domctl, etc. See comment for MGMT_HYPERCALLS. ```
Quoted 4 lines
Penny, I also don't think "consolidate" is what is happening here. Perhaps "split" would be getting closer?
Jan
Re: [PATCH v4 02/24] xen: consolidate cpuid library
Quoted 47 lines · Zheng
[Public]
Quoted 40 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Tuesday, November 25, 2025 2:39 PM
To: Penny, Zheng <[email protected]>; Andrew Cooper <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Juergen Gross <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v4 02/24] xen: consolidate cpuid libraryQuoted 26 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-) create modeQuoted 1 line
100644
xen/lib/x86/cpuid-generic.cQuoted 4 lines
Andrew - what's your take on such a split? Personally I'm not overly happy to see related functions be scattered across two files. The separation also feels pretty random, posing the risk that later some of the code may need to move back.
Quoted 4 lines
Right now, I could not think a better way to guard x86_cpuid_copy_from{,to}_buffer with
MGMT_HYPERCALLSwithout split, any better suggestion? Or maybe I could add up some explanations on the filecpuid_generic.chead note to explain the diffs between itself andcpuid.c, something like:``` The difference between cpuid.c and cpuid_generic.c is that the former contains library functions that has only been referenced in management hypercalls, such as sysctl, domctl, etc. See comment for MGMT_HYPERCALLS. ```
If one of the files is to have only MGMT_HYPERCALLS related stuff (and if, prior to that, using #ifdef-ary in the existing file was proven unwieldy), then imo the more "natural" split would be to have a separate cpuid-mgmt.c file, where then from its name alone it already becomes halfway clear what it to live there.
Another option might be to properly library-fy the copy-in and copy-out functions, one per source file, and then referenced by lib-y (or lib-$(CONFIG_...)) from the Makefile.
Jan
RE: [PATCH v4 02/24] xen: consolidate cpuid library
[Public]
Quoted 70 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Monday, December 1, 2025 4:23 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Juergen Gross <[email protected]>; xen- [email protected]; Andrew Cooper <[email protected]>
Subject: Re: [PATCH v4 02/24] xen: consolidate cpuid libraryQuoted 45 lines · Zheng
[Public]
Quoted 43 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Tuesday, November 25, 2025 2:39 PM
To: Penny, Zheng <[email protected]>; Andrew Cooper <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Juergen Gross <[email protected]>; xen- [email protected]
Subject: Re: [PATCH v4 02/24] xen: consolidate cpuid libraryQuoted 26 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-) create modeQuoted 1 line
100644
xen/lib/x86/cpuid-generic.cAndrew - what's your take on such a split? Personally I'm not overly happy to see related functions be scattered across two files. The separation also feels pretty random, posing the risk that later some of the code
may need to move back.
Quoted 3 lines
Quoted 1 line
Right now, I could not think a better way to guard
x86_cpuid_copy_from{,to}_buffer with
MGMT_HYPERCALLSwithout split, any better suggestion? Or maybe I could add up some explanations on the filecpuid_generic.chead note to explain the diffs between itself andcpuid.c, something like:Quoted 2 lines
```
The difference betweencpuid.candcpuid_generic.cis that the former containslibrary functions that has only been referenced in management hypercalls, such as sysctl, domctl, etc. See comment for
MGMT_HYPERCALLS.Quoted 1 line
```
Quoted 9 lines
If one of the files is to have only
MGMT_HYPERCALLSrelated stuff (and if, prior to that, using #ifdef-ary in the existing file was proven unwieldy), then imo the more "natural" split would be to have a separatecpuid-mgmt.cfile, where then from its name alone it already becomes halfway clear what it to live there.Another option might be to properly library-fy the copy-in and copy-out functions, one per source file, and then referenced by lib-y (or lib-$(CONFIG_...)) from the
Makefile.
Thx!
I'd prefer second option, we need to library-fy the copy-in, copy-out, and trim-cpuid-leaves functions. Maybe it is fragmentated, but could avoid future movement in option one
Quoted 1 line
Jan
Re: [PATCH v4 02/24] xen: consolidate cpuid library
In reply to Penny ZhengQuoted 26 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-)
Quoted 1 line
create mode 100644
xen/lib/x86/cpuid-generic.c
It seems this patch is not required prerequisite, at least definitely not for Patch 3.
In general, i think it can be removed from this series and sent as follow up patch.
Signature · 2 lines
Best regards, -grygorii
RE: [PATCH v4 02/24] xen: consolidate cpuid library
[Public]
Quoted 41 lines
-----Original Message-----
From: Grygorii Strashko <[email protected]>
Sent: Thursday, November 27, 2025 5:45 AM
To: Penny, Zheng <[email protected]>; [email protected]
Cc: Huang, Ray <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Juergen Gross <[email protected]>
Subject: Re: [PATCH v4 02/24] xen: consolidate cpuid libraryQuoted 26 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-)Quoted 1 line
create mode 100644
xen/lib/x86/cpuid-generic.c
Quoted 2 lines
It seems this patch is not required prerequisite, at least definitely not for Patch 3.
It is the pre-requisite for commit " xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS ", We want to guard new cpuid.o with MGMT_HYPERCALLS there. Without the split, fwis, I could not think a better way to avoid functions like x86_cpuid_copy_to{,from}_buffer becoming unreachable when MGMT_HYPERCALLS=n.
Quoted 5 lines
In general, i think it can be removed from this series and sent as follow up patch.
--
Best regards,
-grygorii
Re: [PATCH v4 02/24] xen: consolidate cpuid library
Quoted 43 lines · Zheng
[Public]
Quoted 41 lines
-----Original Message-----
From: Grygorii Strashko <[email protected]>
Sent: Thursday, November 27, 2025 5:45 AM
To: Penny, Zheng <[email protected]>; [email protected]
Cc: Huang, Ray <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Juergen Gross <[email protected]>
Subject: Re: [PATCH v4 02/24] xen: consolidate cpuid libraryQuoted 27 lines · Penny Zheng
There are some cpuid library functions only referenced in XEN_DOMCTL_get{,set}_cpu_policy-case, and shall be wrapped with
CONFIG_MGMT_HYPERCALLSlater, otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence violate Misra 2.1
-x86_cpu_policy_clear_out_of_range_leaves
-zero_leaves
-x86_cpuid_copy_to_buffer
-copy_leaf_to_buffer
-x86_cpuid_copy_from_buffer
We seperate these functions by moving other functions to a new file namedcpuid-generic.c, and modify related Makefile-s to retain same behavior.Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit--- tools/fuzz/cpu-policy/Makefile | 2 +- tools/fuzz/x86_instruction_emulator/Makefile | 10 +- tools/libs/guest/Makefile.common | 2 +- tools/tests/cpu-policy/Makefile | 2 +- tools/tests/x86_emulator/Makefile | 2 +- xen/lib/x86/Makefile | 1 + xen/lib/x86/cpuid-generic.c | 273 +++++++++++++++++++ xen/lib/x86/cpuid.c | 260 ------------------ 8 files changed, 283 insertions(+), 269 deletions(-)create mode 100644
xen/lib/x86/cpuid-generic.c
Quoted 4 lines
Quoted 2 lines
It seems this patch is not required prerequisite, at least definitely not for Patch 3.
It is the pre-requisite for commit " xen/x86: wrap x86-specific domctl-op with
CONFIG_MGMT_HYPERCALLS", We want to guard new cpuid.o withMGMT_HYPERCALLSthere. Without the split, fwis, I could not think a better way to avoid functions like x86_cpuid_copy_to{,from}_buffer becoming unreachable when MGMT_HYPERCALLS=n.
I think, confusion here is that this patch:
- new
- placed before patch 3
which introduces false assumption that all patches after it are dependent on it. Effectively blocking possible merge of Patch 3, for example.
Could it be moved up in this series before patch you've mentioned?
Quoted 2 lines
Quoted 2 lines
In general, i think it can be removed from this series and sent as follow up patch.
Signature · 2 lines
Best regards, -grygorii
PATCH v4 3/24 xen/sysctl: replace CONFIG_SYSCTL with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengRename all the CONFIG_SYSCTL into CONFIG_MGMT_HYPERCALLS to help provide a single option to manage all unnecessary hypercalls, including sysctl, domctl, etc, in dom0less system and PV shim mode, which could also make it easier to support randconfigs.
While doing the replacement, we fix some bugs on xsm system:
- wrap the whole xsm function to avoid bringing unreachable codes when MGMT_DOMCTL=n
- add missing wrapping in include/xsm/dummy.h
---
v2 -> v3:
- wrap the whole xsm function
- add missing wrapping in include/xsm/dummy.h
- refine kconfig description
--- xen/Kconfig.debug | 2 +- xen/arch/arm/Makefile | 2 +- xen/arch/riscv/stubs.c | 4 ++-- xen/arch/x86/Makefile | 2 +- xen/arch/x86/configs/pvshim_defconfig | 2 +- xen/arch/x86/psr.c | 26 +++++++++++++------------- xen/common/Kconfig | 15 ++++++++------- xen/common/Makefile | 2 +- xen/common/page_alloc.c | 8 ++++---- xen/common/perfc.c | 4 ++-- xen/common/sched/arinc653.c | 10 +++++----- xen/common/sched/core.c | 6 +++--- xen/common/sched/cpupool.c | 16 ++++++++-------- xen/common/sched/credit.c | 6 +++--- xen/common/sched/credit2.c | 6 +++--- xen/common/sched/private.h | 4 ++-- xen/common/spinlock.c | 4 ++-- xen/drivers/char/console.c | 4 ++-- xen/include/hypercall-defs.c | 4 ++-- xen/include/xsm/dummy.h | 6 ++++++ xen/include/xsm/xsm.h | 24 +++++++++--------------- xen/xsm/dummy.c | 6 +++--- xen/xsm/flask/hooks.c | 22 +++++++++++----------- 23 files changed, 93 insertions(+), 92 deletions(-)
xen/Kconfig.debug +1 -1
@@ -37,7 +37,7 @@ config SELF_TESTS config COVERAGE bool "Code coverage support" - depends on SYSCTL && !LIVEPATCH + depends on MGMT_HYPERCALLS && !LIVEPATCH select SUPPRESS_DUPLICATE_SYMBOL_WARNINGS if !ENFORCE_UNIQUE_SYMBOLS help Enable code coverage support.
xen/arch/arm/Makefile +1 -1
@@ -51,7 +51,7 @@ obj-y += setup.o obj-y += shutdown.o obj-y += smp.o obj-y += smpboot.o -obj-$(CONFIG_SYSCTL) += sysctl.o +obj-$(CONFIG_MGMT_HYPERCALLS) += sysctl.o obj-y += time.o obj-y += traps.o obj-y += vcpreg.o
xen/arch/riscv/stubs.c +2 -2
@@ -277,7 +277,7 @@ unsigned long raw_copy_from_guest(void *to, const void __user *from,BUG_ON ("unimplemented" ); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* sysctl.c */ long arch_do_sysctl(struct xen_sysctl *sysctl,
@@ -290,7 +290,7 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) {BUG_ON ("unimplemented" ); } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /* p2m.c */
xen/arch/x86/Makefile +1 -1
@@ -66,7 +66,7 @@ obj-y += smpboot.o obj-y += spec_ctrl.o obj-y += srat.o obj-y += string.o -obj-$(CONFIG_SYSCTL) += sysctl.o +obj-$(CONFIG_MGMT_HYPERCALLS) += sysctl.o obj-y += time.o obj-y += traps-setup.o obj-y += traps.o
xen/arch/x86/configs/pvshim_defconfig +1 -1
@@ -25,4 +25,4 @@ CONFIG_PDX_NONE=y # CONFIG_INTEL_IOMMU is not set # CONFIG_DEBUG is not set # CONFIG_GDBSX is not set -# CONFIG_SYSCTL is not set +# CONFIG_MGMT_HYPERCALLS is not set
xen/arch/x86/psr.c +13 -13
@@ -135,7 +135,7 @@ static const struct feat_props {*/ enum psr_type alt_type; -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* 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);
@@ -422,7 +422,7 @@ static bool mba_init_feature(const struct cpuid_leaf *regs,return true; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static bool cf_check cat_get_feat_info(const struct feat_node *feat,uint32_t data[],unsigned int array_len) {
@@ -435,7 +435,7 @@ static bool cf_check cat_get_feat_info(return true; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /* L3 CAT props */ static void cf_check l3_cat_write_msr(
@@ -448,14 +448,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 +#ifdef CONFIG_MGMT_HYPERCALLS .get_feat_info = cat_get_feat_info, #endif .write_msr = l3_cat_write_msr, .sanitize = cat_check_cbm, }; -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* L3 CDP props */ static bool cf_check l3_cdp_get_feat_info(const struct feat_node *feat,uint32_t data[],uint32_t array_len)
@@ -467,7 +467,7 @@ static bool cf_check l3_cdp_get_feat_info(return true; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static void cf_check l3_cdp_write_msr(unsigned int cos,uint32_t val,enum psr_type type)
@@ -483,7 +483,7 @@ 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 +#ifdef CONFIG_MGMT_HYPERCALLS .get_feat_info = l3_cdp_get_feat_info, #endif .write_msr = l3_cdp_write_msr,
@@ -501,14 +501,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 +#ifdef CONFIG_MGMT_HYPERCALLS .get_feat_info = cat_get_feat_info, #endif .write_msr = l2_cat_write_msr, .sanitize = cat_check_cbm, }; -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* MBA props */ static bool cf_check mba_get_feat_info(const struct feat_node *feat,uint32_t data[],unsigned int array_len)
@@ -523,7 +523,7 @@ static bool cf_check mba_get_feat_info(return true; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static void cf_check mba_write_msr(unsigned int cos,uint32_t val,enum psr_type type)
@@ -561,7 +561,7 @@ static const struct feat_props mba_props = { .cos_num = 1, .type[0] = PSR_TYPE_MBA_THRTL, .alt_type =PSR_TYPE_UNKNOWN , -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS .get_feat_info = mba_get_feat_info, #endif .write_msr = mba_write_msr,
@@ -826,7 +826,7 @@ static struct psr_socket_info *get_socket_info(unsigned int socket)return socket_info + socket; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS int psr_get_info (unsigned int socket,enum psr_type type,uint32_t data[],unsigned int array_len) {
@@ -858,7 +858,7 @@ int psr_get_info(unsigned int socket, enum psr_type type, return -EINVAL; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ int psr_get_val (struct domain *d,unsigned int socket,uint32_t *val,enum psr_type type)
xen/common/Kconfig +8 -7
@@ -508,7 +508,7 @@ config CRYPTO config LIVEPATCH bool "Live patching support" default X86 - depends on "$(XEN_HAS_BUILD_ID)" = "y" && SYSCTL && HAS_VMAP + depends on "$(XEN_HAS_BUILD_ID)" = "y" && MGMT_HYPERCALLS && HAS_VMAP select CC_SPLIT_SECTIONS help Allows a running Xen hypervisor to be dynamically patched using
@@ -600,7 +600,7 @@ config DTB_FILE config TRACEBUFFER bool "Enable tracing infrastructure" if EXPERT default y - depends on SYSCTL + depends on MGMT_HYPERCALLS help Enable tracing infrastructure and pre-defined tracepoints within Xen. This will allow live information about Xen's execution and performance
@@ -651,19 +651,20 @@ config SYSTEM_SUSPEND menu "Supported hypercall interfaces" visible if EXPERT -config SYSCTL - bool "Enable sysctl hypercall" +config MGMT_HYPERCALLS + bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE default y help This option shall only be disabled on some dom0less systems, or - PV shim on x86, to reduce Xen footprint. + PV shim on x86, to reduce Xen footprint via managing unnessary + hypercalls, like sysctl, etc. endmenu config PM_OP bool "Enable Performance Management Operation" - depends on ACPI && HAS_CPUFREQ && SYSCTL + depends on ACPI && HAS_CPUFREQ && MGMT_HYPERCALLS default y help This option shall enable userspace performance management control
@@ -671,7 +672,7 @@ config PM_OP config PM_STATS bool "Enable Performance Management Statistics" - depends on ACPI && HAS_CPUFREQ && SYSCTL + depends on ACPI && HAS_CPUFREQ && MGMT_HYPERCALLS default y help Enable collection of performance management statistics to aid in
xen/common/Makefile +1 -1
@@ -51,7 +51,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-$(CONFIG_MGMT_HYPERCALLS) += sysctl.o obj-y += tasklet.o obj-y += time.o obj-y += timer.o
xen/common/page_alloc.c +4 -4
@@ -602,7 +602,7 @@ out:return ret; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS void get_outstanding_claims (uint64_t *free_pages,uint64_t *outstanding_pages) {spin_lock (&heap_lock);
@@ -610,7 +610,7 @@ void get_outstanding_claims(uint64_t *free_pages, uint64_t *outstanding_pages) *free_pages =avail_heap_pages (MEMZONE_XEN +1 ,NR_ZONES -1 ,-1 ); spin_unlock(&heap_lock); } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static bool __read_mostly first_node_initialised;#ifndef CONFIG_SEPARATE_XENHEAP
@@ -1788,7 +1788,7 @@ int offline_page(mfn_t mfn, int broken, uint32_t *status)return 0 ; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* * Online the memory. * The caller should make sure end_pfn <= max_page,
@@ -1873,7 +1873,7 @@ int query_page_offline(mfn_t mfn, uint32_t *status) return 0; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * This function should only be called with valid pages from the same NUMA
xen/common/perfc.c +2 -2
@@ -149,7 +149,7 @@ void cf_check perfc_reset(unsigned char key) } } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static struct xen_sysctl_perfc_desc perfc_d[NR_PERFCTRS ];static xen_sysctl_perfc_val_t *perfc_vals;static unsigned int perfc_nbr_vals;
@@ -266,7 +266,7 @@ int perfc_control(struct xen_sysctl_perfc_op *pc) return rc; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * Local variables:
xen/common/sched/arinc653.c +5 -5
@@ -220,7 +220,7 @@ static void update_schedule_units(const struct scheduler *ops) SCHED_PRIV(ops)->schedule[i].unit_id); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /** * This function is called by the adjust_global scheduler hook to put * in place a new ARINC653 schedule.
@@ -335,7 +335,7 @@ arinc653_sched_get( return 0; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /************************************************************************** * Scheduler callback functions *
@@ -661,7 +661,7 @@ a653_switch_sched(struct scheduler *new_ops, unsigned int cpu,return &sr->_lock; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /** * 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
@@ -701,7 +701,7 @@ a653sched_adjust_global(const struct scheduler *ops, return rc; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /** * This structure defines our scheduler for Xen.
@@ -736,7 +736,7 @@ static const struct scheduler sched_arinc653_def = { .switch_sched = a653_switch_sched, .adjust = NULL, -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS .adjust_global = a653sched_adjust_global,#endif
xen/common/sched/core.c +3 -3
@@ -2064,7 +2064,7 @@ long do_set_timer_op(s_time_t timeout)return 0 ; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* scheduler_id - fetch ID of current scheduler */ int scheduler_id (void ) {
@@ -2107,7 +2107,7 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)return ret; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS long sched_adjust_global (struct xen_sysctl_scheduler_op *op) {struct cpupool *pool;
@@ -2136,7 +2136,7 @@ long sched_adjust_global(struct xen_sysctl_scheduler_op *op) return rc; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static void vcpu_periodic_timer_work_locked (struct vcpu *v) {
xen/common/sched/cpupool.c +8 -8
@@ -241,12 +241,12 @@ struct cpupool *cpupool_get_by_id(unsigned int poolid)return __cpupool_get_by_id (poolid, true); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static struct cpupool *cpupool_get_next_by_id (unsigned int poolid) {return __cpupool_get_by_id (poolid, false); } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ void cpupool_put (struct cpupool *pool) {
@@ -354,7 +354,7 @@ static struct cpupool *cpupool_create(unsigned int poolid,return ERR_PTR (ret); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* * destroys the given cpupool * returns 0 on success, 1 else
@@ -382,7 +382,7 @@ static int cpupool_destroy(struct cpupool *c)debugtrace_printk ("cpupool_destroy(pool=%u)\n" , c->cpupool_id); return 0; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * Move domain to another cpupool
@@ -572,7 +572,7 @@ static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu)return ret; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static long cf_check cpupool_unassign_cpu_helper (void *info) {struct cpupool *c = info;
@@ -638,7 +638,7 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu) }return continue_hypercall_on_cpu (work_cpu, cpupool_unassign_cpu_helper, c); } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * add a new domain to a cpupool
@@ -816,7 +816,7 @@ static void cpupool_cpu_remove_forced(unsigned int cpu)rcu_read_unlock (&sched_res_rculock); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS /* * do cpupool related sysctl operations */
@@ -982,7 +982,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) return ret; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ unsigned int cpupool_get_id (const struct domain *d) {
xen/common/sched/credit.c +3 -3
@@ -1256,7 +1256,7 @@ __csched_set_tslice(struct csched_private *prv, unsigned int timeslice_ms) prv->credit = prv->credits_per_tslice * prv->ncpus; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_checkcsched_sys_cntl (const struct scheduler *ops,struct xen_sysctl_scheduler_op *sc)
@@ -1299,7 +1299,7 @@ csched_sys_cntl(const struct scheduler *ops, out:return rc; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static void *cf_checkcsched_alloc_domdata (const struct scheduler *ops,struct domain *dom)
@@ -2290,7 +2290,7 @@ static const struct scheduler sched_credit_def = { .adjust = csched_dom_cntl, .adjust_affinity= csched_aff_cntl, -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS .adjust_global = csched_sys_cntl,#endif
xen/common/sched/credit2.c +3 -3
@@ -3131,7 +3131,7 @@ csched2_aff_cntl(const struct scheduler *ops, struct sched_unit *unit,__clear_bit (__CSFLAG_pinned, &svc->flags); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check csched2_sys_cntl(const struct scheduler *ops,struct xen_sysctl_scheduler_op *sc) {
@@ -3163,7 +3163,7 @@ static int cf_check csched2_sys_cntl(return 0 ; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static void *cf_checkcsched2_alloc_domdata (const struct scheduler *ops,struct domain *dom)
@@ -4248,7 +4248,7 @@ static const struct scheduler sched_credit2_def = { .adjust = csched2_dom_cntl, .adjust_affinity= csched2_aff_cntl, -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS .adjust_global = csched2_sys_cntl,#endif
xen/common/sched/private.h +2 -2
@@ -356,7 +356,7 @@ struct scheduler {struct sched_unit *unit, const struct cpumask *hard, const struct cpumask *soft); -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS int (*adjust_global) (const struct scheduler *ops,struct xen_sysctl_scheduler_op *sc);#endif
@@ -512,7 +512,7 @@ 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 +#ifdef CONFIG_MGMT_HYPERCALLS static inline int sched_adjust_cpupool (const struct scheduler *s,struct xen_sysctl_scheduler_op *op) {
xen/common/spinlock.c +2 -2
@@ -690,7 +690,7 @@ void cf_check spinlock_profile_reset(unsigned char key)spinlock_profile_iterate (spinlock_profile_reset_elem,NULL ); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS typedef struct { struct xen_sysctl_lockprof_op *pc; int rc;
@@ -750,7 +750,7 @@ int spinlock_profile_control(struct xen_sysctl_lockprof_op *pc) return rc; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ void _lock_profile_register_struct (int32_t type,struct lock_profile_qhead *qhead,int32_t idx)
xen/drivers/char/console.c +2 -2
@@ -371,7 +371,7 @@ static void conring_puts(const char *str, size_t len) conringc = conringp - conring_size; } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS long read_console_ring (struct xen_sysctl_readconsole *op) {XEN_GUEST_HANDLE_PARAM (char ) str;
@@ -414,7 +414,7 @@ long read_console_ring(struct xen_sysctl_readconsole *op) return 0; } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ /*
xen/include/hypercall-defs.c +2 -2
@@ -194,7 +194,7 @@ 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 -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS sysctl(xen_sysctl_t *u_sysctl)#endif #if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE )
@@ -277,7 +277,7 @@ physdev_op compat do hvm hvm do_arm#ifdef CONFIG_HVM hvm_op do do do do do#endif -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS sysctl do do do do do#endif #ifndef CONFIG_PV_SHIM_EXCLUSIVE
xen/include/xsm/dummy.h +6 -0
@@ -148,11 +148,13 @@ static XSM_INLINE int cf_check xsm_domctl_scheduler_op(return xsm_default_action (action, current->domain, d); } +#ifdef CONFIG_MGMT_HYPERCALLS static XSM_INLINE int cf_check xsm_sysctl_scheduler_op(XSM_DEFAULT_ARG int cmd) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ static XSM_INLINE int cf_check xsm_set_target( XSM_DEFAULT_ARG struct domain *d, struct domain *e)
@@ -180,6 +182,7 @@ static XSM_INLINE int cf_check xsm_domctl( } } +#ifdef CONFIG_MGMT_HYPERCALLS static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd) {XSM_ASSERT_ACTION (XSM_PRIV );
@@ -191,6 +194,7 @@ static XSM_INLINE int cf_check xsm_readconsole(XSM_DEFAULT_ARG uint32_t clear)XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ static XSM_INLINE int cf_check xsm_alloc_security_domain(struct domain *d) {
@@ -485,11 +489,13 @@ static XSM_INLINE int cf_check xsm_resource_setup_misc(XSM_DEFAULT_VOID)return xsm_default_action (action, current->domain,NULL ); } +#ifdef CONFIG_MGMT_HYPERCALLS static XSM_INLINE int cf_check xsm_page_offline(XSM_DEFAULT_ARG uint32_t cmd) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ static XSM_INLINE int cf_check xsm_hypfs_op(XSM_DEFAULT_VOID) {
xen/include/xsm/xsm.h +9 -15
@@ -57,13 +57,15 @@ 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 +#ifdef CONFIG_MGMT_HYPERCALLS 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); +#ifdef CONFIG_MGMT_HYPERCALLS int (*sysctl)(int cmd);int (*readconsole)(uint32_t clear); +#endif int (*evtchn_unbound)(struct domain *d,struct evtchn *chn,domid_t id2); int (*evtchn_interdomain)(struct domain *d1, struct evtchn *chn1,
@@ -138,7 +140,7 @@ struct xsm_ops {int (*resource_setup_gsi)(int gsi);int (*resource_setup_misc)(void ); -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS int (*page_offline)(uint32_t cmd);#endif int (*hypfs_op)(void );
@@ -244,7 +246,7 @@ static inline int xsm_domctl_scheduler_op(return alternative_call (xsm_ops.domctl_scheduler_op, d, cmd); } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static inline int xsm_sysctl_scheduler_op (xsm_default_t def,int cmd) {return alternative_call (xsm_ops.sysctl_scheduler_op, cmd);
@@ -263,23 +265,17 @@ static inline int xsm_domctl(xsm_default_t def, struct domain *d,return alternative_call (xsm_ops.domctl, d, cmd, ssidref); } +#ifdef CONFIG_MGMT_HYPERCALLS 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) { -#ifdef CONFIG_SYSCTL return alternative_call (xsm_ops.readconsole, clear); -#else -return -EOPNOTSUPP ; -#endif } +#endif /* CONFIG_MGMT_HYPERCALLS */ static inline int xsm_evtchn_unbound (xsm_default_t def,struct domain *d1,struct evtchn *chn,domid_t id2)
@@ -593,14 +589,12 @@ static inline int xsm_resource_setup_misc(xsm_default_t def)return alternative_call (xsm_ops.resource_setup_misc); } +#ifdef CONFIG_MGMT_HYPERCALLS 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 } +#endif /* CONFIG_MGMT_HYPERCALLS */ static inline int xsm_hypfs_op (xsm_default_t def) {
xen/xsm/dummy.c +3 -3
@@ -19,12 +19,12 @@ 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 +#ifdef CONFIG_MGMT_HYPERCALLS .sysctl_scheduler_op = xsm_sysctl_scheduler_op, #endif .set_target = xsm_set_target, .domctl = xsm_domctl, -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS .sysctl = xsm_sysctl, .readconsole = xsm_readconsole, #endif
@@ -97,7 +97,7 @@ 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 +#ifdef CONFIG_MGMT_HYPERCALLS .page_offline = xsm_page_offline, #endif .hypfs_op = xsm_hypfs_op,
xen/xsm/flask/hooks.c +11 -11
@@ -626,7 +626,7 @@ static int cf_check flask_domctl_scheduler_op(struct domain *d, int op) } } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check flask_sysctl_scheduler_op(int op) { switch ( op )
@@ -641,7 +641,7 @@ static int cf_check flask_sysctl_scheduler_op(int op) return avc_unknown_permission("sysctl_scheduler_op", op); } } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static int cf_check flask_set_target(struct domain *d, struct domain *t) {
@@ -858,7 +858,7 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd, } } -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check flask_sysctl(int cmd) { switch ( cmd )
@@ -946,7 +946,7 @@ static int cf_check flask_readconsole(uint32_t clear) return domain_has_xen(current->domain, perms); } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static inline uint32_t resource_to_perm (uint8_t access) {
@@ -1203,12 +1203,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 +#ifdef CONFIG_MGMT_HYPERCALLS static int flask_resource_use_core (void ) {return avc_current_has_perm (SECINITSID_DOMXEN ,SECCLASS_RESOURCE ,RESOURCE__USE ,NULL ); } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static int cf_check flask_resource_plug_pci(uint32_t machine_bdf) {
@@ -1273,7 +1273,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 +#ifdef CONFIG_MGMT_HYPERCALLS static inline int cf_check flask_page_offline(uint32_t cmd) { switch ( cmd )
@@ -1288,7 +1288,7 @@ static inline int cf_check flask_page_offline(uint32_t cmd) return avc_unknown_permission("page_offline", cmd); } } -#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_MGMT_HYPERCALLS */ static inline int cf_check flask_hypfs_op(void) {
@@ -1884,12 +1884,12 @@ 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 +#ifdef CONFIG_MGMT_HYPERCALLS .sysctl_scheduler_op = flask_sysctl_scheduler_op, #endif .set_target = flask_set_target, .domctl = flask_domctl, -#ifdef CONFIG_SYSCTL +#ifdef CONFIG_MGMT_HYPERCALLS .sysctl = flask_sysctl, .readconsole = flask_readconsole, #endif
@@ -1950,7 +1950,7 @@ 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 +#ifdef CONFIG_MGMT_HYPERCALLS .page_offline = flask_page_offline, #endif .hypfs_op = flask_hypfs_op,
Signature · 1 line
2.34.1
Re: [PATCH v4 03/24] xen/sysctl: replace CONFIG_SYSCTL with CONFIG_MGMT_HYPERCALLS
Hi
Quoted 16 lines · Penny Zheng
Rename all the
CONFIG_SYSCTLintoCONFIG_MGMT_HYPERCALLSto help provide a single option to manage all unnecessary hypercalls, including sysctl, domctl, etc, in dom0less system and PV shim mode, which could also make it easier to support randconfigs.
While doing the replacement, we fix some bugs on xsm system:
- wrap the whole xsm function to avoid bringing unreachable codes when MGMT_DOMCTL=n
- add missing wrapping ininclude/xsm/dummy.hSuggested-by Stefano Stabellini <[email protected]>Signed-off-by Penny Zheng <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>Reviewed-by Juergen Gross <[email protected]>Acked-by Jan Beulich <[email protected]>Cc Alistair Francis <[email protected]>
Quoted 6 lines
---
v2 -> v3:
- wrap the whole xsm function
- add missing wrapping ininclude/xsm/dummy.h
- refine kconfig description
---
With below diff..
xen/common/Kconfig +1 -2
@@ -652,9 +652,8 @@ menu "Supported hypercall interfaces" visible if EXPERT config MGMT_HYPERCALLS - bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE - default y + def_bool y help This option shall only be disabled on some dom0less systems, or PV shim on x86, to reduce Xen footprint via managing unnessary
It could be very helpful to consider this patch to be applied first.
- number of tags indicates that it's the way to move forward
- with above diff patch 4 can be dropped
- it is mechanical change, but it's big and constant source of rebase/merge/cherry-pick conflicts
- once applied it will allow, actually, parallel development of this feature as MGMT_HYPERCALLS will be defined while build not broken.
Signature · 2 lines
Best regards, -grygorii
Re: [PATCH v4 03/24] xen/sysctl: replace CONFIG_SYSCTL with CONFIG_MGMT_HYPERCALLS
Quoted 44 lines · Grygorii Strashko
Hi
Quoted 16 lines · Penny Zheng
Rename all the
CONFIG_SYSCTLintoCONFIG_MGMT_HYPERCALLSto help provide a single option to manage all unnecessary hypercalls, including sysctl, domctl, etc, in dom0less system and PV shim mode, which could also make it easier to support randconfigs.
While doing the replacement, we fix some bugs on xsm system:
- wrap the whole xsm function to avoid bringing unreachable codes when MGMT_DOMCTL=n
- add missing wrapping ininclude/xsm/dummy.hSuggested-by Stefano Stabellini <[email protected]>Signed-off-by Penny Zheng <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>Reviewed-by Juergen Gross <[email protected]>Acked-by Jan Beulich <[email protected]>Cc Alistair Francis <[email protected]>Quoted 6 lines
---
v2 -> v3:
- wrap the whole xsm function
- add missing wrapping ininclude/xsm/dummy.h
- refine kconfig description
---With below diff..
xen/common/Kconfig +0
-0@@ -652,9 +652,8 @@ menu "Supported hypercall interfaces"visible if EXPERT
configMGMT_HYPERCALLS
- bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE
- default y
+def_booly
help
This option shall only be disabled on some dom0less systems, or PV shim on x86, to reduce Xen footprint via managing unnessary
Quoted 1 line
It could be very helpful to consider this patch to be applied first.
It doesn't need the change above, does it? It (aiui) deliberately sits ahead of the patch (supposedly) doing the above. While (once again) it is not being said anywhere that it's independent of patches 01 and 02, I expect it really is. In which case all that looks to prevent it from having gone in already is the lack of an ack for the XSM changes.
Quoted 2 lines
- number of tags indicates that it's the way to move forward
- with above diff patch 4 can be dropped
Except that imo really wants to be separate. And that could have gone in already as well, if only it had been done correctly.
Jan
Quoted 4 lines
- it is mechanical change, but it's big and constant source of rebase/merge/cherry-pick conflicts
- once applied it will allow, actually, parallel development of this feature asMGMT_HYPERCALLSwill be defined while build not broken.
Re: [PATCH v4 03/24] xen/sysctl: replace CONFIG_SYSCTL with CONFIG_MGMT_HYPERCALLS
Quoted 45 lines · Jan Beulich
Quoted 44 lines · Grygorii Strashko
Hi
Quoted 16 lines · Penny Zheng
Rename all the
CONFIG_SYSCTLintoCONFIG_MGMT_HYPERCALLSto help provide a single option to manage all unnecessary hypercalls, including sysctl, domctl, etc, in dom0less system and PV shim mode, which could also make it easier to support randconfigs.
While doing the replacement, we fix some bugs on xsm system:
- wrap the whole xsm function to avoid bringing unreachable codes when MGMT_DOMCTL=n
- add missing wrapping ininclude/xsm/dummy.hSuggested-by Stefano Stabellini <[email protected]>Signed-off-by Penny Zheng <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>Reviewed-by Juergen Gross <[email protected]>Acked-by Jan Beulich <[email protected]>Cc Alistair Francis <[email protected]>Quoted 6 lines
---
v2 -> v3:
- wrap the whole xsm function
- add missing wrapping ininclude/xsm/dummy.h
- refine kconfig description
---With below diff..
xen/common/Kconfig +1
-2@@ -652,9 +652,8 @@ menu "Supported hypercall interfaces" visible if EXPERT config MGMT_HYPERCALLS - bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE - default y + def_bool y help This option shall only be disabled on some dom0less systems, or PV shim on x86, to reduce Xen footprint via managing unnessary
Quoted 4 lines
Quoted 1 line
It could be very helpful to consider this patch to be applied first.
It doesn't need the change above, does it? It (aiui) deliberately sits ahead of the patch (supposedly) doing the above. While (once again)
Understood.
Quoted 2 lines
it is not being said anywhere that it's independent of patches 01 and 02, I expect it really is.
I do not see any dependencies.
Quoted 2 lines
In which case all that looks to prevent it from
having gone in already is the lack of an ack for the XSM changes.
:(
Quoted 13 lines
Quoted 2 lines
- number of tags indicates that it's the way to move forward
- with above diff patch 4 can be droppedExcept that imo really wants to be separate. And that could have gone in already as well, if only it had been done correctly.
Jan
Quoted 4 lines
- it is mechanical change, but it's big and constant source of rebase/merge/cherry-pick conflicts
- once applied it will allow, actually, parallel development of this feature asMGMT_HYPERCALLSwill be defined while build not broken.
Signature · 2 lines
Best regards, -grygorii
PATCH v4 4/24 xen/domctl: make MGMT_HYPERCALLS transiently def_bool
In reply to Penny ZhengIn order to asist in reviewing/developing disabling domctl-op patch serie, we will transiently make MGMT_HYPERCALLS def_bool. And it will become optional at the last of domctl-op patch serie, where common/domctl.o's building as a whole becomes dependent upon that setting.
---
v2 -> v3:
- new commit
--- xen/common/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/Kconfig +1 -1
@@ -654,7 +654,7 @@ menu "Supported hypercall interfaces" config MGMT_HYPERCALLS bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE - default y + def_bool y help This option shall only be disabled on some dom0less systems, or PV shim on x86, to reduce Xen footprint via managing unnessary
Signature · 1 line
2.34.1
Re: [PATCH v4 04/24] xen/domctl: make MGMT_HYPERCALLS transiently def_bool
xen/common/Kconfig menu "Supported hypercall interfaces" · line 660
Quoted 11 lines · Penny Zheng
xen/common/Kconfig +1
-1@@ -654,7 +654,7 @@ menu "Supported hypercall interfaces" config MGMT_HYPERCALLS bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE - default y + def_bool y help This option shall only be disabled on some dom0less systems, or PV shim on x86, to reduce Xen footprint via managing unnessary
This is a no-op change, as "def_bool y" means nothing else than "bool" plus "default y". As long as the prompt is there, people can turn it off manually.
Jan
PATCH v4 5/24 xen/vm_event: make VM_EVENT depend on CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengVM event could only be enabled/disabled via vm_event domctl-op, so CONFIG_VM_EVENT shall depend on CONFIG_MGMT_HYPERCALLS
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
--- xen/common/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/Kconfig +1 -1
@@ -175,7 +175,7 @@ config LIBFDT config VM_EVENT bool "Memory Access and VM events" - depends on HVM + depends on HVM && MGMT_HYPERCALLS default X86 help
Signature · 1 line
2.34.1
PATCH v4 6/24 xen/domctl: consolidate domain.c with MGMT_HYPERCALLS
In reply to Penny ZhengThe following functions, scattered in common/domain.c, and are only referenced and responsible for domctl-op:
- domain_pause_by_systemcontroller
- domain_resume
- domain_set_node_affinity
So they shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
Move them together to avoid scattering #ifdef.
---
v3 - v4:
- combine commit "xen/domctl: wrap domain_pause_by_systemcontroller() with MGMT_HYPERCALLS", "xen/domctl: wrap domain_resume() with CONFIG_MGMT_HYPERCALLS", and "xen/domctl: wrap domain_set_node_affinity() with CONFIG_MGMT_HYPERCALLS"
--- xen/common/domain.c | 114 ++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 56 deletions(-)
xen/common/domain.c +58 -56
@@ -1115,35 +1115,6 @@ void __init setup_system_domains(void)#endif } -int domain_set_node_affinity (struct domain *d,const nodemask_t *affinity) -{ -/* Being disjoint with the system is just wrong. */ -if ( !nodes_intersects (*affinity, node_online_map) ) -return -EINVAL ; - -spin_lock (&d->node_affinity_lock); - -/* -* Being/becoming explicitly affine to all nodes is not particularly -* useful. Let's take it as the `reset node affinity` command. -*/ -if (nodes_full (*affinity) ) - { - d->auto_node_affinity =1 ; - goto out; - } - - d->auto_node_affinity =0 ; - d->node_affinity = *affinity; - -out: -spin_unlock (&d->node_affinity_lock); - -domain_update_node_affinity (d); - -return 0 ; -} -/* rcu_read_lock(&domlist_read_lock) must be held. */ static struct domain *domid_to_domain (domid_t dom) {
@@ -1361,33 +1332,6 @@ int domain_shutdown(struct domain *d, u8 reason)return 0 ; } -void domain_resume (struct domain *d) -{ -struct vcpu *v; - -/* -* Some code paths assume that shutdown status does not get reset under -* their feet (e.g., some assertions make this assumption). -*/ -domain_pause (d); - -spin_lock (&d->shutdown_lock); - - d->is_shutting_down = d->is_shut_down =0 ; - d->shutdown_code =SHUTDOWN_CODE_INVALID ; - - for_each_vcpu ( d, v ) - { -if ( v->paused_for_shutdown ) -vcpu_unpause (v); - v->paused_for_shutdown =0 ; - } - -spin_unlock (&d->shutdown_lock); - -domain_unpause (d); -} -int vcpu_start_shutdown_deferral (struct vcpu *v) {if ( v->defer_shutdown )
@@ -1616,10 +1560,68 @@ static int _domain_pause_by_systemcontroller(struct domain *d, bool sync)return 0 ; } +#ifdef CONFIG_MGMT_HYPERCALLS +int domain_set_node_affinity (struct domain *d,const nodemask_t *affinity) +{ +/* Being disjoint with the system is just wrong. */ +if ( !nodes_intersects (*affinity, node_online_map) ) +return -EINVAL ; + +spin_lock (&d->node_affinity_lock); + +/* +* Being/becoming explicitly affine to all nodes is not particularly +* useful. Let's take it as the `reset node affinity` command. +*/ +if (nodes_full (*affinity) ) + { + d->auto_node_affinity =1 ; + goto out; + } + + d->auto_node_affinity =0 ; + d->node_affinity = *affinity; + +out: +spin_unlock (&d->node_affinity_lock); + +domain_update_node_affinity (d); + +return 0 ; +} + +void domain_resume (struct domain *d) +{ +struct vcpu *v; + +/* +* Some code paths assume that shutdown status does not get reset under +* their feet (e.g., some assertions make this assumption). +*/ +domain_pause (d); + +spin_lock (&d->shutdown_lock); + + d->is_shutting_down = d->is_shut_down =0 ; + d->shutdown_code =SHUTDOWN_CODE_INVALID ; + + for_each_vcpu ( d, v ) + { +if ( v->paused_for_shutdown ) +vcpu_unpause (v); + v->paused_for_shutdown =0 ; + } + +spin_unlock (&d->shutdown_lock); + +domain_unpause (d); +} +int domain_pause_by_systemcontroller (struct domain *d) {return _domain_pause_by_systemcontroller (d, true/* sync */ ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ int domain_pause_by_systemcontroller_nosync (struct domain *d) {
Signature · 1 line
2.34.1
Re: [PATCH v4 06/24] xen/domctl: consolidate domain.c with MGMT_HYPERCALLS
Quoted 11 lines · Penny Zheng
The following functions, scattered in
common/domain.c, and are only referenced and responsible for domctl-op:
-domain_pause_by_systemcontroller
-domain_resume
-domain_set_node_affinity
So they shall be wrapped withCONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
Move them together to avoid scattering #ifdef.Signed-off-by Penny Zheng <[email protected]>
I again think though that the title doesn't quite get it. While "consolidate" may be fine here, I'd like to suggest s/with/towards/ or some such.
Jan
Re: [PATCH v4 06/24] xen/domctl: consolidate domain.c with MGMT_HYPERCALLS
In reply to Penny ZhengQuoted 11 lines · Penny Zheng
The following functions, scattered in
common/domain.c, and are only referenced and responsible for domctl-op:
-domain_pause_by_systemcontroller
-domain_resume
-domain_set_node_affinity
So they shall be wrapped withCONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
Move them together to avoid scattering #ifdef.Signed-off-by Penny Zheng <[email protected]>
One further small request here:
Quoted 18 lines
xen/common/domain.c +0
-12@@ -1115,35 +1115,6 @@ void __init setup_system_domains(void)#endif } -int domain_set_node_affinity (struct domain *d,const nodemask_t *affinity) -{ -/* Being disjoint with the system is just wrong. */ -if ( !nodes_intersects (*affinity, node_online_map) ) -return -EINVAL ; - -spin_lock (&d->node_affinity_lock); - -/* -* Being/becoming explicitly affine to all nodes is not particularly -* useful. Let's take it as the `reset node affinity` command. -*/
xen/common/domain.c void __init setup_system_domains(void) · line 1139
Quoted 10 lines
xen/common/domain.c +0
-10-if (nodes_full (*affinity) ) - { - d->auto_node_affinity =1 ; - goto out; - } - - d->auto_node_affinity =0 ; - d->node_affinity = *affinity; - -out:
I realize you only move this, but ...
Quoted 17 lines
xen/common/domain.c +13
-0@@ -1616,10 +1560,68 @@ static int _domain_pause_by_systemcontroller(struct domain *d, bool sync)return 0 ; } +#ifdef CONFIG_MGMT_HYPERCALLS +int domain_set_node_affinity (struct domain *d,const nodemask_t *affinity) +{ +/* Being disjoint with the system is just wrong. */ +if ( !nodes_intersects (*affinity, node_online_map) ) +return -EINVAL ; + +spin_lock (&d->node_affinity_lock); + +/* +* Being/becoming explicitly affine to all nodes is not particularly +* useful. Let's take it as the `reset node affinity` command. +*/
xen/common/domain.c static int _domain_pause_by_systemcontroller(struct domain *d, bool sync) · line 1585
Quoted 10 lines
xen/common/domain.c +10
-0+if (nodes_full (*affinity) ) + { + d->auto_node_affinity =1 ; + goto out; + } + + d->auto_node_affinity =0 ; + d->node_affinity = *affinity; + +out:
... can you please add a leading blank here, to conform to ./CODING_STYLE?
Jan
PATCH v4 7/24 xen/mem_sharing: make memory sharing depend on MGMT_HYPERCALLS
In reply to Penny ZhengThe enabling bit (d->arch.hvm.mem_sharing.enabled) for memory sharing could only be enabled via domctl-op, so we shall make memory sharing feature depend on MGMT_HYPERCALLS.
---
v3 -> v4:
- new commit
--- xen/arch/x86/hvm/Kconfig | 1 + 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/Kconfig +1 -0
@@ -81,5 +81,6 @@ config MEM_PAGING config MEM_SHARING bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED depends on INTEL_VMX + depends on MGMT_HYPERCALLS endif
Signature · 1 line
2.34.1
PATCH v4 8/24 xen/domctl: wrap domain_kill() with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction domain_kill() is responsible for killing domain and relinquish domain-held resources. and it is only invoked under XEN_DOMCTL_destroydomain-case. So it shall be wrapped with CONFIG_MGMT_HYPERCALLS.
Tracking its calling chain, the following functions could also be wrapped with CONFIG_MGMT_HYPERCALLS:
- domain_relinquish_resource
- pci_release_device
- paging_teardown
- p2m_pod_empty_cache
- relinquish_memory
- pit_deinit
- iommu_release_dt_devices
- tee_relinquish_resources
- ffa_relinquish_resources/optee_relinquish_resources
- relinquish_p2m_mapping
- p2m_clear_root_pages
Otherwise all these functions will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
The reason why {arch_}domain_teardown() is not wrapped is that it is also used on the failure path of domain_create(). And the exclusion of paging_final_teardown() is blocked by domain_destroy(), which will be triggered when d->refcnt equals zero.
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_destroydomain-case transiently
---
v2 -> v3:
- add back stub wrapping in ppc/riscv
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping around XEN_DOMCTL_destroydomain-case
---
v3 -> v4:
- remove diff in mem_sharing.c
- add description for some functions to aid review
--- xen/arch/arm/domain.c | 3 +++ xen/arch/arm/include/asm/tee/tee.h | 2 ++ xen/arch/arm/mmu/p2m.c | 4 ++++ xen/arch/arm/mpu/p2m.c | 2 ++ xen/arch/arm/tee/ffa.c | 4 ++++ xen/arch/arm/tee/optee.c | 4 ++++ xen/arch/arm/tee/tee.c | 2 ++ xen/arch/ppc/stubs.c | 2 ++ xen/arch/riscv/stubs.c | 2 ++ xen/arch/x86/domain.c | 2 ++ xen/arch/x86/emul-i8254.c | 2 ++ xen/arch/x86/mm/p2m-pod.c | 2 ++ xen/arch/x86/mm/p2m.c | 2 ++ xen/arch/x86/mm/paging.c | 2 ++ xen/common/domain.c | 2 ++ xen/drivers/passthrough/device_tree.c | 2 ++ xen/drivers/passthrough/pci.c | 2 ++ 17 files changed, 41 insertions(+)
xen/arch/arm/domain.c +3 -0
@@ -988,6 +988,7 @@ int arch_vcpu_reset(struct vcpu *v)return 0 ; } +#ifdef CONFIG_MGMT_HYPERCALLS static int relinquish_memory (struct domain *d,struct page_list_head *list) {struct page_info *page, *tmp;
@@ -1139,6 +1140,8 @@ int domain_relinquish_resources(struct domain *d)#undef PROGRESS +#endif /* CONFIG_MGMT_HYPERCALLS */ +void arch_dump_domain_info (struct domain *d) {p2m_dump_info (d);
xen/arch/arm/include/asm/tee/tee.h +2 -0
@@ -40,12 +40,14 @@ struct tee_mediator_ops {int (*domain_teardown)(struct domain *d);void (*free_domain_ctx)(struct domain *d); +#ifdef CONFIG_MGMT_HYPERCALLS /* * Called during domain destruction to relinquish resources used * by mediator itself. This function can return -ERESTART to indicate * that it does not finished work and should be called again. */ int (*relinquish_resources)(struct domain *d); +#endif /* Handle SMCCC call for current domain. */ bool (*handle_call)(struct cpu_user_regs *regs);
xen/arch/arm/mmu/p2m.c +4 -0
@@ -1243,6 +1243,7 @@ static void p2m_invalidate_table(struct p2m_domain *p2m, mfn_t mfn) p2m->need_flush = true; } +#ifdef CONFIG_MGMT_HYPERCALLS /* * The domain will not be scheduled anymore, so in theory we should * not need to flush the TLBs. Do it for safety purpose.
@@ -1262,6 +1263,7 @@ void p2m_clear_root_pages(struct p2m_domain *p2m) p2m_write_unlock(p2m); } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * Invalidate all entries in the root page-tables. This is
@@ -1556,6 +1558,7 @@ int p2m_init(struct domain *d)return 0 ; } +#ifdef CONFIG_MGMT_HYPERCALLS /* * The function will go through the p2m and remove page reference when it * is required. The mapping will be removed from the p2m.
@@ -1626,6 +1629,7 @@ int relinquish_p2m_mapping(struct domain *d) return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * Clean & invalidate RAM associated to the guest vCPU.
xen/arch/arm/mpu/p2m.c +2 -0
@@ -57,10 +57,12 @@ bool p2m_resolve_translation_fault(struct domain *d, gfn_t gfn)void p2m_flush_vm (struct vcpu *v) {} +#ifdef CONFIG_MGMT_HYPERCALLS int relinquish_p2m_mapping (struct domain *d) {return 0 ; } +#endif /* CONFIG_MGMT_HYPERCALLS */ void p2m_domain_creation_finished (struct domain *d) {}
xen/arch/arm/tee/ffa.c +4 -0
@@ -469,10 +469,12 @@ static void ffa_free_domain_ctx(struct domain *d)XFREE (d->arch.tee); } +#ifdef CONFIG_MGMT_HYPERCALLS static int ffa_relinquish_resources (struct domain *d) {return 0 ; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static void ffa_init_secondary (void ) {
@@ -623,7 +625,9 @@ static const struct tee_mediator_ops ffa_ops = .domain_init = ffa_domain_init, .domain_teardown = ffa_domain_teardown, .free_domain_ctx = ffa_free_domain_ctx, +#ifdef CONFIG_MGMT_HYPERCALLS .relinquish_resources = ffa_relinquish_resources, +#endif .handle_call = ffa_handle_call, };
xen/arch/arm/tee/optee.c +4 -0
@@ -632,6 +632,7 @@ static void free_optee_shm_buf_pg_list(struct optee_domain *ctx, cookie); } +#ifdef CONFIG_MGMT_HYPERCALLS static int optee_relinquish_resources (struct domain *d) {struct arm_smccc_res resp;
@@ -693,6 +694,7 @@ static int optee_relinquish_resources(struct domain *d) return 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */ #define PAGELIST_ENTRIES_PER_PAGE \ ((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1)
@@ -1727,7 +1729,9 @@ static const struct tee_mediator_ops optee_ops = .probe = optee_probe, .domain_init = optee_domain_init, .domain_teardown = optee_domain_teardown, +#ifdef CONFIG_MGMT_HYPERCALLS .relinquish_resources = optee_relinquish_resources, +#endif .handle_call = optee_handle_call, };
xen/arch/arm/tee/tee.c +2 -0
@@ -65,6 +65,7 @@ int tee_domain_teardown(struct domain *d)return cur_mediator->ops->domain_teardown (d); } +#ifdef CONFIG_MGMT_HYPERCALLS int tee_relinquish_resources (struct domain *d) {if ( !cur_mediator )
@@ -72,6 +73,7 @@ int tee_relinquish_resources(struct domain *d) return cur_mediator->ops->relinquish_resources(d); } +#endif /* CONFIG_MGMT_HYPERCALLS */ uint16_t tee_get_type (void ) {
xen/arch/ppc/stubs.c +2 -0
@@ -234,10 +234,12 @@ int arch_vcpu_reset(struct vcpu *v)BUG_ON ("unimplemented" ); } +#ifdef CONFIG_MGMT_HYPERCALLS int domain_relinquish_resources (struct domain *d) {BUG_ON ("unimplemented" ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ void arch_dump_domain_info (struct domain *d) {
xen/arch/riscv/stubs.c +2 -0
@@ -208,10 +208,12 @@ int arch_vcpu_reset(struct vcpu *v)BUG_ON ("unimplemented" ); } +#ifdef CONFIG_MGMT_HYPERCALLS int domain_relinquish_resources (struct domain *d) {BUG_ON ("unimplemented" ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ void arch_dump_domain_info (struct domain *d) {
xen/arch/x86/domain.c +2 -0
@@ -2305,6 +2305,7 @@ void sync_vcpu_execstate(struct vcpu *v) read_atomic(&v->dirty_cpu) != dirty_cpu); } +#ifdef CONFIG_MGMT_HYPERCALLS static int relinquish_memory (struct domain *d,struct page_list_head *list,unsigned long type) {
@@ -2629,6 +2630,7 @@ int domain_relinquish_resources(struct domain *d) return 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */ void arch_dump_domain_info (struct domain *d) {
xen/arch/x86/emul-i8254.c +2 -0
@@ -651,6 +651,7 @@ void pit_init(struct domain *d)pit_reset (d); } +#ifdef CONFIG_MGMT_HYPERCALLS void pit_deinit (struct domain *d) {PITState *pit =domain_vpit (d);
@@ -664,6 +665,7 @@ void pit_deinit(struct domain *d) destroy_periodic_time(&pit->pt0); } } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * Local variables:
xen/arch/x86/mm/p2m-pod.c +2 -0
@@ -366,6 +366,7 @@ void p2m_pod_get_mem_target(const struct domain *d, xen_pod_target_t *target)pod_unlock (p2m); } +#ifdef CONFIG_MGMT_HYPERCALLS int p2m_pod_empty_cache (struct domain *d) {struct p2m_domain *p2m =p2m_get_hostp2m (d);
@@ -409,6 +410,7 @@ int p2m_pod_empty_cache(struct domain *d)unlock_page_alloc (p2m); return p2m->pod.count ? -ERESTART : 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */ int p2m_pod_offline_or_broken_hit (struct page_info *p)
xen/arch/x86/mm/p2m.c +2 -0
@@ -2097,6 +2097,7 @@ int xenmem_add_to_physmap_one(return rc; } +#ifdef CONFIG_MGMT_HYPERCALLS /* * Remove foreign mappings from the p2m, as that drops the page reference taken * when mapped.
@@ -2160,6 +2161,7 @@ int relinquish_p2m_mapping(struct domain *d) return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ void p2m_log_dirty_range (struct domain *d,unsigned long begin_pfn,unsigned long nr,uint8_t *dirty_bitmap)
xen/arch/x86/mm/paging.c +2 -0
@@ -768,6 +768,7 @@ void paging_vcpu_teardown(struct vcpu *v)shadow_vcpu_teardown (v); } +#ifdef CONFIG_MGMT_HYPERCALLS /* Call when destroying a domain */ int paging_teardown (struct domain *d) {
@@ -794,6 +795,7 @@ int paging_teardown(struct domain *d) return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* Call once all of the references to the domain have gone away */ void paging_final_teardown (struct domain *d)
xen/common/domain.c +2 -0
@@ -1211,6 +1211,7 @@ int rcu_lock_live_remote_domain_by_id(domid_t dom, struct domain **d)return 0 ; } +#ifdef CONFIG_MGMT_HYPERCALLS int domain_kill (struct domain *d) {int rc =0 ;
@@ -1261,6 +1262,7 @@ int domain_kill(struct domain *d) return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ void __domain_crash (struct domain *d)
xen/drivers/passthrough/device_tree.c +2 -0
@@ -108,6 +108,7 @@ int iommu_dt_domain_init(struct domain *d)return 0 ; } +#ifdef CONFIG_MGMT_HYPERCALLS int iommu_release_dt_devices (struct domain *d) {const struct domain_iommu *hd =dom_iommu (d);
@@ -136,6 +137,7 @@ int iommu_release_dt_devices(struct domain *d)return 0 ; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static int iommu_dt_xlate(struct device *dev, const struct dt_phandle_args *iommu_spec,
xen/drivers/passthrough/pci.c +2 -0
@@ -946,6 +946,7 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus,return ret; } +#ifdef CONFIG_MGMT_HYPERCALLS int pci_release_devices (struct domain *d) {int combined_ret;
@@ -1004,6 +1005,7 @@ int pci_release_devices(struct domain *d) return combined_ret; } +#endif /* CONFIG_MGMT_HYPERCALLS */ #define PCI_CLASS_BRIDGE_HOST 0x0600#define PCI_CLASS_BRIDGE_PCI 0x0604
Signature · 1 line
2.34.1
Re: [PATCH v4 08/24] xen/domctl: wrap domain_kill() with CONFIG_MGMT_HYPERCALLS
Quoted 24 lines · Penny Zheng
Function
domain_kill()is responsible for killing domain and relinquish domain-held resources. and it is only invoked under XEN_DOMCTL_destroydomain-case. So it shall be wrapped withCONFIG_MGMT_HYPERCALLS.
Tracking its calling chain, the following functions could also be wrapped withCONFIG_MGMT_HYPERCALLS:
-domain_relinquish_resource
-pci_release_device
-paging_teardown
-p2m_pod_empty_cache
-relinquish_memory
-pit_deinit
-iommu_release_dt_devices
-tee_relinquish_resources
- ffa_relinquish_resources/optee_relinquish_resources
-relinquish_p2m_mapping
-p2m_clear_root_pages
Otherwise all these functions will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
The reason why {arch_}domain_teardown() is not wrapped is that it is also used on the failure path ofdomain_create(). And the exclusion ofpaging_final_teardown()is blocked bydomain_destroy(), which will be triggered whend->refcntequals zero.
Quoted 2 lines
Signed-off-by Penny Zheng <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
PATCH v4 9/24 xen/domctl: wrap vcpu_affinity_domctl() with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction vcpu_affinity_domctl() is responsible for XEN_DOMCTL_{getvcpuaffinity,setvcpuaffinity} domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1. Tracking its calling chain, vcpuaffinity_params_invalid() also needs wrapping too
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_{getvcpuaffinity,setvcpuaffinity}-case transiently
---
v2 -> v3:
- adapt to changes of "remove vcpu_set_soft_affinity()"
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping around XEN_DOMCTL_{getvcpuaffinity,setvcpuaffinity}-case
---
v3 -> v4
- wrap vcpuaffinity_params_invalid()
--- xen/common/sched/core.c | 2 ++ 1 file changed, 2 insertions(+)
xen/common/sched/core.c +2 -0
@@ -1678,6 +1678,7 @@ int vcpu_temporary_affinity(struct vcpu *v, unsigned int cpu, uint8_t reason)return ret; } +#ifdef CONFIG_MGMT_HYPERCALLS static inline int vcpuaffinity_params_invalid (const struct xen_domctl_vcpuaffinity *vcpuaff) {
@@ -1798,6 +1799,7 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t cmd, return ret; } +#endif /* CONFIG_MGMT_HYPERCALLS */ bool alloc_affinity_masks (struct affinity_masks *affinity) {
Signature · 1 line
2.34.1
PATCH v4 10/24 xen/domctl: wrap sched_adjust() with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction sched_adjust() is responsible for XEN_DOMCTL_scheduler_op domctl-op, so it could be wrapped with CONFIG_MGMT_HYPERCALLS.
Tracing its calling chain, the following functions shall be wrapped with CONFIG_MGMT_HYPERCALLS too:
- sched_adjust_dom()
- scheduler-specific .adjust() callback
- xsm_sysctl_scheduler_op()
Otherwise all these functions will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_scheduler_op-case transiently
---
v2 -> v3
- add missing wrapping in xsm/dummy.h
- move and get away with just a single #ifdef
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping around XEN_DOMCTL_scheduler_op-case
--- xen/common/sched/arinc653.c | 1 - xen/common/sched/core.c | 2 -- xen/common/sched/credit.c | 4 +++- xen/common/sched/credit2.c | 4 +++- xen/common/sched/private.h | 8 ++++---- xen/common/sched/rt.c | 4 ++++ xen/include/xsm/dummy.h | 2 ++ xen/include/xsm/xsm.h | 4 ++-- xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 4 ++-- 10 files changed, 21 insertions(+), 14 deletions(-)
xen/common/sched/arinc653.c +0 -1
@@ -735,7 +735,6 @@ static const struct scheduler sched_arinc653_def = { .switch_sched = a653_switch_sched, - .adjust = NULL,#ifdef CONFIG_MGMT_HYPERCALLS .adjust_global = a653sched_adjust_global,#endif
xen/common/sched/core.c +0 -2
@@ -2072,7 +2072,6 @@ int scheduler_id(void) {return operations.sched_id; } -#endif /* Adjust scheduling parameter for a given domain. */ long sched_adjust (struct domain *d,struct xen_domctl_scheduler_op *op)
@@ -2109,7 +2108,6 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)return ret; } -#ifdef CONFIG_MGMT_HYPERCALLS long sched_adjust_global (struct xen_sysctl_scheduler_op *op) {struct cpupool *pool;
xen/common/sched/credit.c +3 -1
@@ -1183,6 +1183,7 @@ csched_unit_yield(const struct scheduler *ops, struct sched_unit *unit)set_bit (CSCHED_FLAG_UNIT_YIELD , &svc->flags); } +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check csched_dom_cntl( const struct scheduler *ops,
@@ -1227,6 +1228,7 @@ csched_dom_cntl(return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static void cf_check csched_aff_cntl(const struct scheduler *ops, struct sched_unit *unit,
@@ -2288,9 +2290,9 @@ static const struct scheduler sched_credit_def = { .wake = csched_unit_wake, .yield = csched_unit_yield, - .adjust = csched_dom_cntl, .adjust_affinity= csched_aff_cntl, #ifdef CONFIG_MGMT_HYPERCALLS + .adjust = csched_dom_cntl, .adjust_global = csched_sys_cntl, #endif
xen/common/sched/credit2.c +3 -1
@@ -2909,6 +2909,7 @@ static void cf_check csched2_unit_migrate(sched_set_res (unit,get_sched_res (new_cpu)); } +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check csched2_dom_cntl( const struct scheduler *ops,
@@ -3114,6 +3115,7 @@ csched2_dom_cntl(return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static void cf_check csched2_aff_cntl(const struct scheduler *ops, struct sched_unit *unit,
@@ -4246,9 +4248,9 @@ static const struct scheduler sched_credit2_def = { .wake = csched2_unit_wake, .yield = csched2_unit_yield, - .adjust = csched2_dom_cntl, .adjust_affinity= csched2_aff_cntl, #ifdef CONFIG_MGMT_HYPERCALLS + .adjust = csched2_dom_cntl, .adjust_global = csched2_sys_cntl, #endif
xen/common/sched/private.h +4 -4
@@ -349,14 +349,14 @@ struct scheduler {void (*migrate) (const struct scheduler *ops,struct sched_unit *unit,unsigned int new_cpu); -int (*adjust) (const struct scheduler *ops, -struct domain *d, -struct xen_domctl_scheduler_op *op);void (*adjust_affinity)(const struct scheduler *ops,struct sched_unit *unit,const struct cpumask *hard,const struct cpumask *soft);#ifdef CONFIG_MGMT_HYPERCALLS +int (*adjust) (const struct scheduler *ops, +struct domain *d, +struct xen_domctl_scheduler_op *op);int (*adjust_global) (const struct scheduler *ops,struct xen_sysctl_scheduler_op *sc);#endif
@@ -506,13 +506,13 @@ static inline void sched_adjust_affinity(const struct scheduler *s, s->adjust_affinity (s, unit, hard, soft); } +#ifdef CONFIG_MGMT_HYPERCALLS static inline int sched_adjust_dom (const struct scheduler *s,struct domain *d,struct xen_domctl_scheduler_op *op) {return s->adjust ? s->adjust (s, d, op) :0 ; } -#ifdef CONFIG_MGMT_HYPERCALLS static inline int sched_adjust_cpupool (const struct scheduler *s,struct xen_sysctl_scheduler_op *op) {
xen/common/sched/rt.c +4 -0
@@ -1362,6 +1362,7 @@ out:unit_schedule_unlock_irq (lock, unit); } +#ifdef CONFIG_MGMT_HYPERCALLS /* * set/get each unit info of each domain */
@@ -1471,6 +1472,7 @@ rt_dom_cntl( return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * The replenishment timer handler picks units
@@ -1572,7 +1574,9 @@ static const struct scheduler sched_rtds_def = { .insert_unit = rt_unit_insert, .remove_unit = rt_unit_remove, +#ifdef CONFIG_MGMT_HYPERCALLS .adjust = rt_dom_cntl, +#endif .pick_resource = rt_res_pick, .do_schedule = rt_schedule,
xen/include/xsm/dummy.h +2 -0
@@ -141,12 +141,14 @@ static XSM_INLINE int cf_check xsm_getdomaininfo(return xsm_default_action (action, current->domain, d); } +#ifdef CONFIG_MGMT_HYPERCALLS static XSM_INLINE int cf_check xsm_domctl_scheduler_op( XSM_DEFAULT_ARG struct domain *d, int cmd) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } +#endif /* CONFIG_MGMT_HYPERCALLS */ #ifdef CONFIG_MGMT_HYPERCALLS static XSM_INLINE int cf_check xsm_sysctl_scheduler_op(XSM_DEFAULT_ARG int cmd)
xen/include/xsm/xsm.h +2 -2
@@ -56,8 +56,8 @@ struct xsm_ops { struct xen_domctl_getdomaininfo *info);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_MGMT_HYPERCALLS +int (*domctl_scheduler_op)(struct domain *d,int op);int (*sysctl_scheduler_op)(int op);#endif int (*set_target)(struct domain *d,struct domain *e);
@@ -240,13 +240,13 @@ static inline int xsm_get_domain_state(xsm_default_t def, struct domain *d)return alternative_call (xsm_ops.get_domain_state, d); } +#ifdef CONFIG_MGMT_HYPERCALLS static inline int xsm_domctl_scheduler_op (xsm_default_t def,struct domain *d,int cmd) {return alternative_call (xsm_ops.domctl_scheduler_op, d, cmd); } -#ifdef CONFIG_MGMT_HYPERCALLS static inline int xsm_sysctl_scheduler_op (xsm_default_t def,int cmd) {return alternative_call (xsm_ops.sysctl_scheduler_op, cmd);
xen/xsm/dummy.c +1 -1
@@ -18,8 +18,8 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .security_domaininfo = xsm_security_domaininfo, .domain_create = xsm_domain_create, .getdomaininfo = xsm_getdomaininfo, - .domctl_scheduler_op = xsm_domctl_scheduler_op, #ifdef CONFIG_MGMT_HYPERCALLS + .domctl_scheduler_op = xsm_domctl_scheduler_op, .sysctl_scheduler_op = xsm_sysctl_scheduler_op, #endif .set_target = xsm_set_target,
xen/xsm/flask/hooks.c +2 -2
@@ -609,6 +609,7 @@ static int cf_check flask_getdomaininfo(struct domain *d)return current_has_perm (d,SECCLASS_DOMAIN ,DOMAIN__GETDOMAININFO ); } +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check flask_domctl_scheduler_op(struct domain *d, int op) { switch ( op )
@@ -626,7 +627,6 @@ static int cf_check flask_domctl_scheduler_op(struct domain *d, int op) } } -#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check flask_sysctl_scheduler_op(int op) { switch ( op )
@@ -1883,8 +1883,8 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .security_domaininfo = flask_security_domaininfo, .domain_create = flask_domain_create, .getdomaininfo = flask_getdomaininfo, - .domctl_scheduler_op = flask_domctl_scheduler_op, #ifdef CONFIG_MGMT_HYPERCALLS + .domctl_scheduler_op = flask_domctl_scheduler_op, .sysctl_scheduler_op = flask_sysctl_scheduler_op, #endif .set_target = flask_set_target,
Signature · 1 line
2.34.1
PATCH v4 11/24 xen/domctl: wrap xsm_irq_permission with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction xsm_irq_permission() is invoked only under XEN_DOMCTL_irq_permission domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will become unreanchable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
---
v2 -> v3
- add missing wrapping in xsm/dummy.h
- adapt to the commit of "remove redundant xsm_iomem_mapping()"
- address "violating Misra rule 2.1" in commit message
--- xen/include/xsm/dummy.h | 2 ++ xen/include/xsm/xsm.h | 4 ++++ xen/xsm/dummy.c | 2 ++ xen/xsm/flask/hooks.c | 4 ++++ 4 files changed, 12 insertions(+)
xen/include/xsm/dummy.h +2 -0
@@ -564,12 +564,14 @@ static XSM_INLINE int cf_check xsm_unmap_domain_irq(return xsm_default_action (action, current->domain, d); } +#ifdef CONFIG_MGMT_HYPERCALLS static XSM_INLINE int cf_check xsm_irq_permission( XSM_DEFAULT_ARG struct domain *d, int pirq, uint8_t allow) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } +#endif static XSM_INLINE int cf_check xsm_iomem_permission( XSM_DEFAULT_ARG struct domain *d, uint64_t s, uint64_t e, uint8_t allow)
xen/include/xsm/xsm.h +4 -0
@@ -115,7 +115,9 @@ struct xsm_ops {int (*unmap_domain_irq)(struct domain *d,int irq,const void *data);int (*bind_pt_irq)(struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*unbind_pt_irq)(struct domain *d,struct xen_domctl_bind_pt_irq *bind); +#ifdef CONFIG_MGMT_HYPERCALLS int (*irq_permission)(struct domain *d,int pirq,uint8_t allow); +#endif int (*iomem_permission)(struct domain *d,uint64_t s,uint64_t e,uint8_t allow); int (*pci_config_permission)(struct domain *d, uint32_t machine_bdf,
@@ -499,11 +501,13 @@ static inline int xsm_unbind_pt_irq(return alternative_call (xsm_ops.unbind_pt_irq, d, bind); } +#ifdef CONFIG_MGMT_HYPERCALLS static inline int xsm_irq_permission (xsm_default_t def,struct domain *d,int pirq,uint8_t allow) {return alternative_call (xsm_ops.irq_permission, d, pirq, allow); } +#endif /* CONFIG_MGMT_HYPERCALLS */ static inline int xsm_iomem_permission (xsm_default_t def,struct domain *d,uint64_t s,uint64_t e,uint8_t allow)
xen/xsm/dummy.c +2 -0
@@ -73,7 +73,9 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .unmap_domain_irq = xsm_unmap_domain_irq, .bind_pt_irq = xsm_bind_pt_irq, .unbind_pt_irq = xsm_unbind_pt_irq, +#ifdef CONFIG_MGMT_HYPERCALLS .irq_permission = xsm_irq_permission, +#endif .iomem_permission = xsm_iomem_permission, .pci_config_permission = xsm_pci_config_permission, .get_vnumainfo = xsm_get_vnumainfo,
xen/xsm/flask/hooks.c +4 -0
@@ -1111,12 +1111,14 @@ static int cf_check flask_unbind_pt_irq(return current_has_perm (d,SECCLASS_RESOURCE ,RESOURCE__REMOVE ); } +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check flask_irq_permission(struct domain *d,int pirq,uint8_t access) {/* the PIRQ number is not useful; real IRQ is checked during mapping */ return current_has_perm (d,SECCLASS_RESOURCE ,resource_to_perm (access)); } +#endif /* CONFIG_MGMT_HYPERCALLS */ struct iomem_has_perm_data {uint32_t ssid;
@@ -1938,7 +1940,9 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .unmap_domain_irq = flask_unmap_domain_irq, .bind_pt_irq = flask_bind_pt_irq, .unbind_pt_irq = flask_unbind_pt_irq, +#ifdef CONFIG_MGMT_HYPERCALLS .irq_permission = flask_irq_permission, +#endif .iomem_permission = flask_iomem_permission, .pci_config_permission = flask_pci_config_permission,
Signature · 1 line
2.34.1
PATCH v4 12/24 xen/domctl: wrap arch-specific domain_set_time_offset() with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengArch-specific domain_set_time_offset() is responisble for XEN_DOMCTL_settimeoffset domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1.
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_settimeoffset-case transiently
---
v2 -> v3:
- add back stub wrapping for riscv
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping around XEN_DOMCTL_settimeoffset-case
--- xen/arch/arm/time.c | 2 ++ xen/arch/riscv/stubs.c | 2 ++ xen/arch/x86/time.c | 2 ++ 3 files changed, 6 insertions(+)
xen/arch/arm/time.c +2 -0
@@ -378,12 +378,14 @@ void force_update_vcpu_system_time(struct vcpu *v)update_vcpu_system_time (v); } +#ifdef CONFIG_MGMT_HYPERCALLS void domain_set_time_offset (struct domain *d,int64_t time_offset_seconds) { d->time_offset.seconds = time_offset_seconds; d->time_offset.set = true;/* XXX update guest visible wallclock time */ } +#endif /* CONFIG_MGMT_HYPERCALLS */ static int cpu_time_callback(struct notifier_block *nfb, unsigned long action,
xen/arch/riscv/stubs.c +2 -0
@@ -31,10 +31,12 @@ void send_timer_event(struct vcpu *v)BUG_ON ("unimplemented" ); } +#ifdef CONFIG_MGMT_HYPERCALLS void domain_set_time_offset (struct domain *d,int64_t time_offset_seconds) {BUG_ON ("unimplemented" ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* domctl.c */
xen/arch/x86/time.c +2 -0
@@ -1841,6 +1841,7 @@ static void update_domain_rtc(void)rcu_read_unlock (&domlist_read_lock); } +#ifdef CONFIG_MGMT_HYPERCALLS void domain_set_time_offset (struct domain *d,int64_t time_offset_seconds) { d->time_offset.seconds = time_offset_seconds;
@@ -1849,6 +1850,7 @@ void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds)rtc_update_clock (d); update_domain_wallclock_time(d); } +#endif /* CONFIG_MGMT_HYPERCALLS */ int cpu_frequency_change (u64 freq) {
Signature · 1 line
2.34.1
PATCH v4 13/24 xen/domctl: wrap xsm_set_target() with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction xsm_set_target() is only invoked under XEN_DOMCTL_set_target domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra 2.1.
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
---
v2 -> v3
- wrap the whole inline function xsm_set_target()
- add missing wrapping in xsm/dummy.h
- address "violating Misra rule 2.1" in commit message
--- xen/include/xsm/dummy.h | 2 ++ xen/include/xsm/xsm.h | 4 +++- xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-)
xen/include/xsm/dummy.h +2 -0
@@ -158,12 +158,14 @@ static XSM_INLINE int cf_check xsm_sysctl_scheduler_op(XSM_DEFAULT_ARG int cmd) }#endif /* CONFIG_MGMT_HYPERCALLS */ +#ifdef CONFIG_MGMT_HYPERCALLS static XSM_INLINE int cf_check xsm_set_target( XSM_DEFAULT_ARG struct domain *d, struct domain *e) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } +#endif /* CONFIG_MGMT_HYPERCALLS */ static XSM_INLINE int cf_check xsm_domctl( XSM_DEFAULT_ARG struct domain *d, unsigned int cmd, uint32_t ssidref)
xen/include/xsm/xsm.h +3 -1
@@ -59,8 +59,8 @@ struct xsm_ops {#ifdef CONFIG_MGMT_HYPERCALLS int (*domctl_scheduler_op)(struct domain *d,int op);int (*sysctl_scheduler_op)(int op); -#endif int (*set_target)(struct domain *d,struct domain *e); +#endif int (*domctl)(struct domain *d,unsigned int cmd,uint32_t ssidref);#ifdef CONFIG_MGMT_HYPERCALLS int (*sysctl)(int cmd);
@@ -255,11 +255,13 @@ static inline int xsm_sysctl_scheduler_op(xsm_default_t def, int cmd) }#endif +#ifdef CONFIG_MGMT_HYPERCALLS static inline int xsm_set_target (xsm_default_t def,struct domain *d,struct domain *e) {return alternative_call (xsm_ops.set_target, d, e); } +#endif /* CONFIG_MGMT_HYPERCALLS */ static inline int xsm_domctl (xsm_default_t def,struct domain *d,unsigned int cmd,uint32_t ssidref)
xen/xsm/dummy.c +1 -1
@@ -21,8 +21,8 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {#ifdef CONFIG_MGMT_HYPERCALLS .domctl_scheduler_op = xsm_domctl_scheduler_op, .sysctl_scheduler_op = xsm_sysctl_scheduler_op, -#endif .set_target = xsm_set_target, +#endif .domctl = xsm_domctl, #ifdef CONFIG_MGMT_HYPERCALLS .sysctl = xsm_sysctl,
xen/xsm/flask/hooks.c +2 -2
@@ -641,7 +641,6 @@ static int cf_check flask_sysctl_scheduler_op(int op)return avc_unknown_permission ("sysctl_scheduler_op" , op); } } -#endif /* CONFIG_MGMT_HYPERCALLS */ static int cf_check flask_set_target(struct domain *d, struct domain *t) {
@@ -666,6 +665,7 @@ static int cf_check flask_set_target(struct domain *d, struct domain *t) &dsec->target_sid);return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,uint32_t ssidref)
@@ -1888,8 +1888,8 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {#ifdef CONFIG_MGMT_HYPERCALLS .domctl_scheduler_op = flask_domctl_scheduler_op, .sysctl_scheduler_op = flask_sysctl_scheduler_op, -#endif .set_target = flask_set_target, +#endif .domctl = flask_domctl, #ifdef CONFIG_MGMT_HYPERCALLS .sysctl = flask_sysctl,
Signature · 1 line
2.34.1
PATCH v4 14/24 xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction iommu_do_pci_domctl() is the main entry for pci-subset iommu-related domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Tracking its calling chain, the following functions shall all be wrapped with CONFIG_MGMT_HYPERCALLS:
- iommu_do_pci_domctl
- iommu_get_device_group
- xsm_get_device_group
- iommu_ops.get_device_group_id
- amd_iommu_group_id/intel_iommu_group_id
- device_assigned
- xsm_assign_device
- assign_device
- iommu_ops.assign_device
- intel_iommu_assign_device/amd_iommu_assign_device
- xsm_deassign_device
- deassign_device
- iommu_ops.reassign_device
- reassign_device_ownership/reassign_device
Otherwise all the functions will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_assign_device{test_assign_device,deassign_device, get_device_group}-case transiently
---
v2 -> v3:
- make PCI_PASSTHROUGH(, then HAS_VPCI_GUEST_SUPPORT) depend on MGMT_HYPERCALLS
- add wrapping for iommu_remove_dt_device/iommu_dt_device_is_assigned_locked/ arm_smmu_detach_dev/arm_smmu_domain_remove_master
- fold commit
"xen/xsm: wrap xsm-iommu-related functions with CONFIG_MGMT_HYPERCALLS" in
- fix overly long #ifdef
- add missing wrapping in xsm/dummy.h
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping of XEN_DOMCTL_assign_device{test_assign_device,deassign_device,get_device_group}-case
---
v3 -> v4:
- move codes to wrap with a single #ifdef
- split into PCI related subset and DT subset
--- xen/drivers/passthrough/amd/pci_amd_iommu.c | 20 ++++---- xen/drivers/passthrough/pci.c | 52 +++++++++++---------- xen/drivers/passthrough/vtd/iommu.c | 6 ++- xen/include/xsm/dummy.h | 6 ++- xen/include/xsm/xsm.h | 12 +++-- xen/xsm/dummy.c | 6 ++- xen/xsm/flask/hooks.c | 12 +++-- 7 files changed, 68 insertions(+), 46 deletions(-)
xen/drivers/passthrough/amd/pci_amd_iommu.c +12 -8
@@ -461,6 +461,7 @@ static void amd_iommu_disable_domain_device(const struct domain *domain,spin_unlock_irqrestore (&iommu->lock, flags); } +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check reassign_device(struct domain *source,struct domain *target,u8 devfn,struct pci_dev *pdev)
@@ -551,6 +552,14 @@ static int cf_check amd_iommu_assign_device(return rc; } +static int cf_check amd_iommu_group_id(u16 seg, u8 bus, u8 devfn) +{ +unsigned int bdf =PCI_BDF (bus, devfn); + +return (bdf < ivrs_bdf_entries) ?get_dma_requestor_id (seg, bdf) : bdf; +} +#endif /* CONFIG_MGMT_HYPERCALLS */ + static void cf_check amd_iommu_clear_root_pgtable(struct domain *d) {struct domain_iommu *hd =dom_iommu (d);
@@ -698,13 +707,6 @@ static int cf_check amd_iommu_remove_device(u8 devfn, struct pci_dev *pdev)return 0 ; } -static int cf_check amd_iommu_group_id(u16 seg, u8 bus, u8 devfn) -{ -unsigned int bdf =PCI_BDF (bus, devfn); - -return (bdf < ivrs_bdf_entries) ?get_dma_requestor_id (seg, bdf) : bdf; -} -#include <asm/io_apic.h> static void amd_dump_page_table_level(struct page_info *pg, int level,
@@ -772,14 +774,16 @@ static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { .quarantine_init = amd_iommu_quarantine_init, .add_device = amd_iommu_add_device, .remove_device = amd_iommu_remove_device, - .assign_device = amd_iommu_assign_device, .teardown = amd_iommu_domain_destroy, .clear_root_pgtable = amd_iommu_clear_root_pgtable, .map_page = amd_iommu_map_page, .unmap_page = amd_iommu_unmap_page, .iotlb_flush = amd_iommu_flush_iotlb_pages, +#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device = amd_iommu_assign_device, .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id, +#endif .enable_x2apic = iov_enable_xt, .update_ire_from_apic = amd_iommu_ioapic_update_ire, .update_ire_from_msi = amd_iommu_msi_msg_update_ire,
xen/drivers/passthrough/pci.c +27 -25
82 lines not on this page · raw message
xen/drivers/passthrough/vtd/iommu.c +5 -1
@@ -2742,6 +2742,7 @@ static int __init cf_check vtd_setup(void)return ret; } +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check reassign_device_ownership( struct domain *source, struct domain *target,
@@ -2937,6 +2938,7 @@ static int cf_check intel_iommu_group_id(u16 seg, u8 bus, u8 devfn)return PCI_BDF (bus, devfn); } +#endif /* CONFIG_MGMT_HYPERCALLS */ static int __must_check cf_check vtd_suspend(void) {
@@ -3245,14 +3247,16 @@ static const struct iommu_ops __initconst_cf_clobber vtd_ops = { .add_device = intel_iommu_add_device, .enable_device = intel_iommu_enable_device, .remove_device = intel_iommu_remove_device, - .assign_device = intel_iommu_assign_device, .teardown = iommu_domain_teardown, .clear_root_pgtable = iommu_clear_root_pgtable, .map_page = intel_iommu_map_page, .unmap_page = intel_iommu_unmap_page, .lookup_page = intel_iommu_lookup_page, +#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device = intel_iommu_assign_device, .reassign_device = reassign_device_ownership, .get_device_group_id = intel_iommu_group_id, +#endif .enable_x2apic = intel_iommu_enable_eim, .disable_x2apic = intel_iommu_disable_eim, .update_ire_from_apic = io_apic_write_remap_rte,
xen/include/xsm/dummy.h +4 -2
@@ -407,7 +407,8 @@ static XSM_INLINE int cf_check xsm_get_vnumainfo(return xsm_default_action (action, current->domain, d); } -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI static XSM_INLINE int cf_check xsm_get_device_group( XSM_DEFAULT_ARG uint32_t machine_bdf) {
@@ -429,7 +430,8 @@ static XSM_INLINE int cf_check xsm_deassign_device(return xsm_default_action (action, current->domain, d); } -#endif /* HAS_PASSTHROUGH && HAS_PCI */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) static XSM_INLINE int cf_check xsm_assign_dtdevice(
xen/include/xsm/xsm.h +8 -4
@@ -123,11 +123,13 @@ struct xsm_ops {int (*pci_config_permission)(struct domain *d,uint32_t machine_bdf,uint16_t start,uint16_t end,uint8_t access); -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_MGMT_HYPERCALLS ) +#ifdef CONFIG_HAS_PCI int (*get_device_group)(uint32_t machine_bdf);int (*assign_device)(struct domain *d,uint32_t machine_bdf);int (*deassign_device)(struct domain *d,uint32_t machine_bdf); -#endif +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY )int (*assign_dtdevice)(struct domain *d,const char *dtpath);
@@ -524,7 +526,8 @@ static inline int xsm_pci_config_permission(return alternative_call (xsm_ops.pci_config_permission, d, machine_bdf, start, end, access); } -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI static inline int xsm_get_device_group(xsm_default_t def, uint32_t machine_bdf) { return alternative_call(xsm_ops.get_device_group, machine_bdf);
@@ -541,7 +544,8 @@ static inline int xsm_deassign_device( {return alternative_call (xsm_ops.deassign_device, d, machine_bdf); } -#endif /* HAS_PASSTHROUGH && HAS_PCI) */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) static inline int xsm_assign_dtdevice(
xen/xsm/dummy.c +4 -2
@@ -80,11 +80,13 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .pci_config_permission = xsm_pci_config_permission, .get_vnumainfo = xsm_get_vnumainfo, -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_MGMT_HYPERCALLS ) +#ifdef CONFIG_HAS_PCI .get_device_group = xsm_get_device_group, .assign_device = xsm_assign_device, .deassign_device = xsm_deassign_device, -#endif +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) .assign_dtdevice = xsm_assign_dtdevice,
xen/xsm/flask/hooks.c +8 -4
@@ -1388,7 +1388,8 @@ static int cf_check flask_mem_sharing(struct domain *d) }#endif -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI static int cf_check flask_get_device_group(uint32_t machine_bdf) { uint32_t rsid;
@@ -1459,7 +1460,8 @@ static int cf_check flask_deassign_device(return avc_current_has_perm (rsid,SECCLASS_RESOURCE ,RESOURCE__REMOVE_DEVICE ,NULL ); } -#endif /* HAS_PASSTHROUGH && HAS_PCI */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY )static int flask_test_assign_dtdevice (const char *dtpath)
@@ -1987,11 +1989,13 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .remove_from_physmap = flask_remove_from_physmap, .map_gmfn_foreign = flask_map_gmfn_foreign, -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_MGMT_HYPERCALLS ) +#ifdef CONFIG_HAS_PCI .get_device_group = flask_get_device_group, .assign_device = flask_assign_device, .deassign_device = flask_deassign_device, -#endif +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) .assign_dtdevice = flask_assign_dtdevice,
Signature · 1 line
2.34.1
Re: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
Quoted 8 lines · Penny Zheng
xen/drivers/passthrough/amd/pci_amd_iommu.c | 20 ++++---- xen/drivers/passthrough/pci.c | 52 +++++++++++---------- xen/drivers/passthrough/vtd/iommu.c | 6 ++- xen/include/xsm/dummy.h | 6 ++- xen/include/xsm/xsm.h | 12 +++-- xen/xsm/dummy.c | 6 ++- xen/xsm/flask/hooks.c | 12 +++-- 7 files changed, 68 insertions(+), 46 deletions(-)
With this diffstat and there being quite a few HAS_PCI under xen/drivers/passthrough/arm/, what's the (PCI) deal there?
Quoted 5 lines
xen/drivers/passthrough/amd/pci_amd_iommu.c +0
-1@@ -772,14 +774,16 @@ static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { .quarantine_init = amd_iommu_quarantine_init, .add_device = amd_iommu_add_device, .remove_device = amd_iommu_remove_device, - .assign_device = amd_iommu_assign_device,
xen/drivers/passthrough/amd/pci_amd_iommu.c static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { · line 786
Quoted 10 lines
xen/drivers/passthrough/amd/pci_amd_iommu.c +3
-0.teardown = amd_iommu_domain_destroy, .clear_root_pgtable = amd_iommu_clear_root_pgtable, .map_page = amd_iommu_map_page, .unmap_page = amd_iommu_unmap_page, .iotlb_flush = amd_iommu_flush_iotlb_pages, +#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device = amd_iommu_assign_device, .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id, +#endif
You don't zap the hooks themselves, i.e. they end up being NULL now in the (still only hypothetical, provided the Kconfig change will be adjusted) case of MGMT_HYPERCALLS=n. I understand the former two hooks are still needed for DT, but at least .get_device_group_id should be properly dealt with in xen/iommu.h right away, imo. This would then also clarify already here that that's the plan for the other two hooks as well.
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_get_vnumainfo( · line 411
Quoted 9 lines
xen/include/xsm/dummy.h +2
-1@@ -407,7 +407,8 @@ static XSM_INLINE int cf_check xsm_get_vnumainfo(return xsm_default_action (action, current->domain, d); } -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_MGMT_HYPERCALLS ) +#ifdef CONFIG_HAS_PCI
Why the separate #ifdef? Can't that be folded with the #if? Are there further changes to be put inside the outer #if? (Applies again further down as well.)
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_deassign_device( · line 437
Quoted 13 lines
xen/include/xsm/dummy.h +2
-1static XSM_INLINE int cf_check xsm_get_device_group( XSM_DEFAULT_ARG uint32_t machine_bdf) {@@ -429,7 +430,8 @@ static XSM_INLINE int cf_check xsm_deassign_device(return xsm_default_action (action, current->domain, d); } -#endif /* HAS_PASSTHROUGH && HAS_PCI */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) static XSM_INLINE int cf_check xsm_assign_dtdevice(
The DT counterpart, otoh, is separate anyway.
Jan
RE: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
[Public]
Quoted 21 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Tuesday, November 25, 2025 11:37 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Andryuk, Jason <[email protected]>; Daniel P. Smith <[email protected]>; [email protected]
Subject: Re: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op withCONFIG_MGMT_HYPERCALLSQuoted 8 lines · Penny Zheng
xen/drivers/passthrough/amd/pci_amd_iommu.c | 20 ++++---- xen/drivers/passthrough/pci.c | 52 +++++++++++---------- xen/drivers/passthrough/vtd/iommu.c | 6 ++- xen/include/xsm/dummy.h | 6 ++- xen/include/xsm/xsm.h | 12 +++-- xen/xsm/dummy.c | 6 ++- xen/xsm/flask/hooks.c | 12 +++-- 7 files changed, 68 insertions(+), 46 deletions(-)
Quoted 2 lines
With this diffstat and there being quite a few
HAS_PCIunder xen/drivers/passthrough/arm/, what's the (PCI) deal there?
In arm, we have the following select chain:HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH -> HAS_VPCI -> HAS_PCI
So if we make PCI_PASSTHROUGH later depend on MGMT_HYPERCALLS, the PCI-subset for arm will also be guarded too. I'll add description in commit message
Quoted 5 lines
Quoted 5 lines
xen/include/xsm/dummy.h +0
-0@@ -407,7 +407,8 @@ static XSM_INLINE int cf_check xsm_get_vnumainfo(return xsm_default_action (action, current->domain, d); }
Quoted 7 lines
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_get_vnumainfo( · line 410
Quoted 3 lines
xen/include/xsm/dummy.h +2
-1-#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && +defined(CONFIG_MGMT_HYPERCALLS) #ifdef CONFIG_HAS_PCIWhy the separate #ifdef? Can't that be folded with the #if? Are there further changes to be put inside the outer #if? (Applies again further down as well.)
Because later in DT-subset, we want something like the following:
```
#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS)
#ifdef CONFIG_HAS_PCI
...
#endif
#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
...
#endif
#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */
Letting HAS_PASSTHROUGH && MGMT_HYPERCALLS being outer wrapper and a separate #ifdef CONFIG_HAS_PCI here could avoid extra changes in DT commit.
Quoted 16 lines
Quoted 10 lines
xen/include/xsm/dummy.h +0
-0static XSM_INLINE int cf_check xsm_get_device_group( XSM_DEFAULT_ARG uint32_t machine_bdf) { @@ -429,7 +430,8 @@static
XSM_INLINEintcf_checkxsm_deassign_device(return xsm_default_action(action, current->domain, d); }xen/include/xsm/dummy.h +2
-1-#endif /* HAS_PASSTHROUGH && HAS_PCI */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ #if defined(CONFIG_HAS_PASSTHROUGH) &&Quoted 2 lines
defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY)
staticXSM_INLINEintcf_checkxsm_assign_dtdevice(The DT counterpart, otoh, is separate anyway.
Jan
RE: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
In reply to Penny Zheng[Public]
Quoted 113 lines
-----Original Message-----
From: Penny, Zheng <[email protected]>
Sent: Friday, November 21, 2025 6:58 PM
To: [email protected]
Cc: Huang, Ray <[email protected]>; [email protected]; Penny, Zheng <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Andryuk, Jason <[email protected]>; Daniel P. Smith <[email protected]>
Subject: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op withCONFIG_MGMT_HYPERCALLSFunction
iommu_do_pci_domctl()is the main entry for pci-subset iommu-related domctl-op, and shall be wrapped withCONFIG_MGMT_HYPERCALLS. Tracking its calling chain, the following functions shall all be wrapped withCONFIG_MGMT_HYPERCALLS:
-iommu_do_pci_domctl
-iommu_get_device_group
-xsm_get_device_group
- iommu_ops.get_device_group_id
- amd_iommu_group_id/intel_iommu_group_id
-device_assigned
-xsm_assign_device
-assign_device
- iommu_ops.assign_device
- intel_iommu_assign_device/amd_iommu_assign_device
-xsm_deassign_device
-deassign_device
- iommu_ops.reassign_device
- reassign_device_ownership/reassign_device
Otherwise all the functions will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1Signed-off-by Penny Zheng <[email protected]>---
v1 -> v2:
- adapt to changes of "unify DOMCTL toMGMT_HYPERCALLS"
- wrap XEN_DOMCTL_assign_device{test_assign_device,deassign_device, get_device_group}-case transiently
---
v2 -> v3:
- makePCI_PASSTHROUGH(, then HAS_VPCI_GUEST_SUPPORT)depend onMGMT_HYPERCALLS
- add wrapping for iommu_remove_dt_device/iommu_dt_device_is_assigned_locked/ arm_smmu_detach_dev/arm_smmu_domain_remove_master
- fold commit
"xen/xsm: wrap xsm-iommu-related functions withCONFIG_MGMT_HYPERCALLS" in
- fix overly long #ifdef
- add missing wrapping inxsm/dummy.h
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping of XEN_DOMCTL_assign_device{test_assign_device,deassign_device,get_device_gr oup}-case
---
v3 -> v4:
- move codes to wrap with a single #ifdef
- split into PCI related subset and DT subset--- xen/drivers/passthrough/amd/pci_amd_iommu.c | 20 ++++---- xen/drivers/passthrough/pci.c | 52 +++++++++++---------- xen/drivers/passthrough/vtd/iommu.c | 6 ++- xen/include/xsm/dummy.h | 6 ++- xen/include/xsm/xsm.h | 12 +++-- xen/xsm/dummy.c | 6 ++- xen/xsm/flask/hooks.c | 12 +++-- 7 files changed, 68 insertions(+), 46 deletions(-)xen/drivers/passthrough/amd/pci_amd_iommu.c +7
-6@@ -461,6 +461,7 @@ static void amd_iommu_disable_domain_device(conststruct domain *domain, spin_unlock_irqrestore(&iommu->lock, flags); } +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check reassign_device(struct domain *source,struct domain *target,u8 devfn,struct pci_dev *pdev)@@ -551,6 +552,14 @@ static int cf_check amd_iommu_assign_device(return rc; } +static int cf_check amd_iommu_group_id(u16 seg, u8 bus, u8 devfn) { +unsigned int bdf =PCI_BDF (bus, devfn); + +return (bdf < ivrs_bdf_entries) ?get_dma_requestor_id (seg, bdf) : +bdf; }#endif /* CONFIG_MGMT_HYPERCALLS */ + static void cf_check amd_iommu_clear_root_pgtable(struct domain *d) { struct domain_iommu *hd = dom_iommu(d); @@ -698,13 +707,6 @@ static int cf_check amd_iommu_remove_device(u8 devfn, struct pci_dev *pdev) return 0; } -static int cf_check amd_iommu_group_id(u16 seg, u8 bus, u8 devfn) -{ -unsigned int bdf =PCI_BDF (bus, devfn); - -return (bdf < ivrs_bdf_entries) ?get_dma_requestor_id (seg, bdf) : bdf; -} -#include <asm/io_apic.h> static void amd_dump_page_table_level(struct page_info *pg, int level, @@ -772,14 +774,16 @@ static const struct
iommu_ops__initconst_cf_clobber_iommu_ops= {
.quarantine_init =amd_iommu_quarantine_init, .add_device =amd_iommu_add_device,
.remove_device =amd_iommu_remove_device,xen/drivers/passthrough/amd/pci_amd_iommu.c +0
-1- .assign_device = amd_iommu_assign_device,
xen/drivers/passthrough/amd/pci_amd_iommu.c static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { · line 786
Quoted 10 lines
xen/drivers/passthrough/amd/pci_amd_iommu.c +3
-0.teardown = amd_iommu_domain_destroy, .clear_root_pgtable = amd_iommu_clear_root_pgtable, .map_page = amd_iommu_map_page, .unmap_page = amd_iommu_unmap_page, .iotlb_flush = amd_iommu_flush_iotlb_pages, +#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device = amd_iommu_assign_device, .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id, +#endif
FWIS, Alejandro has come up a more clever way to DCE these kinds of op, staying conditionally as callback. Here, I just took this commit as example to show the methodology:
```
.assign_device = IS_ENABLED(CONFIG_MGMT_HYPERCALLS)
? amd_iommu_assign_device
: NULL,
```The compiler has enough visibility to know that static(amd_iommu_assign_device()) is used, and is droppable when MGMT_HYPERCALLS=n. So there is no need to do ifdef-wrapping around these statics now. Later when jason's "--gc-section" patch serie in, --gc-section will help linker identify them unused when MGMT_HYPERCALLS=n, then remove them automatically.
If we all agreed to use above methodology to do DCE.
Alejandro also recommended that since we will do this assignments in enough places in this patch serie, we probably want something like MAYBE_OP() somewhere in xen/macros.h:
#define MAYBE_OP(c, fn) (IS_ENABLED(c) ? fn : NULL)
I'd like to listen from your opinions on whether I shall do such update for v5, since it is quite a big update
Quoted 7 lines
xen/xsm/dummy.c index 9774bb3bdb..0026a0963b renamed from xen/xsm/dummy.c +0
-0100644
xen/xsm/dummy.c +0
-0@@ -80,11 +80,13 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .pci_config_permission = xsm_pci_config_permission,
xen/xsm/dummy.c static const struct xsm_ops __initconst_cf_clobber · line 89
Quoted 10 lines
xen/xsm/dummy.c +2
-2.get_vnumainfo = xsm_get_vnumainfo, -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_MGMT_HYPERCALLS ) +#ifdef CONFIG_HAS_PCI .get_device_group = xsm_get_device_group, .assign_device = xsm_assign_device, .deassign_device = xsm_deassign_device, -#endif
The same thing we shall do for XSM-changes too:
.get_device_group = IS_ENABLED(CONFIG_MGMT_HYPERCALLS)
? xsm_get_device_group : NULL,
Many thanks
Penny Zheng
Re: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
Quoted 22 lines · Zheng
Quoted 10 lines
-----Original Message-----
From: Penny, Zheng <[email protected]>
Sent: Friday, November 21, 2025 6:58 PM
[...]
772,14 +774,16 @@ static const structiommu_ops__initconst_cf_clobber_iommu_ops= {
.quarantine_init =amd_iommu_quarantine_init, .add_device =amd_iommu_add_device,
.remove_device =amd_iommu_remove_device,xen/drivers/passthrough/amd/pci_amd_iommu.c +0
-1- .assign_device = amd_iommu_assign_device,xen/drivers/passthrough/amd/pci_amd_iommu.c static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { · line 786
Quoted 10 lines
xen/drivers/passthrough/amd/pci_amd_iommu.c +3
-0.teardown = amd_iommu_domain_destroy, .clear_root_pgtable = amd_iommu_clear_root_pgtable, .map_page = amd_iommu_map_page, .unmap_page = amd_iommu_unmap_page, .iotlb_flush = amd_iommu_flush_iotlb_pages, +#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device = amd_iommu_assign_device, .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id, +#endifFWIS, Alejandro has come up a more clever way to DCE these kinds of op, staying conditionally as callback. Here, I just took this commit as example to show the methodology:
Quoted 6 lines
``` .assign_device = IS_ENABLED(CONFIG_MGMT_HYPERCALLS) ? amd_iommu_assign_device : NULL, ```The compiler has enough visibility to know that static(amd_iommu_assign_device()) is used, and is droppable when MGMT_HYPERCALLS=n. So there is no need to do ifdef-wrapping around these statics now. Later when jason's "--gc-section" patch serie in, --gc-section will help linker identify them unused when MGMT_HYPERCALLS=n, then remove them automatically.
I fear I don't see why --gc-sections would make a difference when, for static functions, the compiler already is in the position of removing the functions.
Quoted 6 lines
If we all agreed to use above methodology to do DCE.
Alejandro also recommended that since we will do this assignments in enough places in this patch serie, we probably want something likeMAYBE_OP()somewhere inxen/macros.h:#define
MAYBE_OP(c, fn)(IS_ENABLED(c)? fn : NULL)I'd like to listen from your opinions on whether I shall do such update for v5, since it is quite a big update
Well, already there I did raise my concern of leaving around function pointer fields in structures which will only ever be NULL. If respective fields are removed altogether, there's no risk whatsoever that an accidental use may be overlooked - the build would simply fail when making such an attempt. Calls through NULL are privilege escalation XSAs when PV guests can somehow leverage them, and use of altcall patching would still only downgrade them to DoS XSAs.
Jan
RE: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
[Public]
Quoted 42 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, February 4, 2026 4:09 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Andryuk, Jason <[email protected]>; Daniel P. Smith <[email protected]>; [email protected]; Garcia Vallejo, Alejandro <[email protected]>; Stabellini, Stefano <[email protected]>
Subject: Re: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op withCONFIG_MGMT_HYPERCALLSQuoted 13 lines · Zheng
Quoted 13 lines
-----Original Message-----
From: Penny, Zheng <[email protected]>
Sent: Friday, November 21, 2025 6:58 PM [...] 772,14 +774,16 @@ static const structiommu_ops__initconst_cf_clobber_iommu_ops= {
.quarantine_init =amd_iommu_quarantine_init, .add_device =amd_iommu_add_device, .remove_device =amd_iommu_remove_device,
- .assign_device =amd_iommu_assign_device,
.teardown =amd_iommu_domain_destroy, .clear_root_pgtable =amd_iommu_clear_root_pgtable, .map_page =amd_iommu_map_page, .unmap_page =amd_iommu_unmap_page,Quoted 8 lines
xen/drivers/passthrough/amd/pci_amd_iommu.c static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { · line 786
Quoted 6 lines
.iotlb_flush =
amd_iommu_flush_iotlb_pages,xen/drivers/passthrough/amd/pci_amd_iommu.c +3
-0+#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device = amd_iommu_assign_device, .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id, +#endif FWIS, Alejandro has come up a more clever way to DCE these kinds of op,
staying conditionally as callback. Here, I just took this commit as example to show the methodology:
Quoted 5 lines
```
.assign_device =IS_ENABLED(CONFIG_MGMT_HYPERCALLS)
?amd_iommu_assign_device
: NULL, ``` The compiler has
enough visibility to know that static(amd_iommu_assign_device()) is used, and is
Quoted 8 lines
droppable when MGMT_HYPERCALLS=n. So there is no need to do ifdef-wrapping around these statics now. Later when jason's "--gc-section" patch serie in, --gc- section will help linker identify them unused when MGMT_HYPERCALLS=n, then remove them automatically.
I fear I don't see why --gc-sections would make a difference when, for static functions, the compiler already is in the position of removing the functions.
I may misunderstand the DCE process. With this change, we don't need to put #ifdef CONFIG_MGMT_HYPERCALLS around the statics (e.g. amd_iommu_assign_device()). So preprocessor will not help us remove them. But if we enable --gc-sections flag, it will help us remove them in linker time, Without --gc-section, they will become unreachable codes.
Quoted 10 lines
Quoted 2 lines
If we all agreed to use above methodology to do DCE.
Alejandro also recommended that since we will do this assignments in enoughplaces in this patch serie, we probably want something like
MAYBE_OP()somewhere inxen/macros.h:Quoted 5 lines
#define
MAYBE_OP(c, fn)(IS_ENABLED(c)? fn : NULL)I'd like to listen from your opinions on whether I shall do such update for v5, since it is quite a big update
Quoted 7 lines
Well, already there I did raise my concern of leaving around function pointer fields in structures which will only ever be NULL. If respective fields are removed altogether, there's no risk whatsoever that an accidental use may be overlooked - the build would simply fail when making such an attempt. Calls through NULL are privilege escalation XSAs when PV guests can somehow leverage them, and use of altcall patching would still only downgrade them to DoS XSAs.
Understood. Conditional NULL pointer fields are better be eliminated way down to the structure definition stage.
Quoted 1 line
Jan
Re: [PATCH v4 14/24] xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
Quoted 38 lines · Zheng
Quoted 38 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, February 4, 2026 4:09 PMQuoted 13 lines · Zheng
Quoted 13 lines
-----Original Message-----
From: Penny, Zheng <[email protected]>
Sent: Friday, November 21, 2025 6:58 PM [...] 772,14 +774,16 @@ static const structiommu_ops__initconst_cf_clobber_iommu_ops= {
.quarantine_init =amd_iommu_quarantine_init, .add_device =amd_iommu_add_device, .remove_device =amd_iommu_remove_device,
- .assign_device =amd_iommu_assign_device,
.teardown =amd_iommu_domain_destroy, .clear_root_pgtable =amd_iommu_clear_root_pgtable, .map_page =amd_iommu_map_page, .unmap_page =amd_iommu_unmap_page,Quoted 8 lines
xen/drivers/passthrough/amd/pci_amd_iommu.c static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { · line 786
Quoted 6 lines
.iotlb_flush =
amd_iommu_flush_iotlb_pages,xen/drivers/passthrough/amd/pci_amd_iommu.c +3
-0+#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device = amd_iommu_assign_device, .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id, +#endif FWIS, Alejandro has come up a more clever way to DCE these kinds of op,
staying conditionally as callback. Here, I just took this commit as example to show the methodology:
Quoted 5 lines
```
.assign_device =IS_ENABLED(CONFIG_MGMT_HYPERCALLS)
?amd_iommu_assign_device
: NULL, ``` The compiler has
enough visibility to know that static(amd_iommu_assign_device()) is used, and isdroppable when MGMT_HYPERCALLS=n. So there is no need to do ifdef-wrapping around these statics now. Later when jason's "--gc-section" patch serie in, --gc- section will help linker identify them unused when MGMT_HYPERCALLS=n, then remove them automatically.
Quoted 4 lines
Quoted 2 lines
I fear I don't see why --gc-sections would make a difference when, for static functions, the compiler already is in the position of removing the functions.
I may misunderstand the DCE process. With this change, we don't need to put #ifdef
CONFIG_MGMT_HYPERCALLSaround the statics (e.g.amd_iommu_assign_device()). So preprocessor will not help us remove them.
But the compiler's optimization passes can, when they observe that a static function, while referenced by source code, is referenced only in branches of conditionals which are compile-time false. Without link-time optimization that's really about all DCE can do.
Jan
PATCH v4 15/24 xen/domctl: wrap device-tree-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction iommu_do_dt_domctl() is the main entry for all device-tree-subset iommu-related domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Tracking its calling chain, the following functions shall all be wrapped with CONFIG_MGMT_HYPERCALLS:
- make PCI_PASSTHROUGH depend on MGMT_HYPERCALLS
- iommu_do_dt_domctl
- xsm_assign_dtdevice
- xsm_deassign_dtdevice
- iommu_deassign_dt_device
- arm_smmu_reassign_dev
- arm_smmu_deassign_dev
- arm_smmu_detach_dev
- arm_smmu_domain_remove_master
- ipmmu_reassign_device
- ipmmu_deassign_device
- ipmmu_detach_device
- iommu_remove_dt_device
- iommu_dt_device_is_assigned_locked
- dt_find_node_by_gpath
Otherwise all the functions will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1
Move codes closer to avoid scattering #ifdef
---
v3 -> v4
- split into PCI related subset and DT subset
- Move codes closer to avoid scattering #ifdef
--- xen/arch/arm/Kconfig | 2 +- xen/common/device-tree/device-tree.c | 2 + xen/drivers/passthrough/arm/ipmmu-vmsa.c | 26 +++--- xen/drivers/passthrough/arm/smmu-v3.c | 4 + xen/drivers/passthrough/arm/smmu.c | 55 ++++++------ xen/drivers/passthrough/device_tree.c | 108 ++++++++++++----------- xen/include/xsm/dummy.h | 6 +- xen/include/xsm/xsm.h | 12 +-- xen/xsm/dummy.c | 6 +- xen/xsm/flask/hooks.c | 12 +-- 10 files changed, 126 insertions(+), 107 deletions(-)
xen/arch/arm/Kconfig +1 -1
@@ -270,7 +270,7 @@ source "arch/arm/firmware/Kconfig" config PCI_PASSTHROUGH bool "PCI passthrough" if EXPERT - depends on ARM_64 && HAS_PASSTHROUGH + depends on ARM_64 && HAS_PASSTHROUGH && MGMT_HYPERCALLS help This option enables PCI device passthrough
xen/common/device-tree/device-tree.c +2 -0
@@ -371,6 +371,7 @@ struct dt_device_node *dt_find_node_by_path_from(struct dt_device_node *from,return np; } +#ifdef CONFIG_MGMT_HYPERCALLS int dt_find_node_by_gpath (XEN_GUEST_HANDLE (char ) u_path,uint32_t u_plen,struct dt_device_node **node) {
@@ -386,6 +387,7 @@ int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, return (*node == NULL) ? -ESRCH : 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */ struct dt_device_node *dt_find_node_by_alias (const char *alias) {
xen/drivers/passthrough/arm/ipmmu-vmsa.c +16 -10
@@ -739,16 +739,6 @@ static int ipmmu_attach_device(struct ipmmu_vmsa_domain *domain,return 0 ; } -static void ipmmu_detach_device (struct ipmmu_vmsa_domain *domain, -struct device *dev) -{ -struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); -unsigned int i; - -for ( i =0 ; i < fwspec->num_ids; ++i ) -ipmmu_utlb_disable (domain, fwspec->ids[i]); -} -static int ipmmu_init_platform_device (struct device *dev,const struct dt_phandle_args *args) {
@@ -1138,7 +1128,9 @@ static void ipmmu_free_root_domain(struct ipmmu_vmsa_domain *domain)xfree (domain); } +#ifdef CONFIG_MGMT_HYPERCALLS static int ipmmu_deassign_device (struct domain *d,struct device *dev); +#endif static int ipmmu_assign_device (struct domain *d,u8 devfn,struct device *dev,uint32_t flag)
@@ -1254,6 +1246,17 @@ out:return ret; } +#ifdef CONFIG_MGMT_HYPERCALLS +static void ipmmu_detach_device (struct ipmmu_vmsa_domain *domain, +struct device *dev) +{ +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); +unsigned int i; + +for ( i =0 ; i < fwspec->num_ids; ++i ) +ipmmu_utlb_disable (domain, fwspec->ids[i]); +} +static int ipmmu_deassign_device (struct domain *d,struct device *dev) {struct ipmmu_vmsa_xen_domain *xen_domain =dom_iommu (d)->arch.priv;
@@ -1309,6 +1312,7 @@ static int ipmmu_reassign_device(struct domain *s, struct domain *t, return 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static int ipmmu_dt_xlate (struct device *dev,const struct dt_phandle_args *spec)
@@ -1487,7 +1491,9 @@ static const struct iommu_ops ipmmu_iommu_ops = .teardown = ipmmu_iommu_domain_teardown, .iotlb_flush = ipmmu_iotlb_flush, .assign_device = ipmmu_assign_device, +#ifdef CONFIG_MGMT_HYPERCALLS .reassign_device = ipmmu_reassign_device, +#endif .map_page = arm_iommu_map_page, .unmap_page = arm_iommu_unmap_page, .dt_xlate = ipmmu_dt_xlate,
xen/drivers/passthrough/arm/smmu-v3.c +4 -0
@@ -2759,6 +2759,7 @@ out:return ret; } +#ifdef CONFIG_MGMT_HYPERCALLS static int arm_smmu_deassign_dev (struct domain *d,uint8_t devfn,struct device *dev) {struct iommu_domain *io_domain =arm_smmu_get_domain (d, dev);
@@ -2826,6 +2827,7 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, return 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static int arm_smmu_iommu_xen_domain_init (struct domain *d) {
@@ -2862,7 +2864,9 @@ static const struct iommu_ops arm_smmu_iommu_ops = { .teardown = arm_smmu_iommu_xen_domain_teardown, .iotlb_flush = arm_smmu_iotlb_flush, .assign_device = arm_smmu_assign_dev, +#ifdef CONFIG_MGMT_HYPERCALLS .reassign_device = arm_smmu_reassign_dev, +#endif .map_page = arm_iommu_map_page, .unmap_page = arm_iommu_unmap_page, .dt_xlate = arm_smmu_dt_xlate,
xen/drivers/passthrough/arm/smmu.c +30 -25
94 lines not on this page · raw message
xen/drivers/passthrough/device_tree.c +55 -53
135 lines not on this page · raw message
xen/include/xsm/dummy.h +3 -3
@@ -431,9 +431,8 @@ static XSM_INLINE int cf_check xsm_deassign_device( }#endif /* CONFIG_HAS_PCI */ -#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static XSM_INLINE int cf_check xsm_assign_dtdevice( XSM_DEFAULT_ARG struct domain *d, const char *dtpath) {
@@ -448,7 +447,8 @@ static XSM_INLINE int cf_check xsm_deassign_dtdevice(return xsm_default_action (action, current->domain, d); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ static XSM_INLINE int cf_check xsm_resource_plug_core(XSM_DEFAULT_VOID) {
xen/include/xsm/xsm.h +6 -6
@@ -129,12 +129,12 @@ struct xsm_ops {int (*assign_device)(struct domain *d,uint32_t machine_bdf);int (*deassign_device)(struct domain *d,uint32_t machine_bdf);#endif /* CONFIG_HAS_PCI */ -#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY int (*assign_dtdevice)(struct domain *d,const char *dtpath);int (*deassign_dtdevice)(struct domain *d,const char *dtpath); -#endif +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ int (*resource_plug_core)(void );int (*resource_unplug_core)(void );
@@ -545,9 +545,8 @@ static inline int xsm_deassign_device(return alternative_call (xsm_ops.deassign_device, d, machine_bdf); }#endif /* CONFIG_HAS_PCI */ -#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static inline int xsm_assign_dtdevice (xsm_default_t def,struct domain *d,const char *dtpath) {
@@ -560,7 +559,8 @@ static inline int xsm_deassign_dtdevice(return alternative_call (xsm_ops.deassign_dtdevice, d, dtpath); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ static inline int xsm_resource_plug_pci (xsm_default_t def,uint32_t machine_bdf) {
xen/xsm/dummy.c +3 -3
@@ -86,12 +86,12 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .assign_device = xsm_assign_device, .deassign_device = xsm_deassign_device,#endif /* CONFIG_HAS_PCI */ -#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY .assign_dtdevice = xsm_assign_dtdevice, .deassign_dtdevice = xsm_deassign_dtdevice, -#endif +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ .resource_plug_core = xsm_resource_plug_core, .resource_unplug_core = xsm_resource_unplug_core,
xen/xsm/flask/hooks.c +6 -6
@@ -1461,9 +1461,8 @@ static int cf_check flask_deassign_device(return avc_current_has_perm (rsid,SECCLASS_RESOURCE ,RESOURCE__REMOVE_DEVICE ,NULL ); }#endif /* CONFIG_HAS_PCI */ -#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static int flask_test_assign_dtdevice (const char *dtpath) {uint32_t rsid;
@@ -1524,7 +1523,8 @@ static int cf_check flask_deassign_dtdevice(return avc_current_has_perm (rsid,SECCLASS_RESOURCE ,RESOURCE__REMOVE_DEVICE ,NULL ); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ static int cf_check flask_platform_op(uint32_t op) {
@@ -1995,12 +1995,12 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .assign_device = flask_assign_device, .deassign_device = flask_deassign_device,#endif /* CONFIG_HAS_PCI */ -#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY .assign_dtdevice = flask_assign_dtdevice, .deassign_dtdevice = flask_deassign_dtdevice, -#endif +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ .platform_op = flask_platform_op,#ifdef CONFIG_X86
Signature · 1 line
2.34.1
Re: [PATCH v4 15/24] xen/domctl: wrap device-tree-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
Hi Penny,
Quoted 67 lines · Penny Zheng
Function
iommu_do_dt_domctl()is the main entry for all device-tree-subset iommu-related domctl-op, and shall be wrapped withCONFIG_MGMT_HYPERCALLS. Tracking its calling chain, the following functions shall all be wrapped withCONFIG_MGMT_HYPERCALLS:
- makePCI_PASSTHROUGHdepend onMGMT_HYPERCALLS
-iommu_do_dt_domctl
-xsm_assign_dtdevice
-xsm_deassign_dtdevice
-iommu_deassign_dt_device
-arm_smmu_reassign_dev
-arm_smmu_deassign_dev
-arm_smmu_detach_dev
-arm_smmu_domain_remove_master
-ipmmu_reassign_device
-ipmmu_deassign_device
-ipmmu_detach_device
-iommu_remove_dt_device
-iommu_dt_device_is_assigned_locked
-dt_find_node_by_gpath
Otherwise all the functions will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1
Move codes closer to avoid scattering #ifdefSigned-off-by Penny Zheng <[email protected]>---
v3 -> v4
- split into PCI related subset and DT subset
- Move codes closer to avoid scattering #ifdef--- xen/arch/arm/Kconfig | 2 +- xen/common/device-tree/device-tree.c | 2 + xen/drivers/passthrough/arm/ipmmu-vmsa.c | 26 +++--- xen/drivers/passthrough/arm/smmu-v3.c | 4 + xen/drivers/passthrough/arm/smmu.c | 55 ++++++------ xen/drivers/passthrough/device_tree.c | 108 ++++++++++++----------- xen/include/xsm/dummy.h | 6 +- xen/include/xsm/xsm.h | 12 +-- xen/xsm/dummy.c | 6 +- xen/xsm/flask/hooks.c | 12 +-- 10 files changed, 126 insertions(+), 107 deletions(-)xen/arch/arm/Kconfig +1
-1@@ -270,7 +270,7 @@ source "arch/arm/firmware/Kconfig" config PCI_PASSTHROUGH bool "PCI passthrough" if EXPERT - depends on ARM_64 && HAS_PASSTHROUGH + depends on ARM_64 && HAS_PASSTHROUGH && MGMT_HYPERCALLS help This option enables PCI device passthroughxen/common/device-tree/device-tree.c +1
-0@@ -371,6 +371,7 @@ struct dt_device_node *dt_find_node_by_path_from(struct dt_device_node *from,return np; } +#ifdef CONFIG_MGMT_HYPERCALLS int dt_find_node_by_gpath (XEN_GUEST_HANDLE (char ) u_path,uint32_t u_plen,struct dt_device_node **node) {
xen/common/device-tree/device-tree.c int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, · line 390
Quoted 4 lines
xen/common/device-tree/device-tree.c +1
-0@@ -386,6 +387,7 @@ int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, return (*node == NULL) ? -ESRCH : 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */
The common/device-tree/device-tree.c contains generic unflatten DT helpers API, while dt_find_node_by_gpath() is specific for domctl (iommu) processing.
Therefore I'd like to propose to move this function into drivers\passthrough\device_tree.c as it is used only there now.
Quoted 3 lines
xen/common/device-tree/device-tree.c +0
-0struct dt_device_node *dt_find_node_by_alias (const char *alias) {
[...]
xen/drivers/passthrough/arm/smmu-v3.c out: · line 2760
Quoted 7 lines
xen/drivers/passthrough/arm/smmu-v3.c +0
-0@@ -2759,6 +2759,7 @@ out:return ret; }
There is not wrapped arm_smmu_deassign_dev() at the beginning of the file which causes ARM64 build failure:
drivers/passthrough/arm/smmu-v3.c:1474:12: error: 'arm_smmu_deassign_dev' declared 'static' but never defined [-Werror=unused-function]
1474 | static int arm_smmu_deassign_dev(struct domain *d, uint8_t devfn,
Quoted 25 lines
xen/drivers/passthrough/arm/smmu-v3.c +4
-0+#ifdef CONFIG_MGMT_HYPERCALLS static int arm_smmu_deassign_dev (struct domain *d,uint8_t devfn,struct device *dev) {struct iommu_domain *io_domain =arm_smmu_get_domain (d, dev);@@ -2826,6 +2827,7 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, return 0; } +#endif /* CONFIG_MGMT_HYPERCALLS */ static int arm_smmu_iommu_xen_domain_init (struct domain *d) {@@ -2862,7 +2864,9 @@ static const struct iommu_ops arm_smmu_iommu_ops = { .teardown = arm_smmu_iommu_xen_domain_teardown, .iotlb_flush = arm_smmu_iotlb_flush, .assign_device = arm_smmu_assign_dev, +#ifdef CONFIG_MGMT_HYPERCALLS .reassign_device = arm_smmu_reassign_dev, +#endif .map_page = arm_iommu_map_page, .unmap_page = arm_iommu_unmap_page, .dt_xlate = arm_smmu_dt_xlate,xen/drivers/passthrough/arm/smmu.c +0
-0
[...]
Signature · 2 lines
Best regards, -grygorii
PATCH v4 16/24 xen/domctl: wrap iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction iommu_do_domctl() is the main entry for all iommu-related domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS.
Otherwise it will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1
---
v3 -> v4:
- new commit
---
Commit "xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS" and "xen/domctl: wrap device-tree-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS" are the prereq commit.
--- xen/drivers/passthrough/iommu.c | 2 ++ 1 file changed, 2 insertions(+)
xen/drivers/passthrough/iommu.c +2 -0
@@ -625,6 +625,7 @@ void iommu_resume(void)iommu_vcall (iommu_get_ops (), resume); } +#ifdef CONFIG_MGMT_HYPERCALLS int iommu_do_domctl (struct xen_domctl *domctl,struct domain *d,XEN_GUEST_HANDLE_PARAM (xen_domctl_t) u_domctl)
@@ -645,6 +646,7 @@ int iommu_do_domctl( return ret; } +#endif /* CONFIG_MGMT_HYPERCALLS */ 1void iommu_crash_shutdown (void ) {
Signature · 1 line
2.34.1
Re: [PATCH v4 16/24] xen/domctl: wrap iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
Quoted 30 lines · Penny Zheng
Function
iommu_do_domctl()is the main entry for all iommu-related domctl-op, and shall be wrapped withCONFIG_MGMT_HYPERCALLS.
Otherwise it will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit
---
Commit "xen/domctl: wrap pci-subset iommu-related domctl op withCONFIG_MGMT_HYPERCALLS" and "xen/domctl: wrap device-tree-subset iommu-related domctl op withCONFIG_MGMT_HYPERCALLS" are the prereq commit.--- xen/drivers/passthrough/iommu.c | 2 ++ 1 file changed, 2 insertions(+)xen/drivers/passthrough/iommu.c +1
-0@@ -625,6 +625,7 @@ void iommu_resume(void)iommu_vcall (iommu_get_ops (), resume); } +#ifdef CONFIG_MGMT_HYPERCALLS int iommu_do_domctl (struct xen_domctl *domctl,struct domain *d,XEN_GUEST_HANDLE_PARAM (xen_domctl_t) u_domctl)
xen/drivers/passthrough/iommu.c int iommu_do_domctl( · line 649
Quoted 4 lines
xen/drivers/passthrough/iommu.c +1
-0@@ -645,6 +646,7 @@ int iommu_do_domctl( return ret; } +#endif /* CONFIG_MGMT_HYPERCALLS */ 1
"/1" type - build fail
Quoted 3 lines
xen/drivers/passthrough/iommu.c +0
-0void iommu_crash_shutdown (void ) {
Signature · 2 lines
Best regards, -grygorii
Re: [PATCH v4 16/24] xen/domctl: wrap iommu-related domctl op with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengQuoted 5 lines · Penny Zheng
Function
iommu_do_domctl()is the main entry for all iommu-related domctl-op, and shall be wrapped withCONFIG_MGMT_HYPERCALLS.
Otherwise it will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1
Quoted 8 lines
Signed-off-by Penny Zheng <[email protected]>---
v3 -> v4:
- new commit
---
Commit "xen/domctl: wrap pci-subset iommu-related domctl op withCONFIG_MGMT_HYPERCALLS" and "xen/domctl: wrap device-tree-subset iommu-related domctl op withCONFIG_MGMT_HYPERCALLS" are the prereq commit.
You state the normal thing here: The general assumption is that later patches in a series depend on earlier ones. What you want to state is when this general rule doesn't apply, i.e. when patches can move ahead (some or entirely), and hence can be committed when they alone are ready, without having other dependencies (or with having only some).
Quoted 3 lines
--- xen/drivers/passthrough/iommu.c | 2 ++ 1 file changed, 2 insertions(+)
The latest here xen/iommu.h also needs touching, as just said in reply to patch 14. Unused hooks shall stay around.
Jan
PATCH v4 17/24 xen/domctl: wrap arch_{get,set}_paging_mempool_size() with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengArch-specific arch_{get,set}_paging_mempool_size() is responsible for XEN_DOMCTL_{get,set}_paging_mempool_size domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra 2.1.
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_{get,set}_paging_mempool_size-case transiently
---
v2 -> v3
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping around XEN_DOMCTL_{get,set}_paging_mempool_size-case
--- xen/arch/arm/mmu/p2m.c | 4 ++++ xen/arch/x86/mm/paging.c | 2 ++ 2 files changed, 6 insertions(+)
xen/arch/arm/mmu/p2m.c +4 -0
@@ -58,12 +58,14 @@ static void p2m_free_page(struct domain *d, struct page_info *pg) } } +#ifdef CONFIG_MGMT_HYPERCALLS /* Return the size of the pool, in bytes. */ int arch_get_paging_mempool_size (struct domain *d,uint64_t *size) { *size = (uint64_t )ACCESS_ONCE (d->arch.paging.p2m_total_pages) <<PAGE_SHIFT ;return 0 ; } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * Set the pool of pages to the required number of pages.
@@ -122,6 +124,7 @@ int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preempted)return 0 ; } +#ifdef CONFIG_MGMT_HYPERCALLS int arch_set_paging_mempool_size (struct domain *d,uint64_t size) {unsigned long pages = size >>PAGE_SHIFT ;
@@ -140,6 +143,7 @@ int arch_set_paging_mempool_size(struct domain *d, uint64_t size) return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ int p2m_teardown_allocation (struct domain *d) {
xen/arch/x86/mm/paging.c +2 -0
@@ -949,6 +949,7 @@ int __init paging_set_allocation(struct domain *d, unsigned int pages, }#endif +#ifdef CONFIG_MGMT_HYPERCALLS int arch_get_paging_mempool_size (struct domain *d,uint64_t *size) {unsigned long pages;
@@ -991,6 +992,7 @@ int arch_set_paging_mempool_size(struct domain *d, uint64_t size) return preempted ? -ERESTART : rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* * Local variables:
Signature · 1 line
2.34.1
PATCH v4 18/24 xen/domctl: make CONFIG_X86_PSR depend on CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengUsers control/monitor Intel Platform Shared Resource (PSR) through related domctl-op or sysctl-op, so CONFIG_X86_PSR can be put under MGMT_HYPERCALLS. With this change, we could remove MGMT_HYPERCALLS-wrapping in psr.c.
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
--- xen/arch/x86/Kconfig | 1 + xen/arch/x86/psr.c | 18 ------------------ 2 files changed, 1 insertion(+), 18 deletions(-)
xen/arch/x86/Kconfig +1 -0
@@ -191,6 +191,7 @@ config TBOOT config X86_PSR bool "Platform Shared Resource support" if EXPERT default INTEL + depends on MGMT_HYPERCALLS help Support of Platform Shared Resource technology, which is basis for monitoring and control of resources like cache and memory bandwidth.
xen/arch/x86/psr.c +0 -18
@@ -135,11 +135,9 @@ static const struct feat_props {*/ enum psr_type alt_type; -#ifdef CONFIG_MGMT_HYPERCALLS /* 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);
@@ -422,7 +420,6 @@ static bool mba_init_feature(const struct cpuid_leaf *regs,return true; } -#ifdef CONFIG_MGMT_HYPERCALLS static bool cf_check cat_get_feat_info(const struct feat_node *feat,uint32_t data[],unsigned int array_len) {
@@ -435,7 +432,6 @@ static bool cf_check cat_get_feat_info(return true; } -#endif /* CONFIG_MGMT_HYPERCALLS */ /* L3 CAT props */ static void cf_check l3_cat_write_msr(
@@ -448,14 +444,11 @@ static const struct feat_props l3_cat_props = { .cos_num = 1, .type[0] = PSR_TYPE_L3_CBM, .alt_type = PSR_TYPE_UNKNOWN, -#ifdef CONFIG_MGMT_HYPERCALLS .get_feat_info = cat_get_feat_info, -#endif .write_msr = l3_cat_write_msr, .sanitize = cat_check_cbm, }; -#ifdef CONFIG_MGMT_HYPERCALLS /* L3 CDP props */ static bool cf_check l3_cdp_get_feat_info(const struct feat_node *feat,uint32_t data[],uint32_t array_len)
@@ -467,7 +460,6 @@ static bool cf_check l3_cdp_get_feat_info(return true; } -#endif /* CONFIG_MGMT_HYPERCALLS */ static void cf_check l3_cdp_write_msr(unsigned int cos,uint32_t val,enum psr_type type)
@@ -483,9 +475,7 @@ 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_MGMT_HYPERCALLS .get_feat_info = l3_cdp_get_feat_info, -#endif .write_msr = l3_cdp_write_msr, .sanitize = cat_check_cbm, };
@@ -501,14 +491,11 @@ static const struct feat_props l2_cat_props = { .cos_num = 1, .type[0] = PSR_TYPE_L2_CBM, .alt_type = PSR_TYPE_UNKNOWN, -#ifdef CONFIG_MGMT_HYPERCALLS .get_feat_info = cat_get_feat_info, -#endif .write_msr = l2_cat_write_msr, .sanitize = cat_check_cbm, }; -#ifdef CONFIG_MGMT_HYPERCALLS /* MBA props */ static bool cf_check mba_get_feat_info(const struct feat_node *feat,uint32_t data[],unsigned int array_len)
@@ -523,7 +510,6 @@ static bool cf_check mba_get_feat_info(return true; } -#endif /* CONFIG_MGMT_HYPERCALLS */ static void cf_check mba_write_msr(unsigned int cos,uint32_t val,enum psr_type type)
@@ -561,9 +547,7 @@ static const struct feat_props mba_props = { .cos_num = 1, .type[0] = PSR_TYPE_MBA_THRTL, .alt_type = PSR_TYPE_UNKNOWN, -#ifdef CONFIG_MGMT_HYPERCALLS .get_feat_info = mba_get_feat_info, -#endif .write_msr = mba_write_msr, .sanitize = mba_sanitize_thrtl, };
@@ -826,7 +810,6 @@ static struct psr_socket_info *get_socket_info(unsigned int socket)return socket_info + socket; } -#ifdef CONFIG_MGMT_HYPERCALLS int psr_get_info (unsigned int socket,enum psr_type type,uint32_t data[],unsigned int array_len) {
@@ -858,7 +841,6 @@ int psr_get_info(unsigned int socket, enum psr_type type,return -EINVAL ; } -#endif /* CONFIG_MGMT_HYPERCALLS */ int psr_get_val (struct domain *d,unsigned int socket,uint32_t *val,enum psr_type type)
Signature · 1 line
2.34.1
PATCH v4 19/24 xen/domctl: wrap hvm_save{,load} with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengThe following functions have been referenced in places which is either guarded with CONFIG_MGMT_HYPERCALLS or CONFIG_MEM_SHARING:
- arch_hvm_save
- arch_hvm_check
- arch_hvm_load
- hvm_save_size
- hvm_save
- hvm_load
While CONFIG_MEM_SHARING is also dependent on CONFIG_MGMT_HYPERCALLS. So they shall be wrapped under MGMT_HYPERCALLS, otherwise they will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1. We move arch_hvm_save(), arch_hvm_check(), arch_hvm_load() and hvm_save_size() nearer to the left functions, to avoid scattered #ifdef-wrapping.
---
v3 -> v4
- new commit
--- xen/arch/x86/hvm/save.c | 154 ++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 76 deletions(-)
xen/arch/x86/hvm/save.c +78 -76
@@ -15,62 +15,6 @@#include <public/hvm/save.h> -static void arch_hvm_save (struct domain *d,struct hvm_save_header *hdr) -{ -uint32_t eax, ebx, ecx, edx; - -/* Save some CPUID bits */ -cpuid (1 , &eax, &ebx, &ecx, &edx); - hdr->cpuid = eax; - -/* Save guest's preferred TSC. */ - hdr->gtsc_khz = d->arch.tsc_khz; - -/* Time when saving started */ - d->arch.hvm.sync_tsc =rdtsc (); -} - -static int arch_hvm_check (const struct domain *d, -const struct hvm_save_header *hdr) -{ -uint32_t eax, ebx, ecx, edx; - -if ( hdr->magic !=HVM_FILE_MAGIC ) - { -printk (XENLOG_G_ERR "HVM%d restore: bad magic number %#" PRIx32"\n" , - d->domain_id, hdr->magic); -return -EINVAL ; - } - -if ( hdr->version !=HVM_FILE_VERSION ) - { -printk (XENLOG_G_ERR "HVM%d restore: unsupported version %u\n" , - d->domain_id, hdr->version); -return -EINVAL ; - } - -cpuid (1 , &eax, &ebx, &ecx, &edx); -/* CPUs ought to match but with feature-masking they might not */ -if ( (hdr->cpuid & ~0x0fUL ) != (eax & ~0x0fUL ) ) -printk (XENLOG_G_INFO "HVM%d restore: VM saved on one CPU " -"(%#" PRIx32") and restored on another (%#" PRIx32").\n" , - d->domain_id, hdr->cpuid, eax); - -return 0 ; -} - -static void arch_hvm_load (struct domain *d,const struct hvm_save_header *hdr) -{ -/* Restore guest's preferred TSC frequency. */ -if ( hdr->gtsc_khz ) - d->arch.tsc_khz = hdr->gtsc_khz; -if ( d->arch.vtsc ) -hvm_set_rdtsc_exiting (d,1 ); - -/* Time when restore started */ - d->arch.hvm.sync_tsc =rdtsc (); -} -/* List of handlers for various HVM save and restore types */ static struct { hvm_save_handler save;
@@ -101,26 +45,6 @@ void __init hvm_register_savevm(uint16_t typecode, hvm_sr_handlers[typecode].kind = kind; } -size_t hvm_save_size (struct domain *d) -{ -struct vcpu *v; -size_t sz; -int i; - -/* Basic overhead for header and footer */ - sz = (2 *sizeof (struct hvm_save_descriptor )) +HVM_SAVE_LENGTH (HEADER ); - -/* Plus space for each thing we will be saving */ -for ( i =0 ; i <=HVM_SAVE_CODE_MAX ; i++ ) -if ( hvm_sr_handlers[i].kind ==HVMSR_PER_VCPU ) -for_each_vcpu (d, v) - sz += hvm_sr_handlers[i].size; -else - sz += hvm_sr_handlers[i].size; - -return sz; -} -/* * Extract a single instance of a save record, by marshalling all records of * that type and copying out the one we need.
@@ -196,6 +120,83 @@ int hvm_save_one(struct domain *d, unsigned int typecode, unsigned int instance,return rv; } +#ifdef CONFIG_MGMT_HYPERCALLS +static void arch_hvm_save (struct domain *d,struct hvm_save_header *hdr) +{ +uint32_t eax, ebx, ecx, edx; + +/* Save some CPUID bits */ +cpuid (1 , &eax, &ebx, &ecx, &edx); + hdr->cpuid = eax; + +/* Save guest's preferred TSC. */ + hdr->gtsc_khz = d->arch.tsc_khz; + +/* Time when saving started */ + d->arch.hvm.sync_tsc =rdtsc (); +} + +static int arch_hvm_check (const struct domain *d, +const struct hvm_save_header *hdr) +{ +uint32_t eax, ebx, ecx, edx; + +if ( hdr->magic !=HVM_FILE_MAGIC ) + { +printk (XENLOG_G_ERR "HVM%d restore: bad magic number %#" PRIx32"\n" , + d->domain_id, hdr->magic); +return -EINVAL ; + } + +if ( hdr->version !=HVM_FILE_VERSION ) + { +printk (XENLOG_G_ERR "HVM%d restore: unsupported version %u\n" , + d->domain_id, hdr->version); +return -EINVAL ; + } + +cpuid (1 , &eax, &ebx, &ecx, &edx); +/* CPUs ought to match but with feature-masking they might not */ +if ( (hdr->cpuid & ~0x0fUL ) != (eax & ~0x0fUL ) ) +printk (XENLOG_G_INFO "HVM%d restore: VM saved on one CPU " +"(%#" PRIx32") and restored on another (%#" PRIx32").\n" , + d->domain_id, hdr->cpuid, eax); + +return 0 ; +} + +static void arch_hvm_load (struct domain *d,const struct hvm_save_header *hdr) +{ +/* Restore guest's preferred TSC frequency. */ +if ( hdr->gtsc_khz ) + d->arch.tsc_khz = hdr->gtsc_khz; +if ( d->arch.vtsc ) +hvm_set_rdtsc_exiting (d,1 ); + +/* Time when restore started */ + d->arch.hvm.sync_tsc =rdtsc (); +} + +size_t hvm_save_size (struct domain *d) +{ +struct vcpu *v; +size_t sz; +unsigned int i; + +/* Basic overhead for header and footer */ + sz = (2 *sizeof (struct hvm_save_descriptor )) +HVM_SAVE_LENGTH (HEADER ); + +/* Plus space for each thing we will be saving */ +for ( i =0 ; i <=HVM_SAVE_CODE_MAX ; i++ ) +if ( hvm_sr_handlers[i].kind ==HVMSR_PER_VCPU ) +for_each_vcpu (d, v) + sz += hvm_sr_handlers[i].size; +else + sz += hvm_sr_handlers[i].size; + +return sz; +} +int hvm_save (struct domain *d,hvm_domain_context_t *h) {char *c;
@@ -390,6 +391,7 @@ int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) /* Not reached */ } +#endif /* CONFIG_MGMT_HYPERCALLS */ int _hvm_init_entry (struct hvm_domain_context *h,uint16_t tc,uint16_t inst,uint32_t len)
Signature · 1 line
2.34.1
Re: [PATCH v4 19/24] xen/domctl: wrap hvm_save{,load} with CONFIG_MGMT_HYPERCALLS
Quoted 5 lines · Penny Zheng
The following functions have been referenced in places which is either guarded with
CONFIG_MGMT_HYPERCALLSorCONFIG_MEM_SHARING:
-arch_hvm_save
-arch_hvm_check
-arch_hvm_load
Quoted 8 lines
-
hvm_save_size
-hvm_save
-hvm_load
WhileCONFIG_MEM_SHARINGis also dependent onCONFIG_MGMT_HYPERCALLS. So they shall be wrapped underMGMT_HYPERCALLS, otherwise they will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1. We movearch_hvm_save(),arch_hvm_check(),arch_hvm_load()andhvm_save_size()nearer to the left functions, to avoid scattered #ifdef-wrapping.
Why would you move things? What is in this source file that is of any use when MGMT_HYPERCALLS=n? The only caller of hvm_save_one() lives in x86/domctl.c. With that also removed, hvm_sr_handlers[] is only ever written to afaict, which means that's an effectively dead array then too.
The final few functions ...
xen/arch/x86/hvm/save.c int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) · line 397
Quoted 8 lines
xen/arch/x86/hvm/save.c +1
-0@@ -390,6 +391,7 @@ int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) /* Not reached */ } +#endif /* CONFIG_MGMT_HYPERCALLS */ int _hvm_init_entry (struct hvm_domain_context *h,uint16_t tc,uint16_t inst,uint32_t len)
... here and below are only helpers for the save/restore machinery, i.e. that _all_ is also usable only when MGMT_HYPERCALLS=y. Yes, that's a lot of further work, but what do you do? You'll then have quite a bit more code removed from the set that as per coverage analysis is never reached.
Jan
Re: [PATCH v4 19/24] xen/domctl: wrap hvm_save{,load} with CONFIG_MGMT_HYPERCALLS
Hi Jan, Penny,
Quoted 28 lines · Jan Beulich
Quoted 5 lines · Penny Zheng
The following functions have been referenced in places which is either guarded with
CONFIG_MGMT_HYPERCALLSorCONFIG_MEM_SHARING:
-arch_hvm_save
-arch_hvm_check
-arch_hvm_loadQuoted 8 lines
-
hvm_save_size
-hvm_save
-hvm_load
WhileCONFIG_MEM_SHARINGis also dependent onCONFIG_MGMT_HYPERCALLS. So they shall be wrapped underMGMT_HYPERCALLS, otherwise they will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1. We movearch_hvm_save(),arch_hvm_check(),arch_hvm_load()andhvm_save_size()nearer to the left functions, to avoid scattered #ifdef-wrapping.Why would you move things? What is in this source file that is of any use when MGMT_HYPERCALLS=n? The only caller of
hvm_save_one()lives inx86/domctl.c. With that also removed, hvm_sr_handlers[] is only ever written to afaict, which means that's an effectively dead array then too.The final few functions ...
Quoted 6 lines
xen/arch/x86/hvm/save.c +1
-0@@ -390,6 +391,7 @@ int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) /* Not reached */ } +#endif /* CONFIG_MGMT_HYPERCALLS */
Quoted 7 lines
xen/arch/x86/hvm/save.c int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) · line 397
Quoted 2 lines
xen/arch/x86/hvm/save.c +0
-0int _hvm_init_entry (struct hvm_domain_context *h,uint16_t tc,uint16_t inst,uint32_t len)... here and below are only helpers for the save/restore machinery, i.e. that _all_ is also usable only when MGMT_HYPERCALLS=y. Yes, that's a lot of further work, but what do you do? You'll then have quite a bit more code removed from the set that as per coverage analysis is never reached.
I have a local patch which allows to disable all HVM save/load code at once by using separated Kconfig option SAVE_RESTORE.
+++ b/xen/arch/x86/hvm/Kconfig
@@ -127,4 +127,8 @@ config VHPET
+config SAVE_RESTORE
+ depends on MGMT_HYPERCALLS
+ def_bool y
SAVE_RESTORE - annotates all HVM save/load code and, in general, could made a feature by allowing it to be selectable.
Of course, It all can be done by just using MGMT_HYPERCALLS.
So, I'd be appreciated for you opinion - does it make sense to have separate SAVE_RESTORE?
Signature · 2 lines
Best regards, -grygorii
Re: [PATCH v4 19/24] xen/domctl: wrap hvm_save{,load} with CONFIG_MGMT_HYPERCALLS
Quoted 51 lines · Grygorii Strashko
Quoted 28 lines · Jan Beulich
Quoted 5 lines · Penny Zheng
The following functions have been referenced in places which is either guarded with
CONFIG_MGMT_HYPERCALLSorCONFIG_MEM_SHARING:
-arch_hvm_save
-arch_hvm_check
-arch_hvm_loadQuoted 8 lines
-
hvm_save_size
-hvm_save
-hvm_load
WhileCONFIG_MEM_SHARINGis also dependent onCONFIG_MGMT_HYPERCALLS. So they shall be wrapped underMGMT_HYPERCALLS, otherwise they will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1. We movearch_hvm_save(),arch_hvm_check(),arch_hvm_load()andhvm_save_size()nearer to the left functions, to avoid scattered #ifdef-wrapping.Why would you move things? What is in this source file that is of any use when MGMT_HYPERCALLS=n? The only caller of
hvm_save_one()lives inx86/domctl.c. With that also removed, hvm_sr_handlers[] is only ever written to afaict, which means that's an effectively dead array then too.The final few functions ...
Quoted 6 lines
xen/arch/x86/hvm/save.c +1
-0@@ -390,6 +391,7 @@ int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) /* Not reached */ } +#endif /* CONFIG_MGMT_HYPERCALLS */ Quoted 7 lines
xen/arch/x86/hvm/save.c int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) · line 397
Quoted 2 lines
xen/arch/x86/hvm/save.c +0
-0int _hvm_init_entry (struct hvm_domain_context *h,uint16_t tc,uint16_t inst,uint32_t len)... here and below are only helpers for the save/restore machinery, i.e. that _all_ is also usable only when MGMT_HYPERCALLS=y. Yes, that's a lot of further work, but what do you do? You'll then have quite a bit more code removed from the set that as per coverage analysis is never reached.
I have a local patch which allows to disable all HVM save/load code at once by using separated
KconfigoptionSAVE_RESTORE.+++ b/xen/arch/x86/hvm/Kconfig
(quoted diff) +3
-0@@ -127,4 +127,8 @@ config VHPET +config SAVE_RESTORE + depends on MGMT_HYPERCALLS + def_bool y
SAVE_RESTORE- annotates all HVM save/load code and, in general, could made a feature by allowing it to be selectable.
Of course, It all can be done by just usingMGMT_HYPERCALLS.
Quoted 1 line
So, I'd be appreciated for you opinion - does it make sense to have separate
SAVE_RESTORE?
Yes, why not? The granularity of MGMT_HYPERCALLS is getting a little unwieldy anyway, so why not leverage what you have to split it up at least some. (Of course much depends on how intrusive that change is. Then again the same intrusiveness would have to be expected if it all went under MGMT_HYPERCALLS.)
Jan
Re: [PATCH v4 19/24] xen/domctl: wrap hvm_save{,load} with CONFIG_MGMT_HYPERCALLS
In reply to Grygorii StrashkoQuoted 47 lines · Grygorii Strashko
Quoted 28 lines · Jan Beulich
Quoted 5 lines · Penny Zheng
The following functions have been referenced in places which is either guarded with
CONFIG_MGMT_HYPERCALLSorCONFIG_MEM_SHARING:
-arch_hvm_save
-arch_hvm_check
-arch_hvm_loadQuoted 8 lines
-
hvm_save_size
-hvm_save
-hvm_load
WhileCONFIG_MEM_SHARINGis also dependent onCONFIG_MGMT_HYPERCALLS. So they shall be wrapped underMGMT_HYPERCALLS, otherwise they will become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra rule 2.1. We movearch_hvm_save(),arch_hvm_check(),arch_hvm_load()andhvm_save_size()nearer to the left functions, to avoid scattered #ifdef-wrapping.Why would you move things? What is in this source file that is of any use when MGMT_HYPERCALLS=n? The only caller of
hvm_save_one()lives inx86/domctl.c. With that also removed, hvm_sr_handlers[] is only ever written to afaict, which means that's an effectively dead array then too.The final few functions ...
Quoted 6 lines
xen/arch/x86/hvm/save.c +1
-0@@ -390,6 +391,7 @@ int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) /* Not reached */ } +#endif /* CONFIG_MGMT_HYPERCALLS */ Quoted 7 lines
xen/arch/x86/hvm/save.c int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h) · line 397
Quoted 2 lines
xen/arch/x86/hvm/save.c +0
-0int _hvm_init_entry (struct hvm_domain_context *h,uint16_t tc,uint16_t inst,uint32_t len)... here and below are only helpers for the save/restore machinery, i.e. that _all_ is also usable only when MGMT_HYPERCALLS=y. Yes, that's a lot of further work, but what do you do? You'll then have quite a bit more code removed from the set that as per coverage analysis is never reached.
I have a local patch which allows to disable all HVM save/load code at once by using separated
KconfigoptionSAVE_RESTORE.+++ b/xen/arch/x86/hvm/Kconfig
(quoted diff) +3
-0@@ -127,4 +127,8 @@ config VHPET +config SAVE_RESTORE + depends on MGMT_HYPERCALLS + def_bool y
Quoted 2 lines
SAVE_RESTORE- annotates all HVM save/load code and, in general, could made a feature by allowing it to be selectable.
Oh, one more thing: SAVE_RESTORE, simply by its name, promises to cover PV as well. That either wants to be the case, or the name may want adjusting.
Jan
PATCH 1/1 x86/hvm: move save/restore under HVM_SAVE_RESTORE config
In reply to Penny ZhengFrom: Grygorii Strashko <[email protected]>
Introduce separate HVM_SAVE_RESTORE config for HVM save/restore feature, which is enabled by default for HVM and depends on MGMT_HYPERCALLS config.
This allows to make MGMT_HYPERCALLS specific changes more granular and, if required, make HVM save/restore optional, selectable feature.
---
I'd like to propose this patch as a replacement of Patch 19 [1]
[1] https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- xen/arch/x86/emul-i8254.c | 4 +++- xen/arch/x86/hvm/Kconfig | 6 ++++++ xen/arch/x86/hvm/Makefile | 2 +- xen/arch/x86/hvm/hpet.c | 3 ++- xen/arch/x86/hvm/hvm.c | 4 ++++ xen/arch/x86/hvm/irq.c | 2 ++ xen/arch/x86/hvm/mtrr.c | 2 ++ xen/arch/x86/hvm/pmtimer.c | 2 ++ xen/arch/x86/hvm/rtc.c | 2 ++ xen/arch/x86/hvm/vioapic.c | 2 ++ xen/arch/x86/hvm/viridian/viridian.c | 2 ++ xen/arch/x86/hvm/vlapic.c | 3 ++- xen/arch/x86/hvm/vpic.c | 2 ++ xen/arch/x86/include/asm/hvm/save.h | 5 ++++- 15 files changed, 38 insertions(+), 7 deletions(-)
xen/arch/x86/cpu/mcheck/vmce.c +2 -2
@@ -349,7 +349,7 @@ int vmce_wrmsr(uint32_t msr, uint64_t val)return ret; } -#if CONFIG_HVM +#if defined(CONFIG_HVM_SAVE_RESTORE) static int cf_check vmce_save_vcpu_ctxt(struct vcpu *v, hvm_domain_context_t *h) { struct hvm_vmce_vcpu ctxt = {
@@ -380,10 +380,10 @@ static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t * return err ?: vmce_restore_vcpu(v, &ctxt); } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (VMCE_VCPU , vmce_save_vcpu_ctxt,NULL , vmce_load_vcpu_ctxt,1 ,HVMSR_PER_VCPU ); -#endif /* * for Intel MCE, broadcast vMCE to all vcpus
xen/arch/x86/emul-i8254.c +3 -1
@@ -409,7 +409,9 @@ void pit_stop_channel0_irq(PITState *pit)destroy_periodic_time (&pit->pt0);spin_unlock (&pit->lock); } +#endif +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check pit_save(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;
@@ -507,9 +509,9 @@ static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h)return rc; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (PIT , pit_save, pit_check, pit_load,1 ,HVMSR_PER_DOM ); -#endif /* The intercept action for PIT DM retval: 0--not handled; 1--handled. */ static int cf_check handle_pit_io(
xen/arch/x86/hvm/Kconfig +6 -0
@@ -93,4 +93,10 @@ config MEM_SHARING depends on INTEL_VMX depends on MGMT_HYPERCALLS +config HVM_SAVE_RESTORE + depends on MGMT_HYPERCALLS + def_bool y + help + Enables HVM save/load functionality. + endif
xen/arch/x86/hvm/Makefile +1 -1
@@ -22,7 +22,7 @@ obj-y += nestedhvm.o obj-y += pmtimer.o obj-y += quirks.o obj-y += rtc.o -obj-y += save.o +obj-$(CONFIG_HVM_SAVE_RESTORE) += save.o obj-y += stdvga.o obj-y += vioapic.o obj-y += vlapic.o
xen/arch/x86/hvm/hpet.c +2 -1
@@ -570,7 +570,7 @@ static const struct hvm_mmio_ops hpet_mmio_ops = { .write = hpet_write }; - +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check hpet_save(struct vcpu *v, hvm_domain_context_t *h) {const struct domain *d = v->domain;
@@ -691,6 +691,7 @@ static int cf_check hpet_load(struct domain *d, hvm_domain_context_t *h) return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (HPET , hpet_save,NULL , hpet_load,1 ,HVMSR_PER_DOM );
xen/arch/x86/hvm/hvm.c +4 -0
@@ -796,6 +796,7 @@ void hvm_domain_destroy(struct domain *d)destroy_vpci_mmcfg (d); } +#if defined(CONFIG_HVM_SAVE_RESTORE) static int cf_check hvm_save_tsc_adjust(struct vcpu *v, hvm_domain_context_t *h) { struct hvm_tsc_adjust ctxt = {
@@ -943,6 +944,7 @@ static int cf_check hvm_save_cpu_ctxt(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (CPU , v->vcpu_id, h, &ctxt); } +#endif /* CONFIG_HVM_SAVE_RESTORE */ /* Return a string indicating the error, or NULL for valid. */ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
@@ -1020,6 +1022,7 @@ unsigned long hvm_cr4_guest_valid_bits(const struct domain *d) 0); } +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) {const struct cpu_policy *p = d->arch.cpu_policy;
@@ -1602,6 +1605,7 @@ static int __init cf_check hvm_register_CPU_save_and_restore(void)return 0 ; }__initcall (hvm_register_CPU_save_and_restore); +#endif /* CONFIG_HVM_SAVE_RESTORE */ static void cf_check hvm_assert_evtchn_irq_tasklet(void *v) {
xen/arch/x86/hvm/irq.c +2 -0
@@ -649,6 +649,7 @@ static int __init cf_check dump_irq_info_key_init(void) }__initcall (dump_irq_info_key_init); +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check irq_save_pci(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;
@@ -799,6 +800,7 @@ static int cf_check irq_load_link(struct domain *d, hvm_domain_context_t *h) return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (PCI_IRQ , irq_save_pci,NULL , irq_load_pci,1 ,HVMSR_PER_DOM );
xen/arch/x86/hvm/mtrr.c +2 -0
@@ -695,6 +695,7 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,return rc; } +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check hvm_save_mtrr_msr(struct vcpu *v, hvm_domain_context_t *h) {const struct mtrr_state *m = &v->arch.hvm.mtrr;
@@ -782,6 +783,7 @@ static int cf_check hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h) return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (MTRR , hvm_save_mtrr_msr,NULL , hvm_load_mtrr_msr,1 ,HVMSR_PER_VCPU );
xen/arch/x86/hvm/pmtimer.c +2 -0
@@ -240,6 +240,7 @@ static int cf_check handle_pmt_io(return X86EMUL_OKAY ; } +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check acpi_save(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;
@@ -300,6 +301,7 @@ static int cf_check acpi_load(struct domain *d, hvm_domain_context_t *h) return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (PMTIMER , acpi_save,NULL , acpi_load,1 ,HVMSR_PER_DOM );
xen/arch/x86/hvm/rtc.c +2 -0
@@ -742,6 +742,7 @@ void rtc_migrate_timers(struct vcpu *v) } } +#if defined(CONFIG_HVM_SAVE_RESTORE )/* Save RTC hardware state */ static int cf_check rtc_save(struct vcpu *v, hvm_domain_context_t *h) {
@@ -797,6 +798,7 @@ static int cf_check rtc_load(struct domain *d, hvm_domain_context_t *h) return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (RTC , rtc_save,NULL , rtc_load,1 ,HVMSR_PER_DOM );
xen/arch/x86/hvm/vioapic.c +2 -0
@@ -594,6 +594,7 @@ int vioapic_get_trigger_mode(const struct domain *d, unsigned int gsi)return vioapic->redirtbl[pin].fields.trig_mode; } +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check ioapic_save(struct vcpu *v, hvm_domain_context_t *h) {const struct domain *d = v->domain;
@@ -629,6 +630,7 @@ static int cf_check ioapic_load(struct domain *d, hvm_domain_context_t *h) return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (IOAPIC , ioapic_save,NULL , ioapic_load,1 ,HVMSR_PER_DOM );
xen/arch/x86/hvm/viridian/viridian.c +2 -0
@@ -1092,6 +1092,7 @@ void viridian_unmap_guest_page(struct viridian_page *vp)put_page_and_type (page); } +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check viridian_save_domain_ctxt(struct vcpu *v,hvm_domain_context_t *h) {
@@ -1171,6 +1172,7 @@ static int cf_check viridian_load_vcpu_ctxt( return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (VIRIDIAN_VCPU , viridian_save_vcpu_ctxt,NULL , viridian_load_vcpu_ctxt,1 ,HVMSR_PER_VCPU );
xen/arch/x86/hvm/vlapic.c +2 -1
@@ -1481,6 +1481,7 @@ void vlapic_reset(struct vlapic *vlapic)vlapic_do_init (vlapic); } +#if defined(CONFIG_HVM_SAVE_RESTORE )/* rearm the actimer if needed, after a HVM restore */ static void lapic_rearm (struct vlapic *s) {
@@ -1578,7 +1579,6 @@ static void lapic_load_fixup(struct vlapic *vlapic) v, vlapic->loaded.id, vlapic->loaded.ldr, good_ldr); } -static int lapic_check_common (const struct domain *d,unsigned int vcpuid) {if ( !has_vlapic (d) )
@@ -1675,6 +1675,7 @@ static int cf_check lapic_load_regs(struct domain *d, hvm_domain_context_t *h)lapic_rearm (s); return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (LAPIC , lapic_save_hidden, lapic_check_hidden, lapic_load_hidden,1 ,HVMSR_PER_VCPU );
xen/arch/x86/hvm/vpic.c +2 -0
@@ -402,6 +402,7 @@ static int cf_check vpic_intercept_elcr_io(return X86EMUL_OKAY ; } +#if defined(CONFIG_HVM_SAVE_RESTORE ) static int cf_check vpic_save(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;
@@ -475,6 +476,7 @@ static int cf_check vpic_load(struct domain *d, hvm_domain_context_t *h) return 0; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (PIC , vpic_save, vpic_check, vpic_load,2 ,HVMSR_PER_DOM );
xen/arch/x86/include/asm/hvm/save.h +4 -1
@@ -123,6 +123,7 @@ void hvm_register_savevm(uint16_t typecode,/* Syntactic sugar around that function: specify the max number of * saves, and this calculates the size of buffer needed */ +#ifdef CONFIG_HVM_SAVE_RESTORE #define HVM_REGISTER_SAVE_RESTORE (_x, _save, check, _load, _num, _k) \ static int __init cf_check __hvm_register_##_x##_save_and_restore(void) \ { \
@@ -137,7 +138,9 @@ static int __init cf_check __hvm_register_##_x##_save_and_restore(void) \return 0 ; \ } \ __initcall(__hvm_register_##_x##_save_and_restore); - +#else +#define HVM_REGISTER_SAVE_RESTORE (_x, _save, check, _load, _num, _k) +#endif /* Entry points for saving and restoring HVM domain state */ size_t hvm_save_size (struct domain *d);
Signature · 1 line
2.34.1
Re: [XEN][PATCH] x86/hvm: move save/restore under HVM_SAVE_RESTORE config
Quoted 36 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Introduce separate
HVM_SAVE_RESTOREconfig for HVM save/restore feature, which is enabled by default for HVM and depends onMGMT_HYPERCALLSconfig.This allows to make
MGMT_HYPERCALLSspecific changes more granular and, if required, make HVM save/restore optional, selectable feature.Signed-off-by Grygorii Strashko <[email protected]>---
I'd like to propose this patch as a replacement of Patch 19 [1][1] https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- xen/arch/x86/emul-i8254.c | 4 +++- xen/arch/x86/hvm/Kconfig | 6 ++++++ xen/arch/x86/hvm/Makefile | 2 +- xen/arch/x86/hvm/hpet.c | 3 ++- xen/arch/x86/hvm/hvm.c | 4 ++++ xen/arch/x86/hvm/irq.c | 2 ++ xen/arch/x86/hvm/mtrr.c | 2 ++ xen/arch/x86/hvm/pmtimer.c | 2 ++ xen/arch/x86/hvm/rtc.c | 2 ++ xen/arch/x86/hvm/vioapic.c | 2 ++ xen/arch/x86/hvm/viridian/viridian.c | 2 ++ xen/arch/x86/hvm/vlapic.c | 3 ++- xen/arch/x86/hvm/vpic.c | 2 ++ xen/arch/x86/include/asm/hvm/save.h | 5 ++++- 15 files changed, 38 insertions(+), 7 deletions(-)xen/arch/x86/cpu/mcheck/vmce.c +0
-0
xen/arch/x86/cpu/mcheck/vmce.c int vmce_wrmsr(uint32_t msr, uint64_t val) · line 352
Quoted 5 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-1@@ -349,7 +349,7 @@ int vmce_wrmsr(uint32_t msr, uint64_t val)return ret; } -#if CONFIG_HVM +#if defined(CONFIG_HVM_SAVE_RESTORE )
#if wasn't really correct to use here; #ifdef was and is wanted.
xen/arch/x86/cpu/mcheck/vmce.c static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t * · line 386
Quoted 12 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-1static int cf_check vmce_save_vcpu_ctxt(struct vcpu *v, hvm_domain_context_t *h) {struct hvm_vmce_vcpu ctxt = {@@ -380,10 +380,10 @@ static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t * return err ?: vmce_restore_vcpu(v, &ctxt); } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (VMCE_VCPU , vmce_save_vcpu_ctxt,NULL , vmce_load_vcpu_ctxt,1 ,HVMSR_PER_VCPU ); -#endif
Why would this #endif move? (It gaining a comment is fine of course.)
xen/arch/x86/emul-i8254.c void pit_stop_channel0_irq(PITState *pit) · line 414
Quoted 9 lines
xen/arch/x86/emul-i8254.c +2
-0@@ -409,7 +409,9 @@ void pit_stop_channel0_irq(PITState *pit)destroy_periodic_time (&pit->pt0); spin_unlock(&pit->lock); } +#endif +#if defined(CONFIG_HVM_SAVE_RESTORE )
Hmm, again - please use the shorter #ifdef.
xen/arch/x86/emul-i8254.c static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h) · line 512
Quoted 8 lines
xen/arch/x86/emul-i8254.c +1
-1@@ -507,9 +509,9 @@ static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h) return rc; } +#endif /* CONFIG_HVM_SAVE_RESTORE */ HVM_REGISTER_SAVE_RESTORE (PIT , pit_save, pit_check, pit_load,1 ,HVMSR_PER_DOM ); -#endif
And again - why move it?
xen/arch/x86/hvm/Kconfig config MEM_SHARING · line 102
Quoted 13 lines
xen/arch/x86/hvm/Kconfig +6
-0@@ -93,4 +93,10 @@ config MEM_SHARING depends on INTEL_VMX depends on MGMT_HYPERCALLS +config HVM_SAVE_RESTORE + depends on MGMT_HYPERCALLS + def_bool y + help + Enables HVM save/load functionality. + endif
This wants to move up some imo; MEM_SHARING is clearing the more niche feature.
Quoted 11 lines
xen/arch/x86/include/asm/hvm/save.h +1
-0@@ -123,6 +123,7 @@ void hvm_register_savevm(uint16_t typecode,/* Syntactic sugar around that function: specify the max number of * saves, and this calculates the size of buffer needed */ +#ifdef CONFIG_HVM_SAVE_RESTORE #define HVM_REGISTER_SAVE_RESTORE (_x, _save, check, _load, _num, _k) \ static int __init cf_check __hvm_register_##_x##_save_and_restore(void) \ { \
xen/arch/x86/include/asm/hvm/save.h static int __init cf_check __hvm_register_##_x##_save_and_restore(void) \ · line 143
Quoted 7 lines
xen/arch/x86/include/asm/hvm/save.h +3
-1@@ -137,7 +138,9 @@ static int __init cf_check __hvm_register_##_x##_save_and_restore(void) \return 0 ; \ } \ __initcall(__hvm_register_##_x##_save_and_restore); - +#else +#define HVM_REGISTER_SAVE_RESTORE (_x, _save, check, _load, _num, _k) +#endif
By suitably moving the #endif-s I would hope we can get away without this dummy #define.
Jan
Re: [XEN][PATCH] x86/hvm: move save/restore under HVM_SAVE_RESTORE config
Quoted 54 lines · Jan Beulich
Quoted 36 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Introduce separate
HVM_SAVE_RESTOREconfig for HVM save/restore feature, which is enabled by default for HVM and depends onMGMT_HYPERCALLSconfig.This allows to make
MGMT_HYPERCALLSspecific changes more granular and, if required, make HVM save/restore optional, selectable feature.Signed-off-by Grygorii Strashko <[email protected]>---
I'd like to propose this patch as a replacement of Patch 19 [1][1] https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- xen/arch/x86/emul-i8254.c | 4 +++- xen/arch/x86/hvm/Kconfig | 6 ++++++ xen/arch/x86/hvm/Makefile | 2 +- xen/arch/x86/hvm/hpet.c | 3 ++- xen/arch/x86/hvm/hvm.c | 4 ++++ xen/arch/x86/hvm/irq.c | 2 ++ xen/arch/x86/hvm/mtrr.c | 2 ++ xen/arch/x86/hvm/pmtimer.c | 2 ++ xen/arch/x86/hvm/rtc.c | 2 ++ xen/arch/x86/hvm/vioapic.c | 2 ++ xen/arch/x86/hvm/viridian/viridian.c | 2 ++ xen/arch/x86/hvm/vlapic.c | 3 ++- xen/arch/x86/hvm/vpic.c | 2 ++ xen/arch/x86/include/asm/hvm/save.h | 5 ++++- 15 files changed, 38 insertions(+), 7 deletions(-)xen/arch/x86/cpu/mcheck/vmce.c +0
-0xen/arch/x86/cpu/mcheck/vmce.c int vmce_wrmsr(uint32_t msr, uint64_t val) · line 352
Quoted 5 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-1@@ -349,7 +349,7 @@ int vmce_wrmsr(uint32_t msr, uint64_t val)return ret; } -#if CONFIG_HVM +#if defined(CONFIG_HVM_SAVE_RESTORE )#if wasn't really correct to use here; #ifdef was and is wanted.
Quoted 9 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-0static int cf_check vmce_save_vcpu_ctxt(struct vcpu *v, hvm_domain_context_t *h) {struct hvm_vmce_vcpu ctxt = {@@ -380,10 +380,10 @@ static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t * return err ?: vmce_restore_vcpu(v, &ctxt); } +#endif /* CONFIG_HVM_SAVE_RESTORE */
Quoted 5 lines
xen/arch/x86/cpu/mcheck/vmce.c static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t * · line 386
Quoted 3 lines
xen/arch/x86/cpu/mcheck/vmce.c +0
-1HVM_REGISTER_SAVE_RESTORE (VMCE_VCPU , vmce_save_vcpu_ctxt,NULL , vmce_load_vcpu_ctxt,1 ,HVMSR_PER_VCPU ); -#endif Why would this #endif move? (It gaining a comment is fine of course.)
Huh. Initially I've used __maybe_unused with save/restore callbacks and HVM_REGISTER_SAVE_RESTORE() defines as NOP.
I'll correct and drop empty HVM_REGISTER_SAVE_RESTORE()
Quoted 6 lines
Quoted 6 lines
xen/arch/x86/hvm/Kconfig +0
-0@@ -93,4 +93,10 @@ config MEM_SHARING depends on INTEL_VMX depends on MGMT_HYPERCALLS
Quoted 10 lines
xen/arch/x86/hvm/Kconfig config MEM_SHARING · line 102
Quoted 7 lines
xen/arch/x86/hvm/Kconfig +6
-0+config HVM_SAVE_RESTORE + depends on MGMT_HYPERCALLS + def_bool y + help + Enables HVM save/load functionality. + endifThis wants to move up some imo;
MEM_SHARINGis clearing the more niche feature.
Could you clarify preferred place - before which Kconfig option in hvm/Kconfig?
Signature · 2 lines
Best regards, -grygorii
Re: [XEN][PATCH] x86/hvm: move save/restore under HVM_SAVE_RESTORE config
Quoted 18 lines · Grygorii Strashko
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Grygorii Strashko
xen/arch/x86/hvm/Kconfig +0
-0@@ -93,4 +93,10 @@ config MEM_SHARING depends on INTEL_VMX depends on MGMT_HYPERCALLSQuoted 9 lines
xen/arch/x86/hvm/Kconfig config MEM_SHARING · line 102
Quoted 7 lines
xen/arch/x86/hvm/Kconfig +6
-0+config HVM_SAVE_RESTORE + depends on MGMT_HYPERCALLS + def_bool y + help + Enables HVM save/load functionality. + endifThis wants to move up some imo;
MEM_SHARINGis clearing the more niche feature.
Quoted 1 line
Could you clarify preferred place - before which
Kconfigoption in hvm/Kconfig?
There's no "ideal" place imo, as the ordering is somewhat clumsy anyway. Before HVM_FEP or after VIRIDIAN, I would say (with a slight preference to the former).
Jan
PATCH v4 20/24 xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction arch_do_domctl() is responsible for arch-specific domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS
We focus on x86 implementation here only. Tracking its calling chain and the following functions shall be wrapped with CONFIG_MGMT_HYPERCALLS too. Otherwise they will all become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra Rule 2.1.
- hvm_acpi_power_button
- hvm_acpi_sleep_button
- hvm_debug_op
- make P2M_AUDIT depend on CONFIG_MGMT_HYPERCALLS
- make PG_log_dirty depend on CONFIG_MGMT_HYPERCALLS
- make cpuid.o/policy.o/msr.o depend on CONFIG_MGMT_HYPERCALLS
- make HAS_SOFT_RESET depend on CONFIG_MGMT_HYPERCALLS
- make VMTRACE depend on CONFIG_MGMT_HYPERCALLS
- paging_domctl_cont
We put the guardian in Makefile for the arch-specific domctl.o compilation.
---
v1 -> v2:
- split out xsm parts
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap default-case and arch_get_domain_info() transiently
---
v2 -> v3:
- add missing guardian in arm/Makefile
- cover RTIT_CTL{,STATUS}_MASK #define-s
- add missing guardian for .vmtrace_output_position
- guard the whole static inline function
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping around default-case and arch_get_domain_info()
---
v3 -> v4:
- make HAS_SOFT_RESET depend on CONFIG_MGMT_HYPERCALLS
- make VMTRACE depend on CONFIG_MGMT_HYPERCALLS
- seperate depends on condition for future convenience
- split arch-specific domctl-op into x86 and arm
--- xen/Kconfig.debug | 1 + xen/arch/x86/Kconfig | 2 +- xen/arch/x86/Makefile | 2 +- xen/arch/x86/hvm/Kconfig | 1 + xen/arch/x86/hvm/hvm.c | 2 ++ xen/arch/x86/hvm/pmtimer.c | 2 ++ xen/arch/x86/include/asm/p2m.h | 2 +- xen/arch/x86/include/asm/paging.h | 2 +- xen/include/hypercall-defs.c | 4 +++- xen/lib/x86/Makefile | 6 +++--- 10 files changed, 16 insertions(+), 8 deletions(-)
xen/Kconfig.debug +1 -0
@@ -15,6 +15,7 @@ if DEBUG || EXPERT config GDBSX bool "Guest debugging with gdbsx" + depends on MGMT_HYPERCALLS depends on X86 default y help
xen/arch/x86/Kconfig +1 -1
@@ -29,7 +29,7 @@ config X86 select HAS_PCI_MSI select HAS_PIRQ select HAS_SCHED_GRANULARITY - imply HAS_SOFT_RESET + select HAS_SOFT_RESET if MGMT_HYPERCALLS select HAS_UBSAN select HAS_VMAP select HAS_VPCI if HVM
xen/arch/x86/Makefile +1 -1
@@ -79,7 +79,7 @@ obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += xstate.o ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) -obj-y += domctl.o +obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += platform_hypercall.o obj-$(CONFIG_COMPAT) += x86_64/platform_hypercall.o endif
xen/arch/x86/hvm/Kconfig +1 -0
@@ -37,6 +37,7 @@ config INTEL_VMX config VMTRACE bool "HW VM tracing support" depends on INTEL_VMX + depends on MGMT_HYPERCALLS default y help Enables HW VM tracing support which allows to configure HW processor
xen/arch/x86/hvm/hvm.c +2 -0
@@ -5204,6 +5204,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)return rc; } +#ifdef CONFIG_MGMT_HYPERCALLS int hvm_debug_op (struct vcpu *v,int32_t op) {int rc =0 ;
@@ -5246,6 +5247,7 @@ int hvm_debug_op(struct vcpu *v, int32_t op) return rc; } +#endif /* CONFIG_MGMT_HYPERCALLS */ #ifdef CONFIG_VM_EVENT void hvm_toggle_singlestep (struct vcpu *v)
xen/arch/x86/hvm/pmtimer.c +2 -0
@@ -56,6 +56,7 @@ static void pmt_update_sci(PMTState *s)hvm_isa_irq_deassert (s->vcpu->domain,SCI_IRQ ); } +#ifdef CONFIG_MGMT_HYPERCALLS void hvm_acpi_power_button (struct domain *d) {PMTState *s = &d->arch.hvm.pl_time->vpmt;
@@ -81,6 +82,7 @@ void hvm_acpi_sleep_button(struct domain *d)pmt_update_sci (s); spin_unlock(&s->lock); } +#endif /* CONFIG_MGMT_HYPERCALLS */ /* Set the correct value in the timer, accounting for time elapsed * since the last time we did that. */
xen/arch/x86/include/asm/p2m.h +1 -1
@@ -20,7 +20,7 @@#include <asm/page.h> /* for pagetable_t */ /* Debugging and auditing of the P2M code? */ -#if !defined(NDEBUG ) && defined(CONFIG_HVM ) +#if !defined(NDEBUG ) && defined(CONFIG_HVM ) && defined(CONFIG_MGMT_HYPERCALLS )#define P2M_AUDIT 1#else #define P2M_AUDIT 0
xen/arch/x86/include/asm/paging.h +1 -1
@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) && defined(CONFIG_MGMT_HYPERCALLS )/* Enable log dirty mode */ #define PG_log_dirty (XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY << PG_mode_shift)#else
xen/include/hypercall-defs.c +3 -1
@@ -196,10 +196,10 @@ dm_op(domid_t domid, unsigned int nr_bufs, xen_dm_op_buf_t *bufs)#endif #ifdef CONFIG_MGMT_HYPERCALLS sysctl(xen_sysctl_t *u_sysctl) -#endif #if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) paging_domctl_cont(xen_domctl_t *u_domctl)#endif +#endif #ifndef CONFIG_PV_SHIM_EXCLUSIVE domctl(xen_domctl_t *u_domctl)platform_op (xen_platform_op_t *u_xenpf_op)
@@ -299,7 +299,9 @@ hypfs_op do do do do do#endif mca do do - - -#if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#ifdef CONFIG_MGMT_HYPERCALLS paging_domctl_cont do do do do -#endif +#endif #endif /* !CPPCHECK */
xen/lib/x86/Makefile +3 -3
@@ -1,4 +1,4 @@ -obj-y += cpuid.o +obj-$(CONFIG_MGMT_HYPERCALLS) += cpuid.o obj-y += cpuid-generic.o -obj-y += msr.o -obj-y += policy.o +obj-$(CONFIG_MGMT_HYPERCALLS) += msr.o +obj-$(CONFIG_MGMT_HYPERCALLS) += policy.o
Signature · 1 line
2.34.1
Re: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS
xen/arch/x86/Kconfig config X86 · line 32
Quoted 8 lines · Penny Zheng
xen/arch/x86/Kconfig +1
-1@@ -29,7 +29,7 @@ config X86 select HAS_PCI_MSI select HAS_PIRQ select HAS_SCHED_GRANULARITY - imply HAS_SOFT_RESET + select HAS_SOFT_RESET if MGMT_HYPERCALLS
Why would you undo an "imply", when really we should use it more? One of its purposes is so that you can add "depends on MGMT_HYPERCALLS" there, and it then won't be auto-enabled if that dependency isn't fulfilled.
xen/arch/x86/include/asm/paging.h line 58
Quoted 8 lines
xen/arch/x86/include/asm/paging.h +1
-1@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) && defined(CONFIG_MGMT_HYPERCALLS )
This line is too long now.
xen/arch/x86/include/asm/paging.h hypfs_op do do do do do · line 302
Quoted 5 lines
xen/arch/x86/include/asm/paging.h +1
-0@@ -299,7 +299,9 @@ hypfs_op do do do do do#endif mca do do - - -#if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#ifdef CONFIG_MGMT_HYPERCALLS
Why not combine with the existing #if?
Jan
RE: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS
[Public]
Quoted 36 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, November 26, 2025 1:00 AM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Roger Pau Monné <[email protected]>; Stefano Stabellini <[email protected]>; Daniel P. Smith <[email protected]>; [email protected]
Subject: Re: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op withCONFIG_MGMT_HYPERCALLSxen/arch/x86/Kconfig config X86 · line 32
Quoted 8 lines · Penny Zheng
xen/arch/x86/Kconfig +1
-1@@ -29,7 +29,7 @@ config X86 select HAS_PCI_MSI select HAS_PIRQ select HAS_SCHED_GRANULARITY - imply HAS_SOFT_RESET + select HAS_SOFT_RESET if MGMT_HYPERCALLSWhy would you undo an "imply", when really we should use it more? One of its purposes is so that you can add "depends on
MGMT_HYPERCALLS" there, and it then won't be auto-enabled if that dependency isn't fulfilled.xen/arch/x86/include/asm/paging.h line 58
Quoted 8 lines
xen/arch/x86/include/asm/paging.h +1
-1@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE )&&
Quoted 3 lines
xen/arch/x86/include/asm/paging.h line 59
Quoted 1 line
xen/arch/x86/include/asm/paging.h +1
-0+defined (CONFIG_MGMT_HYPERCALLS )This line is too long now.
Hmm, how about I introduce a new Kconfig, something like:
```
diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index c808c989fc..ec8f51b0b1 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -166,6 +166,9 @@ config SHADOW_PAGING
config PAGING
def_bool HVM || SHADOW_PAGING
+config PAGING_LOG_DIRTY
+ def_bool PAGING
+
config BIGMEM
bool "big memory support"
default n
```Then, later future dependency could be added to PAGING_LOG_DIRTY
Quoted 1 line
Jan
Re: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS
Quoted 58 lines · Zheng
[Public]
Quoted 36 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, November 26, 2025 1:00 AM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Roger Pau Monné <[email protected]>; Stefano Stabellini <[email protected]>; Daniel P. Smith <[email protected]>; [email protected]
Subject: Re: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op withCONFIG_MGMT_HYPERCALLSxen/arch/x86/Kconfig config X86 · line 32
Quoted 8 lines · Penny Zheng
xen/arch/x86/Kconfig +1
-1@@ -29,7 +29,7 @@ config X86 select HAS_PCI_MSI select HAS_PIRQ select HAS_SCHED_GRANULARITY - imply HAS_SOFT_RESET + select HAS_SOFT_RESET if MGMT_HYPERCALLSWhy would you undo an "imply", when really we should use it more? One of its purposes is so that you can add "depends on
MGMT_HYPERCALLS" there, and it then won't be auto-enabled if that dependency isn't fulfilled.xen/arch/x86/include/asm/paging.h line 58
Quoted 8 lines
xen/arch/x86/include/asm/paging.h +1
-1@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE )&&
Quoted 3 lines
xen/arch/x86/include/asm/paging.h line 59
Quoted 1 line
xen/arch/x86/include/asm/paging.h +1
-0+defined (CONFIG_MGMT_HYPERCALLS )This line is too long now.
Hmm, how about I introduce a new
Kconfig, something like:
```xen/arch/x86/Kconfig +3
-0@@ -166,6 +166,9 @@ config SHADOW_PAGING config PAGING def_bool HVM || SHADOW_PAGING +config PAGING_LOG_DIRTY + def_bool PAGING + config BIGMEM bool "big memory support" default n
Quoted 2 lines
```
Then, later future dependency could be added toPAGING_LOG_DIRTY
I fear I don't see how having an option merely aliasing another option would help the line length issue. I may simply be missing some context ...
Jan
RE: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS
[Public]
Quoted 67 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Thursday, December 4, 2025 5:41 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Roger Pau Monné <[email protected]>; Stefano Stabellini <[email protected]>; Daniel P. Smith <[email protected]>; [email protected]
Subject: Re: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op withCONFIG_MGMT_HYPERCALLSQuoted 30 lines · Zheng
[Public]
Quoted 28 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, November 26, 2025 1:00 AM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Roger Pau Monné <[email protected]>; Stefano Stabellini <[email protected]>; Daniel P. Smith <[email protected]>; [email protected]
Subject: Re: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op withCONFIG_MGMT_HYPERCALLSxen/arch/x86/Kconfig config X86 · line 32
Quoted 8 lines · Penny Zheng
xen/arch/x86/Kconfig +1
-1@@ -29,7 +29,7 @@ config X86 select HAS_PCI_MSI select HAS_PIRQ select HAS_SCHED_GRANULARITY - imply HAS_SOFT_RESET + select HAS_SOFT_RESET if MGMT_HYPERCALLSWhy would you undo an "imply", when really we should use it more? One of its purposes is so that you can add "depends on
MGMT_HYPERCALLS" there, and it then won't be auto-enabled if that dependency isn't fulfilled.Quoted 8 lines
Quoted 8 lines
xen/arch/x86/include/asm/paging.h line 58
Quoted 8 lines
xen/arch/x86/include/asm/paging.h +1
-1@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#if defined(CONFIG_PAGING )&& !defined(CONFIG_PV_SHIM_EXCLUSIVE)
Quoted 14 lines
Quoted 4 lines
&&
xen/arch/x86/include/asm/paging.h line 59
Quoted 1 line
xen/arch/x86/include/asm/paging.h +1
-0+defined (CONFIG_MGMT_HYPERCALLS )This line is too long now.
Hmm, how about I introduce a new
Kconfig, something like:
```xen/arch/x86/Kconfig index renamed from xen/arch/x86/Kconfig +0
-0
c808c989fc..ec8f51b0b1100644xen/arch/x86/Kconfig +0
-0@@ -166,6 +166,9 @@ config SHADOW_PAGING config PAGING def_bool HVM || SHADOW_PAGING
Quoted 11 lines
Quoted 8 lines
xen/arch/x86/Kconfig +3
-0+config PAGING_LOG_DIRTY + def_bool PAGING + config BIGMEM bool "big memory support" default n```
Then, later future dependency could be added toPAGING_LOG_DIRTYI fear I don't see how having an option merely aliasing another option would help the line length issue. I may simply be missing some context ...
Later when MGMT_HYPERCCALLS kicks in, we could have to avoid overlong #ifdef:
```
#if defined(CONFIG_PAGING_LOG_DIRTY) && !defined(CONFIG_PV_SHIM_EXCLUSIVE)
#define PG_log_dirty (XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY << PG_mode_shift)
...
```
The addition of MGMT_HYPERCCALLS dependency could be added to PAGING_LOG_DIRTY kconfig
```
config PAGING_LOG_DIRTY
def_bool PAGING && MGMT_HYPERCALLS
```Quoted 2 lines
Jan
Re: [PATCH v4 20/24] xen/x86: wrap x86-specific domctl-op with CONFIG_MGMT_HYPERCALLS
Quoted 59 lines · Zheng
Quoted 47 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Thursday, December 4, 2025 5:41 PMQuoted 19 lines · Zheng
Quoted 19 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, November 26, 2025 1:00 AMxen/arch/x86/Kconfig config X86 · line 32
Quoted 8 lines · Penny Zheng
xen/arch/x86/Kconfig +1
-1@@ -29,7 +29,7 @@ config X86 select HAS_PCI_MSI select HAS_PIRQ select HAS_SCHED_GRANULARITY - imply HAS_SOFT_RESET + select HAS_SOFT_RESET if MGMT_HYPERCALLSWhy would you undo an "imply", when really we should use it more? One of its purposes is so that you can add "depends on
MGMT_HYPERCALLS" there, and it then won't be auto-enabled if that dependency isn't fulfilled.Quoted 8 lines
Quoted 8 lines
xen/arch/x86/include/asm/paging.h line 58
Quoted 8 lines
xen/arch/x86/include/asm/paging.h +1
-1@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#if defined(CONFIG_PAGING )&& !defined(CONFIG_PV_SHIM_EXCLUSIVE)
Quoted 14 lines
Quoted 4 lines
&&
xen/arch/x86/include/asm/paging.h line 59
Quoted 1 line
xen/arch/x86/include/asm/paging.h +1
-0+defined (CONFIG_MGMT_HYPERCALLS )This line is too long now.
Hmm, how about I introduce a new
Kconfig, something like:
```xen/arch/x86/Kconfig index renamed from xen/arch/x86/Kconfig +0
-0
c808c989fc..ec8f51b0b1100644xen/arch/x86/Kconfig +0
-0@@ -166,6 +166,9 @@ config SHADOW_PAGING config PAGING def_bool HVM || SHADOW_PAGINGQuoted 11 lines
Quoted 8 lines
xen/arch/x86/Kconfig +3
-0+config PAGING_LOG_DIRTY + def_bool PAGING + config BIGMEM bool "big memory support" default n```
Then, later future dependency could be added toPAGING_LOG_DIRTYI fear I don't see how having an option merely aliasing another option would help the line length issue. I may simply be missing some context ...
Quoted 3 lines
Later when
MGMT_HYPERCCALLSkicks in, we could have to avoid overlong #ifdef:
```
#ifdefined(CONFIG_PAGING_LOG_DIRTY)&& !defined(CONFIG_PV_SHIM_EXCLUSIVE)
Yet this is a bogus construct to have. It really means PAGING_LOG_DIRTY would better depend on !PV_SHIM_EXCLUSIVE, except that this is precisely the pattern we want to get rid of. At which point imo the usefulness of PAGING_LOG_DIRTY would be somewhat limited.
Jan
Quoted 11 lines
#define
PG_log_dirty(XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY<<PG_mode_shift)
...``` The addition of MGMT_HYPERCCALLS dependency could be added to PAGING_LOG_DIRTY kconfig ``` config PAGING_LOG_DIRTY def_bool PAGING && MGMT_HYPERCALLS```
Quoted 2 lines
Jan
PATCH v4 21/24 xen/arm: wrap arm-specific domctl-op with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengFunction arch_do_domctl() is responsible for arch-specific domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS
Guard arm-specific domctl.o compilation with CONFIG_MGMT_HYPERCALLS. Otherwise the whole file will become unreachable when MGMT_HYPERCALLS=n, and hence violating Misra Rule 2.1.
---
v3 -> v4:
- split arch-specific domctl-op into x86 and arm
--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/arm32/Makefile | 2 +- xen/arch/arm/arm64/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/Makefile +1 -1
@@ -20,7 +20,7 @@ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.init.o obj-y += domain.o obj-y += domain_build.init.o -obj-y += domctl.o +obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-y += efi/ obj-y += gic.o
xen/arch/arm/arm32/Makefile +1 -1
@@ -4,7 +4,7 @@ obj-$(CONFIG_MPU) += mpu/ obj-y += cache.o obj-$(CONFIG_EARLY_PRINTK) += debug.o -obj-y += domctl.o +obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += domain.o obj-y += entry.o obj-y += head.o
xen/arch/arm/arm64/Makefile +1 -1
@@ -6,7 +6,7 @@ obj-y += cache.o obj-y += cpufeature.o obj-$(CONFIG_HARDEN_BRANCH_PREDICTOR) += bpi.o obj-$(CONFIG_EARLY_PRINTK) += debug.o -obj-y += domctl.o +obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += domain.o obj-y += entry.o obj-y += head.o
Signature · 1 line
2.34.1
PATCH v4 22/24 xen/domctl: domctl_lock synchronization only when MGMT_HYPERCALLS=y
In reply to Penny ZhengHelper domctl_lock_{acquire,release} is domctl_lock, which HVM_PARAM_IDENT_PT uses to ensure synchronization on potential domctl-op altering guest state. So it is only needed when MGMT_HYPERCALLS=y.
---
v3 -> v4:
- new commit
--- xen/arch/x86/hvm/hvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/hvm.c +3 -2
@@ -4268,7 +4268,7 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value)* the domctl_lock. */ rc = -ERESTART ; -if ( !domctl_lock_acquire () ) +if (IS_ENABLED (CONFIG_MGMT_HYPERCALLS ) && !domctl_lock_acquire () )break ; rc =0 ;
@@ -4278,7 +4278,8 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value)paging_update_cr3 (v, false);domain_unpause (d); -domctl_lock_release (); +if (IS_ENABLED (CONFIG_MGMT_HYPERCALLS ) ) +domctl_lock_release ();break ;case HVM_PARAM_DM_DOMAIN :/* The only value this should ever be set to is DOMID_SELF */
Signature · 1 line
2.34.1
Re: [PATCH v4 22/24] xen/domctl: domctl_lock synchronization only when MGMT_HYPERCALLS=y
Quoted 6 lines · Penny Zheng
Helper domctl_lock_{acquire,release} is
domctl_lock, whichHVM_PARAM_IDENT_PTuses to ensure synchronization on potential domctl-op altering guest state. So it is only needed when MGMT_HYPERCALLS=y.Suggested-by Jan Beulich <[email protected]>Signed-off-by Penny Zheng <[email protected]>
I'd like to note though that ...
Quoted 6 lines
---
v3 -> v4:
- new commit--- xen/arch/x86/hvm/hvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
... with this diffstat the subject prefix is pretty misleading once again. I may take the liberty and convert it to x86/hvm: (and then also add parentheses to domctl_lock()).
Jan
Re: [PATCH v4 22/24] xen/domctl: domctl_lock synchronization only when MGMT_HYPERCALLS=y
Quoted 19 lines · Jan Beulich
Quoted 6 lines · Penny Zheng
Helper domctl_lock_{acquire,release} is
domctl_lock, whichHVM_PARAM_IDENT_PTuses to ensure synchronization on potential domctl-op altering guest state. So it is only needed when MGMT_HYPERCALLS=y.Suggested-by Jan Beulich <[email protected]>Signed-off-by Penny Zheng <[email protected]>Acked-by Jan Beulich <[email protected]>I'd like to note though that ...
Quoted 6 lines
---
v3 -> v4:
- new commit--- xen/arch/x86/hvm/hvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 3 lines
... with this diffstat the subject prefix is pretty misleading once again. I may take the liberty and convert it to x86/hvm: (and then also add parentheses to
domctl_lock()).
Actually, the series looks to be in need of a full re-submission anyway. I.e. I can't sensibly cherry-pick parts to put in early.
Jan
RE: [PATCH v4 22/24] xen/domctl: domctl_lock synchronization only when MGMT_HYPERCALLS=y
In reply to Jan Beulich[Public]
Quoted 13 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, November 26, 2025 5:21 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; [email protected]
Subject: Re: [PATCH v4 22/24] xen/domctl:domctl_locksynchronization only when MGMT_HYPERCALLS=yQuoted 2 lines · Penny Zheng
Helper domctl_lock_{acquire,release} is
domctl_lock, whichHVM_PARAM_IDENT_PTuses to ensure synchronization on potential domctl-op
Quoted 7 lines
altering guest state.
Quoted 4 lines
So it is only needed when MGMT_HYPERCALLS=y.
Suggested-by Jan Beulich <[email protected]>Signed-off-by Penny Zheng <[email protected]>Acked-by Jan Beulich <[email protected]>
Thx
Quoted 10 lines
I'd like to note though that ...
Quoted 6 lines
---
v3 -> v4:
- new commit--- xen/arch/x86/hvm/hvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 4 lines
... with this diffstat the subject prefix is pretty misleading once again. I may take the liberty and convert it to x86/hvm: (and then also add parentheses to
domctl_lock()).
Will fix
Quoted 1 line
Jan
PATCH v4 23/24 xen/domctl: wrap common/domctl.c with CONFIG_MGMT_HYPERCALLS
In reply to Penny ZhengWrap domctl hypercall def and domctl.o with CONFIG_MGMT_HYPERCALLS. Make CONFIG_MGMT_HYPERCALLS optional and expand help message
---
v1 -> v2:
- remove stub in common/domctl.c
- combine the original commit of "xen/domctl: provide stub for domctl_lock_{acquire,release}"
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
---
v2 -> v3:
- add pitfall warnning in Kconfig help
---
v3 -> v4:
- refine help message
--- xen/common/Kconfig | 14 ++++++++++---- xen/common/Makefile | 2 +- xen/include/hypercall-defs.c | 6 ++++-- 3 files changed, 15 insertions(+), 7 deletions(-)
xen/common/Kconfig +10 -4
@@ -654,11 +654,17 @@ menu "Supported hypercall interfaces" config MGMT_HYPERCALLS bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE - def_bool y help - This option shall only be disabled on some dom0less systems, or - PV shim on x86, to reduce Xen footprint via managing unnessary - hypercalls, like sysctl, etc. + Management hypercalls provide the means for dom0 to manage the + overall Xen system and other domains, including sysctl, domctl, etc. + In a dom0less or pv-shim build, they can be omitted to cut down + on the Xen binary's size. However, this comes at the loss of + significant runtime functionality. + So be cautious to disable it, as admins will face missing a few basic + hypercalls like listdomains, getdomaininfo, etc, hence leading to + have an impact on device-passthrough and DM. + + Unless you know what you are doing, you should enable this. endmenu
xen/common/Makefile +1 -1
@@ -71,7 +71,7 @@ obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma lzo unlzo un 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_MGMT_HYPERCALLS) += domctl.o endif extra-y := symbols-dummy.o
xen/include/hypercall-defs.c +4 -2
@@ -199,9 +199,11 @@ sysctl(xen_sysctl_t *u_sysctl)#if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) paging_domctl_cont(xen_domctl_t *u_domctl)#endif -#endif #ifndef CONFIG_PV_SHIM_EXCLUSIVE domctl(xen_domctl_t *u_domctl) +#endif +#endif +#ifndef CONFIG_PV_SHIM_EXCLUSIVE platform_op(xen_platform_op_t *u_xenpf_op)#endif #ifdef CONFIG_HVM
@@ -279,10 +281,10 @@ hvm_op do do do do do#endif #ifdef CONFIG_MGMT_HYPERCALLS sysctl do do do do do -#endif #ifndef CONFIG_PV_SHIM_EXCLUSIVE domctl do do do do do#endif +#endif #ifdef CONFIG_KEXEC kexec_op compat do - - -#endif
Signature · 1 line
2.34.1
Re: [PATCH v4 23/24] xen/domctl: wrap common/domctl.c with CONFIG_MGMT_HYPERCALLS
xen/common/Kconfig menu "Supported hypercall interfaces" · line 657
Quoted 7 lines · Penny Zheng
xen/common/Kconfig +0
-1@@ -654,11 +654,17 @@ menu "Supported hypercall interfaces" config MGMT_HYPERCALLS bool "Enable privileged hypercalls for system management" depends on !PV_SHIM_EXCLUSIVE - def_bool y
Why would the default not be Y anymore?
Quoted 4 lines
xen/common/Kconfig +0
-3help - This option shall only be disabled on some dom0less systems, or - PV shim on x86, to reduce Xen footprint via managing unnessary - hypercalls, like sysctl, etc.
xen/common/Kconfig menu "Supported hypercall interfaces" · line 667
Quoted 10 lines
xen/common/Kconfig +10
-0+ Management hypercalls provide the means for dom0 to manage the + overall Xen system and other domains, including sysctl, domctl, etc. + In a dom0less or pv-shim build, they can be omitted to cut down + on the Xen binary's size. However, this comes at the loss of + significant runtime functionality. + So be cautious to disable it, as admins will face missing a few basic + hypercalls like listdomains, getdomaininfo, etc, hence leading to + have an impact on device-passthrough and DM. + + Unless you know what you are doing, you should enable this.
To be in line with what other help texts say, can this be "..., say Y" please?
Jan
PATCH v4 24/24 xen: move MGMT_HYPERCALLS out of PV_SHIM_EXCLUSIVE
In reply to Penny ZhengAs we're aiming at moving away from PV_SHIM_EXCLUSIVE=y, we are moving MGMT_HYPERCALLS out of it.
---
v3 -> v4:
- new commit
--- xen/arch/x86/Makefile | 2 +- xen/arch/x86/hvm/Kconfig | 1 - xen/arch/x86/include/asm/paging.h | 2 +- xen/common/Kconfig | 1 - xen/common/Makefile | 5 +---- xen/include/hypercall-defs.c | 10 ++-------- xen/include/xen/domain.h | 4 ---- 7 files changed, 5 insertions(+), 20 deletions(-)
xen/arch/x86/Makefile +1 -1
@@ -30,6 +30,7 @@ obj-bin-y += dmi_scan.init.o obj-y += domain.o obj-bin-y += dom0_build.init.o obj-y += domain_page.o +obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += e820.o obj-y += emul-i8254.o obj-y += extable.o
@@ -79,7 +80,6 @@ obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += xstate.o ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) -obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += platform_hypercall.o obj-$(CONFIG_COMPAT) += x86_64/platform_hypercall.o endif
xen/arch/x86/hvm/Kconfig +0 -1
@@ -1,6 +1,5 @@ menuconfig HVM bool "HVM support" - depends on !PV_SHIM_EXCLUSIVE default !PV_SHIM select COMPAT select IOREQ_SERVER
xen/arch/x86/include/asm/paging.h +1 -1
@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) && defined(CONFIG_MGMT_HYPERCALLS ) +#if defined(CONFIG_PAGING ) && defined(CONFIG_MGMT_HYPERCALLS )/* Enable log dirty mode */ #define PG_log_dirty (XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY << PG_mode_shift)#else
xen/common/Kconfig +0 -1
@@ -653,7 +653,6 @@ menu "Supported hypercall interfaces" config MGMT_HYPERCALLS bool "Enable privileged hypercalls for system management" - depends on !PV_SHIM_EXCLUSIVE help Management hypercalls provide the means for dom0 to manage the overall Xen system and other domains, including sysctl, domctl, etc.
xen/common/Makefile +1 -4
@@ -11,6 +11,7 @@ obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o obj-$(CONFIG_DEVICE_TREE_PARSE) += device-tree/ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-y += domain.o +obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += domid.o obj-y += event_2l.o obj-y += event_channel.o
@@ -70,10 +71,6 @@ obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma lzo unlzo un obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o memory.o multicall.o xlat.o) -ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) -obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o -endif - extra-y := symbols-dummy.o obj-$(CONFIG_COVERAGE) += coverage/
xen/include/hypercall-defs.c +2 -8
@@ -196,13 +196,11 @@ dm_op(domid_t domid, unsigned int nr_bufs, xen_dm_op_buf_t *bufs)#endif #ifdef CONFIG_MGMT_HYPERCALLS sysctl(xen_sysctl_t *u_sysctl) -#if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) +#if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) paging_domctl_cont(xen_domctl_t *u_domctl)#endif -#ifndef CONFIG_PV_SHIM_EXCLUSIVE domctl(xen_domctl_t *u_domctl)#endif -#endif #ifndef CONFIG_PV_SHIM_EXCLUSIVE platform_op(xen_platform_op_t *u_xenpf_op)#endif
@@ -281,10 +279,8 @@ hvm_op do do do do do #endif #ifdef CONFIG_MGMT_HYPERCALLS sysctl do do do do do -#ifndef CONFIG_PV_SHIM_EXCLUSIVE domctl do do do do do #endif -#endif #ifdef CONFIG_KEXEC kexec_op compat do - - - #endif
@@ -300,10 +296,8 @@ dm_op compat do compat do do hypfs_op do do do do do#endif mca do do - - - -#if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) -#ifdef CONFIG_MGMT_HYPERCALLS +#if defined(CONFIG_X86 ) && defined(CONFIG_PAGING ) && defined(CONFIG_MGMT_HYPERCALLS ) paging_domctl_cont do do do do -#endif -#endif #endif /* !CPPCHECK */
xen/include/xen/domain.h +0 -4
@@ -185,11 +185,7 @@ struct vnuma_info {struct xen_vmemrange *vmemrange; }; -#ifndef CONFIG_PV_SHIM_EXCLUSIVE void vnuma_destroy (struct vnuma_info *vnuma); -#else -static inline void vnuma_destroy (struct vnuma_info *vnuma) {ASSERT (!vnuma); } -#endif #ifdef CONFIG_VMTRACE extern bool vmtrace_available;
Signature · 1 line
2.34.1
Re: [PATCH v4 24/24] xen: move MGMT_HYPERCALLS out of PV_SHIM_EXCLUSIVE
Quoted 2 lines · Penny Zheng
As we're aiming at moving away from PV_SHIM_EXCLUSIVE=y, we are moving
MGMT_HYPERCALLSout of it.
How are we "moving away from PV_SHIM_EXCLUSIVE=y"? It's the "depends on !PV_SHIM_EXCLUSIVE" (and related Makefile constructs) which we decided to get rid of.
Quoted 11 lines
xen/arch/x86/Makefile +1
-0@@ -30,6 +30,7 @@ obj-bin-y += dmi_scan.init.o obj-y += domain.o obj-bin-y += dom0_build.init.o obj-y += domain_page.o +obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += e820.o obj-y += emul-i8254.o obj-y += extable.o
xen/arch/x86/Makefile obj-$(CONFIG_VM_EVENT) += vm_event.o · line 85
Quoted 7 lines
xen/arch/x86/Makefile +0
-1@@ -79,7 +80,6 @@ obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += xstate.o ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) -obj-$(CONFIG_MGMT_HYPERCALLS) += domctl.o obj-y += platform_hypercall.o obj-$(CONFIG_COMPAT) += x86_64/platform_hypercall.o endif
A change like this fits under the subject.
xen/arch/x86/hvm/Kconfig line 5
Quoted 9 lines
xen/arch/x86/hvm/Kconfig +0
-1@@ -1,6 +1,5 @@ menuconfig HVM bool "HVM support" - depends on !PV_SHIM_EXCLUSIVE default !PV_SHIM select COMPAT select IOREQ_SERVER
This, however, is entirely unrelated afaics.
xen/arch/x86/include/asm/paging.h line 61
Quoted 11 lines
xen/arch/x86/include/asm/paging.h +1
-1@@ -55,7 +55,7 @@#define PG_translate 0#define PG_external 0#endif -#if defined(CONFIG_PAGING ) && !defined(CONFIG_PV_SHIM_EXCLUSIVE ) && defined(CONFIG_MGMT_HYPERCALLS ) +#if defined(CONFIG_PAGING ) && defined(CONFIG_MGMT_HYPERCALLS )/* Enable log dirty mode */ #define PG_log_dirty (XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY << PG_mode_shift)#else
Whereas this could fit here if the subject was e.g. "decouple PV_SHIM_EXCLUSIVE and MGMT_HYPERCALLS".
Further, because of prior issue: Can you please clarify that you have tried builds with all (possible) combinations of the involved Kconfig settings? The set isn't that big, so exhaustive testing is possible.
Jan
RE: [PATCH v4 24/24] xen: move MGMT_HYPERCALLS out of PV_SHIM_EXCLUSIVE
[Public]
Quoted 12 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, November 26, 2025 5:34 PM
To: Penny, Zheng <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Andrew Cooper <[email protected]>; Roger Pau Monné <[email protected]>; Anthony PERARD <[email protected]>; Orzel, Michal <[email protected]>; Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]
Subject: Re: [PATCH v4 24/24] xen: moveMGMT_HYPERCALLSout ofPV_SHIM_EXCLUSIVE
Quoted 3 lines
Further, because of prior issue: Can you please clarify that you have tried builds with all (possible) combinations of the involved
Kconfigsettings? The set isn't that big, so exhaustive testing is possible.
In case I omits anything:
I'll test the following four scenario, (turning on all other possible kconfigs at the same time):
1) MGMT_HYPERCALLS=y && PV_SHIM_EXCLUSIVE=y
2) MGMT_HYPERCALLS=n && PV_SHIM_EXCLUSIVE=y
3) MGMT_HYPERCALLS=y && PV_SHIM_EXCLUSIVE=n
4) MGMT_HYPERCALLS=n && PV_SHIM_EXCLUSIVE=n
Quoted 2 lines
Jan
Re: [PATCH v4 24/24] xen: move MGMT_HYPERCALLS out of PV_SHIM_EXCLUSIVE
Quoted 8 lines · Zheng
Quoted 7 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: Wednesday, November 26, 2025 5:34 PMFurther, because of prior issue: Can you please clarify that you have tried builds with all (possible) combinations of the involved
Kconfigsettings? The set isn't that big, so exhaustive testing is possible.
Quoted 6 lines
In case I omits anything:
I'll test the following four scenario, (turning on all other possible kconfigs at the same time):
1) MGMT_HYPERCALLS=y && PV_SHIM_EXCLUSIVE=y
2) MGMT_HYPERCALLS=n && PV_SHIM_EXCLUSIVE=y
3) MGMT_HYPERCALLS=y && PV_SHIM_EXCLUSIVE=n
4) MGMT_HYPERCALLS=n && PV_SHIM_EXCLUSIVE=n
Judging from this patch alone, at least PAGING also looks to be in need of testing both ways (indirectly, as it can't be controlled directly).
Jan
Quoted 19 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.
We are introducing a new singleKconfigCONFIG_MGMT_HYPERCALLSto manage such hypercalls.We are trying to disable hypercalls in the following aspects:
- sysctl
- domctl
- hvm
- physdev
- platform
This patch serie is only focusing on domctl-op. Different aspects will be covered in different patch serie.Features, like VM event, or paging log-dirty support, which fully rely on domctl-op, will be wrapped with
CONFIG_MGMT_HYPERCALLS, to reduce Xen footprint as much as possible.
Quoted 7 lines
It is derived from Stefano Stabellini's commit "xen: introduce kconfig options to disable hypercalls"(
https://lore.kernel.org/xen-devel/[email protected])
---
This patch serie is based on two patch serie, one is
"[XEN][PATCH v4] xen: make VMTRACE support optional" and "
[PATCH v3 0/7] consolidate vm event subsystem"
While looking at patch 20, I came to wonder what exactly the above means: By the words, nothing in this series can go in ahead of those other patches. Which doesn't seem quite right. Please can you state dependencies in a helpful (for reviewers as well as committers) way?
Jan