From 874cf987658016b4951a3bc654b2db0e1c95e649 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 8 Mar 2018 11:03:17 +0000 Subject: [PATCH] xen/domain: Drop DOMCRF_dummy At the moment, there is a tight coupling between the domid and the use of DOMCRF_dummy. Instead of using DOMCRF_dummy, base the one relevant decision on domid alone. Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu Acked-by: Jan Beulich Acked-by: Julien Grall --- xen/arch/arm/mm.c | 6 +++--- xen/arch/x86/mm.c | 6 +++--- xen/common/domain.c | 3 ++- xen/include/xen/sched.h | 10 ++++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 3c328e2df5..ce83f694c5 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -520,7 +520,7 @@ void __init arch_init_memory(void) * Any Xen-heap pages that we will allow to be mapped will have * their domain field set to dom_xen. */ - dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0, NULL); + dom_xen = domain_create(DOMID_XEN, 0, 0, NULL); BUG_ON(IS_ERR(dom_xen)); /* @@ -528,14 +528,14 @@ void __init arch_init_memory(void) * This domain owns I/O pages that are within the range of the page_info * array. Mappings occur at the priv of the caller. */ - dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0, NULL); + dom_io = domain_create(DOMID_IO, 0, 0, NULL); BUG_ON(IS_ERR(dom_io)); /* * Initialise our COW domain. * This domain owns sharable pages. */ - dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0, NULL); + dom_cow = domain_create(DOMID_COW, 0, 0, NULL); BUG_ON(IS_ERR(dom_cow)); } diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 9b559448a7..c275d4b72c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -271,7 +271,7 @@ void __init arch_init_memory(void) * Hidden PCI devices will also be associated with this domain * (but be [partly] controlled by Dom0 nevertheless). */ - dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0, NULL); + dom_xen = domain_create(DOMID_XEN, 0, 0, NULL); BUG_ON(IS_ERR(dom_xen)); INIT_LIST_HEAD(&dom_xen->arch.pdev_list); @@ -280,14 +280,14 @@ void __init arch_init_memory(void) * This domain owns I/O pages that are within the range of the page_info * array. Mappings occur at the priv of the caller. */ - dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0, NULL); + dom_io = domain_create(DOMID_IO, 0, 0, NULL); BUG_ON(IS_ERR(dom_io)); /* * Initialise our COW domain. * This domain owns sharable pages. */ - dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0, NULL); + dom_cow = domain_create(DOMID_COW, 0, 0, NULL); BUG_ON(IS_ERR(dom_cow)); /* diff --git a/xen/common/domain.c b/xen/common/domain.c index 219a3e325e..cd39a58621 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -312,7 +312,8 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, rangeset_domain_initialise(d); init_status |= INIT_rangeset; - if ( domcr_flags & DOMCRF_dummy ) + /* DOMID_{XEN,IO,etc} (other than IDLE) are sufficiently constructed. */ + if ( is_system_domain(d) && !is_idle_domain(d) ) return d; if ( !is_idle_domain(d) ) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 39f938644a..b204b1230a 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -494,6 +494,11 @@ extern struct vcpu *idle_vcpu[NR_CPUS]; #define is_idle_domain(d) ((d)->domain_id == DOMID_IDLE) #define is_idle_vcpu(v) (is_idle_domain((v)->domain)) +static inline bool is_system_domain(const struct domain *d) +{ + return d->domain_id >= DOMID_FIRST_RESERVED; +} + #define DOMAIN_DESTROYED (1u << 31) /* assumes atomic_t is >= 32 bits */ #define put_domain(_d) \ if ( atomic_dec_and_test(&(_d)->refcnt) ) domain_destroy(_d) @@ -531,7 +536,7 @@ void domain_update_node_affinity(struct domain *d); /* * Create a domain: the configuration is only necessary for real domain - * (i.e !DOMCRF_dummy, excluded idle domain). + * (domid < DOMID_FIRST_RESERVED). */ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, uint32_t ssidref, @@ -546,9 +551,6 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, by tboot */ #define _DOMCRF_s3_integrity 2 #define DOMCRF_s3_integrity (1U<<_DOMCRF_s3_integrity) - /* DOMCRF_dummy: Create a dummy domain (not scheduled; not on domain list) */ -#define _DOMCRF_dummy 3 -#define DOMCRF_dummy (1U<<_DOMCRF_dummy) /* DOMCRF_oos_off: dont use out-of-sync optimization for shadow page tables */ #define _DOMCRF_oos_off 4 #define DOMCRF_oos_off (1U<<_DOMCRF_oos_off) -- 2.30.2