diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 3e32a15cac..47973f99d9 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -468,23 +468,6 @@ void startup_cpu_idle_loop(void) reset_stack_and_jump(idle_loop); } -struct domain *alloc_domain_struct(void) -{ - struct domain *d; - BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); - d = alloc_xenheap_pages(0, 0); - if ( d == NULL ) - return NULL; - - clear_page(d); - return d; -} - -void free_domain_struct(struct domain *d) -{ - free_xenheap_page(d); -} - void dump_pageframe_info(struct domain *d) { diff --git a/xen/arch/ppc/stubs.c b/xen/arch/ppc/stubs.c index 75ebcae5e2..9953ea1c6c 100644 --- a/xen/arch/ppc/stubs.c +++ b/xen/arch/ppc/stubs.c @@ -147,11 +147,6 @@ void startup_cpu_idle_loop(void) BUG_ON("unimplemented"); } -void free_domain_struct(struct domain *d) -{ - BUG_ON("unimplemented"); -} - void dump_pageframe_info(struct domain *d) { BUG_ON("unimplemented"); @@ -269,11 +264,6 @@ void vcpu_kick(struct vcpu *v) BUG_ON("unimplemented"); } -struct domain *alloc_domain_struct(void) -{ - BUG_ON("unimplemented"); -} - struct vcpu *alloc_vcpu_struct(const struct domain *d) { BUG_ON("unimplemented"); diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c index 340ed3cd6c..fe7d85ee1d 100644 --- a/xen/arch/riscv/stubs.c +++ b/xen/arch/riscv/stubs.c @@ -121,11 +121,6 @@ void startup_cpu_idle_loop(void) BUG_ON("unimplemented"); } -void free_domain_struct(struct domain *d) -{ - BUG_ON("unimplemented"); -} - void dump_pageframe_info(struct domain *d) { BUG_ON("unimplemented"); @@ -243,11 +238,6 @@ void vcpu_kick(struct vcpu *v) BUG_ON("unimplemented"); } -struct domain *alloc_domain_struct(void) -{ - BUG_ON("unimplemented"); -} - struct vcpu *alloc_vcpu_struct(const struct domain *d) { BUG_ON("unimplemented"); diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index d89b7667d4..bd75d044a0 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -463,10 +463,8 @@ void domain_cpu_policy_changed(struct domain *d) } } -struct domain *alloc_domain_struct(void) +unsigned int arch_domain_struct_memflags(void) { - struct domain *d; - /* * Without CONFIG_BIGMEM, we pack the PDX of the domain structure into * a 32-bit field within the page_info structure. Hence the MEMF_bits() @@ -492,16 +490,7 @@ struct domain *alloc_domain_struct(void) - 1; #endif - BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); - d = alloc_xenheap_pages(0, MEMF_bits(bits)); - if ( d != NULL ) - clear_page(d); - return d; -} - -void free_domain_struct(struct domain *d) -{ - free_xenheap_page(d); + return MEMF_bits(bits); } struct vcpu *alloc_vcpu_struct(const struct domain *d) diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index 5df8c78253..386ec61745 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -12,6 +12,9 @@ #include #include +unsigned int arch_domain_struct_memflags(void); +#define arch_domain_struct_memflags arch_domain_struct_memflags + #define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo) /* diff --git a/xen/common/domain.c b/xen/common/domain.c index 850daf1ee8..93c71bc766 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -799,6 +799,27 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) return arch_sanitise_domain_config(config); } +struct domain *alloc_domain_struct(void) +{ +#ifndef arch_domain_struct_memflags +# define arch_domain_struct_memflags() 0 +#endif + + struct domain *d = alloc_xenheap_pages(0, arch_domain_struct_memflags()); + + BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); + + if ( d ) + clear_page(d); + + return d; +} + +void free_domain_struct(struct domain *d) +{ + free_xenheap_page(d); +} + struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, unsigned int flags)