Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1865997pxb; Fri, 5 Mar 2021 01:19:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWvfsPkL7OKLC2e+ecwyvgjetp3TJsYTuuGIZUM6J+G87wQ0I8p/S/3B1/qoi0YjOM9Q+o X-Received: by 2002:a17:906:b20b:: with SMTP id p11mr1464183ejz.0.1614935990376; Fri, 05 Mar 2021 01:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614935990; cv=none; d=google.com; s=arc-20160816; b=EOD5FxregxS66yhB7+yq4UCj7r9tN3X1Y89oHGbgDKbveys5h4Y/IPd9iXuaj6TpBu Cr6NZ4ZmVLBwGCKx7XrC9lFKcM3jafxuhJOc4lR4DdeQ+cl+d86DutDIom9Lreh7GFy6 Ix51wqbAgEvRDb0eCOuoVaB0/xJg3XYb4jMNQvBh3RDz522uSZ+9PQxPnEJsicboQThG BqEIZb1utGnAiZ2dSgzTCi4woHqXc7rEr4GSZJd6F00CmOZj3rgPl1nMHoGAwXYkpyQc j6tN7QTqAKogXrF/HCxSucf75rKk4eLBO9XWQAfJREyaU3zpHW3gx8Qm3eQF5VbotJhO eOzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=m0BaSCINjuV6YKS4LQw2bQ0VOXZwqzhx3JH5vS4yw4A=; b=NvnVrhov/TDwF8AxsZjpiRV8jvrR7/K7K9G3mRU5OFKFzyhUU67mfExsDOgsRKeM1U fofH3xqA7o2Gxq5tg2rTO2L3s7GzL9PH5QFF9Uspqps3Qlw92TsG+F/vi5YsBmiS8Fbo tef8Evyl4XzSloCLv6uLMb0TVrnvIyYcB4xFWdpHAbGNsdjsiF0fje5ro6wAcQxH/3A9 aoUm8FKf+uV+BHRcDfXFH2AnfHhlOOEmF6knXHrXUXmGCM6uGNnojagdL4BDQ2aocR11 efBhC0195xUGdGjbQdc+sHf64Dcab40h0Dy0fNDjqCAWd0yuVO81jgsyPQe1mlhs9i+j 73pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dSK8cK8Y; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr9si1095052ejc.436.2021.03.05.01.19.27; Fri, 05 Mar 2021 01:19: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=@google.com header.s=20161025 header.b=dSK8cK8Y; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbhCEJR1 (ORCPT + 99 others); Fri, 5 Mar 2021 04:17:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229646AbhCEJRV (ORCPT ); Fri, 5 Mar 2021 04:17:21 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA964C061574 for ; Fri, 5 Mar 2021 01:17:20 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id l12so1274838wry.2 for ; Fri, 05 Mar 2021 01:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=m0BaSCINjuV6YKS4LQw2bQ0VOXZwqzhx3JH5vS4yw4A=; b=dSK8cK8YdJCHbOxvyzk4NaS2W1an+k1SSlSqlbzAfzisIIOT114FG3nmrlwBPZfX/L IWpalQMzqqRrpNoJN3JNcSt+XkcD1u5p3Mfw18YrEXh2neL+YKp5CGnvLQ21jChB6el0 Zr22QATr21AzfIQlNTeAXBJC4bnCpLCjsBMe7/2NVXPnniv2k2OGDq1TnpAx+Vq/tPw4 uf0A6ZKubbxRsOBfwliKV+8Nh8/1fVB9EzCnyK0IYPAGcHm5fwnl9BLs1Q3yvhz37ycd SRZgFuQUQVV3T4Gk4DB+f1O2eaCSx7GeK/l9XkEANOk6165hF7fVKRFToyHmNLxVG636 xjbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=m0BaSCINjuV6YKS4LQw2bQ0VOXZwqzhx3JH5vS4yw4A=; b=n96U+h8WDaxnWr0YzDi/Je+RLECI20HYpKDaCUYLSlbv9AJiy0n4nJxIVOQ6IP008s Da9vKtwA1M4weAMh2yuJgnR/xNPdy1/8ymNLBlDsby0jWZqlgZ+BWKitCdQUuMEm8FQ4 N7yw4xji8YJJazHR8r6mOCpiDq2I0zGEGpJl53zprJmLdWTiWYiNjw2j5kiqKPNdSWtL PQ+56hiiv5panYjo9zgk/P1HnmgS7A2yduzbbtJzFvduIKd9TQZc66Crj1Zsb3qaERlh lyAtj1PUqcyro1+5LQ/IOKDfAj9Whe84TZtR+Si/EAhX5Ia1Ji76bj1GHKX2kYmdzO11 c45w== X-Gm-Message-State: AOAM532wtKKybYBQ+wUFxZm93aJ2OuZcnUlTzHxfUX0d+i2tk4GQl0CU xO+8JxBpxRZiaCiCQFewvdCBvA== X-Received: by 2002:a5d:4dd2:: with SMTP id f18mr8379236wru.366.1614935839616; Fri, 05 Mar 2021 01:17:19 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id s20sm3833269wmj.36.2021.03.05.01.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 01:17:19 -0800 (PST) Date: Fri, 5 Mar 2021 09:17:16 +0000 From: Quentin Perret To: Will Deacon 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: References: <20210302150002.3685113-1-qperret@google.com> <20210302150002.3685113-25-qperret@google.com> <20210304194953.GD21950@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210304194953.GD21950@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 04 Mar 2021 at 19:49:53 (+0000), Will Deacon wrote: > 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? Yes it is, to be sure we have a safe upper-bound. > If so, please add a comment to that effect. Will do, thanks. Quentin