From patchwork Wed Apr 13 12:58:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 703741 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3DCx7cm020950 for ; Wed, 13 Apr 2011 12:59:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753283Ab1DMM7D (ORCPT ); Wed, 13 Apr 2011 08:59:03 -0400 Received: from mail-ww0-f42.google.com ([74.125.82.42]:54148 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752842Ab1DMM7C (ORCPT ); Wed, 13 Apr 2011 08:59:02 -0400 Received: by wwk4 with SMTP id 4so4832624wwk.1 for ; Wed, 13 Apr 2011 05:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=2ahSL5T+v9JNm1HgFNmC4F64IpqdCqAWyPP4WClCNx0=; b=xspr2i5D3O6PZ4ZEHJfT0OfPuAHrFENjgqi+Pktv7yFmBJR1bSzoFy8myuipsSeH8z c9H5MwRiJQo6NIo3YsYcyG/No8r29eKVklfyMRpW3OARvLBlha75++sQTFR4QwfRON3p qiSBxl+7VnGZH6lIBl4T/rj7+o6ytPIyVdYvw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=wPcoi01qb3jL7cRAAEbsTLcI70UA1P8PUOqkDUeoIPY+B4B894SeNW456l0McVOC9O +DZFdJnNxtNYpGHNplHQCNDfMga9Q9/FywDXLxx1e0S0zFF+tYv75sHYBwiXcJIWoBe6 F84QJywN7D0X4h0s7r4mo7euKF7Kxmeg51Iak= Received: by 10.216.35.132 with SMTP id u4mr7164932wea.98.1302699540706; Wed, 13 Apr 2011 05:59:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.88.75 with HTTP; Wed, 13 Apr 2011 05:58:40 -0700 (PDT) In-Reply-To: References: <4DA4BF6D.7000607@web.de> From: Sasha Levin Date: Wed, 13 Apr 2011 15:58:40 +0300 Message-ID: Subject: Re: Kernel oops in host caused by mmaping RAM To: Pekka Enberg Cc: Jan Kiszka , kvm@vger.kernel.org Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 13 Apr 2011 12:59:08 +0000 (UTC) On Wed, Apr 13, 2011 at 3:50 PM, Pekka Enberg wrote: > On Wed, Apr 13, 2011 at 12:09 AM, Jan Kiszka 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. 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;