Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1460660pxb; Thu, 4 Mar 2021 11:54:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNhbqU6vkkR0KdLqd6ylWdKIkaZTZx2hYQJtPhvYvXGn/Hs9ifyTr8683rEjOXZXoCkFrq X-Received: by 2002:a05:6402:27d3:: with SMTP id c19mr6348365ede.129.1614887641956; Thu, 04 Mar 2021 11:54:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614887641; cv=none; d=google.com; s=arc-20160816; b=ZTzDp1gZe1ce/hjSkmDrg+VLd4KtpWzA3aWim9SagNu5c/MdLVEG3YMzYB0yBhJPWH LaHaN/wT8cQM1KHM/XemiUAn5cIjXxHd794U1ADoJLaB/Ss0UfJpohRGTbc9tJoXZL9a Zx2bp5D39fNmz3Mf2OAb4LckkvBfLsbSA5kxU76Crq/S2nDH5D0lhvrr/C2vxLiCZZWR N2JsVHqwWhnTmCeg4ukKhRok7UDW+7vWakCHU+4PNvxa8tD8q7EAyHE0WWTv//DHI/Te xWs1Uw03gIHhO3sDS6vU6GiXkX/wqG+LMp9uAuyydmoB4aKjlQnZe9Ci1M29hKp+nfvO ts1Q== 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=wAA6tU8F8zvVZelfSuhUhRIf2C2mSjeaOTFd1zfiGs0=; b=dOd9ZzmXkesDFIMWvMsSn18xOQsG22tpuVDVciBdXaweVO58nw3c3o4idgEtx4cZMM CHTKPZZ2OqWWIiy8nH5r8ClbuAlizn6tg/hSwl46X5/bbEkPNfikBwNCdRE4LcaWXR/N /K9EZNGQ0+py2Ygo2XnFRikAPiQ3NJMqlQxMUkSYKNf1GaqIGPp3TS+S8u3HQ7txQSe7 aD0kmwY3GKXxWGzUgTPH33bE3JvN7y1/9Kcm+3fYLn95NMJymR4eisj0zqYiCeH2Mzu3 r8DJNyEtWXwpIVsXOPYyRhwUhzm2G8RYbi5sVgxhyaycz7gfDb3Zm5o7ShKm6RIG+SnT 2L4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZWQ7DETm; 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 n20si304332edq.273.2021.03.04.11.53.38; Thu, 04 Mar 2021 11:54:01 -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=ZWQ7DETm; 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 S234788AbhCDTup (ORCPT + 99 others); Thu, 4 Mar 2021 14:50:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:47124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233074AbhCDTuj (ORCPT ); Thu, 4 Mar 2021 14:50:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1A1864EAE; Thu, 4 Mar 2021 19:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614887399; bh=rbJBnbip++59oMvemPv0UgOnN48fZ3mavVDtdREo3QA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZWQ7DETmHFsQA6lwmTnfoOa+Q9Irkf5q2C4UmWvL/JHQ1qcalcbNorvEw35hz+pFK 8xBYECCDmudPwtzgrAmwgJM01RAx6E/LJrB2j63eeVfozezpMjmEejrdIhwI+mz06e qsFZL2Nj05tgwwnuoSr4OPQ5L/9dAWEu0qqofN63+Cm+yortNfPgFTx8VFc22FRZ7m KCHjHuhj3rMY3nnoJHdPABwMUgycCUR8/7oHbr9fLK7JwX5Ha5qPzrWEtyNZvLnj03 tBTrUyvzjKvOqBWZzxTVyBfXPVc9km+IZFr70JkBQs5FvYSeXGeKq5Cwf/5Ar3MXBa fZNKsLB56KILg== Date: Thu, 4 Mar 2021 19:49:53 +0000 From: Will Deacon To: Quentin Perret Cc: catalin.marinas@arm.com, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, robh+dt@kernel.org Subject: Re: [PATCH v3 24/32] KVM: arm64: Reserve memory for host stage 2 Message-ID: <20210304194953.GD21950@willie-the-truck> References: <20210302150002.3685113-1-qperret@google.com> <20210302150002.3685113-25-qperret@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210302150002.3685113-25-qperret@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 02, 2021 at 02:59:54PM +0000, Quentin Perret wrote: > Extend the memory pool allocated for the hypervisor to include enough > pages to map all of memory at page granularity for the host stage 2. > While at it, also reserve some memory for device mappings. > > Signed-off-by: Quentin Perret > --- > arch/arm64/kvm/hyp/include/nvhe/mm.h | 23 ++++++++++++++++++++++- > arch/arm64/kvm/hyp/nvhe/setup.c | 12 ++++++++++++ > arch/arm64/kvm/hyp/reserved_mem.c | 2 ++ > 3 files changed, 36 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mm.h b/arch/arm64/kvm/hyp/include/nvhe/mm.h > index ac0f7fcffd08..411a35db949c 100644 > --- a/arch/arm64/kvm/hyp/include/nvhe/mm.h > +++ b/arch/arm64/kvm/hyp/include/nvhe/mm.h > @@ -53,7 +53,7 @@ static inline unsigned long __hyp_pgtable_max_pages(unsigned long nr_pages) > return total; > } > > -static inline unsigned long hyp_s1_pgtable_pages(void) > +static inline unsigned long __hyp_pgtable_total_pages(void) > { > unsigned long res = 0, i; > > @@ -63,9 +63,30 @@ static inline unsigned long hyp_s1_pgtable_pages(void) > res += __hyp_pgtable_max_pages(reg->size >> PAGE_SHIFT); > } > > + return res; > +} > + > +static inline unsigned long hyp_s1_pgtable_pages(void) > +{ > + unsigned long res; > + > + res = __hyp_pgtable_total_pages(); > + > /* Allow 1 GiB for private mappings */ > res += __hyp_pgtable_max_pages(SZ_1G >> PAGE_SHIFT); > > return res; > } > + > +static inline unsigned long host_s2_mem_pgtable_pages(void) > +{ > + return __hyp_pgtable_total_pages() + 16; Is this 16 due to the possibility of a concatenated pgd? If so, please add a comment to that effect. With that: Acked-by: Will Deacon Will