From e22df3fbcf50b8deddd6c6e1044b39afc3a792b5 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 (master) Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447457 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker --- 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 67da6a887..16ba85383 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1085,8 +1085,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; }