Skip to contentSkip to conversation

kvm: make --mem-path memory allocation depend on mmu notifiers

PATCH Marcelo Tosatti 3 participants 5 messages Jan 13, 2009 – Jan 14, 2009 KVM

lore
Share & tools
lore
#0 lore raw

Without mmu notifiers usage of hugepages to back guest memory can cause memory corruption.

qemu/vl.c +5 -0
index d0660ab..49cf066 100644
@@ -4664,6 +4664,11 @@ void *alloc_mem_area(size_t memory, unsigned long *len, const char *path)
     void *area;
     int fd;
 
+    if (!kvm_has_sync_mmu()) {
+        fprintf(stderr, "host lacks mmu notifiers, disabling --mem-path\n");
+        return NULL;
+    }
+
     if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1)
 	return NULL;
 
#1 lore raw
Quoted 3 lines · Marcelo Tosatti

Without mmu notifiers usage of hugepages to back guest memory can cause memory corruption.

Really? Why's that? Sorry if I missed a previous discussion of this.

Regards,

Anthony Liguori

Quoted 24 lines
qemu/vl.c +5 -1
index d0660ab..49cf066 100644
@@ -4664,6 +4664,11 @@ void *alloc_mem_area(size_t memory, unsigned long *len, const char *path)
     void *area;
     int fd;
 
+    if (!kvm_has_sync_mmu()) {
+        fprintf(stderr, "host lacks mmu notifiers, disabling --mem-path\n");
+        return NULL;
+    }
+
     if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1)
 	return NULL;
 
--

To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Marcelo Tosatti
Quoted 12 lines · Marcelo Tosatti

Without mmu notifiers usage of hugepages to back guest memory can cause memory corruption.

qemu/vl.c +0 -0
index d0660ab..49cf066 100644
@@ -4664,6 +4664,11 @@ void *alloc_mem_area(size_t memory, unsigned long *len, const char *path)
     void *area;

qemu/vl.c void *alloc_mem_area(size_t memory, unsigned long *len, const char *path) · line 4674

Quoted 10 lines
qemu/vl.c +5 -0
     int fd;
 
+    if (!kvm_has_sync_mmu()) {
+        fprintf(stderr, "host lacks mmu notifiers, disabling --mem-path\n");
+        return NULL;
+    }
+
     if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1)
 	return NULL;
 

That means you can't use hugepages with RHEL5 as the host OS. That's not good for me. I've exclusively used hugepages for the past 6 months or so, the past 2 months with RHEL5 as the host OS without a problem. How likely is it to occur (theoretically possible or random selection)?

david

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 17 lines · David S. Ahern
Quoted 14 lines · Marcelo Tosatti

Without mmu notifiers usage of hugepages to back guest memory can cause memory corruption.

qemu/vl.c +0 -0
index d0660ab..49cf066 100644
@@ -4664,6 +4664,11 @@ void *alloc_mem_area(size_t memory, unsigned long *len, const char *path)
     void *area;
     int fd;
 
Quoted 13 lines

qemu/vl.c void *alloc_mem_area(size_t memory, unsigned long *len, const char *path) · line 4674

Quoted 8 lines
qemu/vl.c +5 -0
+    if (!kvm_has_sync_mmu()) {
+        fprintf(stderr, "host lacks mmu notifiers, disabling --mem-path\n");
+        return NULL;
+    }
+
     if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1)
 	return NULL;
 

That means you can't use hugepages with RHEL5 as the host OS. That's not good for me. I've exclusively used hugepages for the past 6 months or so, the past 2 months with RHEL5 as the host OS without a problem. How likely is it to occur (theoretically possible or random selection)?

What happens is that hugetlbfs quota accounting structures are freed before the huge pages which kvm holds the last reference for are freed.

So the huge page freeing function may write to memory that might have been reallocated for some other purpose.

... but only since

commit c79fb75e5a514a5a35f22c229042aa29f4237e3a

Author: Adam Litke <[email protected]>
Date:   Wed Nov 14 16:59:38 2007 -0800

hugetlb: fix quota management for private mappings

Which is not included in RHEL5 in particular, so one can comment out the kvm_has_sync_mmu check.