xen: remove some checks for always present Xen features
Subsystems (3)
Juergen Gross
maintainerv2 cover xen: remove some checks for always present Xen features
Some features of Xen can be assumed to be always present, so add a central check to verify this being true and remove the other checks.
Juergen Gross (3):
xen: check required Xen features
xen: assume XENFEAT_mmu_pt_update_preserve_ad being set for pv guests
xen: assume XENFEAT_gnttab_map_avail_bits being set for pv guests
arch/x86/xen/enlighten_pv.c | 12 ++---------- arch/x86/xen/mmu_pv.c | 4 ++-- drivers/xen/features.c | 18 ++++++++++++++++++ drivers/xen/gntdev.c | 36 ++---------------------------------- 4 files changed, 24 insertions(+), 46 deletions(-)
Signature · 1 line
2.26.2
Juergen Gross
maintainerPATCH v2 1/3 xen: check required Xen features
Linux kernel is not supported to run on Xen versions older than 4.0.
Add tests for required Xen features always being present in Xen 4.0 and newer.
---
V2:
- rename macro (Boris Ostrovsky)
- panic() in case of missing feature (Boris Ostrovsky)
--- drivers/xen/features.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/xen/features.c +18 -0
@@ -9,13 +9,26 @@#include <linux/types.h> #include <linux/cache.h> #include <linux/export.h> +#include <linux/printk.h> #include <asm/xen/hypercall.h> +#include <xen/xen.h> #include <xen/interface/xen.h> #include <xen/interface/version.h> #include <xen/features.h> +/* +* Linux kernel expects at least Xen 4.0. +* +* Assume some features to be available for that reason (depending on guest +* mode, of course). +*/ +#define chk_required_feature (f) { \ + if (!xen_feature(f)) \ + panic("Xen: feature %s not available!\n", #f); \ + } +u8 xen_features[XENFEAT_NR_SUBMAPS *32 ]__read_mostly ;EXPORT_SYMBOL_GPL (xen_features);
@@ -31,4 +44,9 @@ void xen_setup_features(void)for (j =0 ; j <32 ; j++) xen_features[i *32 + j] = !!(fi.submap &1 <<j); } + +if (xen_pv_domain ()) { +chk_required_feature (XENFEAT_mmu_pt_update_preserve_ad); +chk_required_feature (XENFEAT_gnttab_map_avail_bits); + } }
Signature · 1 line
2.26.2
Juergen Gross
maintainerPATCH v2 2/3 xen: assume XENFEAT_mmu_pt_update_preserve_ad being set for pv guests
In reply to Juergen GrossXENFEAT_mmu_pt_update_preserve_ad is always set in Xen 4.0 and newer. Remove coding assuming it might be zero.
--- arch/x86/xen/enlighten_pv.c | 12 ++---------- arch/x86/xen/mmu_pv.c | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-)
arch/x86/xen/enlighten_pv.c +2 -10
@@ -116,9 +116,8 @@ static void __init xen_banner(void)HYPERVISOR_xen_version (XENVER_extraversion, &extra);pr_info ("Booting paravirtualized kernel on %s\n" , pv_info.name); -printk (KERN_INFO "Xen version: %d.%d%s%s\n" , - version >>16 , version &0xffff , extra.extraversion, -xen_feature (XENFEAT_mmu_pt_update_preserve_ad) ?" (preserve-AD)" :"" ); +pr_info ("Xen version: %d.%d%s (preserve-AD)\n" , + version >>16 , version &0xffff , extra.extraversion); }static void __init xen_pv_init_platform (void )
@@ -1302,13 +1301,6 @@ asmlinkage __visible void __init xen_start_kernel(void)xen_init_apic ();#endif -if (xen_feature (XENFEAT_mmu_pt_update_preserve_ad)) { - pv_ops.mmu.ptep_modify_prot_start = - xen_ptep_modify_prot_start; - pv_ops.mmu.ptep_modify_prot_commit = - xen_ptep_modify_prot_commit; - } - machine_ops = xen_machine_ops;/*
arch/x86/xen/mmu_pv.c +2 -2
@@ -2099,8 +2099,8 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = { .set_pte = xen_set_pte_init, .set_pmd = xen_set_pmd_hyper, - .ptep_modify_prot_start = __ptep_modify_prot_start, - .ptep_modify_prot_commit = __ptep_modify_prot_commit, + .ptep_modify_prot_start = xen_ptep_modify_prot_start, + .ptep_modify_prot_commit = xen_ptep_modify_prot_commit, .pte_val = PV_CALLEE_SAVE(xen_pte_val), .pgd_val = PV_CALLEE_SAVE(xen_pgd_val),
Signature · 1 line
2.26.2
Juergen Gross
maintainerPATCH v2 3/3 xen: assume XENFEAT_gnttab_map_avail_bits being set for pv guests
In reply to Juergen GrossXENFEAT_gnttab_map_avail_bits is always set in Xen 4.0 and newer. Remove coding assuming it might be zero.
--- drivers/xen/gntdev.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-)
drivers/xen/gntdev.c +2 -34
@@ -266,20 +266,13 @@ static int find_grant_ptes(pte_t *pte, unsigned long addr, void *data) {struct gntdev_grant_map *map = data;unsigned int pgnr = (addr - map->vma->vm_start) >>PAGE_SHIFT ; -int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte; +int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte | + (1 << _GNTMAP_guest_avail0);u64 pte_maddr;BUG_ON (pgnr >= map->count); pte_maddr =arbitrary_virt_to_machine (pte).maddr; -/* -* Set the PTE as special to force get_user_pages_fast() fall -* back to the slow path. If this is not supported as part of -* the grant map, it will be done afterwards. -*/ -if (xen_feature (XENFEAT_gnttab_map_avail_bits)) - flags |= (1 << _GNTMAP_guest_avail0); -gnttab_set_map_op (&map->map_ops[pgnr], pte_maddr, flags, map->grants[pgnr].ref, map->grants[pgnr].domid);
@@ -288,14 +281,6 @@ static int find_grant_ptes(pte_t *pte, unsigned long addr, void *data)return 0 ; } -#ifdef CONFIG_X86 -static int set_grant_ptes_as_special (pte_t *pte,unsigned long addr,void *data) -{ -set_pte_at (current->mm, addr, pte,pte_mkspecial (*pte)); -return 0 ; -} -#endif -int gntdev_map_grant_pages (struct gntdev_grant_map *map) {int i, err =0 ;
@@ -1055,23 +1040,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) err =vm_map_pages_zero (vma, map->pages, map->count);if (err) goto out_put_map; - }else { -#ifdef CONFIG_X86 -/* -* If the PTEs were not made special by the grant map -* hypercall, do so here. -* -* This is racy since the mapping is already visible -* to userspace but userspace should be well-behaved -* enough to not touch it until the mmap() call -* returns. -*/ -if (!xen_feature (XENFEAT_gnttab_map_avail_bits)) { -apply_to_page_range (vma->vm_mm, vma->vm_start, - vma->vm_end - vma->vm_start, - set_grant_ptes_as_special,NULL ); - } -#endif }return 0 ;
Signature · 1 line
2.26.2
Quoted 8 lines · Juergen Gross
Some features of Xen can be assumed to be always present, so add a central check to verify this being true and remove the other checks.
Juergen Gross (3):
xen: check required Xen features
xen: assumeXENFEAT_mmu_pt_update_preserve_adbeing set for pv guests
xen: assumeXENFEAT_gnttab_map_avail_bitsbeing set for pv guests
Quoted 5 lines
arch/x86/xen/enlighten_pv.c | 12 ++---------- arch/x86/xen/mmu_pv.c | 4 ++-- drivers/xen/features.c | 18 ++++++++++++++++++ drivers/xen/gntdev.c | 36 ++---------------------------------- 4 files changed, 24 insertions(+), 46 deletions(-)