purge free_shared_domheap_page()
v8 cover purge free_shared_domheap_page()
Paul Durrant (4):
x86 / vmx: move teardown from domain_destroy()... add a domain_tot_pages() helper function
mm: make pages allocated with MEMF_no_refcount safe to assign x86 / vmx: use a MEMF_no_refcount domheap page for
APIC_DEFAULT_PHYS_BASE
xen/arch/x86/domain.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 25 ++++++++--- xen/arch/x86/mm.c | 19 +++----- xen/arch/x86/mm/p2m-pod.c | 10 ++--- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/msi.c | 2 +- xen/arch/x86/numa.c | 2 +- xen/arch/x86/pv/dom0_build.c | 25 ++++++----- xen/arch/x86/pv/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 +- xen/common/keyhandler.c | 2 +- xen/common/memory.c | 4 +- xen/common/page_alloc.c | 78 ++++++++++++++++++++++++--------- xen/include/asm-arm/mm.h | 5 ++- xen/include/asm-x86/mm.h | 9 ++-- xen/include/public/memory.h | 4 +- xen/include/xen/sched.h | 27 +++++++++--- 18 files changed, 143 insertions(+), 81 deletions(-)
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v8 1/4 x86 / vmx: move teardown from domain_destroy()...
... to domain_relinquish_resources().
The teardown code frees the APICv page. This does not need to be done late so do it in domain_relinquish_resources() rather than domain_destroy().
---
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
Cc: George Dunlap <[email protected]>
v4:
- New in v4 (disaggregated from v3 patch #3)
--- xen/arch/x86/hvm/vmx/vmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +2 -2
@@ -419,7 +419,7 @@ static int vmx_domain_initialise(struct domain *d)return 0 ; } -static void vmx_domain_destroy (struct domain *d) +static void vmx_domain_relinquish_resources (struct domain *d) {if ( !has_vlapic (d) )return ;
@@ -2240,7 +2240,7 @@ static struct hvm_function_table __initdata vmx_function_table = { .cpu_up_prepare = vmx_cpu_up_prepare, .cpu_dead = vmx_cpu_dead, .domain_initialise = vmx_domain_initialise, - .domain_destroy = vmx_domain_destroy, + .domain_relinquish_resources = vmx_domain_relinquish_resources, .vcpu_initialise = vmx_vcpu_initialise, .vcpu_destroy = vmx_vcpu_destroy, .save_cpu_ctxt = vmx_save_vmcs_ctxt,
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v8 2/4 add a domain_tot_pages() helper function
In reply to Paul DurrantThis patch adds a new domain_tot_pages() inline helper function into sched.h, which will be needed by a subsequent patch.
No functional change.
NOTE: While modifying the comment for 'tot_pages' in sched.h this patch
makes some cosmetic fixes to surrounding comments.
---
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Tim Deegan <[email protected]>
v8:
- New in v8
--- xen/arch/x86/domain.c | 2 +- xen/arch/x86/mm.c | 6 +++--- xen/arch/x86/mm/p2m-pod.c | 10 +++++----- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/msi.c | 2 +- xen/arch/x86/numa.c | 2 +- xen/arch/x86/pv/dom0_build.c | 25 +++++++++++++------------ xen/arch/x86/pv/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 ++-- xen/common/keyhandler.c | 2 +- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 15 ++++++++------- xen/include/public/memory.h | 4 ++-- xen/include/xen/sched.h | 24 ++++++++++++++++++------ 15 files changed, 60 insertions(+), 46 deletions(-)
xen/arch/x86/domain.c +1 -1
@@ -218,7 +218,7 @@ void dump_pageframe_info(struct domain *d)printk ("Memory pages belonging to domain %u:\n" , d->domain_id); -if ( d->tot_pages >=10 && d->is_dying < DOMDYING_dead ) +if (domain_tot_pages (d) >=10 && d->is_dying < DOMDYING_dead ) {printk (" DomPage list too long to display\n" ); }
xen/arch/x86/mm.c +3 -3
@@ -4194,8 +4194,8 @@ long do_mmu_update(* - page caching attributes cleaned up * - removed from the domain's page_list * -* If MEMF_no_refcount is not set, the domain's tot_pages will be -* adjusted. If this results in the page count falling to 0, +* If MEMF_no_refcount is not set, the domain_adjust_tot_pages() will +* be called. If this results in the page count falling to 0, * put_domain() will be called. * * The caller should either call free_domheap_page() to free the
@@ -4870,7 +4870,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)else if ( rc >=0 ) { p2m =p2m_get_hostp2m (d); - target.tot_pages = d->tot_pages; + target.tot_pages =domain_tot_pages (d); target.pod_cache_pages = p2m->pod.count; target.pod_entries = p2m->pod.entry_count;
xen/arch/x86/mm/p2m-pod.c +5 -5
@@ -302,7 +302,7 @@ out:* The following equations should hold: * 0 <= P <= T <= B <= M * d->arch.p2m->pod.entry_count == B - P -* d->tot_pages == P + d->arch.p2m->pod.count +* domain_tot_pages(d) == P + d->arch.p2m->pod.count * * Now we have the following potential cases to cover: * B <T': Set the PoD cache size equal to the number of outstanding PoD
@@ -336,7 +336,7 @@ p2m_pod_set_mem_target(struct domain *d, unsigned long target)pod_lock (p2m);/* P == B: Nothing to do (unless the guest is being created). */ - populated = d->tot_pages - p2m->pod.count; + populated =domain_tot_pages (d) - p2m->pod.count;if ( populated >0 && p2m->pod.entry_count ==0 ) goto out;
@@ -348,7 +348,7 @@ p2m_pod_set_mem_target(struct domain *d, unsigned long target)* T' < B: Don't reduce the cache size; let the balloon driver * take care of it. */ -if ( target < d->tot_pages ) +if ( target <domain_tot_pages (d) ) goto out; pod_target = target - populated;
@@ -1231,8 +1231,8 @@ out_of_memory:pod_unlock (p2m);printk ("%s: Dom%d out of PoD memory! (tot=%" PRIu32" ents=%ld dom%d)\n" , - __func__, d->domain_id, d->tot_pages, p2m->pod.entry_count, - current->domain->domain_id); + __func__, d->domain_id,domain_tot_pages (d), + p2m->pod.entry_count, current->domain->domain_id);domain_crash (d);return false; out_fail:
xen/arch/x86/mm/shadow/common.c +1 -1
@@ -1256,7 +1256,7 @@ static unsigned int sh_min_allocation(const struct domain *d)* up of slot zero and an LAPIC page), plus one for HVM's 1-to-1 pagetable. */ return shadow_min_acceptable_pages (d) + -max (max (d->tot_pages /256 , +max (max (domain_tot_pages (d) /256 ,is_hvm_domain (d) ?CONFIG_PAGING_LEVELS +2 :0U ) +is_hvm_domain (d), d->arch.paging.shadow.p2m_pages);
xen/arch/x86/msi.c +1 -1
@@ -991,7 +991,7 @@ static int msix_capability_init(struct pci_dev *dev, seg, bus, slot, func, d->domain_id);if ( !is_hardware_domain (d) &&/* Assume a domain without memory has no mappings yet. */ - (!is_hardware_domain (currd) || d->tot_pages) ) + (!is_hardware_domain (currd) ||domain_tot_pages (d)) )domain_crash (d);/* XXX How to deal with existing mappings? */ }
xen/arch/x86/numa.c +1 -1
@@ -419,7 +419,7 @@ static void dump_numa(unsigned char key) {process_pending_softirqs (); -printk ("Domain %u (total: %u):\n" , d->domain_id, d->tot_pages); +printk ("Domain %u (total: %u):\n" , d->domain_id,domain_tot_pages (d));for_each_online_node ( i ) page_num_node[i] =0 ;
xen/arch/x86/pv/dom0_build.c +13 -12
@@ -110,8 +110,9 @@ static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn,while ( vphysmap_start < vphysmap_end ) { -if ( d->tot_pages + ((round_pgup (vphysmap_end) - vphysmap_start) - >>PAGE_SHIFT ) +3 > nr_pages ) +if (domain_tot_pages (d) + + ((round_pgup (vphysmap_end) - vphysmap_start) >>PAGE_SHIFT ) + +3 > nr_pages )panic ("Dom0 allocation too small for initial P->M table\n" );if ( pl1e )
@@ -264,7 +265,7 @@ static struct page_info * __init alloc_chunk(struct domain *d, {struct page_info *pg2; -if ( d->tot_pages + (1 << order) > d->max_pages ) +if (domain_tot_pages (d) + (1 << order) > d->max_pages )continue ; pg2 =alloc_domheap_pages (d, order, MEMF_exact_node | MEMF_no_scrub);if ( pg2 > page )
@@ -500,13 +501,13 @@ int __init dom0_construct_pv(struct domain *d,if ( page ==NULL )panic ("Not enough RAM for domain 0 allocation\n" ); alloc_spfn =mfn_x (page_to_mfn (page)); - alloc_epfn = alloc_spfn + d->tot_pages; + alloc_epfn = alloc_spfn +domain_tot_pages (d);if ( initrd_len ) { initrd_pfn = vinitrd_start ? (vinitrd_start - v_start) >>PAGE_SHIFT : - d->tot_pages; +domain_tot_pages (d); initrd_mfn = mfn = initrd->mod_start; count =PFN_UP (initrd_len); if ( d->arch.physaddr_bitsize &&
@@ -541,9 +542,9 @@ int __init dom0_construct_pv(struct domain *d,printk ("PHYSICAL MEMORY ARRANGEMENT:\n" " Dom0 alloc.: %" PRIpaddr"->%" PRIpaddr,pfn_to_paddr (alloc_spfn),pfn_to_paddr (alloc_epfn)); -if ( d->tot_pages < nr_pages ) +if (domain_tot_pages (d) < nr_pages )printk (" (%lu pages to be allocated)" , - nr_pages - d->tot_pages); + nr_pages -domain_tot_pages (d));if ( initrd ) { mpt_alloc = (paddr_t )initrd->mod_start <<PAGE_SHIFT ;
@@ -755,7 +756,7 @@ int __init dom0_construct_pv(struct domain *d,snprintf (si->magic,sizeof (si->magic),"xen-3.0-x86_%d%s" ,elf_64bit (&elf) ?64 :32 , parms.pae ?"p" :"" ); - count = d->tot_pages; + count =domain_tot_pages (d);/* Set up the phys->machine table if not part of the initial mapping. */ if ( parms.p2m_base !=UNSET_ADDR )
@@ -786,7 +787,7 @@ int __init dom0_construct_pv(struct domain *d,process_pending_softirqs (); } si->first_p2m_pfn = pfn; - si->nr_p2m_frames = d->tot_pages - count; + si->nr_p2m_frames =domain_tot_pages (d) - count; page_list_for_each ( page, &d->page_list ) { mfn =mfn_x (page_to_mfn (page));
@@ -804,15 +805,15 @@ int __init dom0_construct_pv(struct domain *d,process_pending_softirqs (); } } -BUG_ON (pfn != d->tot_pages); +BUG_ON (pfn !=domain_tot_pages (d));#ifndef NDEBUG alloc_epfn +=PFN_UP (initrd_len) + si->nr_p2m_frames;#endif while ( pfn < nr_pages ) { -if ( (page =alloc_chunk (d, nr_pages - d->tot_pages)) ==NULL ) +if ( (page =alloc_chunk (d, nr_pages -domain_tot_pages (d))) ==NULL )panic ("Not enough RAM for DOM0 reservation\n" ); -while ( pfn < d->tot_pages ) +while ( pfn <domain_tot_pages (d) ) { mfn =mfn_x (page_to_mfn (page));#ifndef NDEBUG
xen/arch/x86/pv/domain.c +1 -1
@@ -173,7 +173,7 @@ int switch_compat(struct domain *d)BUILD_BUG_ON (offsetof(struct shared_info , vcpu_info) !=0 ); -if (is_hvm_domain (d) || d->tot_pages !=0 ) +if (is_hvm_domain (d) ||domain_tot_pages (d) !=0 )return -EACCES ;if (is_pv_32bit_domain (d) )return 0 ;
xen/common/domctl.c +1 -1
@@ -191,7 +191,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)xsm_security_domaininfo (d, info); - info->tot_pages = d->tot_pages; + info->tot_pages =domain_tot_pages (d); info->max_pages = d->max_pages; info->outstanding_pages = d->outstanding_pages; info->shr_pages =atomic_read (&d->shr_pages);
xen/common/grant_table.c +2 -2
@@ -2261,7 +2261,7 @@ gnttab_transfer(* pages when it is dying. */ if (unlikely (e->is_dying) || -unlikely (e->tot_pages >= e->max_pages) ) +unlikely (domain_tot_pages (e) >= e->max_pages) ) {spin_unlock (&e->page_alloc_lock);
@@ -2271,7 +2271,7 @@ gnttab_transfer(else gdprintk (XENLOG_INFO ,"Transferee d%d has no headroom (tot %u, max %u)\n" , - e->domain_id, e->tot_pages, e->max_pages); + e->domain_id,domain_tot_pages (e), e->max_pages); gop.status = GNTST_general_error; goto unlock_and_copyback;
xen/common/keyhandler.c +1 -1
@@ -271,7 +271,7 @@ static void dump_domains(unsigned char key) atomic_read(&d->pause_count));printk (" nr_pages=%d xenheap_pages=%d shared_pages=%u paged_pages=%u " "dirty_cpus={%*pbl} max_pages=%u\n" , - d->tot_pages, d->xenheap_pages,atomic_read (&d->shr_pages), +domain_tot_pages (d), d->xenheap_pages,atomic_read (&d->shr_pages),atomic_read (&d->paged_pages),CPUMASK_PR (d->dirty_cpumask), d->max_pages); printk(" handle=%02x%02x%02x%02x-%02x%02x-%02x%02x-"
xen/common/memory.c +2 -2
@@ -717,7 +717,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)/* * Pages in in_chunk_list is stolen without -* decreasing the tot_pages. If the domain is dying when +* decreasing domain_tot_pages(). If the domain is dying when * assign pages, we need decrease the count. For those pages * that has been assigned, it should be covered by * domain_relinquish_resources().
@@ -1267,7 +1267,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)switch ( op ) {case XENMEM_current_reservation: - rc = d->tot_pages; + rc =domain_tot_pages (d);break ;case XENMEM_maximum_reservation: rc = d->max_pages;
xen/common/page_alloc.c +8 -7
@@ -518,8 +518,8 @@ int domain_set_outstanding_pages(struct domain *d, unsigned long pages) goto out; } -/* disallow a claim not exceeding current tot_pages or above max_pages */ -if ( (pages <= d->tot_pages) || (pages > d->max_pages) ) +/* disallow a claim not exceeding domain_tot_pages() or above max_pages */ +if ( (pages <=domain_tot_pages (d)) || (pages > d->max_pages) ) { ret = -EINVAL ; goto out;
@@ -532,9 +532,9 @@ int domain_set_outstanding_pages(struct domain *d, unsigned long pages)/* * Note, if domain has already allocated memory before making a claim -* then the claim must take tot_pages into account +* then the claim must take domain_tot_pages() into account */ - claim = pages - d->tot_pages; + claim = pages -domain_tot_pages (d);if ( claim > avail_pages ) goto out;
@@ -2269,11 +2269,12 @@ int assign_pages(if ( !(memflags & MEMF_no_refcount) ) { -if (unlikely ((d->tot_pages + (1 << order)) > d->max_pages) ) +unsigned int tot_pages =domain_tot_pages (d) + (1 << order); + +if (unlikely (tot_pages > d->max_pages) ) {gprintk (XENLOG_INFO ,"Over-allocation for domain %u: " -"%u > %u\n" , d->domain_id, - d->tot_pages + (1 << order), d->max_pages); +"%u > %u\n" , d->domain_id, tot_pages, d->max_pages); rc = -E2BIG ; goto out; }
xen/include/public/memory.h +2 -2
@@ -553,8 +553,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_sharing_op_t);* * Note that a valid claim may be staked even after memory has been * allocated for a domain. In this case, the claim is not incremental, -* i.e. if the domain's tot_pages is 3, and a claim is staked for 10, -* only 7 additional pages are claimed. +* i.e. if the domain's total page count is 3, and a claim is staked +* for 10, only 7 additional pages are claimed. * * Caller must be privileged or the hypercall fails. */
xen/include/xen/sched.h +18 -6
@@ -364,12 +364,18 @@ struct domainspinlock_t page_alloc_lock;/* protects all the following fields */ struct page_list_head page_list;/* linked list */ struct page_list_head xenpage_list;/* linked list (size xenheap_pages) */ -unsigned int tot_pages;/* number of pages currently possesed */ -unsigned int xenheap_pages;/* # pages allocated from Xen heap */ -unsigned int outstanding_pages;/* pages claimed but not possessed */ -unsigned int max_pages;/* maximum value for tot_pages */ -atomic_t shr_pages;/* number of shared pages */ -atomic_t paged_pages;/* number of paged-out pages */ + +/* +* This field should only be directly accessed by domain_adjust_tot_pages() +* and the domain_tot_pages() helper function defined below. +*/ +unsigned int tot_pages; + +unsigned int xenheap_pages;/* pages allocated from Xen heap */ +unsigned int outstanding_pages;/* pages claimed but not possessed */ +unsigned int max_pages;/* maximum value for domain_tot_pages() */ +atomic_t shr_pages;/* shared pages */ +atomic_t paged_pages;/* paged-out pages */ /* Scheduling. */ void *sched_priv;/* scheduler-specific data */
@@ -539,6 +545,12 @@ struct domain#endif }; +/* Return number of pages currently posessed by the domain */ +static inline unsigned int domain_tot_pages (const struct domain *d) +{ +return d->tot_pages; +} +/* Protect updates/reads (resp.) of domain_list and domain_hash. */ extern spinlock_t domlist_update_lock;extern rcu_read_lock_t domlist_read_lock;
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v8 3/4 mm: make pages allocated with MEMF_no_refcount safe to assign
In reply to Paul DurrantCurrently it is unsafe to assign a domheap page allocated with MEMF_no_refcount to a domain because the domain't 'tot_pages' will not be incremented, but will be decrement when the page is freed (since free_domheap_pages() has no way of telling that the increment was skipped).
This patch allocates a new 'count_info' bit for a PGC_extra flag which is then used to mark pages when alloc_domheap_pages() is called with MEMF_no_refcount. assign_pages() because it still needs to call domain_adjust_tot_pages() to make sure the domain is appropriately referenced. Hence it is modified to do that for PGC_extra pages even if it is passed MEMF_no_refount.
The number of PGC_extra pages assigned to a domain is tracked in a new 'extra_pages' counter, which is then subtracted from 'total_pages' in the domain_tot_pages() helper. Thus 'normal' page assignments will still be appropriately checked against 'max_pages'.
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Volodymyr Babchuk <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
v8:
- Drop the idea of post-allocation assignment adding an error path to steal_page() if it encounters a PGC_extra page
- Tighten up the ASSERTs in assign_pages()
v7:
- s/PGC_no_refcount/PGC_extra/g
- Re-work allocation to account for 'extra' pages, also making it safe to assign PGC_extra pages post-allocation
v6:
- Add an extra ASSERT into assign_pages() that PGC_no_refcount is not set if MEMF_no_refcount is clear
- ASSERT that count_info is 0 in alloc_domheap_pages() and set to PGC_no_refcount rather than ORing
v5:
- Make sure PGC_no_refcount is set before assign_pages() is called
- Don't bother to clear PGC_no_refcount in free_domheap_pages() and drop ASSERT in free_heap_pages()
- Don't latch count_info in free_heap_pages()
v4:
- New in v4
--- xen/arch/x86/mm.c | 3 +- xen/common/page_alloc.c | 63 +++++++++++++++++++++++++++++++--------- xen/include/asm-arm/mm.h | 5 +++- xen/include/asm-x86/mm.h | 7 +++-- xen/include/xen/sched.h | 5 +++- 5 files changed, 64 insertions(+), 19 deletions(-)
xen/arch/x86/mm.c +2 -1
@@ -4217,7 +4217,8 @@ int steal_page(if ( !(owner =page_get_owner_and_reference (page)) ) goto fail; -if ( owner != d ||is_xen_heap_page (page) ) +if ( owner != d ||is_xen_heap_page (page) || + (page->count_info & PGC_extra) ) goto fail_put;/*
xen/common/page_alloc.c +49 -14
102 lines not on this page · raw message
xen/include/asm-arm/mm.h +4 -1
@@ -119,9 +119,12 @@ struct page_info#define PGC_state_offlined PG_mask(2, 9)#define PGC_state_free PG_mask(3, 9)#define page_state_is (pg, st) (((pg)->count_info&PGC_state) == PGC_state_##st) +/* Page is not reference counted */ +#define _PGC_extra PG_shift(10) +#define PGC_extra PG_mask(1, 10)/* Count of references to this frame. */ -#define PGC_count_width PG_shift(9) +#define PGC_count_width PG_shift(10)#define PGC_count_mask ((1UL<<PGC_count_width)-1)/*
xen/include/asm-x86/mm.h +5 -2
@@ -77,9 +77,12 @@#define PGC_state_offlined PG_mask(2, 9)#define PGC_state_free PG_mask(3, 9)#define page_state_is (pg, st) (((pg)->count_info&PGC_state) == PGC_state_##st) +/* Page is not reference counted */ +#define _PGC_extra PG_shift(10) +#define PGC_extra PG_mask(1, 10) -/* Count of references to this frame. */ -#define PGC_count_width PG_shift(9) +/* Count of references to this frame. */ +#define PGC_count_width PG_shift(10)#define PGC_count_mask ((1UL<<PGC_count_width)-1)/*
xen/include/xen/sched.h +4 -1
@@ -374,6 +374,7 @@ struct domainunsigned int xenheap_pages;/* pages allocated from Xen heap */ unsigned int outstanding_pages;/* pages claimed but not possessed */ unsigned int max_pages;/* maximum value for domain_tot_pages() */ +unsigned int extra_pages;/* pages not included in domain_tot_pages() */ atomic_t shr_pages;/* shared pages */ atomic_t paged_pages;/* paged-out pages */
@@ -548,7 +549,9 @@ struct domain/* Return number of pages currently posessed by the domain */ static inline unsigned int domain_tot_pages (const struct domain *d) { -return d->tot_pages; +ASSERT (d->extra_pages <= d->tot_pages); + +return d->tot_pages - d->extra_pages; }/* Protect updates/reads (resp.) of domain_list and domain_hash. */
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v8 4/4 x86 / vmx: use a MEMF_no_refcount domheap page for APIC_DEFAULT_PHYS_BASE
In reply to Paul Durrantvmx_alloc_vlapic_mapping() currently contains some very odd looking code that allocates a MEMF_no_owner domheap page and then shares with the guest as if it were a xenheap page. This then requires vmx_free_vlapic_mapping() to call a special function in the mm code: free_shared_domheap_page().
By using a MEMF_no_refcount domheap page instead, the odd looking code in vmx_alloc_vlapic_mapping() can simply use get_page_and_type() to set up a writable mapping before insertion in the P2M and vmx_free_vlapic_mapping() can simply release the page using put_page_alloc_ref() followed by put_page_and_type(). This then allows free_shared_domheap_page() to be purged.
---
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
v4:
- Use a MEMF_no_refcount page rather than a 'normal' page
v2:
- Set an initial value for max_pages rather than avoiding the check in assign_pages()
- Make domain_destroy() optional
--- xen/arch/x86/hvm/vmx/vmx.c | 21 ++++++++++++++++++--- xen/arch/x86/mm.c | 10 ---------- xen/include/asm-x86/mm.h | 2 -- 3 files changed, 18 insertions(+), 15 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +18 -3
@@ -3028,12 +3028,22 @@ static int vmx_alloc_vlapic_mapping(struct domain *d)if ( !cpu_has_vmx_virtualize_apic_accesses )return 0 ; - pg =alloc_domheap_page (d, MEMF_no_owner); + pg =alloc_domheap_page (d, MEMF_no_refcount);if ( !pg )return -ENOMEM ; + +if ( !get_page_and_type (pg, d, PGT_writable_page) ) + { +/* +* The domain can't possibly know about this page yet, so failure +* here is a clear indication of something fishy going on. +*/ +domain_crash (d); +return -ENODATA ; + } + mfn =page_to_mfn (pg);clear_domain_page (mfn); -share_xen_page_with_guest (pg, d, SHARE_rw); d->arch.hvm.vmx.apic_access_mfn = mfn; return set_mmio_p2m_entry(d, paddr_to_pfn(APIC_DEFAULT_PHYS_BASE), mfn,
@@ -3047,7 +3057,12 @@ static void vmx_free_vlapic_mapping(struct domain *d) d->arch.hvm.vmx.apic_access_mfn =_mfn (0 );if ( !mfn_eq (mfn,_mfn (0 )) ) -free_shared_domheap_page (mfn_to_page (mfn)); + { +struct page_info *pg =mfn_to_page (mfn); + +put_page_alloc_ref (pg); +put_page_and_type (pg); + } }static void vmx_install_vlapic_mapping (struct vcpu *v)
xen/arch/x86/mm.c +0 -10
@@ -496,16 +496,6 @@ void share_xen_page_with_guest(struct page_info *page, struct domain *d,spin_unlock (&d->page_alloc_lock); } -void free_shared_domheap_page (struct page_info *page) -{ -put_page_alloc_ref (page); -if ( !test_and_clear_bit (_PGC_xen_heap, &page->count_info) ) -ASSERT_UNREACHABLE (); - page->u.inuse.type_info =0 ; -page_set_owner (page,NULL ); -free_domheap_page (page); -} -void make_cr3 (struct vcpu *v,mfn_t mfn) {struct domain *d = v->domain;
xen/include/asm-x86/mm.h +0 -2
@@ -320,8 +320,6 @@ struct page_info#define maddr_get_owner (ma) (page_get_owner(maddr_to_page((ma)))) -extern void free_shared_domheap_page (struct page_info *page); -#define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)extern unsigned long max_page;extern unsigned long total_pages;
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 3/4] mm: make pages allocated with MEMF_no_refcount safe to assign
In reply to Paul DurrantQuoted 12 lines · Paul Durrant
Currently it is unsafe to assign a domheap page allocated with
MEMF_no_refcountto a domain because the domain't 'tot_pages' will not be incremented, but will be decrement when the page is freed (sincefree_domheap_pages()has no way of telling that the increment was skipped).This patch allocates a new '
count_info' bit for aPGC_extraflag which is then used to mark pages whenalloc_domheap_pages()is called withMEMF_no_refcount.assign_pages()because it still needs to calldomain_adjust_tot_pages()to make sure the domain is appropriately referenced. Hence it is modified to do that forPGC_extrapages even if it is passedMEMF_no_refount.
Quoted 6 lines
The number of
PGC_extrapages assigned to a domain is tracked in a new 'extra_pages' counter, which is then subtracted from 'total_pages' in thedomain_tot_pages()helper. Thus 'normal' page assignments will still be appropriately checked against 'max_pages'.Signed-off-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 2/4] add a domain_tot_pages() helper function
In reply to Paul Durrantxen/arch/x86/domain.c void dump_pageframe_info(struct domain *d) · line 221
Quoted 8 lines · Paul Durrant
xen/arch/x86/domain.c +1
-1@@ -218,7 +218,7 @@ void dump_pageframe_info(struct domain *d)printk ("Memory pages belonging to domain %u:\n" , d->domain_id); -if ( d->tot_pages >=10 && d->is_dying < DOMDYING_dead ) +if (domain_tot_pages (d) >=10 && d->is_dying < DOMDYING_dead )
Before I go any further - are you simply replacing _all_ ->tot_pages uses by the new helper? In the case here, for example, I don't think this is what we want.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 2/4] add a domain_tot_pages() helper function
Quoted 17 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 30 January 2020 16:29
To: Durrant, Paul <[email protected]>
Cc: [email protected]; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim Deegan <[email protected]>
Subject: Re: [PATCH v8 2/4] add adomain_tot_pages()helper functionQuoted 4 lines · Paul Durrant
xen/arch/x86/domain.c +0
-0@@ -218,7 +218,7 @@ void dump_pageframe_info(struct domain *d)
Quoted 7 lines
xen/arch/x86/domain.c void dump_pageframe_info(struct domain *d) · line 221
Quoted 4 lines
xen/arch/x86/domain.c +1
-1printk ("Memory pages belonging to domain %u:\n" , d->domain_id); -if ( d->tot_pages >=10 && d->is_dying < DOMDYING_dead ) +if (domain_tot_pages (d) >=10 && d->is_dying < DOMDYING_dead )Before I go any further - are you simply replacing _all_ ->tot_pages uses by the new helper?
Basically, apart from domain_adjust_tot_pages(), yes.
Quoted 3 lines
In the case here, for
example, I don't think this is what we want.
Why not? I would have thought any 'extra' pages would always be of interest.
Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 2/4] add a domain_tot_pages() helper function
Quoted 25 lines · Paul
Quoted 17 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 30 January 2020 16:29
To: Durrant, Paul <[email protected]>
Cc: [email protected]; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim Deegan <[email protected]>
Subject: Re: [PATCH v8 2/4] add adomain_tot_pages()helper functionQuoted 4 lines · Paul Durrant
xen/arch/x86/domain.c +0
-0@@ -218,7 +218,7 @@ void dump_pageframe_info(struct domain *d)Quoted 7 lines
xen/arch/x86/domain.c void dump_pageframe_info(struct domain *d) · line 221
Quoted 4 lines
xen/arch/x86/domain.c +1
-1printk ("Memory pages belonging to domain %u:\n" , d->domain_id); -if ( d->tot_pages >=10 && d->is_dying < DOMDYING_dead ) +if (domain_tot_pages (d) >=10 && d->is_dying < DOMDYING_dead )Before I go any further - are you simply replacing _all_ ->tot_pages uses by the new helper?
Quoted 7 lines
Basically, apart from
domain_adjust_tot_pages(), yes.Quoted 3 lines
In the case here, for
example, I don't think this is what we want.Why not? I would have thought any 'extra' pages would always be of interest.
Could be hundreds or thousands in the future. As long as it's in reality just one, perhaps it indeed doesn't matter much. I'll take a closer look tomorrow, to see if there are other places where the adjusted count would better not be used. From my partial audit in the morning I seem to recall that there were both kinds of situations...
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 2/4] add a domain_tot_pages() helper function
In reply to Paul DurrantQuoted 11 lines · Paul Durrant
v8:
- New in v8--- xen/arch/x86/domain.c | 2 +- xen/arch/x86/mm.c | 6 +++--- xen/arch/x86/mm/p2m-pod.c | 10 +++++----- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/msi.c | 2 +- xen/arch/x86/numa.c | 2 +- xen/arch/x86/pv/dom0_build.c | 25 +++++++++++++------------ xen/arch/x86/pv/domain.c | 2 +-
Quoted 8 lines
xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 ++-- xen/common/keyhandler.c | 2 +- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 15 ++++++++------- xen/include/public/memory.h | 4 ++-- xen/include/xen/sched.h | 24 ++++++++++++++++++------ 15 files changed, 60 insertions(+), 46 deletions(-)
From this, with the comment you add next to the struct field, and with your reply yesterday, what about the uses in
- arch/arm/arm64/domctl.c:switch_mode(),
- arch/x86/pv/shim.c:pv_shim_setup_dom(),
- arch/x86/pv/shim.c:write_start_info()?
xen/arch/x86/mm.c long do_mmu_update( · line 4199
Quoted 11 lines
xen/arch/x86/mm.c +2
-2@@ -4194,8 +4194,8 @@ long do_mmu_update(* - page caching attributes cleaned up * - removed from the domain's page_list * -* If MEMF_no_refcount is not set, the domain's tot_pages will be -* adjusted. If this results in the page count falling to 0, +* If MEMF_no_refcount is not set, the domain_adjust_tot_pages() will +* be called. If this results in the page count falling to 0, * put_domain() will be called.
If you fiddle with this comment, please also drop the "the" ahead of the function name. Unless you as a native speaker would confirm it's appropriate there (it doesn't seem so to me). Of course I also wouldn't mind leaving this untouched altogether.
xen/common/memory.c static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) · line 720
Quoted 8 lines
xen/common/memory.c +1
-1@@ -717,7 +717,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)/* * Pages in in_chunk_list is stolen without -* decreasing the tot_pages. If the domain is dying when +* decreasing domain_tot_pages(). If the domain is dying when
I'd leave this comment alone, or at least not use the function name. Maybe do as you did in the public header?
Quoted 8 lines
xen/include/xen/sched.h +0
-2@@ -364,12 +364,18 @@ struct domainspinlock_t page_alloc_lock;/* protects all the following fields */ struct page_list_head page_list;/* linked list */ struct page_list_head xenpage_list;/* linked list (size xenheap_pages) */ -unsigned int tot_pages;/* number of pages currently possesed */ -unsigned int xenheap_pages;/* # pages allocated from Xen heap */
xen/include/xen/sched.h struct domain · line 372
Quoted 10 lines
xen/include/xen/sched.h +6
-4-unsigned int outstanding_pages;/* pages claimed but not possessed */ -unsigned int max_pages;/* maximum value for tot_pages */ -atomic_t shr_pages;/* number of shared pages */ -atomic_t paged_pages;/* number of paged-out pages */ + +/* +* This field should only be directly accessed by domain_adjust_tot_pages() +* and the domain_tot_pages() helper function defined below. +*/ +unsigned int tot_pages;
If the three missing ones got taken care of, with there being arguments both pro and con your change to dump_pageframe_info(), I'd be okay with it getting changed as you do, to not render this comment partially wrong.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 1/4] x86 / vmx: move teardown from domain_destroy()...
In reply to Paul DurrantQuoted 6 lines · Paul Durrant
... to
domain_relinquish_resources().The teardown code frees the APICv page. This does not need to be done late so do it in
domain_relinquish_resources()rather thandomain_destroy().Signed-off-by Paul Durrant <[email protected]>
Btw., this can have my
as soon as "x86/HVM: relinquish resources also from hvm_domain_destroy()" has gone in. But that's still pending an ack or otherwise by you.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 1/4] x86 / vmx: move teardown from domain_destroy()...
Quoted 16 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 31 January 2020 13:32
To: Durrant, Paul <[email protected]>
Cc: [email protected]; Jun Nakajima <[email protected]>; Kevin Tian <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>; George Dunlap <[email protected]>
Subject: Re: [PATCH v8 1/4] x86 / vmx: move teardown fromdomain_destroy()...Quoted 3 lines · Paul Durrant
... to
domain_relinquish_resources().The teardown code frees the APICv page. This does not need to be done
late
Quoted 9 lines
Quoted 3 lines
so do it in
domain_relinquish_resources()rather thandomain_destroy().Signed-off-by Paul Durrant <[email protected]>Btw., this can have my
Reviewed-by Jan Beulich <[email protected]>as soon as "x86/HVM: relinquish resources also from
hvm_domain_destroy()" has gone in. But that's still pending an ack or otherwise by you.
Ok, thanks, I'll get on and review that.
Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 2/4] add a domain_tot_pages() helper function
In reply to Jan BeulichQuoted 33 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 31 January 2020 12:53
To: Durrant, Paul <[email protected]>
Cc: [email protected]; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim Deegan <[email protected]>
Subject: Re: [PATCH v8 2/4] add adomain_tot_pages()helper functionQuoted 11 lines · Paul Durrant
v8:
- New in v8--- xen/arch/x86/domain.c | 2 +- xen/arch/x86/mm.c | 6 +++--- xen/arch/x86/mm/p2m-pod.c | 10 +++++----- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/msi.c | 2 +- xen/arch/x86/numa.c | 2 +- xen/arch/x86/pv/dom0_build.c | 25 +++++++++++++------------ xen/arch/x86/pv/domain.c | 2 +-Quoted 8 lines
xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 ++-- xen/common/keyhandler.c | 2 +- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 15 ++++++++------- xen/include/public/memory.h | 4 ++-- xen/include/xen/sched.h | 24 ++++++++++++++++++------ 15 files changed, 60 insertions(+), 46 deletions(-)
Quoted 3 lines
From this, with the comment you add next to the struct field, and with your reply yesterday, what about the uses in
- arch/arm/arm64/domctl.c:switch_mode(),
TBH I'm not sure with that one. It looks to me like it needs to check whether the domain has *any* memory assigned. Perhaps checking page_list would be more appropriate. Perhaps Julien can comment?
Quoted 2 lines
- arch/x86/pv/shim.c:pv_shim_setup_dom(),
- arch/x86/pv/shim.c:write_start_info()?
It looks like both of those should be changed.
Quoted 18 lines
xen/arch/x86/mm.c long do_mmu_update( · line 4199
Quoted 12 lines
xen/arch/x86/mm.c +2
-2@@ -4194,8 +4194,8 @@ long do_mmu_update(* - page caching attributes cleaned up * - removed from the domain's page_list * -* If MEMF_no_refcount is not set, the domain's tot_pages will be -* adjusted. If this results in the page count falling to 0, +* If MEMF_no_refcount is not set, the domain_adjust_tot_pages() will +* be called. If this results in the page count falling to 0, * put_domain() will be called. If you fiddle with this comment, please also drop the "the" ahead of the function name. Unless you as a native speaker would confirm it's appropriate there (it doesn't seem so to me). Of course I also wouldn't mind leaving this untouched altogether.
Ok, I'll drop that hunk.
Quoted 8 lines
xen/common/memory.c static long
Quoted 3 lines
xen/common/memory.c +0
-0@@ -717,7 +717,7 @@ static long
memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)xen/common/memory.c static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)
Quoted 4 lines
xen/common/memory.c +0
-1/* * Pages in in_chunk_list is stolen without -* decreasing the tot_pages. If the domain is dying
Quoted 7 lines
when
xen/common/memory.c static long · line 719
Quoted 1 line
xen/common/memory.c +1
-0+* decreasing domain_tot_pages(). If the domain is dying when
I'd leave this comment alone, or at least not use the function name. Maybe do as you did in the public header?
OK I'll leave this alone too.
Quoted 24 lines
xen/include/xen/sched.h struct domain · line 364
Quoted 4 lines
xen/include/xen/sched.h +0
-0@@ -364,12 +364,18 @@ struct domainspinlock_t page_alloc_lock;/* protects all the following fields */
xen/include/xen/sched.h struct domain · line 366
Quoted 2 lines
xen/include/xen/sched.h +0
-0struct page_list_head page_list;/* linked list */ struct page_list_head xenpage_list;/* linked list (size
xenheap_pages) */xen/include/xen/sched.h struct domain · line 367
Quoted 1 line
xen/include/xen/sched.h +0
-1-unsigned int tot_pages;/* number of pages currently possesed */
xen/include/xen/sched.h struct domain · line 368
Quoted 1 line
xen/include/xen/sched.h +0
-1-unsigned int xenheap_pages;/* # pages allocated from Xen heap */
xen/include/xen/sched.h struct domain · line 369
Quoted 1 line
xen/include/xen/sched.h +0
-1-unsigned int outstanding_pages;/* pages claimed but not possessed */
xen/include/xen/sched.h struct domain · line 370
Quoted 1 line
xen/include/xen/sched.h +0
-1-unsigned int max_pages;/* maximum value for tot_pages */
xen/include/xen/sched.h struct domain · line 371
Quoted 1 line
xen/include/xen/sched.h +0
-1-atomic_t shr_pages;/* number of shared pages */
xen/include/xen/sched.h struct domain · line 372
Quoted 1 line
xen/include/xen/sched.h +0
-1-atomic_t paged_pages;/* number of paged-out pages */
xen/include/xen/sched.h struct domain
Quoted 3 lines
xen/include/xen/sched.h +3
-0+ +/* +* This field should only be directly accessed by
domain_adjust_tot_pages()
Quoted 8 lines
xen/include/xen/sched.h struct domain · line 372
Quoted 3 lines
xen/include/xen/sched.h +3
-0+* and the domain_tot_pages() helper function defined below. +*/ +unsigned int tot_pages;If the three missing ones got taken care of, with there being arguments both pro and con your change to
dump_pageframe_info(), I'd be okay with it getting changed as you do, to not render this comment partially wrong.
Ok.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 2/4] add a domain_tot_pages() helper function
Quoted 47 lines
-----Original Message-----
From: Xen-devel <[email protected]> On Behalf Of Durrant, Paul
Sent: 31 January 2020 15:19
To: Jan Beulich <[email protected]>; Julien Grall <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; Tim Deegan <[email protected]>; xen- [email protected]; Roger Pau Monné <[email protected]>
Subject: Re: [Xen-devel] [PATCH v8 2/4] add adomain_tot_pages()helper functionQuoted 8 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 31 January 2020 12:53
To: Durrant, Paul <[email protected]>
Cc: [email protected]; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>;Konrad
Quoted 25 lines
Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim Deegan <[email protected]>
Subject: Re: [PATCH v8 2/4] add adomain_tot_pages()helper functionQuoted 19 lines · Paul Durrant
v8:
- New in v8--- xen/arch/x86/domain.c | 2 +- xen/arch/x86/mm.c | 6 +++--- xen/arch/x86/mm/p2m-pod.c | 10 +++++----- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/msi.c | 2 +- xen/arch/x86/numa.c | 2 +- xen/arch/x86/pv/dom0_build.c | 25 +++++++++++++------------ xen/arch/x86/pv/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 ++-- xen/common/keyhandler.c | 2 +- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 15 ++++++++------- xen/include/public/memory.h | 4 ++-- xen/include/xen/sched.h | 24 ++++++++++++++++++------ 15 files changed, 60 insertions(+), 46 deletions(-)
Quoted 8 lines
Quoted 3 lines
From this, with the comment you add next to the struct field, and with your reply yesterday, what about the uses in
- arch/arm/arm64/domctl.c:switch_mode(),TBH I'm not sure with that one. It looks to me like it needs to check whether the domain has *any* memory assigned. Perhaps checking
page_listwould be more appropriate. Perhaps Julien can comment?
Having chatted to Julien, the aim of checking tot_pages here is to test whether the domain is newly created, in which case using domain_tot_pages() is the appropriate thing to do.
Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v8 4/4] x86 / vmx: use a MEMF_no_refcount domheap page for APIC_DEFAULT_PHYS_BASE
In reply to Paul DurrantQuoted 18 lines
From: Paul Durrant <[email protected]>
Sent: Thursday, January 30, 2020 10:58 PM
vmx_alloc_vlapic_mapping()currently contains some very odd looking code that allocates aMEMF_no_ownerdomheap page and then shares with the guest
as if it were a xenheap page. This then requiresvmx_free_vlapic_mapping()to call a special function in the mm code:free_shared_domheap_page().By using a
MEMF_no_refcountdomheap page instead, the odd looking code invmx_alloc_vlapic_mapping()can simply useget_page_and_type()to set up a writable mapping before insertion in the P2M andvmx_free_vlapic_mapping()
can simply release the page usingput_page_alloc_ref()followed byput_page_and_type(). This then allowsfree_shared_domheap_page()to be purged.
Quoted 2 lines
Signed-off-by Paul Durrant <[email protected]>Reviewed-by Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel