mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen: move alloc/free_vcpu_struct() to common code
alloc_vcpu_struct() and free_vcpu_struct() contain little architecture-specific logic and are suitable for sharing across architectures. Move both helpers to common code. To support the remaining architectural differences, introduce arch_vcpu_struct_memflags(), allowing architectures to override the memory flags passed to alloc_xenheap_pages(). This is currently needed by x86, which may require MEMF_bits(32) for HVM guests using shadow paging. The ARM implementation of alloc/free_vcpu_struct() is removed and replaced by the common version. Stub implementations are also dropped from PPC and RISC-V. Now that the size of struct vcpu for Arm64 is smaller than PAGE_SIZE, MAX_PAGES_PER_VCPU is no longer needed and is removed. Finally, make alloc_vcpu_struct() and free_vcpu_struct() static to common/domain.c, as they are no longer used outside common code. No functional changes. Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> Acked-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Michal Orzel <michal.orzel@amd.com>
This commit is contained in:
1 parent
b7d3accd92
commit
a6fccf74e1
7 files changed
+32
-65
No files matched your search
@@ -473,23 +473,6 @@ void dump_pageframe_info(struct domain *d)
|
||||
|
||||
}
|
||||
|
||||
struct vcpu *alloc_vcpu_struct(const struct domain *d)
|
||||
{
|
||||
struct vcpu *v;
|
||||
|
||||
BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
|
||||
v = alloc_xenheap_page();
|
||||
if ( v != NULL )
|
||||
clear_page(v);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
void free_vcpu_struct(struct vcpu *v)
|
||||
{
|
||||
free_xenheap_page(v);
|
||||
}
|
||||
|
||||
int arch_vcpu_create(struct vcpu *v)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
@@ -152,11 +152,6 @@ void dump_pageframe_info(struct domain *d)
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
void free_vcpu_struct(struct vcpu *v)
|
||||
{
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
int arch_vcpu_create(struct vcpu *v)
|
||||
{
|
||||
BUG_ON("unimplemented");
|
||||
@@ -264,11 +259,6 @@ void vcpu_kick(struct vcpu *v)
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
struct vcpu *alloc_vcpu_struct(const struct domain *d)
|
||||
{
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
unsigned long
|
||||
hypercall_create_continuation(unsigned int op, const char *format, ...)
|
||||
{
|
||||
|
||||
@@ -121,11 +121,6 @@ void dump_pageframe_info(struct domain *d)
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
void free_vcpu_struct(struct vcpu *v)
|
||||
{
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
int arch_vcpu_create(struct vcpu *v)
|
||||
{
|
||||
BUG_ON("unimplemented");
|
||||
@@ -233,11 +228,6 @@ void vcpu_kick(struct vcpu *v)
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
struct vcpu *alloc_vcpu_struct(const struct domain *d)
|
||||
{
|
||||
BUG_ON("unimplemented");
|
||||
}
|
||||
|
||||
unsigned long
|
||||
hypercall_create_continuation(unsigned int op, const char *format, ...)
|
||||
{
|
||||
|
||||
@@ -493,30 +493,6 @@ unsigned int arch_domain_struct_memflags(void)
|
||||
return MEMF_bits(bits);
|
||||
}
|
||||
|
||||
struct vcpu *alloc_vcpu_struct(const struct domain *d)
|
||||
{
|
||||
struct vcpu *v;
|
||||
/*
|
||||
* This structure contains embedded PAE PDPTEs, used when an HVM guest
|
||||
* runs on shadow pagetables outside of 64-bit mode. In this case the CPU
|
||||
* may require that the shadow CR3 points below 4GB, and hence the whole
|
||||
* structure must satisfy this restriction. Thus we specify MEMF_bits(32).
|
||||
*/
|
||||
unsigned int memflags =
|
||||
(is_hvm_domain(d) && paging_mode_shadow(d)) ? MEMF_bits(32) : 0;
|
||||
|
||||
BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
|
||||
v = alloc_xenheap_pages(0, memflags);
|
||||
if ( v != NULL )
|
||||
clear_page(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
void free_vcpu_struct(struct vcpu *v)
|
||||
{
|
||||
free_xenheap_page(v);
|
||||
}
|
||||
|
||||
/* Initialise various registers to their architectural INIT/RESET state. */
|
||||
void arch_vcpu_regs_init(struct vcpu *v)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,18 @@
|
||||
unsigned int arch_domain_struct_memflags(void);
|
||||
#define arch_domain_struct_memflags arch_domain_struct_memflags
|
||||
|
||||
/*
|
||||
* This structure contains embedded PAE PDPTEs, used when an HVM guest
|
||||
* runs on shadow pagetables outside of 64-bit mode. In this case the CPU
|
||||
* may require that the shadow CR3 points below 4GB, and hence the whole
|
||||
* structure must satisfy this restriction. Thus we specify MEMF_bits(32).
|
||||
*/
|
||||
#define arch_vcpu_struct_memflags(d) ({ \
|
||||
const struct domain *d_ = (d); \
|
||||
\
|
||||
(is_hvm_domain(d_) && paging_mode_shadow(d_) ? MEMF_bits(32) : 0); \
|
||||
})
|
||||
|
||||
#define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo)
|
||||
|
||||
/*
|
||||
|
||||
@@ -316,6 +316,26 @@ static void vcpu_info_reset(struct vcpu *v)
|
||||
: &dummy_vcpu_info);
|
||||
}
|
||||
|
||||
static struct vcpu *alloc_vcpu_struct(const struct domain *d)
|
||||
{
|
||||
#ifndef arch_vcpu_struct_memflags
|
||||
# define arch_vcpu_struct_memflags(d) ((void)(d), 0)
|
||||
#endif
|
||||
struct vcpu *v;
|
||||
|
||||
BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
|
||||
v = alloc_xenheap_pages(0, arch_vcpu_struct_memflags(d));
|
||||
if ( v )
|
||||
clear_page(v);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static void free_vcpu_struct(struct vcpu *v)
|
||||
{
|
||||
free_xenheap_page(v);
|
||||
}
|
||||
|
||||
static void vmtrace_free_buffer(struct vcpu *v)
|
||||
{
|
||||
const struct domain *d = v->domain;
|
||||
|
||||
@@ -70,10 +70,6 @@ void domid_free(domid_t domid);
|
||||
struct domain *alloc_domain_struct(void);
|
||||
void free_domain_struct(struct domain *d);
|
||||
|
||||
/* Allocate/free a VCPU structure. */
|
||||
struct vcpu *alloc_vcpu_struct(const struct domain *d);
|
||||
void free_vcpu_struct(struct vcpu *v);
|
||||
|
||||
/* Allocate/free a PIRQ structure. */
|
||||
#ifndef alloc_pirq_struct
|
||||
struct pirq *alloc_pirq_struct(struct domain *d);
|
||||
|
||||