diff mbox

[02/10] kvm tools, powerpc: Use mmap_anon_or_hugetblfs() in kvm__arch_init()

Message ID 1342501220-10209-3-git-send-email-michael@ellerman.id.au
State New, archived
Headers show

Commit Message

Michael Ellerman July 17, 2012, 5 a.m. UTC
It implements essentially the same logic. The one difference is it sets
MAP_NORESERVE when using anonymous mmap, but I think that is OK.

Reword the comment about hugetblfs, we are no longer required to use
hugepages to back the guest.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 tools/kvm/powerpc/kvm.c |   20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/powerpc/kvm.c b/tools/kvm/powerpc/kvm.c
index cbc0d8f..0d8a9da 100644
--- a/tools/kvm/powerpc/kvm.c
+++ b/tools/kvm/powerpc/kvm.c
@@ -97,20 +97,12 @@  void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
 
 	kvm->ram_size		= ram_size;
 
-	/*
-	 * Currently, HV-mode PPC64 SPAPR requires that we map from hugetlfs.
-	 * Allow a 'default' option to assist.
-	 * PR-mode does not require this.
-	 */
-	if (hugetlbfs_path) {
-		if (!strcmp(hugetlbfs_path, "default"))
-			hugetlbfs_path = HUGETLBFS_PATH;
-		kvm->ram_start = mmap_hugetlbfs(hugetlbfs_path, kvm->ram_size);
-	} else {
-		kvm->ram_start = mmap(0, kvm->ram_size, PROT_READ | PROT_WRITE,
-				      MAP_ANON | MAP_PRIVATE,
-				      -1, 0);
-	}
+	/* Map "default" hugetblfs path to the standard 16M mount point */
+	if (hugetlbfs_path && !strcmp(hugetlbfs_path, "default"))
+		hugetlbfs_path = HUGETLBFS_PATH;
+
+	kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, kvm->ram_size);
+
 	if (kvm->ram_start == MAP_FAILED)
 		die("Couldn't map %lld bytes for RAM (%d)\n",
 		    kvm->ram_size, errno);