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 X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42CE9C433E0 for ; Fri, 5 Mar 2021 09:17:25 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 7F12164F53 for ; Fri, 5 Mar 2021 09:17:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F12164F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E6B314B3D2; Fri, 5 Mar 2021 04:17:23 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9UJGICesz7QZ; Fri, 5 Mar 2021 04:17:22 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CF1764B3FA; Fri, 5 Mar 2021 04:17:22 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D95084B3FA for ; Fri, 5 Mar 2021 04:17:21 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dQjiuQsJ8k3h for ; Fri, 5 Mar 2021 04:17:20 -0500 (EST) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id A9CB84B3D2 for ; Fri, 5 Mar 2021 04:17:20 -0500 (EST) Received: by mail-wr1-f44.google.com with SMTP id b18so1258544wrn.6 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=a/joArySmTSM0+SDQIrsaSamp/FAaCC17AEzK7sUBawlRF0xACm0+aC8zLa24HnYtY ZGpSKxYUa3KaYIv0ByeinFz3ML/LQoXu+Rjj/NWHJrkXoas3V08oTU9KSKsV6nUJD4+/ zAvE1rUKkz5vLAszYjXcNbzye5DczxgpP7kuWKyX7i2U6CWe0ILv6sc2nKQn3BOI14OD u14TxLIB+MBJednSCAftIYizuLC/1vYrT8QSi13OXdlCGZanhzLp2NqC4w5yWAVbF7me G5RUJTq+NWhDGf677FR1KJh6HKPRscr4bPvG2lT86BFE8uxCoNsZT218aYjG8lrmoOFc 4s9A== X-Gm-Message-State: AOAM530WBXiFfUCGo2QfCLqA+j4K/aX105uW3U7iIyjbmzeiAJf2/rWC Xg/+H4d9NcdUCkIULvomhOojlA== X-Google-Smtp-Source: ABdhPJwkqGaJDZi1qJyXxeSAeeGexX9CiTR+848rPCJ3/MZ5zmUWeN2uI8ddfxcqr8O1iyHfvoSCkg== 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 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-Disposition: inline In-Reply-To: <20210304194953.GD21950@willie-the-truck> Cc: android-kvm@google.com, catalin.marinas@arm.com, mate.toth-pal@arm.com, seanjc@google.com, tabba@google.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 270D4C433E0 for ; Fri, 5 Mar 2021 09:18:46 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 866F564F53 for ; Fri, 5 Mar 2021 09:18:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 866F564F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=1FqFe5Y8b6bgRzqAUUgyprc3gHj+dQzRfGcthyc+zKM=; b=RzlkicUsBN5LCQJYab22eZ7Dr lS+T+pH5/TLintVMJA+2aoRbuAaDg5G6R3P5OH0gkVdBLFPxcSM9cPiVbsTL2ddJBnrV7ig6kAKhC XPCB8s40H6ZItz1UdgV6MxTQsyyZ0ofFoO82GEHwBeyw6PRMQLp02C2FHip6GMKceSTmckqgptiKz laRe/+/2IvP42IfQNkX5DWnczgbbOdbv62Kg44fXpqyfGomC+Sm7wRZT23/lget0HUN/znim3le7q /mYVsvid8KQxw6RhZHvLQJcotd08mcge6qXCK40EX0FXSHfFkAyQVoUo1precvCxg0zj1Tn0VdMWN SVS/dKvPQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lI6aO-00EDuZ-51; Fri, 05 Mar 2021 09:17:29 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lI6aG-00EDsI-JS for linux-arm-kernel@lists.infradead.org; Fri, 05 Mar 2021 09:17:22 +0000 Received: by mail-wr1-x435.google.com with SMTP id 7so1282489wrz.0 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=Dxo4+aDlrTdfXzmNOGxVf3nrOOriq8TJm41Ed/S8rxlXPAzBrMrlCeTpOOnibHR6VD iO/2gSdk6R5tLeFOdaa9f7yDVWWi6K1Ucaqn8NJaBo1iF1c4JdmXVTG/hSlF8BC+qbrG 3mbenlRXycXjaYqzQPT7BlOEiAmi0o5XnDG6sGJ8lgBo/4yh2BgerqCatRVO8VOoMdSz H0GXsA1zhxSxWMB+Mi5P0l6g12tJyhIfMT2mzAqhGuucaEuNhhh2iZiodnY3b7Erg0xQ 8zT9FgIVbyA9ltJzzudm6LCFtWmWvTLHkKmg71vZK0asPU+q1Yrj+Q5MALoEaRtUDkty gRdg== X-Gm-Message-State: AOAM533uM4J8rDQciWNAdSlcBnGHXnyTWErWwCMIdx8TQbVT2zgPt/BZ QebQ3DcbxfKy5vwj1OxPY3rYbQ== X-Google-Smtp-Source: ABdhPJwkqGaJDZi1qJyXxeSAeeGexX9CiTR+848rPCJ3/MZ5zmUWeN2uI8ddfxcqr8O1iyHfvoSCkg== 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-Disposition: inline In-Reply-To: <20210304194953.GD21950@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210305_091720_825276_497918DD X-CRM114-Status: GOOD ( 21.58 ) 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB080C433E0 for ; Fri, 5 Mar 2021 09:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 906DE64DD1 for ; Fri, 5 Mar 2021 09:17:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229517AbhCEJR2 (ORCPT ); Fri, 5 Mar 2021 04:17:28 -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-Google-Smtp-Source: ABdhPJwkqGaJDZi1qJyXxeSAeeGexX9CiTR+848rPCJ3/MZ5zmUWeN2uI8ddfxcqr8O1iyHfvoSCkg== 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