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 <james.r.harris@intel.com>
Change-Id: I1644bb6d8a8fb1fd51a548ae7a17da061c18c669

Reviewed-on: https://review.gerrithub.io/c/445764
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jim Harris 2019-02-21 04:30:19 -07:00 committed by Changpeng Liu
parent c12a254083
commit 7739a1f338

View File

@ -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;
}