[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/P2M: the majority for struct p2m_domain's fields are HVM-only
commit 347d36c2ec2b6f78cd1023f30b8426f2b1444ecc Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Fri Apr 8 14:51:06 2022 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Fri Apr 8 14:51:06 2022 +0200 x86/P2M: the majority for struct p2m_domain's fields are HVM-only ..., as are the majority of the locks involved. Conditionalize things accordingly. Also adjust the ioreq field's indentation at this occasion. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Paul Durrant <paul@xxxxxxx> Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx> --- xen/arch/x86/include/asm/p2m.h | 58 +++++++++++++++++++++++-------------- xen/arch/x86/mm.c | 3 ++ xen/arch/x86/mm/mm-locks.h | 4 +++ xen/arch/x86/mm/p2m-basic.c | 7 ++--- xen/arch/x86/mm/p2m.c | 2 ++ xen/drivers/passthrough/x86/iommu.c | 2 +- 6 files changed, 49 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index cd5cd1c3a3..6f14e7b46d 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -205,8 +205,10 @@ typedef enum { /* Per-p2m-table state */ struct p2m_domain { +#ifdef CONFIG_HVM /* Lock that protects updates to the p2m */ mm_rwlock_t lock; +#endif /* * Same as a domain's dirty_cpumask but limited to @@ -226,13 +228,14 @@ struct p2m_domain { */ p2m_access_t default_access; +#ifdef CONFIG_HVM + /* Host p2m: Log-dirty ranges registered for the domain. */ struct rangeset *logdirty_ranges; /* Host p2m: Global log-dirty mode enabled for the domain. */ bool global_logdirty; -#ifdef CONFIG_HVM /* Translated domain: p2m mapping */ pagetable_t phys_table; @@ -275,7 +278,6 @@ struct p2m_domain { unsigned int level); void (*write_p2m_entry_post)(struct p2m_domain *p2m, unsigned int oflags); -#endif #if P2M_AUDIT long (*audit_p2m)(struct p2m_domain *p2m); #endif @@ -310,7 +312,6 @@ struct p2m_domain { unsigned long min_remapped_gfn; unsigned long max_remapped_gfn; -#ifdef CONFIG_HVM /* Populate-on-demand variables * All variables are protected with the pod lock. We cannot rely on * the p2m lock if it's turned into a fine-grained lock. @@ -367,27 +368,27 @@ struct p2m_domain { * threaded on in LRU order. */ struct list_head np2m_list; -#endif union { struct ept_data ept; /* NPT-equivalent structure could be added here. */ }; - struct { - spinlock_t lock; - /* - * ioreq server who's responsible for the emulation of - * gfns with specific p2m type(for now, p2m_ioreq_server). - */ - struct ioreq_server *server; - /* - * flags specifies whether read, write or both operations - * are to be emulated by an ioreq server. - */ - unsigned int flags; - unsigned long entry_count; - } ioreq; + struct { + spinlock_t lock; + /* + * ioreq server who's responsible for the emulation of + * gfns with specific p2m type(for now, p2m_ioreq_server). + */ + struct ioreq_server *server; + /* + * flags specifies whether read, write or both operations + * are to be emulated by an ioreq server. + */ + unsigned int flags; + unsigned long entry_count; + } ioreq; +#endif /* CONFIG_HVM */ }; /* get host p2m table */ @@ -651,6 +652,15 @@ int p2m_finish_type_change(struct domain *d, gfn_t first_gfn, unsigned long max_nr); +static inline bool p2m_is_global_logdirty(const struct domain *d) +{ +#ifdef CONFIG_HVM + return p2m_get_hostp2m(d)->global_logdirty; +#else + return false; +#endif +} + int p2m_is_logdirty_range(struct p2m_domain *, unsigned long start, unsigned long end); @@ -792,6 +802,8 @@ extern void audit_p2m(struct domain *d, #define P2M_DEBUG(f, a...) do { (void)(f); } while(0) #endif +#ifdef CONFIG_HVM + /* * Functions specific to the p2m-pt implementation */ @@ -852,7 +864,7 @@ void cf_check nestedp2m_write_p2m_entry_post( /* * Alternate p2m: shadow p2m tables used for alternate memory views */ -#ifdef CONFIG_HVM + /* get current alternate p2m table */ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu *v) { @@ -905,10 +917,10 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, /* Set a specific p2m view visibility */ int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int idx, uint8_t visible); -#else +#else /* !CONFIG_HVM */ struct p2m_domain *p2m_get_altp2m(struct vcpu *v); static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) {} -#endif +#endif /* CONFIG_HVM */ /* p2m access to IOMMU flags */ static inline unsigned int p2m_access_to_iommu_flags(p2m_access_t p2ma) @@ -972,6 +984,8 @@ static inline unsigned int p2m_get_iommu_flags(p2m_type_t p2mt, return flags; } +#ifdef CONFIG_HVM + int p2m_set_ioreq_server(struct domain *d, unsigned int flags, struct ioreq_server *s); struct ioreq_server *p2m_get_ioreq_server(struct domain *d, @@ -1036,6 +1050,8 @@ static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt, return 0; } +#endif /* CONFIG_HVM */ + #endif /* _XEN_ASM_X86_P2M_H */ /* diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index e90789085b..c271e383b5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -480,8 +480,11 @@ unsigned int page_get_ram_type(mfn_t mfn) unsigned long domain_get_maximum_gpfn(struct domain *d) { +#ifdef CONFIG_HVM if ( is_hvm_domain(d) ) return p2m_get_hostp2m(d)->max_mapped_pfn; +#endif + /* NB. PV guests specify nr_pfns rather than max_pfn so we adjust here. */ return (arch_get_max_pfn(d) ?: 1) - 1; } diff --git a/xen/arch/x86/mm/mm-locks.h b/xen/arch/x86/mm/mm-locks.h index 831e56d281..c1523aeccf 100644 --- a/xen/arch/x86/mm/mm-locks.h +++ b/xen/arch/x86/mm/mm-locks.h @@ -237,6 +237,8 @@ static inline void mm_enforce_order_unlock(int unlock_level, * * ************************************************************************/ +#ifdef CONFIG_HVM + /* Nested P2M lock (per-domain) * * A per-domain lock that protects the mapping from nested-CR3 to @@ -354,6 +356,8 @@ declare_mm_lock(pod) #define pod_unlock(p) mm_unlock(&(p)->pod.lock) #define pod_locked_by_me(p) mm_locked_by_me(&(p)->pod.lock) +#endif /* CONFIG_HVM */ + /* Page alloc lock (per-domain) * * This is an external lock, not represented by an mm_lock_t. However, diff --git a/xen/arch/x86/mm/p2m-basic.c b/xen/arch/x86/mm/p2m-basic.c index dcf94dbc7f..9130fc2a70 100644 --- a/xen/arch/x86/mm/p2m-basic.c +++ b/xen/arch/x86/mm/p2m-basic.c @@ -28,16 +28,15 @@ #include "mm-locks.h" #include "p2m.h" -DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); - /* Init the datastructures for later use by the p2m code */ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) { int ret = 0; - mm_rwlock_init(&p2m->lock); #ifdef CONFIG_HVM + mm_rwlock_init(&p2m->lock); INIT_PAGE_LIST_HEAD(&p2m->pages); + spin_lock_init(&p2m->ioreq.lock); #endif p2m->domain = d; @@ -55,8 +54,6 @@ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) else p2m_pt_init(p2m); - spin_lock_init(&p2m->ioreq.lock); - return ret; } diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 493702ce9b..a2446f0c41 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -48,6 +48,8 @@ #undef virt_to_mfn #define virt_to_mfn(v) _mfn(__virt_to_mfn(v)) +DEFINE_PERCPU_RWLOCK_GLOBAL(p2m_percpu_rwlock); + /* Turn on/off host superpage page table support for hap, default on. */ bool_t __initdata opt_hap_1gb = 1, __initdata opt_hap_2mb = 1; boolean_param("hap_1gb", opt_hap_1gb); diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index 209aeb8c2f..d5bf4d3241 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -518,7 +518,7 @@ bool arch_iommu_use_permitted(const struct domain *d) return d == dom_io || (likely(!mem_sharing_enabled(d)) && likely(!mem_paging_enabled(d)) && - likely(!p2m_get_hostp2m(d)->global_logdirty)); + likely(!p2m_is_global_logdirty(d))); } static int __init cf_check adjust_irq_affinities(void) -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |