|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 09/25] xen/domctl: wrap around XEN_DOMCTL_destroydomain
Function domain_kill() is responsible for killing domain and relinquish
domain-held resources. Tracking its calling chain, the following
functions shall also be wrapped:
- domain_relinquish_resource
- pci_release_device
- relinquish_shared_pages
- paging_teardown
- p2m_pod_empty_cache
- relinquish_memory
- pit_deinit
- iommu_release_dt_devices
- tee_relinquish_resources
- ffa_relinquish_resources/optee_relinquish_resources
- relinquish_p2m_mapping
- p2m_clear_root_pages
- vm_event_cleanup
Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
xen/arch/arm/domain.c | 3 +++
xen/arch/arm/include/asm/tee/tee.h | 2 ++
xen/arch/arm/mmu/p2m.c | 4 ++++
xen/arch/arm/mpu/p2m.c | 2 ++
xen/arch/arm/tee/ffa.c | 4 ++++
xen/arch/arm/tee/optee.c | 4 ++++
xen/arch/arm/tee/tee.c | 2 ++
xen/arch/ppc/stubs.c | 2 ++
xen/arch/x86/domain.c | 2 ++
xen/arch/x86/emul-i8254.c | 2 ++
xen/arch/x86/mm/mem_sharing.c | 2 ++
xen/arch/x86/mm/p2m-pod.c | 2 ++
xen/arch/x86/mm/p2m.c | 2 ++
xen/arch/x86/mm/paging.c | 2 ++
xen/common/domain.c | 2 ++
xen/common/vm_event.c | 2 ++
xen/drivers/passthrough/device_tree.c | 2 ++
xen/drivers/passthrough/pci.c | 2 ++
18 files changed, 43 insertions(+)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 4124d201d1..e55ff966d2 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -990,6 +990,7 @@ int arch_vcpu_reset(struct vcpu *v)
return 0;
}
+#ifdef CONFIG_DOMCTL
static int relinquish_memory(struct domain *d, struct page_list_head *list)
{
struct page_info *page, *tmp;
@@ -1135,6 +1136,8 @@ int domain_relinquish_resources(struct domain *d)
#undef PROGRESS
+#endif /* CONFIG_DOMCTL */
+
void arch_dump_domain_info(struct domain *d)
{
p2m_dump_info(d);
diff --git a/xen/arch/arm/include/asm/tee/tee.h
b/xen/arch/arm/include/asm/tee/tee.h
index 0169fd746b..dc08e7e0ba 100644
--- a/xen/arch/arm/include/asm/tee/tee.h
+++ b/xen/arch/arm/include/asm/tee/tee.h
@@ -40,12 +40,14 @@ struct tee_mediator_ops {
int (*domain_teardown)(struct domain *d);
void (*free_domain_ctx)(struct domain *d);
+#ifdef CONFIG_DOMCTL
/*
* Called during domain destruction to relinquish resources used
* by mediator itself. This function can return -ERESTART to indicate
* that it does not finished work and should be called again.
*/
int (*relinquish_resources)(struct domain *d);
+#endif
/* Handle SMCCC call for current domain. */
bool (*handle_call)(struct cpu_user_regs *regs);
diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c
index 51abf3504f..4b13867fa2 100644
--- a/xen/arch/arm/mmu/p2m.c
+++ b/xen/arch/arm/mmu/p2m.c
@@ -1243,6 +1243,7 @@ static void p2m_invalidate_table(struct p2m_domain *p2m,
mfn_t mfn)
p2m->need_flush = true;
}
+#ifdef CONFIG_DOMCTL
/*
* The domain will not be scheduled anymore, so in theory we should
* not need to flush the TLBs. Do it for safety purpose.
@@ -1262,6 +1263,7 @@ void p2m_clear_root_pages(struct p2m_domain *p2m)
p2m_write_unlock(p2m);
}
+#endif /* CONFIG_DOMCTL */
/*
* Invalidate all entries in the root page-tables. This is
@@ -1556,6 +1558,7 @@ int p2m_init(struct domain *d)
return 0;
}
+#ifdef CONFIG_DOMCTL
/*
* The function will go through the p2m and remove page reference when it
* is required. The mapping will be removed from the p2m.
@@ -1626,6 +1629,7 @@ int relinquish_p2m_mapping(struct domain *d)
return rc;
}
+#endif /* CONFIG_DOMCTL */
/*
* Clean & invalidate RAM associated to the guest vCPU.
diff --git a/xen/arch/arm/mpu/p2m.c b/xen/arch/arm/mpu/p2m.c
index f7fb58ab6a..e8c5665ab9 100644
--- a/xen/arch/arm/mpu/p2m.c
+++ b/xen/arch/arm/mpu/p2m.c
@@ -57,10 +57,12 @@ bool p2m_resolve_translation_fault(struct domain *d, gfn_t
gfn)
void p2m_flush_vm(struct vcpu *v) {}
+#ifdef CONFIG_DOMCTL
int relinquish_p2m_mapping(struct domain *d)
{
return 0;
}
+#endif /* CONFIG_DOMCTL */
void p2m_domain_creation_finished(struct domain *d) {}
diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
index 3bbdd7168a..bb9b50932c 100644
--- a/xen/arch/arm/tee/ffa.c
+++ b/xen/arch/arm/tee/ffa.c
@@ -434,10 +434,12 @@ static void ffa_free_domain_ctx(struct domain *d)
XFREE(d->arch.tee);
}
+#ifdef CONFIG_DOMCTL
static int ffa_relinquish_resources(struct domain *d)
{
return 0;
}
+#endif /* CONFIG_DOMCTL */
static void ffa_init_secondary(void)
{
@@ -559,7 +561,9 @@ static const struct tee_mediator_ops ffa_ops =
.domain_init = ffa_domain_init,
.domain_teardown = ffa_domain_teardown,
.free_domain_ctx = ffa_free_domain_ctx,
+#ifdef CONFIG_DOMCTL
.relinquish_resources = ffa_relinquish_resources,
+#endif
.handle_call = ffa_handle_call,
};
diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index 5151bd90ed..8d91df4e23 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -632,6 +632,7 @@ static void free_optee_shm_buf_pg_list(struct optee_domain
*ctx,
cookie);
}
+#ifdef CONFIG_DOMCTL
static int optee_relinquish_resources(struct domain *d)
{
struct arm_smccc_res resp;
@@ -693,6 +694,7 @@ static int optee_relinquish_resources(struct domain *d)
return 0;
}
+#endif /* CONFIG_DOMCTL */
#define PAGELIST_ENTRIES_PER_PAGE \
((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1)
@@ -1727,7 +1729,9 @@ static const struct tee_mediator_ops optee_ops =
.probe = optee_probe,
.domain_init = optee_domain_init,
.domain_teardown = optee_domain_teardown,
+#ifdef CONFIG_DOMCTL
.relinquish_resources = optee_relinquish_resources,
+#endif
.handle_call = optee_handle_call,
};
diff --git a/xen/arch/arm/tee/tee.c b/xen/arch/arm/tee/tee.c
index 3f65e45a78..c97b19cd6f 100644
--- a/xen/arch/arm/tee/tee.c
+++ b/xen/arch/arm/tee/tee.c
@@ -60,6 +60,7 @@ int tee_domain_teardown(struct domain *d)
return cur_mediator->ops->domain_teardown(d);
}
+#ifdef CONFIG_DOMCTL
int tee_relinquish_resources(struct domain *d)
{
if ( !cur_mediator )
@@ -67,6 +68,7 @@ int tee_relinquish_resources(struct domain *d)
return cur_mediator->ops->relinquish_resources(d);
}
+#endif /* CONFIG_DOMCTL */
uint16_t tee_get_type(void)
{
diff --git a/xen/arch/ppc/stubs.c b/xen/arch/ppc/stubs.c
index b2b97c6eb7..0d8563f11f 100644
--- a/xen/arch/ppc/stubs.c
+++ b/xen/arch/ppc/stubs.c
@@ -263,10 +263,12 @@ int arch_vcpu_reset(struct vcpu *v)
BUG_ON("unimplemented");
}
+#ifdef CONFIG_DOMCTL
int domain_relinquish_resources(struct domain *d)
{
BUG_ON("unimplemented");
}
+#endif /* CONFIG_DOMCTL */
void arch_dump_domain_info(struct domain *d)
{
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 13ccaf1c79..a0d650cb86 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -2235,6 +2235,7 @@ void sync_vcpu_execstate(struct vcpu *v)
read_atomic(&v->dirty_cpu) != dirty_cpu);
}
+#ifdef CONFIG_DOMCTL
static int relinquish_memory(
struct domain *d, struct page_list_head *list, unsigned long type)
{
@@ -2559,6 +2560,7 @@ int domain_relinquish_resources(struct domain *d)
return 0;
}
+#endif /* CONFIG_DOMCTL */
void arch_dump_domain_info(struct domain *d)
{
diff --git a/xen/arch/x86/emul-i8254.c b/xen/arch/x86/emul-i8254.c
index 144aa168a3..bb9718bb97 100644
--- a/xen/arch/x86/emul-i8254.c
+++ b/xen/arch/x86/emul-i8254.c
@@ -651,6 +651,7 @@ void pit_init(struct domain *d)
pit_reset(d);
}
+#ifdef CONFIG_DOMCTL
void pit_deinit(struct domain *d)
{
PITState *pit = domain_vpit(d);
@@ -664,6 +665,7 @@ void pit_deinit(struct domain *d)
destroy_periodic_time(&pit->pt0);
}
}
+#endif /* CONFIG_DOMCTL */
/*
* Local variables:
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index da28266ef0..7858565429 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1391,6 +1391,7 @@ int __mem_sharing_unshare_page(struct domain *d,
return rc;
}
+#ifdef CONFIG_DOMCTL
int relinquish_shared_pages(struct domain *d)
{
int rc = 0;
@@ -1447,6 +1448,7 @@ int relinquish_shared_pages(struct domain *d)
p2m_unlock(p2m);
return rc;
}
+#endif /* CONFIG_DOMCTL */
static int range_share(struct domain *d, struct domain *cd,
struct mem_sharing_op_range *range)
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 05633fe2ac..98a846bb55 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -366,6 +366,7 @@ void p2m_pod_get_mem_target(const struct domain *d,
xen_pod_target_t *target)
pod_unlock(p2m);
}
+#ifdef CONFIG_DOMCTL
int p2m_pod_empty_cache(struct domain *d)
{
struct p2m_domain *p2m = p2m_get_hostp2m(d);
@@ -409,6 +410,7 @@ int p2m_pod_empty_cache(struct domain *d)
unlock_page_alloc(p2m);
return p2m->pod.count ? -ERESTART : 0;
}
+#endif /* CONFIG_DOMCTL */
int
p2m_pod_offline_or_broken_hit(struct page_info *p)
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index b9a7c2dc53..c2840131ad 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2088,6 +2088,7 @@ int xenmem_add_to_physmap_one(
return rc;
}
+#ifdef CONFIG_DOMCTL
/*
* Remove foreign mappings from the p2m, as that drops the page reference taken
* when mapped.
@@ -2151,6 +2152,7 @@ int relinquish_p2m_mapping(struct domain *d)
return rc;
}
+#endif /* CONFIG_DOMCTL */
/*
* Local variables:
diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 1216a181c3..3da99ad371 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -768,6 +768,7 @@ void paging_vcpu_teardown(struct vcpu *v)
shadow_vcpu_teardown(v);
}
+#ifdef CONFIG_DOMCTL
/* Call when destroying a domain */
int paging_teardown(struct domain *d)
{
@@ -794,6 +795,7 @@ int paging_teardown(struct domain *d)
return rc;
}
+#endif /* CONFIG_DOMCTL */
/* Call once all of the references to the domain have gone away */
void paging_final_teardown(struct domain *d)
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 604217d782..be722c9f09 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1222,6 +1222,7 @@ int rcu_lock_live_remote_domain_by_id(domid_t dom, struct
domain **d)
return 0;
}
+#ifdef CONFIG_DOMCTL
int domain_kill(struct domain *d)
{
int rc = 0;
@@ -1272,6 +1273,7 @@ int domain_kill(struct domain *d)
return rc;
}
+#endif /* CONFIG_DOMCTL */
void __domain_crash(struct domain *d)
diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
index 1666ff615f..102745117e 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -559,6 +559,7 @@ static void cf_check mem_sharing_notification(struct vcpu
*v, unsigned int port)
}
#endif
+#ifdef CONFIG_DOMCTL
/* Clean up on domain destruction */
void vm_event_cleanup(struct domain *d)
{
@@ -589,6 +590,7 @@ void vm_event_cleanup(struct domain *d)
}
#endif
}
+#endif /* CONFIG_DOMCTL */
int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec)
{
diff --git a/xen/drivers/passthrough/device_tree.c
b/xen/drivers/passthrough/device_tree.c
index f5850a2607..704910de3d 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -108,6 +108,7 @@ int iommu_dt_domain_init(struct domain *d)
return 0;
}
+#ifdef CONFIG_DOMCTL
int iommu_release_dt_devices(struct domain *d)
{
const struct domain_iommu *hd = dom_iommu(d);
@@ -136,6 +137,7 @@ int iommu_release_dt_devices(struct domain *d)
return 0;
}
+#endif /* CONFIG_DOMCTL */
static int iommu_dt_xlate(struct device *dev,
const struct dt_phandle_args *iommu_spec,
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 3edcfa8a04..41638b71d6 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -945,6 +945,7 @@ static int deassign_device(struct domain *d, uint16_t seg,
uint8_t bus,
return ret;
}
+#ifdef CONFIG_DOMCTL
int pci_release_devices(struct domain *d)
{
int combined_ret;
@@ -1003,6 +1004,7 @@ int pci_release_devices(struct domain *d)
return combined_ret;
}
+#endif /* CONFIG_DOMCTL */
#define PCI_CLASS_BRIDGE_HOST 0x0600
#define PCI_CLASS_BRIDGE_PCI 0x0604
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |