From 7739a1f3387f3e630ad2eca33c0a83011c71d74c Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 21 Feb 2019 04:30:19 -0700 Subject: [PATCH] vhost: use mmap_size to check for 2MB hugepage multiple Older versions of QEMU (<= 2.11) expose the VGA BIOS hole (0xA0000-0xBFFFF) by specifying two separate memory regions - one before and one after the hole. This results in the "size" not being a 2MB multiple. But the underlying memory is still mmaped at a 2MB multiple - so that's what we should be checking to ensure the memory is hugepage backed. Fixes #673. Signed-off-by: Jim Harris Change-Id: I1644bb6d8a8fb1fd51a548ae7a17da061c18c669 Reviewed-on: https://review.gerrithub.io/c/445764 Reviewed-by: Changpeng Liu Reviewed-by: Darek Stojaczyk Tested-by: SPDK CI Jenkins --- lib/vhost/vhost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 412f27902..ee8f13277 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1095,8 +1095,11 @@ start_device(int vid) } for (i = 0; i < vsession->mem->nregions; i++) { - if (vsession->mem->regions[i].size & MASK_2MB) { - SPDK_ERRLOG("vhost device %d: Guest memory size is not a 2MB multiple\n", vid); + uint64_t mmap_size = vsession->mem->regions[i].mmap_size; + + if (mmap_size & MASK_2MB) { + SPDK_ERRLOG("vhost device %d: Guest mmaped memory size %" PRIx64 + " is not a 2MB multiple\n", vid, mmap_size); free(vsession->mem); goto out; }