Re: Kernel oops in host caused by mmaping RAM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 13, 2011 at 3:50 PM, Pekka Enberg <penberg@xxxxxxxxxx> wrote:
> On Wed, Apr 13, 2011 at 12:09 AM, Jan Kiszka <jan.kiszka@xxxxxx> wrote:
>> On 2011-04-12 21:41, Sasha Levin wrote:
>>> Hello,
>>>
>>> I've tried using mmap to map the RAM of a guest instead of
>>> posix_memalign which is used both in the kvm tool and qemu.
>>>
>>> Doing so caused a kernel Oops, which happens every time I run the code
>>> and was confirmed both on 2.6.38 and the latest git build of 2.6.39.
>>>
>>
>> Can you share the test case that triggers it? That's easier than
>> guessing what you did precisely.
>
> It's the native Linux kvm tool patched to use mmap() instead of
> posix_memalign(). Sasha, maybe you should post your patch so other
> people can try to reproduce the problem?
>

I provided Jan with a patch to the kvm tool yesterday, Jan has
reproduced the oops and sent a patch to kernel-side KVM to fix it.
Here's the patch for the Linux kvm tool which triggered the oops.

diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index 08ff63c..bac2a5e 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -158,7 +158,6 @@ struct kvm *kvm__init(const char *kvm_dev,
unsigned long ram_size)
 	struct kvm_userspace_memory_region mem;
 	struct kvm_pit_config pit_config = { .flags = 0, };
 	struct kvm *self;
-	long page_size;
 	int ret;

 	if (!kvm__cpu_supports_vm())
@@ -199,8 +198,8 @@ struct kvm *kvm__init(const char *kvm_dev,
unsigned long ram_size)

 	self->ram_size		= ram_size;

-	page_size	= sysconf(_SC_PAGESIZE);
-	if (posix_memalign(&self->ram_start, page_size, self->ram_size) != 0)
+	self->ram_start = mmap(NULL, self->ram_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS, -1, 0);
+	if (self == MAP_FAILED)
 		die("out of memory");

 	mem = (struct kvm_userspace_memory_region) {


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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux