xen/domain: introduce generic functions for domain struct allocation and freeing

Move x86's free_domain_struct() to common code since it is shared between
architectures.

Move the x86 version of alloc_domain_struct() to common code as most of the
logic is architecture-independent. To handle the remaining architectural
differences, introduce arch_domain_struct_memflags() for x86-specific
allocation requirements.

No functional change.

Suggested-by: Jan Beulich <jbeulich@suse.com>
[Introduce an arch-specific function instead of using a weak function]
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Michal Orzel <michal.orzel@amd.com>
This commit is contained in:
Roger Pau Monné authored and Jan Beulich committed 2025-12-09 11:27:39 +01:00
1 parent 9dfcbabb68
commit 63137a8731
6 files changed
+26 -50

No files matched your search

-17
View File
@@ -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)
{
-10
View File
@@ -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");
-10
View File
@@ -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");
+2 -13
View File
@@ -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)
+3
View File
@@ -12,6 +12,9 @@
#include <public/vcpu.h>
#include <public/hvm/hvm_info_table.h>
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)
/*
+21
View File
@@ -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)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.