xen: support priv-mapping in an HVM tools domain
Subsystems (3)
PATCH v2 1/1 xen: support priv-mapping in an HVM tools domain
If the domain has XENFEAT_auto_translated_physmap then use of the PV- specific HYPERVISOR_mmu_update hypercall is clearly incorrect.
This patch adds checks in xen_remap_domain_gfn_array() and xen_unmap_domain_gfn_array() which call through to the approprate xlate_mmu function if the feature is present.
This patch also moves xen_remap_domain_gfn_range() into the PV-only MMU code and #ifdefs the (only) calling code in privcmd accordingly.
---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
--- arch/x86/xen/mmu.c | 36 +++++++++++++++++------------------- arch/x86/xen/mmu_pv.c | 11 +++++++++++ drivers/xen/privcmd.c | 17 +++++++++++++---- include/xen/xen-ops.h | 7 +++++++ 4 files changed, 48 insertions(+), 23 deletions(-)
arch/x86/xen/mmu.c +17 -19
@@ -91,12 +91,12 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,return 0 ; } -static int do_remap_gfn (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t *gfn,int nr, -int *err_ptr,pgprot_t prot, -unsigned domid, -struct page **pages) +int xen_remap_gfn (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t *gfn,int nr, +int *err_ptr,pgprot_t prot, +unsigned int domid, +struct page **pages) {int err =0 ;struct remap_data rmd;
@@ -166,36 +166,34 @@ static int do_remap_gfn(struct vm_area_struct *vma,return err <0 ? err : mapped; } -int xen_remap_domain_gfn_range (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t gfn,int nr, -pgprot_t prot,unsigned domid, -struct page **pages) -{ -return do_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, pages); -} -EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range); -int xen_remap_domain_gfn_array (struct vm_area_struct *vma,unsigned long addr,xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot,unsigned domid,struct page **pages) { +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_remap_gfn_array (vma, addr, gfn, nr, err_ptr, + prot, domid, pages); +/* We BUG_ON because it's a programmer error to pass a NULL err_ptr, * and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". */ BUG_ON (err_ptr ==NULL ); -return do_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, pages); +return xen_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, + pages); }EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_array);/* Returns: 0 success */ int xen_unmap_domain_gfn_range (struct vm_area_struct *vma, -int numpgs,struct page **pages) +int nr,struct page **pages) { -if (!pages || !xen_feature (XENFEAT_auto_translated_physmap)) +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_unmap_gfn_range (vma, nr, pages); + +if (!pages)return 0 ;return -EINVAL ;
arch/x86/xen/mmu_pv.c +11 -0
@@ -2670,3 +2670,14 @@ phys_addr_t paddr_vmcoreinfo_note(void) return __pa(vmcoreinfo_note); }#endif /* CONFIG_KEXEC_CORE */ + +int xen_remap_domain_gfn_range (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t gfn,int nr, +pgprot_t prot,unsigned int domid, +struct page **pages) +{ +return xen_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, + pages); +} +EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range);
drivers/xen/privcmd.c +13 -4
@@ -215,6 +215,8 @@ static int traverse_pages_block(unsigned nelem, size_t size,return ret; } +#ifdef CONFIG_XEN_PV + struct mmap_gfn_state { unsigned long va; struct vm_area_struct *vma;
@@ -261,10 +263,6 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)LIST_HEAD (pagelist);struct mmap_gfn_state state; -/* We only support privcmd_ioctl_mmap_batch for auto translated. */ -if (xen_feature (XENFEAT_auto_translated_physmap)) -return -ENOSYS ; -if (copy_from_user (&mmapcmd, udata,sizeof (mmapcmd)))return -EFAULT ;
@@ -312,6 +310,17 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)return rc; } +#else + +static long privcmd_ioctl_mmap (struct file *file,void __user *udata) +{ +/* We only support privcmd_ioctl_mmap for PV. */ +return -ENOSYS ; +} + + +#endif /* CONFIG_XEN_PV */ +struct mmap_batch_state {domid_t domain;unsigned long va;
include/xen/xen-ops.h +7 -0
@@ -60,6 +60,10 @@ static inline void xen_destroy_contiguous_region(phys_addr_t pstart,struct vm_area_struct ; +int xen_remap_gfn (struct vm_area_struct *vma,unsigned long addr, +xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot, +unsigned int domid,struct page **pages); +/* * xen_remap_domain_gfn_array() - map an array of foreign frames * @vma: VMA to map the pages into
@@ -84,6 +88,7 @@ int xen_remap_domain_gfn_array(struct vm_area_struct *vma,unsigned domid, struct page **pages); +#ifdef CONFIG_XEN_PV /* xen_remap_domain_gfn_range() - map a range of foreign frames * @vma: VMA to map the pages into * @addr: Address at which to map the pages
@@ -101,6 +106,8 @@ int xen_remap_domain_gfn_range(struct vm_area_struct *vma, xen_pfn_t gfn, int nr, pgprot_t prot, unsigned domid, struct page **pages); +#endif +int xen_unmap_domain_gfn_range (struct vm_area_struct *vma,int numpgs,struct page **pages); int xen_xlate_remap_gfn_array(struct vm_area_struct *vma,
Signature · 1 line
2.11.0
Juergen Gross
maintainerQuoted 128 lines · Paul Durrant
If the domain has
XENFEAT_auto_translated_physmapthen use of the PV- specificHYPERVISOR_mmu_updatehypercall is clearly incorrect.This patch adds checks in
xen_remap_domain_gfn_array()andxen_unmap_domain_gfn_array()which call through to the appropratexlate_mmufunction if the feature is present.This patch also moves
xen_remap_domain_gfn_range()into the PV-only MMU code and #ifdefs the (only) calling code in privcmd accordingly.Signed-off-by Paul Durrant <[email protected]>---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>--- arch/x86/xen/mmu.c | 36 +++++++++++++++++------------------- arch/x86/xen/mmu_pv.c | 11 +++++++++++ drivers/xen/privcmd.c | 17 +++++++++++++---- include/xen/xen-ops.h | 7 +++++++ 4 files changed, 48 insertions(+), 23 deletions(-)arch/x86/xen/mmu.c +17
-19@@ -91,12 +91,12 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,return 0 ; } -static int do_remap_gfn (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t *gfn,int nr, -int *err_ptr,pgprot_t prot, -unsigned domid, -struct page **pages) +int xen_remap_gfn (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t *gfn,int nr, +int *err_ptr,pgprot_t prot, +unsigned int domid, +struct page **pages) {int err =0 ;struct remap_data rmd;@@ -166,36 +166,34 @@ static int do_remap_gfn(struct vm_area_struct *vma,return err <0 ? err : mapped; } -int xen_remap_domain_gfn_range (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t gfn,int nr, -pgprot_t prot,unsigned domid, -struct page **pages) -{ -return do_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, pages); -} -EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range); -int xen_remap_domain_gfn_array (struct vm_area_struct *vma,unsigned long addr,xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot,unsigned domid,struct page **pages) { +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_remap_gfn_array (vma, addr, gfn, nr, err_ptr, + prot, domid, pages); +/* We BUG_ON because it's a programmer error to pass a NULL err_ptr, * and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". */ BUG_ON (err_ptr ==NULL ); -return do_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, pages); +return xen_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, + pages); }EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_array);/* Returns: 0 success */ int xen_unmap_domain_gfn_range (struct vm_area_struct *vma, -int numpgs,struct page **pages) +int nr,struct page **pages) { -if (!pages || !xen_feature (XENFEAT_auto_translated_physmap)) +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_unmap_gfn_range (vma, nr, pages); + +if (!pages)return 0 ;return -EINVAL ;arch/x86/xen/mmu_pv.c +11
-0@@ -2670,3 +2670,14 @@ phys_addr_t paddr_vmcoreinfo_note(void) return __pa(vmcoreinfo_note); }#endif /* CONFIG_KEXEC_CORE */ + +int xen_remap_domain_gfn_range (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t gfn,int nr, +pgprot_t prot,unsigned int domid, +struct page **pages) +{ +return xen_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, + pages); +} +EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range);drivers/xen/privcmd.c +2
-0@@ -215,6 +215,8 @@ static int traverse_pages_block(unsigned nelem, size_t size,return ret; } +#ifdef CONFIG_XEN_PV + struct mmap_gfn_state { unsigned long va; struct vm_area_struct *vma;
drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata) · line 267
Quoted 7 lines
drivers/xen/privcmd.c +0
-4@@ -261,10 +263,6 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)LIST_HEAD (pagelist);struct mmap_gfn_state state; -/* We only support privcmd_ioctl_mmap_batch for auto translated. */ -if (xen_feature (XENFEAT_auto_translated_physmap)) -return -ENOSYS ; -
CONFIG_XEN_PV doesn't mean we don't support running as HVM guest.
I don't think you can remove this test, nor do I think it makes sense to put privcmd_ioctl_mmap() inside an #ifdef.
You should rather add something like privcmd_ioctl_mmap_pv() with all the PV-specific functionality and call this here. For !CONFIG_XEN_PV it can e.g. just BUG().
Juergen
Quoted 153 lines
-----Original Message-----
From: Juergen Gross [mailto:[email protected]]
Sent: 01 November 2017 13:40
To: Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Boris Ostrovsky <[email protected]>; Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domainQuoted 8 lines · Paul Durrant
If the domain has
XENFEAT_auto_translated_physmapthen use of the PV- specificHYPERVISOR_mmu_updatehypercall is clearly incorrect.This patch adds checks in
xen_remap_domain_gfn_array()andxen_unmap_domain_gfn_array()which call through to the appropratexlate_mmufunction if the feature is present.This patch also moves
xen_remap_domain_gfn_range()into the PV-onlyMMU
arch/x86/xen/mmu.c static int remap_area_mfn_pte_fn(pte_t *ptep,
Quoted 21 lines
code and #ifdefs the (only) calling code in privcmd accordingly.
Signed-off-by Paul Durrant <[email protected]>---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>--- arch/x86/xen/mmu.c | 36 +++++++++++++++++------------------- arch/x86/xen/mmu_pv.c | 11 +++++++++++ drivers/xen/privcmd.c | 17 +++++++++++++---- include/xen/xen-ops.h | 7 +++++++ 4 files changed, 48 insertions(+), 23 deletions(-)arch/x86/xen/mmu.c +0
-0@@ -91,12 +91,12 @@ static int remap_area_mfn_pte_fn(pte_t *ptep,
pgtable_ttoken,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct
Quoted 19 lines
arch/x86/xen/mmu.c +6
-6return 0 ; } -static int do_remap_gfn (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t *gfn,int nr, -int *err_ptr,pgprot_t prot, -unsigned domid, -struct page **pages) +int xen_remap_gfn (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t *gfn,int nr, +int *err_ptr,pgprot_t prot, +unsigned int domid, +struct page **pages) {int err =0 ;struct remap_data rmd;@@ -166,36 +166,34 @@ static int do_remap_gfn(struct vm_area_struct*vma,
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 10 lines
arch/x86/xen/mmu.c +0
-7return err <0 ? err : mapped; } -int xen_remap_domain_gfn_range (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t gfn,int nr, -pgprot_t prot,unsigned domid, -struct page **pages) -{ - return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid,pages);
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 11 lines
arch/x86/xen/mmu.c +2
-3-} -EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range); -int xen_remap_domain_gfn_array (struct vm_area_struct *vma,unsigned long addr,xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot,unsigned domid,struct page **pages) { +if (xen_feature (XENFEAT_auto_translated_physmap)) + return xen_xlate_remap_gfn_array(vma, addr, gfn, nr,
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 3 lines
arch/x86/xen/mmu.c +2
-0+ prot, domid, pages); +/* We BUG_ON because it's a programmer error to pass a NULL
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 5 lines
arch/x86/xen/mmu.c +0
-1* and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". */ BUG_ON (err_ptr ==NULL ); - return do_remap_gfn(vma, addr, gfn, nr, err_ptr, prot, domid,pages);
drivers/xen/privcmd.c static int traverse_pages_block(unsigned nelem,
Quoted 42 lines
arch/x86/xen/mmu.c +7
-2+return xen_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, + pages); }EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_array);/* Returns: 0 success */ int xen_unmap_domain_gfn_range (struct vm_area_struct *vma, -int numpgs,struct page **pages) +int nr,struct page **pages) { -if (!pages || !xen_feature (XENFEAT_auto_translated_physmap)) +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_unmap_gfn_range (vma, nr, pages); + +if (!pages)return 0 ;return -EINVAL ;arch/x86/xen/mmu_pv.c +11
-0@@ -2670,3 +2670,14 @@ phys_addr_t paddr_vmcoreinfo_note(void) return __pa(vmcoreinfo_note); }#endif /* CONFIG_KEXEC_CORE */ + +int xen_remap_domain_gfn_range (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t gfn,int nr, +pgprot_t prot,unsigned int domid, +struct page **pages) +{ +return xen_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, + pages); +} +EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range);drivers/xen/privcmd.c +0
-0@@ -215,6 +215,8 @@ static int traverse_pages_block(unsigned nelem,
size_tsize,drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file,
Quoted 9 lines
drivers/xen/privcmd.c +2
-0return ret; } +#ifdef CONFIG_XEN_PV + struct mmap_gfn_state { unsigned long va; struct vm_area_struct *vma;@@ -261,10 +263,6 @@ static long privcmd_ioctl_mmap(struct file *file,void
__user*udata)drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
Quoted 4 lines
drivers/xen/privcmd.c +0
-1LIST_HEAD (pagelist);struct mmap_gfn_state state; -/* We only support privcmd_ioctl_mmap_batch for auto translated. */
Quoted 8 lines
drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata) · line 267
Quoted 3 lines
drivers/xen/privcmd.c +0
-3-if (xen_feature (XENFEAT_auto_translated_physmap)) -return -ENOSYS ; -
CONFIG_XEN_PVdoesn't mean we don't support running as HVM guest.I don't think you can remove this test, nor do I think it makes sense to put
privcmd_ioctl_mmap()inside an #ifdef.
Ok, I can leave the test in, but I only put the function inside the ifdef at Boris's request (unless I misinterpreted what he meant).
Quoted 5 lines
You should rather add something like
privcmd_ioctl_mmap_pv()with all the PV-specific functionality and call this here. For !CONFIG_XEN_PV it can e.g. justBUG().
Personally, I prefer my original patch where all the changes were kept inside mmu.c. It was much neater.
Paul
Quoted 2 lines
Juergen
Juergen Gross
maintainerQuoted 165 lines · Paul Durrant
Quoted 153 lines
-----Original Message-----
From: Juergen Gross [mailto:[email protected]]
Sent: 01 November 2017 13:40
To: Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Boris Ostrovsky <[email protected]>; Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domainQuoted 8 lines · Paul Durrant
If the domain has
XENFEAT_auto_translated_physmapthen use of the PV- specificHYPERVISOR_mmu_updatehypercall is clearly incorrect.This patch adds checks in
xen_remap_domain_gfn_array()andxen_unmap_domain_gfn_array()which call through to the appropratexlate_mmufunction if the feature is present.This patch also moves
xen_remap_domain_gfn_range()into the PV-onlyMMU
arch/x86/xen/mmu.c static int remap_area_mfn_pte_fn(pte_t *ptep,
Quoted 21 lines
code and #ifdefs the (only) calling code in privcmd accordingly.
Signed-off-by Paul Durrant <[email protected]>---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>--- arch/x86/xen/mmu.c | 36 +++++++++++++++++------------------- arch/x86/xen/mmu_pv.c | 11 +++++++++++ drivers/xen/privcmd.c | 17 +++++++++++++---- include/xen/xen-ops.h | 7 +++++++ 4 files changed, 48 insertions(+), 23 deletions(-)arch/x86/xen/mmu.c +0
-0@@ -91,12 +91,12 @@ static int remap_area_mfn_pte_fn(pte_t *ptep,
pgtable_ttoken,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct
Quoted 19 lines
arch/x86/xen/mmu.c +6
-6return 0 ; } -static int do_remap_gfn (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t *gfn,int nr, -int *err_ptr,pgprot_t prot, -unsigned domid, -struct page **pages) +int xen_remap_gfn (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t *gfn,int nr, +int *err_ptr,pgprot_t prot, +unsigned int domid, +struct page **pages) {int err =0 ;struct remap_data rmd;@@ -166,36 +166,34 @@ static int do_remap_gfn(struct vm_area_struct*vma,
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 10 lines
arch/x86/xen/mmu.c +0
-7return err <0 ? err : mapped; } -int xen_remap_domain_gfn_range (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t gfn,int nr, -pgprot_t prot,unsigned domid, -struct page **pages) -{ - return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid,pages);
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 11 lines
arch/x86/xen/mmu.c +2
-3-} -EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range); -int xen_remap_domain_gfn_array (struct vm_area_struct *vma,unsigned long addr,xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot,unsigned domid,struct page **pages) { +if (xen_feature (XENFEAT_auto_translated_physmap)) + return xen_xlate_remap_gfn_array(vma, addr, gfn, nr,
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 3 lines
arch/x86/xen/mmu.c +2
-0+ prot, domid, pages); +/* We BUG_ON because it's a programmer error to pass a NULL
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 5 lines
arch/x86/xen/mmu.c +0
-1* and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". */ BUG_ON (err_ptr ==NULL ); - return do_remap_gfn(vma, addr, gfn, nr, err_ptr, prot, domid,pages);
drivers/xen/privcmd.c static int traverse_pages_block(unsigned nelem,
Quoted 42 lines
arch/x86/xen/mmu.c +7
-2+return xen_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, + pages); }EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_array);/* Returns: 0 success */ int xen_unmap_domain_gfn_range (struct vm_area_struct *vma, -int numpgs,struct page **pages) +int nr,struct page **pages) { -if (!pages || !xen_feature (XENFEAT_auto_translated_physmap)) +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_unmap_gfn_range (vma, nr, pages); + +if (!pages)return 0 ;return -EINVAL ;arch/x86/xen/mmu_pv.c +11
-0@@ -2670,3 +2670,14 @@ phys_addr_t paddr_vmcoreinfo_note(void) return __pa(vmcoreinfo_note); }#endif /* CONFIG_KEXEC_CORE */ + +int xen_remap_domain_gfn_range (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t gfn,int nr, +pgprot_t prot,unsigned int domid, +struct page **pages) +{ +return xen_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, + pages); +} +EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range);drivers/xen/privcmd.c +0
-0@@ -215,6 +215,8 @@ static int traverse_pages_block(unsigned nelem,
size_tsize,drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file,
Quoted 9 lines
drivers/xen/privcmd.c +2
-0return ret; } +#ifdef CONFIG_XEN_PV + struct mmap_gfn_state { unsigned long va; struct vm_area_struct *vma;@@ -261,10 +263,6 @@ static long privcmd_ioctl_mmap(struct file *file,void
__user*udata)drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
Quoted 4 lines
drivers/xen/privcmd.c +0
-1LIST_HEAD (pagelist);struct mmap_gfn_state state; -/* We only support privcmd_ioctl_mmap_batch for auto translated. */
Quoted 8 lines
drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata) · line 267
Quoted 3 lines
drivers/xen/privcmd.c +0
-3-if (xen_feature (XENFEAT_auto_translated_physmap)) -return -ENOSYS ; -
CONFIG_XEN_PVdoesn't mean we don't support running as HVM guest.I don't think you can remove this test, nor do I think it makes sense to put
privcmd_ioctl_mmap()inside an #ifdef.Ok, I can leave the test in, but I only put the function inside the ifdef at Boris's request (unless I misinterpreted what he meant).
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
You should rather add something like
privcmd_ioctl_mmap_pv()with all the PV-specific functionality and call this here. For !CONFIG_XEN_PV it can e.g. justBUG().Personally, I prefer my original patch where all the changes were kept inside
mmu.c. It was much neater.
Hmm, this was sent (and commented) during my vacation, so I didn't look at it very thoroughly with Boris having done so.
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerQuoted 165 lines · Paul Durrant
Quoted 153 lines
-----Original Message-----
From: Juergen Gross [mailto:[email protected]]
Sent: 01 November 2017 13:40
To: Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Boris Ostrovsky <[email protected]>; Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domainQuoted 8 lines · Paul Durrant
If the domain has
XENFEAT_auto_translated_physmapthen use of the PV- specificHYPERVISOR_mmu_updatehypercall is clearly incorrect.This patch adds checks in
xen_remap_domain_gfn_array()andxen_unmap_domain_gfn_array()which call through to the appropratexlate_mmufunction if the feature is present.This patch also moves
xen_remap_domain_gfn_range()into the PV-onlyMMU
arch/x86/xen/mmu.c static int remap_area_mfn_pte_fn(pte_t *ptep,
Quoted 21 lines
code and #ifdefs the (only) calling code in privcmd accordingly.
Signed-off-by Paul Durrant <[email protected]>---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>--- arch/x86/xen/mmu.c | 36 +++++++++++++++++------------------- arch/x86/xen/mmu_pv.c | 11 +++++++++++ drivers/xen/privcmd.c | 17 +++++++++++++---- include/xen/xen-ops.h | 7 +++++++ 4 files changed, 48 insertions(+), 23 deletions(-)arch/x86/xen/mmu.c +0
-0@@ -91,12 +91,12 @@ static int remap_area_mfn_pte_fn(pte_t *ptep,
pgtable_ttoken,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct
Quoted 19 lines
arch/x86/xen/mmu.c +6
-6return 0 ; } -static int do_remap_gfn (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t *gfn,int nr, -int *err_ptr,pgprot_t prot, -unsigned domid, -struct page **pages) +int xen_remap_gfn (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t *gfn,int nr, +int *err_ptr,pgprot_t prot, +unsigned int domid, +struct page **pages) {int err =0 ;struct remap_data rmd;@@ -166,36 +166,34 @@ static int do_remap_gfn(struct vm_area_struct*vma,
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 10 lines
arch/x86/xen/mmu.c +0
-7return err <0 ? err : mapped; } -int xen_remap_domain_gfn_range (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t gfn,int nr, -pgprot_t prot,unsigned domid, -struct page **pages) -{ - return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid,pages);
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 11 lines
arch/x86/xen/mmu.c +2
-3-} -EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range); -int xen_remap_domain_gfn_array (struct vm_area_struct *vma,unsigned long addr,xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot,unsigned domid,struct page **pages) { +if (xen_feature (XENFEAT_auto_translated_physmap)) + return xen_xlate_remap_gfn_array(vma, addr, gfn, nr,
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 3 lines
arch/x86/xen/mmu.c +2
-0+ prot, domid, pages); +/* We BUG_ON because it's a programmer error to pass a NULL
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 5 lines
arch/x86/xen/mmu.c +0
-1* and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". */ BUG_ON (err_ptr ==NULL ); - return do_remap_gfn(vma, addr, gfn, nr, err_ptr, prot, domid,pages);
drivers/xen/privcmd.c static int traverse_pages_block(unsigned nelem,
Quoted 42 lines
arch/x86/xen/mmu.c +7
-2+return xen_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, + pages); }EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_array);/* Returns: 0 success */ int xen_unmap_domain_gfn_range (struct vm_area_struct *vma, -int numpgs,struct page **pages) +int nr,struct page **pages) { -if (!pages || !xen_feature (XENFEAT_auto_translated_physmap)) +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_unmap_gfn_range (vma, nr, pages); + +if (!pages)return 0 ;return -EINVAL ;arch/x86/xen/mmu_pv.c +11
-0@@ -2670,3 +2670,14 @@ phys_addr_t paddr_vmcoreinfo_note(void) return __pa(vmcoreinfo_note); }#endif /* CONFIG_KEXEC_CORE */ + +int xen_remap_domain_gfn_range (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t gfn,int nr, +pgprot_t prot,unsigned int domid, +struct page **pages) +{ +return xen_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, + pages); +} +EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range);drivers/xen/privcmd.c +0
-0@@ -215,6 +215,8 @@ static int traverse_pages_block(unsigned nelem,
size_tsize,drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file,
Quoted 9 lines
drivers/xen/privcmd.c +2
-0return ret; } +#ifdef CONFIG_XEN_PV + struct mmap_gfn_state { unsigned long va; struct vm_area_struct *vma;@@ -261,10 +263,6 @@ static long privcmd_ioctl_mmap(struct file *file,void
__user*udata)drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
Quoted 4 lines
drivers/xen/privcmd.c +0
-1LIST_HEAD (pagelist);struct mmap_gfn_state state; -/* We only support privcmd_ioctl_mmap_batch for auto translated. */
Quoted 8 lines
drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata) · line 267
Quoted 3 lines
drivers/xen/privcmd.c +0
-3-if (xen_feature (XENFEAT_auto_translated_physmap)) -return -ENOSYS ; -
CONFIG_XEN_PVdoesn't mean we don't support running as HVM guest.I don't think you can remove this test, nor do I think it makes sense to put
privcmd_ioctl_mmap()inside an #ifdef.Ok, I can leave the test in, but I only put the function inside the ifdef at Boris's request (unless I misinterpreted what he meant).
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
You should rather add something like
privcmd_ioctl_mmap_pv()with all the PV-specific functionality and call this here. For !CONFIG_XEN_PV it can e.g. justBUG().Personally, I prefer my original patch where all the changes were kept inside
mmu.c. It was much neater.
Hmm, this was sent (and commented) during my vacation, so I didn't look at it very thoroughly with Boris having done so.
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Juergen
Boris Ostrovsky
reviewerQuoted 4 lines · Juergen Gross
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Having looked at what this turned into I now like V1 better too ;-)
Sorry, Paul.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerQuoted 4 lines · Juergen Gross
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Having looked at what this turned into I now like V1 better too ;-)
Sorry, Paul.
-boris
Quoted 12 lines
-----Original Message-----
From: Boris Ostrovsky [mailto:[email protected]]
Sent: 01 November 2017 18:19
To: Juergen Gross <[email protected]>; Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domainQuoted 1 line · Juergen Gross
Quoted 7 lines
Quoted 3 lines
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Having looked at what this turned into I now like V1 better too ;-)
Sorry, Paul.
That's ok. Are you happy with v1 as-is or do you want me to submit a v3 with any tweaks?
Paul
Quoted 3 lines
-boris
Quoted 10 lines · Paul Durrant
Quoted 10 lines
-----Original Message-----
From: Boris Ostrovsky [mailto:[email protected]]
Sent: 01 November 2017 18:19
To: Juergen Gross <[email protected]>; Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domain
Quoted 8 lines
Quoted 7 lines · Juergen Gross
Quoted 3 lines
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Having looked at what this turned into I now like V1 better too ;-)
Sorry, Paul.
That's ok. Are you happy with v1 as-is or do you want me to submit a v3 with any tweaks?
V1:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 10 lines · Paul Durrant
Quoted 10 lines
-----Original Message-----
From: Boris Ostrovsky [mailto:[email protected]]
Sent: 01 November 2017 18:19
To: Juergen Gross <[email protected]>; Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domain
Quoted 8 lines
Quoted 7 lines · Juergen Gross
Quoted 3 lines
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Having looked at what this turned into I now like V1 better too ;-)
Sorry, Paul.
That's ok. Are you happy with v1 as-is or do you want me to submit a v3 with any tweaks?
V1:
Quoted 12 lines
-----Original Message-----
From: Boris Ostrovsky [mailto:[email protected]]
Sent: 01 November 2017 18:19
To: Juergen Gross <[email protected]>; Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domainQuoted 1 line · Juergen Gross
Quoted 7 lines
Quoted 3 lines
TBH I like V1 better, too.
Boris, do you feel strong about the #ifdef part?
Having looked at what this turned into I now like V1 better too ;-)
Sorry, Paul.
That's ok. Are you happy with v1 as-is or do you want me to submit a v3 with any tweaks?
Paul
Quoted 3 lines
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 153 lines
-----Original Message-----
From: Juergen Gross [mailto:[email protected]]
Sent: 01 November 2017 13:40
To: Paul Durrant <[email protected]>; [email protected]; xen- [email protected]; [email protected]
Cc: Boris Ostrovsky <[email protected]>; Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>
Subject: Re: [PATCH v2] xen: support priv-mapping in an HVM tools domainQuoted 8 lines · Paul Durrant
If the domain has
XENFEAT_auto_translated_physmapthen use of the PV- specificHYPERVISOR_mmu_updatehypercall is clearly incorrect.This patch adds checks in
xen_remap_domain_gfn_array()andxen_unmap_domain_gfn_array()which call through to the appropratexlate_mmufunction if the feature is present.This patch also moves
xen_remap_domain_gfn_range()into the PV-onlyMMU
arch/x86/xen/mmu.c static int remap_area_mfn_pte_fn(pte_t *ptep,
Quoted 21 lines
code and #ifdefs the (only) calling code in privcmd accordingly.
Signed-off-by Paul Durrant <[email protected]>---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>--- arch/x86/xen/mmu.c | 36 +++++++++++++++++------------------- arch/x86/xen/mmu_pv.c | 11 +++++++++++ drivers/xen/privcmd.c | 17 +++++++++++++---- include/xen/xen-ops.h | 7 +++++++ 4 files changed, 48 insertions(+), 23 deletions(-)arch/x86/xen/mmu.c +0
-0@@ -91,12 +91,12 @@ static int remap_area_mfn_pte_fn(pte_t *ptep,
pgtable_ttoken,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct
Quoted 19 lines
arch/x86/xen/mmu.c +6
-6return 0 ; } -static int do_remap_gfn (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t *gfn,int nr, -int *err_ptr,pgprot_t prot, -unsigned domid, -struct page **pages) +int xen_remap_gfn (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t *gfn,int nr, +int *err_ptr,pgprot_t prot, +unsigned int domid, +struct page **pages) {int err =0 ;struct remap_data rmd;@@ -166,36 +166,34 @@ static int do_remap_gfn(struct vm_area_struct*vma,
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 10 lines
arch/x86/xen/mmu.c +0
-7return err <0 ? err : mapped; } -int xen_remap_domain_gfn_range (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t gfn,int nr, -pgprot_t prot,unsigned domid, -struct page **pages) -{ - return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid,pages);
arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 11 lines
arch/x86/xen/mmu.c +2
-3-} -EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range); -int xen_remap_domain_gfn_array (struct vm_area_struct *vma,unsigned long addr,xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot,unsigned domid,struct page **pages) { +if (xen_feature (XENFEAT_auto_translated_physmap)) + return xen_xlate_remap_gfn_array(vma, addr, gfn, nr,
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 3 lines
arch/x86/xen/mmu.c +2
-0+ prot, domid, pages); +/* We BUG_ON because it's a programmer error to pass a NULL
err_ptr,arch/x86/xen/mmu.c static int do_remap_gfn(struct vm_area_struct *vma,
Quoted 5 lines
arch/x86/xen/mmu.c +0
-1* and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". */ BUG_ON (err_ptr ==NULL ); - return do_remap_gfn(vma, addr, gfn, nr, err_ptr, prot, domid,pages);
drivers/xen/privcmd.c static int traverse_pages_block(unsigned nelem,
Quoted 42 lines
arch/x86/xen/mmu.c +7
-2+return xen_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, + pages); }EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_array);/* Returns: 0 success */ int xen_unmap_domain_gfn_range (struct vm_area_struct *vma, -int numpgs,struct page **pages) +int nr,struct page **pages) { -if (!pages || !xen_feature (XENFEAT_auto_translated_physmap)) +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_unmap_gfn_range (vma, nr, pages); + +if (!pages)return 0 ;return -EINVAL ;arch/x86/xen/mmu_pv.c +11
-0@@ -2670,3 +2670,14 @@ phys_addr_t paddr_vmcoreinfo_note(void) return __pa(vmcoreinfo_note); }#endif /* CONFIG_KEXEC_CORE */ + +int xen_remap_domain_gfn_range (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t gfn,int nr, +pgprot_t prot,unsigned int domid, +struct page **pages) +{ +return xen_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, + pages); +} +EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range);drivers/xen/privcmd.c +0
-0@@ -215,6 +215,8 @@ static int traverse_pages_block(unsigned nelem,
size_tsize,drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file,
Quoted 9 lines
drivers/xen/privcmd.c +2
-0return ret; } +#ifdef CONFIG_XEN_PV + struct mmap_gfn_state { unsigned long va; struct vm_area_struct *vma;@@ -261,10 +263,6 @@ static long privcmd_ioctl_mmap(struct file *file,void
__user*udata)drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
Quoted 4 lines
drivers/xen/privcmd.c +0
-1LIST_HEAD (pagelist);struct mmap_gfn_state state; -/* We only support privcmd_ioctl_mmap_batch for auto translated. */
Quoted 8 lines
drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata) · line 267
Quoted 3 lines
drivers/xen/privcmd.c +0
-3-if (xen_feature (XENFEAT_auto_translated_physmap)) -return -ENOSYS ; -
CONFIG_XEN_PVdoesn't mean we don't support running as HVM guest.I don't think you can remove this test, nor do I think it makes sense to put
privcmd_ioctl_mmap()inside an #ifdef.
Ok, I can leave the test in, but I only put the function inside the ifdef at Boris's request (unless I misinterpreted what he meant).
Quoted 5 lines
You should rather add something like
privcmd_ioctl_mmap_pv()with all the PV-specific functionality and call this here. For !CONFIG_XEN_PV it can e.g. justBUG().
Personally, I prefer my original patch where all the changes were kept inside mmu.c. It was much neater.
Paul
Quoted 2 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerQuoted 128 lines · Paul Durrant
If the domain has
XENFEAT_auto_translated_physmapthen use of the PV- specificHYPERVISOR_mmu_updatehypercall is clearly incorrect.This patch adds checks in
xen_remap_domain_gfn_array()andxen_unmap_domain_gfn_array()which call through to the appropratexlate_mmufunction if the feature is present.This patch also moves
xen_remap_domain_gfn_range()into the PV-only MMU code and #ifdefs the (only) calling code in privcmd accordingly.Signed-off-by Paul Durrant <[email protected]>---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>--- arch/x86/xen/mmu.c | 36 +++++++++++++++++------------------- arch/x86/xen/mmu_pv.c | 11 +++++++++++ drivers/xen/privcmd.c | 17 +++++++++++++---- include/xen/xen-ops.h | 7 +++++++ 4 files changed, 48 insertions(+), 23 deletions(-)arch/x86/xen/mmu.c +17
-19@@ -91,12 +91,12 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,return 0 ; } -static int do_remap_gfn (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t *gfn,int nr, -int *err_ptr,pgprot_t prot, -unsigned domid, -struct page **pages) +int xen_remap_gfn (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t *gfn,int nr, +int *err_ptr,pgprot_t prot, +unsigned int domid, +struct page **pages) {int err =0 ;struct remap_data rmd;@@ -166,36 +166,34 @@ static int do_remap_gfn(struct vm_area_struct *vma,return err <0 ? err : mapped; } -int xen_remap_domain_gfn_range (struct vm_area_struct *vma, -unsigned long addr, -xen_pfn_t gfn,int nr, -pgprot_t prot,unsigned domid, -struct page **pages) -{ -return do_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, pages); -} -EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range); -int xen_remap_domain_gfn_array (struct vm_area_struct *vma,unsigned long addr,xen_pfn_t *gfn,int nr,int *err_ptr,pgprot_t prot,unsigned domid,struct page **pages) { +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_remap_gfn_array (vma, addr, gfn, nr, err_ptr, + prot, domid, pages); +/* We BUG_ON because it's a programmer error to pass a NULL err_ptr, * and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". */ BUG_ON (err_ptr ==NULL ); -return do_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, pages); +return xen_remap_gfn (vma, addr, gfn, nr, err_ptr, prot, domid, + pages); }EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_array);/* Returns: 0 success */ int xen_unmap_domain_gfn_range (struct vm_area_struct *vma, -int numpgs,struct page **pages) +int nr,struct page **pages) { -if (!pages || !xen_feature (XENFEAT_auto_translated_physmap)) +if (xen_feature (XENFEAT_auto_translated_physmap)) +return xen_xlate_unmap_gfn_range (vma, nr, pages); + +if (!pages)return 0 ;return -EINVAL ;arch/x86/xen/mmu_pv.c +11
-0@@ -2670,3 +2670,14 @@ phys_addr_t paddr_vmcoreinfo_note(void) return __pa(vmcoreinfo_note); }#endif /* CONFIG_KEXEC_CORE */ + +int xen_remap_domain_gfn_range (struct vm_area_struct *vma, +unsigned long addr, +xen_pfn_t gfn,int nr, +pgprot_t prot,unsigned int domid, +struct page **pages) +{ +return xen_remap_gfn (vma, addr, &gfn, nr,NULL , prot, domid, + pages); +} +EXPORT_SYMBOL_GPL (xen_remap_domain_gfn_range);drivers/xen/privcmd.c +2
-0@@ -215,6 +215,8 @@ static int traverse_pages_block(unsigned nelem, size_t size,return ret; } +#ifdef CONFIG_XEN_PV + struct mmap_gfn_state { unsigned long va; struct vm_area_struct *vma;
drivers/xen/privcmd.c static long privcmd_ioctl_mmap(struct file *file, void __user *udata) · line 267
Quoted 7 lines
drivers/xen/privcmd.c +0
-4@@ -261,10 +263,6 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)LIST_HEAD (pagelist);struct mmap_gfn_state state; -/* We only support privcmd_ioctl_mmap_batch for auto translated. */ -if (xen_feature (XENFEAT_auto_translated_physmap)) -return -ENOSYS ; -
CONFIG_XEN_PV doesn't mean we don't support running as HVM guest.
I don't think you can remove this test, nor do I think it makes sense to put privcmd_ioctl_mmap() inside an #ifdef.
You should rather add something like privcmd_ioctl_mmap_pv() with all the PV-specific functionality and call this here. For !CONFIG_XEN_PV it can e.g. just BUG().
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel