Skip to contentSkip to conversation

linux-next: manual merge of the kvm-arm tree with the kvm-arm-fixes tree

PATCH Mark Brown 1 participant 1 message Nov 24

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

Hi all,

Today's linux-next merge of the kvm-arm tree got a conflict in:

arch/arm64/kvm/mmu.c

between commit:

fb92b5981ae3c ("KVM: arm64: Fix THP block mapping when the PMD level is folded")

from the kvm-arm-fixes tree and commit:

9da9b26ce1aca ("KVM: arm64: Fast fail transparent_hugepage_adjust() for non-PMD folios")

from the kvm-arm tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

arch/arm64/kvm/mmu.c +0 -0
diff --cc arch/arm64/kvm/mmu.c
index a0d4981ebb998,042dc53267cb3..0000000000000
@@@ -1564,25 -1566,31 +1566,31 @@@ transparent_hugepage_adjust(const struc
  	 * sure that the HVA and IPA are sufficiently aligned and that the
  	 * block map is contained within the memslot.
  	 */
- 	if (fault_supports_stage2_huge_mapping(s2fd, PMD_SIZE)) {
- 		int sz = get_user_mapping_size(kvm, s2fd->hva);
+ 	if (!fault_supports_stage2_huge_mapping(s2fd, PMD_SIZE))
+ 		return PAGE_SIZE;
  
- 		if (sz < 0)
- 			return sz;
+ 	/*
+ 	 * If the allocated folio isn't at least PMD_SIZE, there is no way a
+ 	 * stage-1 PMD level was installed.
+ 	 */
+ 	if (s2vi->page && !folio_test_pmd_mappable(page_folio(s2vi->page)))
+ 		return PAGE_SIZE;
  
- 		if (sz < PMD_SIZE)
- 			return PAGE_SIZE;
+ 	/*
+ 	 * Even though the folio size is big enough, the stage-1 mapping might
+ 	 * have been split. Verify it.
+ 	 */
+ 	sz = get_user_mapping_size(kvm, s2fd->hva);
+ 	if (sz < 0)
+ 		return sz;
  
- 		gfn = ALIGN_DOWN(gfn, PMD_SIZE >> PAGE_SHIFT);
- 		*gfnp = gfn;
- 		pfn = ALIGN_DOWN(pfn, PMD_SIZE >> PAGE_SHIFT);
- 		*pfnp = pfn;
+ 	if (sz < PMD_SIZE)
+ 		return PAGE_SIZE;
  
- 		return PMD_SIZE;
- 	}
 -	*gfnp &= ~(PTRS_PER_PMD - 1);
 -	*pfnp &= ~(PTRS_PER_PMD - 1);
++	*gfnp = ALIGN_DOWN(*gfnp, PMD_SIZE >> PAGE_SHIFT);
++	*pfnp = ALIGN_DOWN(*pfnp, PMD_SIZE >> PAGE_SHIFT);
  
- 	/* Use page mapping if we cannot use block mapping. */
- 	return PAGE_SIZE;
+ 	return PMD_SIZE;
  }
  
  static int get_vma_page_shift(struct vm_area_struct *vma)