From patchwork Wed Mar 13 12:57:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 13591384 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 6681AC54791 for ; Wed, 13 Mar 2024 12:59:42 +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=0NvbAH8Ift4woWX5mY3ltK46SRbpBsBxgKeadGz8h8Q=; b=kVWWLCXGhYAxvA gFNi2zyFvV/PWVCWq6/DjK5g4O1H9g97AtSZkdSqvZxC5pLSJwuLHnIDhEdOwEfUjhLTAd0lRuVyh Wo9vdBeksoVHFDiYOF5rtKX6kkicslhEH84mujlBmXhRpZ0y3rkIDeqXZY43AFXe8kdV3OKdRNIBq 1Mm1oL5g7VvAw4WtGr49yChDd2IJ917YkLU9sWzPvaDhqI9bXttKSxixju1tzRa8ep1wj3euTlt0c CsML9nC1+jZp+HnNmPJKckSIFHlkmF0bzUe9gfSv9xWg2r0bs+cpGj6aQj+uNtS+sjsLJ/suW4QZm NCW+psIyR6w6Am2oTy7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkOCb-0000000A8zi-11lK; Wed, 13 Mar 2024 12:59:25 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkOCW-0000000A8wm-44xz for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 12:59:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710334758; 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=2r+392XXwuc3n014z3yI/az0vrJLvijlDnFFnJlEVmc=; b=CiQ5eMCuiVpV+maFacIEzbMU2bCIy+ssJSv7hry2S8+xmbthkLugnNpEtDsfeHXQWE3fVo hv3Hh9gEKFakyS4q/TjrycNkg3kYE/tXY/ZIeMUCwFwX1Bck8IDpc5zO9r+oAOig0jjzM1 gPQapewtAzegmKvQHEFYrmntu7evu6w= 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-464-Gg5js5fyMQ-hNBvcV9Pluw-1; Wed, 13 Mar 2024 08:57:42 -0400 X-MC-Unique: Gg5js5fyMQ-hNBvcV9Pluw-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 89D7D872860; Wed, 13 Mar 2024 12:57:42 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10BE8111FA; Wed, 13 Mar 2024 12:57:39 +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 05/10] arm64: mm: Force early mapping aligned on SWAPPER_BLOCK_SIZE Date: Wed, 13 Mar 2024 20:57:03 +0800 Message-ID: <20240313125711.20651-6-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_055921_790566_D5E19AD7 X-CRM114-Status: UNSURE ( 9.55 ) X-CRM114-Notice: Please train this message. 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 At this very early stage, the page table size is limited and block-mapping is appealed. Force the input param aligned on SWAPPER_BLOCK_SIZE, so that __create_pgd_mapping_locked() can use the block-mapping scheme. 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/mm/mmu_head.c b/arch/arm64/mm/mmu_head.c index 562d036dc30a..e00f6f2c7bec 100644 --- a/arch/arm64/mm/mmu_head.c +++ b/arch/arm64/mm/mmu_head.c @@ -60,5 +60,11 @@ void INSTRUMENT_OPTION mmu_head_create_pgd_mapping(pgd_t *pgdir, phys_addr_t phy phys_addr_t (*pgtable_alloc)(int), int flags) { + phys_addr_t end = phys + size; + + phys = ALIGN_DOWN(phys, SWAPPER_BLOCK_SIZE); + virt = ALIGN_DOWN(virt, SWAPPER_BLOCK_SIZE); + end = ALIGN(end, SWAPPER_BLOCK_SIZE); + size = end - phys; __create_pgd_mapping_locked(pgdir, phys, virt, size, prot, pgtable_alloc, flags); }