Subject: linux-next: manual merge of the kvm tree with the s390 tree

From: Stephen Rothwell <[email-masked]>
Date: Tue, 7 Oct 2014 15:59:26 +1100

Hi all,

Today's linux-next merge of the kvm tree got a conflict in
arch/s390/mm/pgtable.c between commit 9511571c4f0e ("s390: mm: fixing
calls of pte_unmap_unlock") from the s390 tree and commit dc77d344b41f
("KVM: s390/mm: fix up indentation of set_guest_storage_key") from the
kvm tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwell                    [email-masked]

diff --cc arch/s390/mm/pgtable.c
index a0f934a435e2,296b61a4af59..000000000000
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@@ -644,82 -656,29 +656,29 @@@ void __gmap_zap(struct gmap *gmap, unsi
  	}
  	pgste_set_unlock(ptep, pgste);
  out_pte:
 -	pte_unmap_unlock(*ptep, ptl);
 +	pte_unmap_unlock(ptep, ptl);
  }
- 
- /*
-  * this function is assumed to be called with mmap_sem held
-  */
- void __gmap_zap(unsigned long address, struct gmap *gmap)
- {
- 	unsigned long *table, *segment_ptr;
- 	unsigned long segment, pgstev, ptev;
- 	struct gmap_pgtable *mp;
- 	struct page *page;
- 
- 	segment_ptr = gmap_table_walk(address, gmap);
- 	if (IS_ERR(segment_ptr))
- 		return;
- 	segment = *segment_ptr;
- 	if (segment & _SEGMENT_ENTRY_INVALID)
- 		return;
- 	page = pfn_to_page(segment >> PAGE_SHIFT);
- 	mp = (struct gmap_pgtable *) page->index;
- 	address = mp->vmaddr | (address & ~PMD_MASK);
- 	/* Page table is present */
- 	table = (unsigned long *)(segment & _SEGMENT_ENTRY_ORIGIN);
- 	table = table + ((address >> 12) & 0xff);
- 	pgstev = table[PTRS_PER_PTE];
- 	ptev = table[0];
- 	/* quick check, checked again with locks held */
- 	if (((pgstev & _PGSTE_GPS_USAGE_MASK) == _PGSTE_GPS_USAGE_UNUSED) ||
- 	    ((pgstev & _PGSTE_GPS_ZERO) && (ptev & _PAGE_INVALID)))
- 		gmap_zap_unused(gmap->mm, address);
- }
  EXPORT_SYMBOL_GPL(__gmap_zap);
  
- void gmap_discard(unsigned long from, unsigned long to, struct gmap *gmap)
+ void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to)
  {
- 
- 	unsigned long *table, address, size;
+ 	unsigned long gaddr, vmaddr, size;
  	struct vm_area_struct *vma;
- 	struct gmap_pgtable *mp;
- 	struct page *page;
  
  	down_read(&gmap->mm->mmap_sem);
- 	address = from;
- 	while (address < to) {
- 		/* Walk the gmap address space page table */
- 		table = gmap->table + ((address >> 53) & 0x7ff);
- 		if (unlikely(*table & _REGION_ENTRY_INVALID)) {
- 			address = (address + PMD_SIZE) & PMD_MASK;
- 			continue;
- 		}
- 		table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
- 		table = table + ((address >> 42) & 0x7ff);
- 		if (unlikely(*table & _REGION_ENTRY_INVALID)) {
- 			address = (address + PMD_SIZE) & PMD_MASK;
+ 	for (gaddr = from; gaddr < to;
+ 	     gaddr = (gaddr + PMD_SIZE) & PMD_MASK) {
+ 		/* Find the vm address for the guest address */
+ 		vmaddr = (unsigned long)
+ 			radix_tree_lookup(&gmap->guest_to_host,
+ 					  gaddr >> PMD_SHIFT);
+ 		if (!vmaddr)
  			continue;
- 		}
- 		table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
- 		table = table + ((address >> 31) & 0x7ff);
- 		if (unlikely(*table & _REGION_ENTRY_INVALID)) {
- 			address = (address + PMD_SIZE) & PMD_MASK;
- 			continue;
- 		}
- 		table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
- 		table = table + ((address >> 20) & 0x7ff);
- 		if (unlikely(*table & _SEGMENT_ENTRY_INVALID)) {
- 			address = (address + PMD_SIZE) & PMD_MASK;
- 			continue;
- 		}
- 		page = pfn_to_page(*table >> PAGE_SHIFT);
- 		mp = (struct gmap_pgtable *) page->index;
- 		vma = find_vma(gmap->mm, mp->vmaddr);
- 		size = min(to - address, PMD_SIZE - (address & ~PMD_MASK));
- 		zap_page_range(vma, mp->vmaddr | (address & ~PMD_MASK),
- 			       size, NULL);
- 		address = (address + PMD_SIZE) & PMD_MASK;
+ 		vmaddr |= gaddr & ~PMD_MASK;
+ 		/* Find vma in the parent mm */
+ 		vma = find_vma(gmap->mm, vmaddr);
+ 		size = min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK));
+ 		zap_page_range(vma, vmaddr, size, NULL);
  	}
  	up_read(&gmap->mm->mmap_sem);
  }
@@@ -994,13 -943,13 +943,13 @@@ retry
  	}
  	if (!(pte_val(*ptep) & _PAGE_INVALID) &&
  	     (pte_val(*ptep) & _PAGE_PROTECT)) {
- 			pte_unmap_unlock(ptep, ptl);
- 			if (fixup_user_fault(current, mm, addr, FAULT_FLAG_WRITE)) {
- 				up_read(&mm->mmap_sem);
- 				return -EFAULT;
- 			}
- 			goto retry;
 -		pte_unmap_unlock(*ptep, ptl);
++		pte_unmap_unlock(ptep, ptl);
+ 		if (fixup_user_fault(current, mm, addr, FAULT_FLAG_WRITE)) {
+ 			up_read(&mm->mmap_sem);
+ 			return -EFAULT;
  		}
+ 		goto retry;
+ 	}
  
  	new = old = pgste_get_lock(ptep);
  	pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT |