From patchwork Fri Oct 2 14:09:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 7316691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 59F5A9F1D5 for ; Fri, 2 Oct 2015 14:11:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93A6D208EC for ; Fri, 2 Oct 2015 14:11:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B397208E8 for ; Fri, 2 Oct 2015 14:11:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zi11v-0005sx-7L; Fri, 02 Oct 2015 14:09:47 +0000 Received: from smtp02.citrix.com ([66.165.176.63]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zi11r-0005dq-Lx for linux-arm-kernel@lists.infradead.org; Fri, 02 Oct 2015 14:09:44 +0000 X-IronPort-AV: E=Sophos;i="5.17,623,1437436800"; d="scan'208";a="307679671" Message-ID: <560E9004.8030604@citrix.com> Date: Fri, 2 Oct 2015 15:09:08 +0100 From: David Vrabel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Julien Grall , Subject: Re: [PATCH v5 12/22] xen/balloon: Don't rely on the page granularity is the same for Xen and Linux References: <1443609937-25278-1-git-send-email-julien.grall@citrix.com> <1443609937-25278-13-git-send-email-julien.grall@citrix.com> In-Reply-To: <1443609937-25278-13-git-send-email-julien.grall@citrix.com> X-DLP: MIA1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151002_070944_009984_67DD6C8D X-CRM114-Status: GOOD ( 14.05 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , ian.campbell@citrix.com, Konrad Rzeszutek Wilk , stefano.stabellini@eu.citrix.com, linux-kernel@vger.kernel.org, Boris Ostrovsky , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 30/09/15 11:45, Julien Grall wrote: > For ARM64 guests, Linux is able to support either 64K or 4K page > granularity. Although, the hypercall interface is always based on 4K > page granularity. > > With 64K page granularity, a single page will be spread over multiple > Xen frame. > > To avoid splitting the page into 4K frame, take advantage of the > extent_order field to directly allocate/free chunk of the Linux page > size. > > Note that PVMMU is only used for PV guest (which is x86) and the page > granularity is always 4KB. Some BUILD_BUG_ON has been added to ensure > that because the code has not been modified. This causes a BUG() in x86 PV guests when decreasing the reservation. Xen says: (XEN) d0v2 Error pfn 0: rd=0 od=32753 caf=8000000000000001 taf=7400000000000001 (XEN) memory.c:250:d0v2 Bad page free for domain 0 And Linux BUGs with: [ 82.032654] kernel BUG at /anfs/drall/scratch/davidvr/x86/linux/drivers/xen/balloon.c:540! Which is a non-zero return value from the decrease_reservation hypercall. The frame_list[] has been incorrectly populated. The below patch fixes it for me. Please test as well. /* David --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -504,9 +504,10 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) * Setup the frame, update direct mapping, invalidate P2M, * and add to balloon. */ + i = 0; list_for_each_entry_safe(page, tmp, &pages, lru) { /* XENMEM_decrease_reservation requires a GFN */ - frame_list[i] = xen_page_to_gfn(page); + frame_list[i++] = xen_page_to_gfn(page); #ifdef CONFIG_XEN_HAVE_PVMMU