From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0667AC38A02 for ; Fri, 28 Oct 2022 08:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8bHPoIK6YPudWvyX8vDbDjV431nIvtasq5hA5e9IGcQ=; b=nYAIsJGoil3gHW FKbsDTb9ZCYzEhfaxs5Oe+FXs9D3AY8+QgGP8bEjD//XT/yKXj2UaQ5W90WtzoP9ZFFGnCX9MOqyx t07gjtqb5eTgOkPctfr1Sn4nYptzYRMoc5JBupL/u0EEpwd1JjnoiPTYuTo3KosiktP5CjcDFgnSK 8LOtF5Riy+iwzNlZXi6KM3F04fVwoTD3y5qI+KkOBna40xhMh6InGPulF48lZTj9Xz7A+85Jf235a DfKd/DTbF7uc6PXTEeVbv6fz2U/SVn0WLJsAuXxI6/Iyqi1JTWUvvNV+jxX/49eQZDUrTVtHtfR0A os9rfbEIJ0nKc19hg+MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooKQx-00G6Ch-Oi; Fri, 28 Oct 2022 08:09:43 +0000 Received: from out0.migadu.com ([2001:41d0:2:267::]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooKQu-00G6A6-Mi for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 08:09:42 +0000 Date: Fri, 28 Oct 2022 08:09:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1666944573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JM6jjCOg4B/nBsCLQJUX0tqnjcO62JfElm0bHX5zSwY=; b=UPIe18vexaYmqZWm9yO6uzv/kq8kwiNK6ZQwKNfNajdfLGC8lX+uCs6hzgVZhxkaGWPHA2 2ZKTycrHY+SAbgZd3H9t7FpsRsaoREvEqxoFX0k+J8jE8LO3XWN9Ibe/RwJi7WUd1Ab62s EoSQxaguZtogPxu0k3eDcROy88h/KtA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Cc: kvmarm@lists.linux.dev, Sean Christopherson , Vincent Donnefort , Alexandru Elisei , Catalin Marinas , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Mark Rutland , Fuad Tabba , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 02/25] KVM: arm64: Allow attaching of non-coalescable pages to a hyp pool Message-ID: References: <20221020133827.5541-1-will@kernel.org> <20221020133827.5541-3-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_010941_309134_50B55E2F X-CRM114-Status: GOOD ( 32.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 28, 2022 at 12:17:40AM +0000, Oliver Upton wrote: > On Thu, Oct 20, 2022 at 02:38:04PM +0100, Will Deacon wrote: > > From: Quentin Perret > > > > All the contiguous pages used to initialize a 'struct hyp_pool' are > > considered coalescable, which means that the hyp page allocator will > > actively try to merge them with their buddies on the hyp_put_page() path. > > However, using hyp_put_page() on a page that is not part of the inital > > memory range given to a hyp_pool() is currently unsupported. > > > > In order to allow dynamically extending hyp pools at run-time, add a > > check to __hyp_attach_page() to allow inserting 'external' pages into > > the free-list of order 0. This will be necessary to allow lazy donation > > of pages from the host to the hypervisor when allocating guest stage-2 > > page-table pages at EL2. > > Is it ever going to be the case that we wind up mixing static and > dynamic memory within the same buddy allocator? Reading ahead a bit it > would seem pKVM uses separate allocators (i.e. pkvm_hyp_vm::pool for > donated memory) but just wanted to make sure. > > I suppose what I'm getting at is the fact that the pool range makes > little sense in this case. Adding a field to hyp_pool describing the > type of pool that it is would make this more readable, such that we know > a pool contains only donated memory, and thus zero order pages should > never be coalesced. > > > Tested-by: Vincent Donnefort > > Signed-off-by: Quentin Perret > > Signed-off-by: Will Deacon > > --- > > arch/arm64/kvm/hyp/nvhe/page_alloc.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/page_alloc.c b/arch/arm64/kvm/hyp/nvhe/page_alloc.c > > index 1ded09fc9b10..0d15227aced8 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/page_alloc.c > > +++ b/arch/arm64/kvm/hyp/nvhe/page_alloc.c > > @@ -93,11 +93,15 @@ static inline struct hyp_page *node_to_page(struct list_head *node) > > static void __hyp_attach_page(struct hyp_pool *pool, > > struct hyp_page *p) > > { > > + phys_addr_t phys = hyp_page_to_phys(p); > > unsigned short order = p->order; > > struct hyp_page *buddy; > > > > memset(hyp_page_to_virt(p), 0, PAGE_SIZE << p->order); > > > > + if (phys < pool->range_start || phys >= pool->range_end) > > + goto insert; > > + > > Assuming this is kept as-is... > > This check reads really odd to me, but I understand how it applies to > the use case here. Perhaps create a helper (to be shared with > __find_buddy_nocheck()) and add a nice comment atop it describing the > significance of pages that exist outside the boundaries of the buddy > allocator. Sorry, I'm a moron. The check in __find_buddy_nocheck() is of course necessary and irrelevant to the comment I've made above. But maybe I've proved my point by tripping over it? :-) -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel