Function 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.
Signed-off-by: Penny Zheng <[email protected]> --- 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(-) diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index a69615cd63..c078c6bf2e 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -15,6 +15,7 @@ if DEBUG || EXPERT config GDBSX bool "Guest debugging with gdbsx" + depends on MGMT_HYPERCALLS depends on X86 default y help diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 8368c6ecf0..d49681beed 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -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 diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index d21fdd49df..006a6e56d3 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -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 diff --git a/xen/arch/x86/hvm/Kconfig b/xen/arch/x86/hvm/Kconfig index d540c0ebf3..52b22e5d17 100644 --- a/xen/arch/x86/hvm/Kconfig +++ b/xen/arch/x86/hvm/Kconfig @@ -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 diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index d03f563d76..b03f7dfcf6 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -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) diff --git a/xen/arch/x86/hvm/pmtimer.c b/xen/arch/x86/hvm/pmtimer.c index 87a7a01c9f..f080f7561d 100644 --- a/xen/arch/x86/hvm/pmtimer.c +++ b/xen/arch/x86/hvm/pmtimer.c @@ -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. */ diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 9016e88411..3574e2eecd 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -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 diff --git a/xen/arch/x86/include/asm/paging.h b/xen/arch/x86/include/asm/paging.h index 0c06b0a7a8..ba5ba7324e 100644 --- a/xen/arch/x86/include/asm/paging.h +++ b/xen/arch/x86/include/asm/paging.h @@ -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 diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c index 4840de805b..38b21dccbd 100644 --- a/xen/include/hypercall-defs.c +++ b/xen/include/hypercall-defs.c @@ -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 */ diff --git a/xen/lib/x86/Makefile b/xen/lib/x86/Makefile index ac6d4369f3..124af43ea0 100644 --- a/xen/lib/x86/Makefile +++ b/xen/lib/x86/Makefile @@ -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 -- 2.34.1
