Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mshv: Allow mappings that overlap in uaddr

Currently the MSHV driver rejects mappings that would overlap in
userspace.

Some VMMs require the same memory to be mapped to different parts of
the guest's address space, and so working around this restriction is
difficult.

The hypervisor itself doesn't prohibit mappings that overlap in uaddr,
(really in SPA; system physical addresses), so supporting this in the
driver doesn't require any extra work: only the checks need to be
removed.

Since no userspace code until now has been able to overlap regions in
userspace, relaxing this constraint can't break any existing code.

Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Magnus Kulke and committed by
Wei Liu
f91bc8f6 ba9eb9b8

+3 -7
+2 -6
drivers/hv/mshv_root_main.c
··· 1188 1188 1189 1189 /* Reject overlapping regions */ 1190 1190 hlist_for_each_entry(rg, &partition->pt_mem_regions, hnode) { 1191 - u64 rg_size = rg->nr_pages << HV_HYP_PAGE_SHIFT; 1192 - 1193 - if ((mem->guest_pfn + nr_pages <= rg->start_gfn || 1194 - rg->start_gfn + rg->nr_pages <= mem->guest_pfn) && 1195 - (mem->userspace_addr + mem->size <= rg->start_uaddr || 1196 - rg->start_uaddr + rg_size <= mem->userspace_addr)) 1191 + if (mem->guest_pfn + nr_pages <= rg->start_gfn || 1192 + rg->start_gfn + rg->nr_pages <= mem->guest_pfn) 1197 1193 continue; 1198 1194 1199 1195 return -EEXIST;
+1 -1
include/uapi/linux/mshv.h
··· 89 89 * @rsvd: MBZ 90 90 * 91 91 * Map or unmap a region of userspace memory to Guest Physical Addresses (GPA). 92 - * Mappings can't overlap in GPA space or userspace. 92 + * Mappings can't overlap in GPA space. 93 93 * To unmap, these fields must match an existing mapping. 94 94 */ 95 95 struct mshv_user_mem_region {