From patchwork Wed Mar 13 12:57:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 13591388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DEA6BC54E58 for ; Wed, 13 Mar 2024 13:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WcVdF/7akC0mr3zZvSqq3rBB1/xKNjtpeYCw766XAcE=; b=iMhSwUHpxZIa3A S8nJut69VQVXBB4EXKdetTyKp6JrNTyS8eDrWsSoiQcDQVxNryxZJgS/xmET8V035UN7GSl5bDUi5 WftzNDV4mISPiX9+Ap4JVBb/Hi5DhQco5KhvQ/nHFmE1XGB3XW3oYWx2AeOMqrtFJseglNkEl0ZPq c7h7K1UyVHZN/MCXOTiKfnapqL7WmLStYpMz7GJ5F16mX5aBqQaaNylftppp6hmNtQrs/YYMqa0bv 1b1P/0QXOm9TzXCy76x+WHF5VGYMXuUTs6qtN3BKgFHUnFphDMOtXNYJBZBcfKLzVkRE1GuXMgYio 9yA2lyVy4pWj5KHvuwvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkODf-0000000A9UN-39w5; Wed, 13 Mar 2024 13:00:31 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkODb-0000000A9Rd-0ryl for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 13:00:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710334826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oYJDM8sSyWlFn9/09ELVf0hZb4Kfsu5P9I2kefxFvzs=; b=Cq3OekzScFZs9dJmzOfWmmrhKBiP3ir/xg/2dCAg5fj1KljJBc2yYyQJ2yXgsdi6Sevf3+ 8dmB/oiK4xp5P1GZgiIhNXMJN22Oiif4cqs8VaZI7vF65U8aTwCAaQtn4PE5b9+5Z5Z9S+ S6D9n+mXmcP99vLvos5bsevQzUPxuII= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-BccFzXOXNiufeLZr3kYqMg-1; Wed, 13 Mar 2024 08:57:46 -0400 X-MC-Unique: BccFzXOXNiufeLZr3kYqMg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9DC89800268; Wed, 13 Mar 2024 12:57:45 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2993B10E47; Wed, 13 Mar 2024 12:57:42 +0000 (UTC) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Ard Biesheuvel , Catalin Marinas , Will Deacon , Mark Rutland Subject: [PATCH 06/10] arm64: mm: Handle scope beyond the capacity of kernel pgtable in mmu_head_create_pgd_mapping() Date: Wed, 13 Mar 2024 20:57:04 +0800 Message-ID: <20240313125711.20651-7-piliu@redhat.com> In-Reply-To: <20240313125711.20651-1-piliu@redhat.com> References: <20240313125711.20651-1-piliu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240313_060027_381180_6FC7D55C X-CRM114-Status: GOOD ( 13.18 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch serves the same purpose as the commit fa2a8445b1d3 ("arm64: allow ID map to be extended to 52 bits") Since it is harmless to ditto init_pg_dir, there is no need to distinguish between init_idmap_pg_dir and init_pg_dir. Signed-off-by: Pingfan Liu Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland To: linux-arm-kernel@lists.infradead.org --- arch/arm64/mm/mmu_head.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/mm/mmu_head.c b/arch/arm64/mm/mmu_head.c index e00f6f2c7bec..2df91e62ddb0 100644 --- a/arch/arm64/mm/mmu_head.c +++ b/arch/arm64/mm/mmu_head.c @@ -66,5 +66,23 @@ void INSTRUMENT_OPTION mmu_head_create_pgd_mapping(pgd_t *pgdir, phys_addr_t phy virt = ALIGN_DOWN(virt, SWAPPER_BLOCK_SIZE); end = ALIGN(end, SWAPPER_BLOCK_SIZE); size = end - phys; + /* + * In case that the kernel routines support small VA range while the boot image + * is put beyond the scope, blindless extending the pgtable by one level + */ + if ((IS_ENABLED(CONFIG_ARM64_16K_PAGES) && IS_ENABLED(CONFIG_ARM64_VA_BITS_36)) || + (IS_ENABLED(CONFIG_ARM64_64K_PAGES) && IS_ENABLED(CONFIG_ARM64_VA_BITS_42)) || + (IS_ENABLED(CONFIG_ARM64_4K_PAGES) && IS_ENABLED(CONFIG_ARM64_VA_BITS_39))) { + unsigned long pgd_paddr; + pgd_t *pgd; + pgd_t pgd_val; + + pgd_paddr = headpool_pgtable_alloc(0); + pgd_val = __pgd(pgd_paddr | P4D_TYPE_TABLE); + /* The shift should be one more level than PGDIR_SHIFT */ + pgd = pgdir + (virt >> ARM64_HW_PGTABLE_LEVEL_SHIFT(3 - CONFIG_PGTABLE_LEVELS)); + set_pgd(pgd, pgd_val); + pgdir = pgd; + } __create_pgd_mapping_locked(pgdir, phys, virt, size, prot, pgtable_alloc, flags); }