Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1569923pxb; Thu, 4 Feb 2021 17:09:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrAuD7nzw6ZLmexl5C/S2uCSrIcozrhoVP0cEUOuMcIZJUfQU4gXH0AtJ8lgDMccEXtqa9 X-Received: by 2002:a05:6402:3589:: with SMTP id y9mr1234942edc.344.1612487390946; Thu, 04 Feb 2021 17:09:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612487390; cv=none; d=google.com; s=arc-20160816; b=KJcdDkDFhp7mVb/7MNScwPGcyMklri6RLTBaeujNsnoXmS9xvgUCuMoi8xeDW+7zkI 4Nz/m1vkIXIzFdFOFfL1SUSKKRoMbqnkX/Y8Pxa3nkYivqiT+0TYAG91diFhuUVj9Kba hOD8PkCrf1e8i1V8fYrtQqZY15CWwrl95/6xYHn0JXvo/1SVE+oPCZ2nTTy48Hn0pA+1 22hyd1WqdDLnIwK01CBOdR8HBCohpSbp5f//zVagJ7VNR+TcOUfAUYJdPGek1RZ3CpnE 4NtmP73To2RRROaDbfQSUgW5Y39vyw8c1J9Xjtuq/C8xrZWbMe6B3XKRcl1BMacEKqBL urhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=x+PjH8HpJnneNLcG+4+Oeo3oQm11Q20bM0X1/Klze4c=; b=NxEHbRY/oZZLeL7UBLPtmJ1UbKtxHoQsfK87sy4409l8uAtfFkXtQDyp4rJZG99q5H OWjp7Cw/6K38i9T4ITwN7BcC/4Wd76d0nwsV8VTvZB0evcQxMRf5yVjuhxI0AssMjDEI bVnqTn1gHKdAfjVsKi+ALK0O8fMgqrT1hI3zoWnG00khnQfX+Q0assBRV3fYoFWnpn9G RHc0+hVDfVNLnf9pfoTyh/6z0gnhSRzkE3TbSp0mLTfKdXB3LNSZVhdMEqUgQuGeGxqi 5KKUFTdEj0t2BOL7BnKxmZchbYUSY6ZCpgztrGZqeS9YX7aDswR1oDlSFRFcDgTTiRrm j3Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BJdPmR0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si2900478edp.485.2021.02.04.17.09.27; Thu, 04 Feb 2021 17:09:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BJdPmR0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238505AbhBDRuy (ORCPT + 99 others); Thu, 4 Feb 2021 12:50:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:36688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237500AbhBDRtm (ORCPT ); Thu, 4 Feb 2021 12:49:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 639A164F41; Thu, 4 Feb 2021 17:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612460936; bh=BE4sTc2vQLpAqcnSed7nO8BgiaDvc3jDuHi/BhMHhuw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BJdPmR0qx04Q0OC8F92po0hMHhrRiWvCaxDONmHEOoUlPgCayFyD25VcKG9WAE5Ab dsuh0qli7OfmSqeEkwH0tHklTV6xlGGaJICNA3Bf4Kc2zQEzKSlwDMjJP4OtHhT/Az unbkjzC/50L2YixQX7un0SEMXdb+1hbaD3m5rjR8iUXk/Rs81QPavwoAn0+TmUUQgq c51he+0ZCZ/l4W+Onfm4pbnVfVAQCatI6xGIqlmqFEpLCjf0/tx9tOt5qOom6lDmNU wSXrZoHUHqE8XQVhWEcCQKWNWBHNhIaLyoHPM4WHK/OO4PWoWHpW1XZpP+9r6IK6Aq jy0+RUjalzziw== Date: Thu, 4 Feb 2021 17:48:49 +0000 From: Will Deacon To: Quentin Perret Cc: Catalin Marinas , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Fuad Tabba , Mark Rutland , David Brazdil Subject: Re: [RFC PATCH v2 12/26] KVM: arm64: Introduce a Hyp buddy page allocator Message-ID: <20210204174849.GA21303@willie-the-truck> References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-13-qperret@google.com> <20210202181307.GA17311@willie-the-truck> <20210204143106.GA20792@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 04, 2021 at 02:52:52PM +0000, Quentin Perret wrote: > On Thursday 04 Feb 2021 at 14:31:08 (+0000), Will Deacon wrote: > > On Wed, Feb 03, 2021 at 06:33:30PM +0000, Quentin Perret wrote: > > > On Tuesday 02 Feb 2021 at 18:13:08 (+0000), Will Deacon wrote: > > > > On Fri, Jan 08, 2021 at 12:15:10PM +0000, Quentin Perret wrote: > > > > > + * __find_buddy(pool, page 0, order 0) => page 1 > > > > > + * __find_buddy(pool, page 0, order 1) => page 2 > > > > > + * __find_buddy(pool, page 1, order 0) => page 0 > > > > > + * __find_buddy(pool, page 2, order 0) => page 3 > > > > > + */ > > > > > +static struct hyp_page *__find_buddy(struct hyp_pool *pool, struct hyp_page *p, > > > > > + unsigned int order) > > > > > +{ > > > > > + phys_addr_t addr = hyp_page_to_phys(p); > > > > > + > > > > > + addr ^= (PAGE_SIZE << order); > > > > > + if (addr < pool->range_start || addr >= pool->range_end) > > > > > + return NULL; > > > > > > > > Are these range checks only needed because the pool isn't required to be > > > > an exact power-of-2 pages in size? If so, maybe it would be more > > > > straightforward to limit the max order on a per-pool basis depending upon > > > > its size? > > > > > > More importantly, it is because pages outside of the pool are not > > > guaranteed to be covered by the hyp_vmemmap, so I really need to make > > > sure I don't dereference them. > > > > Wouldn't having a per-pool max order help with that? > > The issue is, I have no alignment guarantees for the pools, so I may end > up with max_order = 0 ... Yeah, so you would still need the range tracking, but it would at least help to reduce HYP_MAX_ORDER failed searches each time. Still, we can always do that later. Will