Skip to content

Commit f869f1b

Browse files
committed
NVIDIA: SAUCE: hw/vfio: adjust alignment for hugepfnmap
Qemu's determination of the VMA address for a region needs an update to handle regions that may be a BAR, but with the actual size of the mapping to not be at a power-of-2 alignment. This happens for the case of Grace based systems, where the device memory is exposed as a BAR. The mapping however is only of the size of the actual physical memory, which may not be a power-of-2 aligned. This affects hugepfnmap mappings on such regions. The current algorithm determines the VMA address alignment based on the mapping alignment. This needs change so as to be based on the next power-of-2 of the mapping size. This patch updates the algorithm to achieve the alignment. Signed-off-by: Ankit Agrawal <[email protected]>
1 parent e60f89a commit f869f1b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hw/vfio/region.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int vfio_region_mmap(VFIORegion *region)
252252
prot |= region->flags & VFIO_REGION_INFO_FLAG_WRITE ? PROT_WRITE : 0;
253253

254254
for (i = 0; i < region->nr_mmaps; i++) {
255-
size_t align = MIN(1ULL << ctz64(region->mmaps[i].size), 1 * GiB);
255+
size_t align = MIN(pow2ceil(region->mmaps[i].size), 1 * GiB);
256256
void *map_base, *map_align;
257257

258258
/*

0 commit comments

Comments
 (0)