x86: per-domain mapping adjustments
v2 cover x86: per-domain mapping adjustments
The main goal being the re-work of the hypercall argument translation area management, this series first breaks out per-domain mapping management into its own set of functions, in order to then use this for setting up the translation areas in per-domain space.
While doing this I also realized that it's pointless for the map_domain_page() code to track L1 page table pointers in a separate Xen heap page - we can equally well use the linear page table for the manipulations needed here.
1: introduce create_perdomain_mapping()
2: rework hypercall argument translation area setup
3: use linear L1 page table for map_domain_page() page table manipulation
PATCH v2 1/3 x86: introduce create_perdomain_mapping()
... as well as free_perdomain_mappings(), and use them to carry out the existing per-domain mapping setup/teardown. This at once makes the setup of the first sub-range PV domain specific (with idle domains also excluded), as the GDT/LDT mapping area is needed only for those.
Also fix an improperly scaled BUILD_BUG_ON() expression in mapcache_domain_init().
xen/arch/x86/domain.c +31 -61
@@ -372,37 +372,16 @@ int switch_compat(struct domain *d)int vcpu_initialise (struct vcpu *v) {struct domain *d = v->domain; -unsigned int idx;int rc; v->arch.flags = TF_kernel_mode; - idx =perdomain_pt_idx (v); -if ( !d->arch.perdomain_pts[idx] ) - { -void *pt; -l2_pgentry_t *l2tab; - - pt =alloc_xenheap_pages (0 ,MEMF_node (vcpu_to_node (v))); -if ( !pt ) -return -ENOMEM ; -clear_page (pt); - d->arch.perdomain_pts[idx] = pt; - - l2tab =__map_domain_page (d->arch.perdomain_l2_pg[0 ]); - l2tab[l2_table_offset (PERDOMAIN_VIRT_START ) + idx] - =l2e_from_paddr (__pa (pt), __PAGE_HYPERVISOR); -unmap_domain_page (l2tab); - } - rc =mapcache_vcpu_init (v);if ( rc )return rc;paging_vcpu_init (v); - v->arch.perdomain_ptes =perdomain_ptes (d, v); -if ( (rc =vcpu_init_fpu (v)) !=0 )return rc;
@@ -420,6 +399,12 @@ int vcpu_initialise(struct vcpu *v)if ( !is_idle_domain (d) ) { + rc =create_perdomain_mapping (d,GDT_VIRT_START (v), +1 <<GDT_LDT_VCPU_SHIFT , + d->arch.pv_domain.gdt_ldt_l1tab,NULL ); +if ( rc ) + goto done; +BUILD_BUG_ON (NR_VECTORS *sizeof (*v->arch.pv_vcpu.trap_ctxt) >PAGE_SIZE ); v->arch.pv_vcpu.trap_ctxt = xzalloc_array(struct trap_info,
@@ -478,8 +463,6 @@ void vcpu_destroy(struct vcpu *v)int arch_domain_create (struct domain *d,unsigned int domcr_flags) { -struct page_info *pg; -l3_pgentry_t *l3tab;int i, paging_initialised =0 ;int rc = -ENOMEM ;
@@ -510,29 +493,24 @@ int arch_domain_create(struct domain *d, d->domain_id); } -BUILD_BUG_ON (PDPT_L2_ENTRIES *sizeof (*d->arch.perdomain_pts) - !=PAGE_SIZE ); - d->arch.perdomain_pts = -alloc_xenheap_pages (0 ,MEMF_node (domain_to_node (d))); -if ( !d->arch.perdomain_pts ) - goto fail; -clear_page (d->arch.perdomain_pts); - - pg =alloc_domheap_page (NULL ,MEMF_node (domain_to_node (d))); -if ( pg ==NULL ) - goto fail; - d->arch.perdomain_l2_pg[0 ] = pg; -clear_domain_page (page_to_mfn (pg)); +if (is_hvm_domain (d) ) + rc =create_perdomain_mapping (d,PERDOMAIN_VIRT_START ,0 ,NULL ,NULL ); +else if (is_idle_domain (d) ) + rc =0 ; +else + { + d->arch.pv_domain.gdt_ldt_l1tab = +alloc_xenheap_pages (0 ,MEMF_node (domain_to_node (d))); +if ( !d->arch.pv_domain.gdt_ldt_l1tab ) + goto fail; +clear_page (d->arch.pv_domain.gdt_ldt_l1tab); - pg =alloc_domheap_page (NULL ,MEMF_node (domain_to_node (d))); -if ( pg ==NULL ) + rc =create_perdomain_mapping (d,GDT_LDT_VIRT_START , +GDT_LDT_MBYTES << (20 -PAGE_SHIFT ), +NULL ,NULL ); + } +if ( rc ) goto fail; - d->arch.perdomain_l3_pg = pg; - l3tab =__map_domain_page (pg); -clear_page (l3tab); - l3tab[l3_table_offset (PERDOMAIN_VIRT_START )] = -l3e_from_page (d->arch.perdomain_l2_pg[0 ], __PAGE_HYPERVISOR); -unmap_domain_page (l3tab);mapcache_domain_init (d);
@@ -608,19 +586,14 @@ int arch_domain_create(struct domain *d,if ( paging_initialised )paging_final_teardown (d);mapcache_domain_exit (d); -for ( i =0 ; i <PERDOMAIN_SLOTS ; ++i) -if ( d->arch.perdomain_l2_pg[i] ) -free_domheap_page (d->arch.perdomain_l2_pg[i]); -if ( d->arch.perdomain_l3_pg ) -free_domheap_page (d->arch.perdomain_l3_pg); -free_xenheap_page (d->arch.perdomain_pts); +free_perdomain_mappings (d); +if ( !is_hvm_domain (d) ) +free_xenheap_page (d->arch.pv_domain.gdt_ldt_l1tab);return rc; }void arch_domain_destroy (struct domain *d) { -unsigned int i; -if (is_hvm_domain (d) )hvm_domain_destroy (d);else
@@ -634,13 +607,9 @@ void arch_domain_destroy(struct domain *mapcache_domain_exit (d); -for ( i =0 ; i <PDPT_L2_ENTRIES ; ++i ) -free_xenheap_page (d->arch.perdomain_pts[i]); -free_xenheap_page (d->arch.perdomain_pts); -for ( i =0 ; i <PERDOMAIN_SLOTS ; ++i) -if ( d->arch.perdomain_l2_pg[i] ) -free_domheap_page (d->arch.perdomain_l2_pg[i]); -free_domheap_page (d->arch.perdomain_l3_pg); +free_perdomain_mappings (d); +if ( !is_hvm_domain (d) ) +free_xenheap_page (d->arch.pv_domain.gdt_ldt_l1tab);free_xenheap_page (d->shared_info);cleanup_domain_irq_mapping (d);
@@ -1515,10 +1484,11 @@ static void __context_switch(void)if (need_full_gdt (n) ) {unsigned long mfn =virt_to_mfn (gdt); +l1_pgentry_t *pl1e =gdt_ldt_ptes (n->domain, n);unsigned int i; +for ( i =0 ; i <NR_RESERVED_GDT_PAGES ; i++ ) -l1e_write (n->arch.perdomain_ptes + -FIRST_RESERVED_GDT_PAGE + i, +l1e_write (pl1e +FIRST_RESERVED_GDT_PAGE + i,l1e_from_pfn (mfn + i, __PAGE_HYPERVISOR)); }
xen/arch/x86/domain_page.c +23 -104
175 lines not on this page · raw message
xen/arch/x86/mm.c +181 -7
244 lines not on this page · raw message
xen/include/asm-x86/config.h +2 -8
@@ -304,19 +304,13 @@ extern unsigned long xen_phys_start;#define LDT_VIRT_START (v) \ (GDT_VIRT_START(v) + (64*1024)) -/* map_domain_page() map cache. The last per-domain-mapping sub-area. */ +/* map_domain_page() map cache. The second per-domain-mapping sub-area. */ #define MAPCACHE_VCPU_ENTRIES (CONFIG_PAGING_LEVELS * CONFIG_PAGING_LEVELS)#define MAPCACHE_ENTRIES (MAX_VIRT_CPUS * MAPCACHE_VCPU_ENTRIES) -#define MAPCACHE_SLOT (PERDOMAIN_SLOTS - 1) -#define MAPCACHE_VIRT_START PERDOMAIN_VIRT_SLOT(MAPCACHE_SLOT) +#define MAPCACHE_VIRT_START PERDOMAIN_VIRT_SLOT(1)#define MAPCACHE_VIRT_END (MAPCACHE_VIRT_START + \ MAPCACHE_ENTRIES * PAGE_SIZE) -#define PDPT_L1_ENTRIES \ - ((PERDOMAIN_VIRT_SLOT(PERDOMAIN_SLOTS - 1) - PERDOMAIN_VIRT_START) >> PAGE_SHIFT) -#define PDPT_L2_ENTRIES \ - ((PDPT_L1_ENTRIES + (1 << PAGETABLE_ORDER) - 1) >> PAGETABLE_ORDER) -#define ELFSIZE 64#define ARCH_CRASH_SAVE_VMCOREINFO
xen/include/asm-x86/domain.h +5 -11
@@ -223,6 +223,8 @@ struct time_scale {struct pv_domain { +l1_pgentry_t **gdt_ldt_l1tab; +/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn;
@@ -241,8 +243,6 @@ struct pv_domainstruct arch_domain { -void **perdomain_pts; -struct page_info *perdomain_l2_pg[PERDOMAIN_SLOTS ];struct page_info *perdomain_l3_pg;unsigned int hv_compat_vstart;
@@ -318,10 +318,10 @@ struct arch_domain#define has_arch_pdevs (d) (!list_empty(&(d)->arch.pdev_list))#define has_arch_mmios (d) (!rangeset_is_empty((d)->iomem_caps)) -#define perdomain_pt_idx (v) \ +#define gdt_ldt_pt_idx (v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) -#define perdomain_ptes (d, v) \ - ((l1_pgentry_t *)(d)->arch.perdomain_pts[perdomain_pt_idx(v)] + \ +#define gdt_ldt_ptes (d, v) \ + ((d)->arch.pv_domain.gdt_ldt_l1tab[gdt_ldt_pt_idx(v)] + \ (((v)->vcpu_id << GDT_LDT_VCPU_SHIFT) & (L1_PAGETABLE_ENTRIES - 1)))struct pv_vcpu
@@ -406,12 +406,6 @@ struct arch_vcpustruct hvm_vcpu hvm_vcpu; }; -/* -* Every domain has a L1 pagetable of its own. Per-domain mappings -* are put in this table (eg. the current GDT is mapped here). -*/ -l1_pgentry_t *perdomain_ptes; -pagetable_t guest_table_user;/* (MFN) x86/64 user-space pagetable */ pagetable_t guest_table;/* (MFN) guest notion of cr3 */ /* guest_table holds a ref to the page, and also a type-count unless
xen/include/asm-x86/mm.h +8 -0
@@ -573,6 +573,14 @@ int donate_page(int map_ldt_shadow_page (unsigned int ); +#define NIL (type) ((type *)NULL - 1) +#define IS_NIL (ptr) (!((ptr) + 1)) + +int create_perdomain_mapping (struct domain *,unsigned long va, +unsigned int nr,l1_pgentry_t **, +struct page_info **); +void free_perdomain_mappings (struct domain *); +extern int memory_add (unsigned long spfn,unsigned long epfn,unsigned int pxm);void domain_set_alloc_bitsize (struct domain *d);
x86: introduce create_perdomain_mapping()
... as well as free_perdomain_mappings(), and use them to carry out the existing per-domain mapping setup/teardown. This at once makes the setup of the first sub-range PV domain specific (with idle domains also excluded), as the GDT/LDT mapping area is needed only for those.
Also fix an improperly scaled BUILD_BUG_ON() expression in mapcache_domain_init().
xen/arch/x86/domain.c +31 -61
153 lines not on this page · raw message
xen/arch/x86/domain_page.c +23 -104
175 lines not on this page · raw message
xen/arch/x86/mm.c +181 -7
244 lines not on this page · raw message
xen/include/asm-x86/config.h +2 -8
@@ -304,19 +304,13 @@ extern unsigned long xen_phys_start;#define LDT_VIRT_START (v) \ (GDT_VIRT_START(v) + (64*1024)) -/* map_domain_page() map cache. The last per-domain-mapping sub-area. */ +/* map_domain_page() map cache. The second per-domain-mapping sub-area. */ #define MAPCACHE_VCPU_ENTRIES (CONFIG_PAGING_LEVELS * CONFIG_PAGING_LEVELS)#define MAPCACHE_ENTRIES (MAX_VIRT_CPUS * MAPCACHE_VCPU_ENTRIES) -#define MAPCACHE_SLOT (PERDOMAIN_SLOTS - 1) -#define MAPCACHE_VIRT_START PERDOMAIN_VIRT_SLOT(MAPCACHE_SLOT) +#define MAPCACHE_VIRT_START PERDOMAIN_VIRT_SLOT(1)#define MAPCACHE_VIRT_END (MAPCACHE_VIRT_START + \ MAPCACHE_ENTRIES * PAGE_SIZE) -#define PDPT_L1_ENTRIES \ - ((PERDOMAIN_VIRT_SLOT(PERDOMAIN_SLOTS - 1) - PERDOMAIN_VIRT_START) >> PAGE_SHIFT) -#define PDPT_L2_ENTRIES \ - ((PDPT_L1_ENTRIES + (1 << PAGETABLE_ORDER) - 1) >> PAGETABLE_ORDER) -#define ELFSIZE 64#define ARCH_CRASH_SAVE_VMCOREINFO
xen/include/asm-x86/domain.h +5 -11
@@ -223,6 +223,8 @@ struct time_scale {struct pv_domain { +l1_pgentry_t **gdt_ldt_l1tab; +/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn;
@@ -241,8 +243,6 @@ struct pv_domainstruct arch_domain { -void **perdomain_pts; -struct page_info *perdomain_l2_pg[PERDOMAIN_SLOTS ];struct page_info *perdomain_l3_pg;unsigned int hv_compat_vstart;
@@ -318,10 +318,10 @@ struct arch_domain#define has_arch_pdevs (d) (!list_empty(&(d)->arch.pdev_list))#define has_arch_mmios (d) (!rangeset_is_empty((d)->iomem_caps)) -#define perdomain_pt_idx (v) \ +#define gdt_ldt_pt_idx (v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) -#define perdomain_ptes (d, v) \ - ((l1_pgentry_t *)(d)->arch.perdomain_pts[perdomain_pt_idx(v)] + \ +#define gdt_ldt_ptes (d, v) \ + ((d)->arch.pv_domain.gdt_ldt_l1tab[gdt_ldt_pt_idx(v)] + \ (((v)->vcpu_id << GDT_LDT_VCPU_SHIFT) & (L1_PAGETABLE_ENTRIES - 1)))struct pv_vcpu
@@ -406,12 +406,6 @@ struct arch_vcpustruct hvm_vcpu hvm_vcpu; }; -/* -* Every domain has a L1 pagetable of its own. Per-domain mappings -* are put in this table (eg. the current GDT is mapped here). -*/ -l1_pgentry_t *perdomain_ptes; -pagetable_t guest_table_user;/* (MFN) x86/64 user-space pagetable */ pagetable_t guest_table;/* (MFN) guest notion of cr3 */ /* guest_table holds a ref to the page, and also a type-count unless
xen/include/asm-x86/mm.h +8 -0
@@ -573,6 +573,14 @@ int donate_page(int map_ldt_shadow_page (unsigned int ); +#define NIL (type) ((type *)NULL - 1) +#define IS_NIL (ptr) (!((ptr) + 1)) + +int create_perdomain_mapping (struct domain *,unsigned long va, +unsigned int nr,l1_pgentry_t **, +struct page_info **); +void free_perdomain_mappings (struct domain *); +extern int memory_add (unsigned long spfn,unsigned long epfn,unsigned int pxm);void domain_set_alloc_bitsize (struct domain *d);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v2 2/3 x86: rework hypercall argument translation area setup
In reply to Jan Beulich... using the new per-domain mapping management functions, adding destroy_perdomain_mapping() to the previously introduced pair.
Rather than using an order-1 Xen heap allocation, use (currently 2) individual domain heap pages to populate space in the per-domain mapping area.
Also fix a benign off-by-one mistake in is_compat_arg_xlat_range().
xen/arch/x86/mm.c +53 -0
@@ -5657,6 +5657,59 @@ int create_perdomain_mapping(struct domareturn rc; } +void destroy_perdomain_mapping (struct domain *d,unsigned long va, +unsigned int nr) +{ +const l3_pgentry_t *l3tab, *pl3e; + +ASSERT (va >=PERDOMAIN_VIRT_START && + va <PERDOMAIN_VIRT_SLOT (PERDOMAIN_SLOTS )); +ASSERT (!l3_table_offset (va ^ (va + nr *PAGE_SIZE -1 ))); + +if ( !d->arch.perdomain_l3_pg ) +return ; + + l3tab =__map_domain_page (d->arch.perdomain_l3_pg); + pl3e = l3tab +l3_table_offset (va); + +if (l3e_get_flags (*pl3e) & _PAGE_PRESENT ) + { +const l2_pgentry_t *l2tab =map_domain_page (l3e_get_pfn (*pl3e)); +const l2_pgentry_t *pl2e = l2tab +l2_table_offset (va); +unsigned int i =l1_table_offset (va); + +while ( nr ) + { +if (l2e_get_flags (*pl2e) & _PAGE_PRESENT ) + { +l1_pgentry_t *l1tab =map_domain_page (l2e_get_pfn (*pl2e)); + +for ( ; nr && i <L1_PAGETABLE_ENTRIES ; --nr, ++i ) + { +if ( (l1e_get_flags (l1tab[i]) & + (_PAGE_PRESENT | _PAGE_AVAIL0)) == + (_PAGE_PRESENT | _PAGE_AVAIL0) ) +free_domheap_page (l1e_get_page (l1tab[i])); + l1tab[i] =l1e_empty (); + } + +unmap_domain_page (l1tab); + } +else if ( nr + i <L1_PAGETABLE_ENTRIES ) +break ; +else + nr -=L1_PAGETABLE_ENTRIES - i; + + ++pl2e; + i =0 ; + } + +unmap_domain_page (l2tab); + } + +unmap_domain_page (l3tab); +} +void free_perdomain_mappings (struct domain *d) {l3_pgentry_t *l3tab =__map_domain_page (d->arch.perdomain_l3_pg);
xen/arch/x86/usercopy.c +1 -1
@@ -6,8 +6,8 @@* Copyright 2002 Andi Kleen <[email protected]> */ -#include <xen/config.h> #include <xen/lib.h> +#include <xen/sched.h> #include <asm/uaccess.h> unsigned long __copy_to_user_ll (void __user *to,const void *from,unsigned n)
xen/arch/x86/x86_64/mm.c +5 -15
@@ -832,27 +832,17 @@ void __init zap_low_mappings(void) __PAGE_HYPERVISOR); } -void *compat_arg_xlat_virt_base (void ) -{ -return current->arch.compat_arg_xlat; -} -int setup_compat_arg_xlat (struct vcpu *v) { -unsigned int order =get_order_from_bytes (COMPAT_ARG_XLAT_SIZE ); - - v->arch.compat_arg_xlat =alloc_xenheap_pages (order, -MEMF_node (vcpu_to_node (v))); - -return v->arch.compat_arg_xlat ?0 : -ENOMEM ; +return create_perdomain_mapping (v->domain,ARG_XLAT_START (v), +PFN_UP (COMPAT_ARG_XLAT_SIZE ), + NULL, NIL(struct page_info *)); }void free_compat_arg_xlat (struct vcpu *v) { -unsigned int order =get_order_from_bytes (COMPAT_ARG_XLAT_SIZE ); - -free_xenheap_pages (v->arch.compat_arg_xlat, order); - v->arch.compat_arg_xlat =NULL ; +destroy_perdomain_mapping (v->domain,ARG_XLAT_START (v), +PFN_UP (COMPAT_ARG_XLAT_SIZE )); }void cleanup_frame_table (struct mem_hotadd_info *info)
xen/include/asm-x86/config.h +8 -1
@@ -212,7 +212,7 @@ extern unsigned char boot_edid_info[128]/* Slot 260: per-domain mappings (including map cache). */ #define PERDOMAIN_VIRT_START (PML4_ADDR(260))#define PERDOMAIN_SLOT_MBYTES (PML4_ENTRY_BYTES >> (20 + PAGETABLE_ORDER)) -#define PERDOMAIN_SLOTS 2 +#define PERDOMAIN_SLOTS 3#define PERDOMAIN_VIRT_SLOT (s) (PERDOMAIN_VIRT_START + (s) * \ (PERDOMAIN_SLOT_MBYTES << 20))/* Slot 261: machine-to-phys conversion table (256GB). */
@@ -311,6 +311,13 @@ extern unsigned long xen_phys_start;#define MAPCACHE_VIRT_END (MAPCACHE_VIRT_START + \ MAPCACHE_ENTRIES * PAGE_SIZE) +/* Argument translation area. The third per-domain-mapping sub-area. */ +#define ARG_XLAT_VIRT_START PERDOMAIN_VIRT_SLOT(2) +/* Allow for at least one guard page (COMPAT_ARG_XLAT_SIZE being 2 pages): */ +#define ARG_XLAT_VA_SHIFT (2 + PAGE_SHIFT) +#define ARG_XLAT_START (v) \ + (ARG_XLAT_VIRT_START + ((v)->vcpu_id << ARG_XLAT_VA_SHIFT)) +#define ELFSIZE 64#define ARCH_CRASH_SAVE_VMCOREINFO
xen/include/asm-x86/domain.h +0 -3
@@ -442,9 +442,6 @@ struct arch_vcpu/* A secondary copy of the vcpu time info. */ XEN_GUEST_HANDLE (vcpu_time_info_t) time_info_guest; - -void *compat_arg_xlat; - } __cacheline_aligned;/* Shorthands to improve code legibility. */
xen/include/asm-x86/mm.h +2 -0
@@ -579,6 +579,8 @@ int map_ldt_shadow_page(unsigned int);int create_perdomain_mapping (struct domain *,unsigned long va,unsigned int nr,l1_pgentry_t **,struct page_info **); +void destroy_perdomain_mapping (struct domain *,unsigned long va, +unsigned int nr);void free_perdomain_mappings (struct domain *);extern int memory_add (unsigned long spfn,unsigned long epfn,unsigned int pxm);
xen/include/asm-x86/x86_64/uaccess.h +2 -3
@@ -1,16 +1,15 @@#ifndef __X86_64_UACCESS_H#define __X86_64_UACCESS_H -#define COMPAT_ARG_XLAT_VIRT_BASE compat_arg_xlat_virt_base() +#define COMPAT_ARG_XLAT_VIRT_BASE ((void *)ARG_XLAT_START(current))#define COMPAT_ARG_XLAT_SIZE (2*PAGE_SIZE)struct vcpu ; -void *compat_arg_xlat_virt_base (void );int setup_compat_arg_xlat (struct vcpu *v);void free_compat_arg_xlat (struct vcpu *v);#define is_compat_arg_xlat_range (addr, size) ({ \ unsigned long __off; \ __off = (unsigned long)(addr) - (unsigned long)COMPAT_ARG_XLAT_VIRT_BASE; \ - (__off <= COMPAT_ARG_XLAT_SIZE) && \ + (__off < COMPAT_ARG_XLAT_SIZE) && \ ((__off + (unsigned long)(size)) <= COMPAT_ARG_XLAT_SIZE); \ })
x86: rework hypercall argument translation area setup
... using the new per-domain mapping management functions, adding destroy_perdomain_mapping() to the previously introduced pair.
Rather than using an order-1 Xen heap allocation, use (currently 2) individual domain heap pages to populate space in the per-domain mapping area.
Also fix a benign off-by-one mistake in is_compat_arg_xlat_range().
xen/arch/x86/mm.c +53 -0
59 lines not on this page · raw message
xen/arch/x86/usercopy.c +1 -1
@@ -6,8 +6,8 @@* Copyright 2002 Andi Kleen <[email protected]> */ -#include <xen/config.h> #include <xen/lib.h> +#include <xen/sched.h> #include <asm/uaccess.h> unsigned long __copy_to_user_ll (void __user *to,const void *from,unsigned n)
xen/arch/x86/x86_64/mm.c +5 -15
@@ -832,27 +832,17 @@ void __init zap_low_mappings(void) __PAGE_HYPERVISOR); } -void *compat_arg_xlat_virt_base (void ) -{ -return current->arch.compat_arg_xlat; -} -int setup_compat_arg_xlat (struct vcpu *v) { -unsigned int order =get_order_from_bytes (COMPAT_ARG_XLAT_SIZE ); - - v->arch.compat_arg_xlat =alloc_xenheap_pages (order, -MEMF_node (vcpu_to_node (v))); - -return v->arch.compat_arg_xlat ?0 : -ENOMEM ; +return create_perdomain_mapping (v->domain,ARG_XLAT_START (v), +PFN_UP (COMPAT_ARG_XLAT_SIZE ), + NULL, NIL(struct page_info *)); }void free_compat_arg_xlat (struct vcpu *v) { -unsigned int order =get_order_from_bytes (COMPAT_ARG_XLAT_SIZE ); - -free_xenheap_pages (v->arch.compat_arg_xlat, order); - v->arch.compat_arg_xlat =NULL ; +destroy_perdomain_mapping (v->domain,ARG_XLAT_START (v), +PFN_UP (COMPAT_ARG_XLAT_SIZE )); }void cleanup_frame_table (struct mem_hotadd_info *info)
xen/include/asm-x86/config.h +8 -1
@@ -212,7 +212,7 @@ extern unsigned char boot_edid_info[128]/* Slot 260: per-domain mappings (including map cache). */ #define PERDOMAIN_VIRT_START (PML4_ADDR(260))#define PERDOMAIN_SLOT_MBYTES (PML4_ENTRY_BYTES >> (20 + PAGETABLE_ORDER)) -#define PERDOMAIN_SLOTS 2 +#define PERDOMAIN_SLOTS 3#define PERDOMAIN_VIRT_SLOT (s) (PERDOMAIN_VIRT_START + (s) * \ (PERDOMAIN_SLOT_MBYTES << 20))/* Slot 261: machine-to-phys conversion table (256GB). */
@@ -311,6 +311,13 @@ extern unsigned long xen_phys_start;#define MAPCACHE_VIRT_END (MAPCACHE_VIRT_START + \ MAPCACHE_ENTRIES * PAGE_SIZE) +/* Argument translation area. The third per-domain-mapping sub-area. */ +#define ARG_XLAT_VIRT_START PERDOMAIN_VIRT_SLOT(2) +/* Allow for at least one guard page (COMPAT_ARG_XLAT_SIZE being 2 pages): */ +#define ARG_XLAT_VA_SHIFT (2 + PAGE_SHIFT) +#define ARG_XLAT_START (v) \ + (ARG_XLAT_VIRT_START + ((v)->vcpu_id << ARG_XLAT_VA_SHIFT)) +#define ELFSIZE 64#define ARCH_CRASH_SAVE_VMCOREINFO
xen/include/asm-x86/domain.h +0 -3
@@ -442,9 +442,6 @@ struct arch_vcpu/* A secondary copy of the vcpu time info. */ XEN_GUEST_HANDLE (vcpu_time_info_t) time_info_guest; - -void *compat_arg_xlat; - } __cacheline_aligned;/* Shorthands to improve code legibility. */
xen/include/asm-x86/mm.h +2 -0
@@ -579,6 +579,8 @@ int map_ldt_shadow_page(unsigned int);int create_perdomain_mapping (struct domain *,unsigned long va,unsigned int nr,l1_pgentry_t **,struct page_info **); +void destroy_perdomain_mapping (struct domain *,unsigned long va, +unsigned int nr);void free_perdomain_mappings (struct domain *);extern int memory_add (unsigned long spfn,unsigned long epfn,unsigned int pxm);
xen/include/asm-x86/x86_64/uaccess.h +2 -3
@@ -1,16 +1,15 @@#ifndef __X86_64_UACCESS_H#define __X86_64_UACCESS_H -#define COMPAT_ARG_XLAT_VIRT_BASE compat_arg_xlat_virt_base() +#define COMPAT_ARG_XLAT_VIRT_BASE ((void *)ARG_XLAT_START(current))#define COMPAT_ARG_XLAT_SIZE (2*PAGE_SIZE)struct vcpu ; -void *compat_arg_xlat_virt_base (void );int setup_compat_arg_xlat (struct vcpu *v);void free_compat_arg_xlat (struct vcpu *v);#define is_compat_arg_xlat_range (addr, size) ({ \ unsigned long __off; \ __off = (unsigned long)(addr) - (unsigned long)COMPAT_ARG_XLAT_VIRT_BASE; \ - (__off <= COMPAT_ARG_XLAT_SIZE) && \ + (__off < COMPAT_ARG_XLAT_SIZE) && \ ((__off + (unsigned long)(size)) <= COMPAT_ARG_XLAT_SIZE); \ })
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v2 3/3 x86: use linear L1 page table for map_domain_page() page table manipulation
In reply to Jan BeulichThis saves allocation of a Xen heap page for tracking the L1 page table pointers.
xen/arch/x86/domain.c +0 -3
@@ -585,7 +585,6 @@ int arch_domain_create(struct domain *d,free_xenheap_page (d->shared_info);if ( paging_initialised )paging_final_teardown (d); -mapcache_domain_exit (d);free_perdomain_mappings (d);if ( !is_hvm_domain (d) )free_xenheap_page (d->arch.pv_domain.gdt_ldt_l1tab);
@@ -605,8 +604,6 @@ void arch_domain_destroy(struct domain *paging_final_teardown (d); -mapcache_domain_exit (d); -free_perdomain_mappings (d);if ( !is_hvm_domain (d) )free_xenheap_page (d->arch.pv_domain.gdt_ldt_l1tab);
xen/arch/x86/domain_page.c +14 -31
120 lines not on this page · raw message
xen/include/asm-x86/domain.h +1 -3
@@ -53,8 +53,7 @@ struct mapcache_vcpu { };struct mapcache_domain { -/* The PTEs that provide the mappings, and a cursor into the array. */ -l1_pgentry_t **l1tab; +/* The number of array entries, and a cursor into the array. */ unsigned int entries;unsigned int cursor;
@@ -71,7 +70,6 @@ struct mapcache_domain { };int mapcache_domain_init (struct domain *); -void mapcache_domain_exit (struct domain *);int mapcache_vcpu_init (struct vcpu *);void mapcache_override_current (struct vcpu *);
x86: use linear L1 page table for map_domain_page() page table manipulation
This saves allocation of a Xen heap page for tracking the L1 page table pointers.
xen/arch/x86/domain.c +0 -3
@@ -585,7 +585,6 @@ int arch_domain_create(struct domain *d,free_xenheap_page (d->shared_info);if ( paging_initialised )paging_final_teardown (d); -mapcache_domain_exit (d);free_perdomain_mappings (d);if ( !is_hvm_domain (d) )free_xenheap_page (d->arch.pv_domain.gdt_ldt_l1tab);
@@ -605,8 +604,6 @@ void arch_domain_destroy(struct domain *paging_final_teardown (d); -mapcache_domain_exit (d); -free_perdomain_mappings (d);if ( !is_hvm_domain (d) )free_xenheap_page (d->arch.pv_domain.gdt_ldt_l1tab);
xen/arch/x86/domain_page.c +14 -31
120 lines not on this page · raw message
xen/include/asm-x86/domain.h +1 -3
@@ -53,8 +53,7 @@ struct mapcache_vcpu { };struct mapcache_domain { -/* The PTEs that provide the mappings, and a cursor into the array. */ -l1_pgentry_t **l1tab; +/* The number of array entries, and a cursor into the array. */ unsigned int entries;unsigned int cursor;
@@ -71,7 +70,6 @@ struct mapcache_domain { };int mapcache_domain_init (struct domain *); -void mapcache_domain_exit (struct domain *);int mapcache_vcpu_init (struct vcpu *);void mapcache_override_current (struct vcpu *);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 10 lines · Jan Beulich
The main goal being the re-work of the hypercall argument translation area management, this series first breaks out per-domain mapping management into its own set of functions, in order to then use this for setting up the translation areas in per-domain space.
While doing this I also realized that it's pointless for the
map_domain_page()code to track L1 page table pointers in a separate Xen heap page - we can equally well use the linear page table for the manipulations needed here.
Quoted 5 lines
1: introduce
create_perdomain_mapping()
2: rework hypercall argument translation area setup
3: use linear L1 page table formap_domain_page()page table manipulationSigned-off-by Jan Beulich <[email protected]>
Quoted 5 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel