From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hollis Blanchard Subject: [BUG] virtio-pci queue allocation not page-aligned Date: Tue, 02 Dec 2008 13:08:21 -0600 Message-ID: <1228244901.8128.13.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Anthony Liguori , kvm-devel To: Rusty Russell Return-path: Received: from e2.ny.us.ibm.com ([32.97.182.142]:46941 "EHLO e2.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754204AbYLBTI0 (ORCPT ); Tue, 2 Dec 2008 14:08:26 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e2.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id mB2J7p0K031837 for ; Tue, 2 Dec 2008 14:07:51 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mB2J8MoJ197764 for ; Tue, 2 Dec 2008 14:08:23 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id mB2J8MCC023027 for ; Tue, 2 Dec 2008 14:08:22 -0500 Sender: kvm-owner@vger.kernel.org List-ID: I just spent a number of hours tracking this one down, and I'm not too thrilled about it. vp_find_vq() does the memory allocation for virtio PCI rings, and it uses kzalloc() to do it. This is bad because the ring memory *must* be page-aligned. According to Anthony, at the time this code was written, various slab allocators were checked and all happened to return page-aligned buffers. So how did I hit a problem? I had enabled CONFIG_SLUB_DEBUG_ON while investigating an unrelated problem, which offset the address by 64 bytes. One option is to add a BUG_ON(addr & ~PAGE_MASK) to vp_find_vq(). That's better than nothing, but still stinks. Another is to use Kconfig to express that slab debugging breaks virtio. Also pretty lame IMHO, will look pretty funny in the Kconfig file, and that only solves today's problem. Another slab allocator or a change in behavior of an existing allocator could mean that "ordinary" allocations also become non-page-aligned. Finally, we could use the interface intended for exactly this purpose: the page allocator. If there's some problem with high memory, don't allocate it with GFP_HIGHMEM. -- Hollis Blanchard IBM Linux Technology Center