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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6551DC43461 for ; Wed, 2 Sep 2020 14:49:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 2FA5A207D3 for ; Wed, 2 Sep 2020 14:49:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lNjIjfEk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FA5A207D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9/mIyjfjsa3qC05vejuAXgd+v2Mjdb4PkoOvP6mNoDY=; b=lNjIjfEkx3gr2u5oaf+hEw2a8 JV5xs5druJepqP3LS0NQYNyhuEYkvg+ns1iwIPiyui1bGRS9hnFvMje4W+oM9GVBnmSHvzswCHvVQ XvmWp2B/+ddRXBHIuDB5JhzxSDmDbs0Ws/UGuCVmtcQiq7ct3dkzIfRn6QlfrZ/VBecZ9otOjmh+K xP9Au1tqY61YLKPKe5ZbXV9YQGgZiR4Tfs1s9Ez0fmjXEu7R1784QsBWtEZrC/4RKwpgyAEGtcbdD ATed+lcXOVomU9jLNj/EBafFUWgnhulvCDT87sWbnCv27eMbLnvMWhCmBTnd+5Ub0aU0UD01vRmgU 7lZGLIEQw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDU3M-00019G-U0; Wed, 02 Sep 2020 14:48:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDU3K-00018c-7S for linux-arm-kernel@lists.infradead.org; Wed, 02 Sep 2020 14:47:59 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 67DA3101E; Wed, 2 Sep 2020 07:47:54 -0700 (PDT) Received: from [192.168.0.110] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 95B4B3F71F; Wed, 2 Sep 2020 07:47:53 -0700 (PDT) Subject: Re: [PATCH v3 04/21] KVM: arm64: Use generic allocator for hyp stage-1 page-tables To: Will Deacon References: <20200825093953.26493-1-will@kernel.org> <20200825093953.26493-5-will@kernel.org> <35435dcb-e821-3769-ac0f-e75b1ede237f@arm.com> <20200902113555.GB5838@willie-the-truck> From: Alexandru Elisei Message-ID: <336662d0-6be9-5747-7ea2-7e5a8b338b66@arm.com> Date: Wed, 2 Sep 2020 15:48:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200902113555.GB5838@willie-the-truck> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200902_104758_324283_0D822424 X-CRM114-Status: GOOD ( 16.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Catalin Marinas 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 Hi Will, On 9/2/20 12:35 PM, Will Deacon wrote: > On Fri, Aug 28, 2020 at 05:32:16PM +0100, Alexandru Elisei wrote: >> On 8/25/20 10:39 AM, Will Deacon wrote: >>> Now that we have a shiny new page-table allocator, replace the hyp >>> page-table code with calls into the new API. This also allows us to >>> remove the extended idmap code, as we can now simply ensure that the >>> VA size is large enough to map everything we need. >>> >>> Cc: Marc Zyngier >>> Cc: Quentin Perret >>> Signed-off-by: Will Deacon >>> --- >>> arch/arm64/include/asm/kvm_mmu.h | 78 +---- >>> arch/arm64/include/asm/kvm_pgtable.h | 5 + >>> arch/arm64/include/asm/pgtable-hwdef.h | 6 - >>> arch/arm64/include/asm/pgtable-prot.h | 6 - >>> arch/arm64/kvm/mmu.c | 414 +++---------------------- >>> 5 files changed, 45 insertions(+), 464 deletions(-) >>> >>> [..] >>> @@ -2356,6 +2028,7 @@ static int kvm_map_idmap_text(pgd_t *pgd) >>> int kvm_mmu_init(void) >>> { >>> int err; >>> + u32 hyp_va_bits; >>> >>> hyp_idmap_start = __pa_symbol(__hyp_idmap_text_start); >>> hyp_idmap_start = ALIGN_DOWN(hyp_idmap_start, PAGE_SIZE); >>> @@ -2369,6 +2042,8 @@ int kvm_mmu_init(void) >>> */ >>> BUG_ON((hyp_idmap_start ^ (hyp_idmap_end - 1)) & PAGE_MASK); >>> >>> + hyp_va_bits = 64 - ((idmap_t0sz & TCR_T0SZ_MASK) >> TCR_T0SZ_OFFSET); >> idmap_t0sz is defined in mm/mmu.c as: TCR_T0SZ(VA_BITS) = (UL(64) - VA_BITS) << >> TCR_T0SZ_OFFSET. Looks to me like hyp_va_bits == VA_BITS. > Careful! It can get rewritten in head.S if we determine that physical memory > is in an awkward place and not covered by VA_BITS in an identity mapping. I wasn't aware of that, I see now that in head.S we can change idmap_t0sz if VA_BITS is not enough, I wasn't away of that, thank you for pointing it out! Thanks, Alex _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel