From patchwork Wed Mar 13 12:57:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 13591387 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 D0B92C54791 for ; Wed, 13 Mar 2024 13:00:25 +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=xftJp2IgZn1ZC5TZ1ChyGLc7gW7G33D8D8/yWV/0sVQ=; b=eSvxAA3Eiy4FrG +SpkGM9MF/JtrysHRxO4fWPp8eo21F9qjtp6sTcC1830m/3Z0r+RLPN5eawXhWJaAEWGtxhejqquJ o1Vrt+PUQmkW1LOdgI+lOQeF8tzq4lGLEDR1Wm5m/jaFKJHNX2Q3WgybrlJk53lzHB9/CfHXCLTsm DzF2j/7hQAtLT/cyRS9tUE1byB9svuLNTSmemGoHv8pXGp8mvZmB68O0nOr7Rem/HyGg59OIe+4Yz p2L4NP5IMF8ACMmYHs1BILDQBdaT4UYxQybJPCQY+R3guZZ/va7vSlbpzv8OQN1PFNxxEGRnOqzBt RViPzk+Pvy45YHEYwLWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkODI-0000000A9Ko-1SpL; Wed, 13 Mar 2024 13:00:08 +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 1rkODE-0000000A9Jb-2gYG for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 13:00:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710334803; 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=Q7UaXx7woWiSjxapRzZBKFnnDL8hoi9yfupYamQFkZI=; b=O1bxNSEDUm6aQC4NBCqatCPAe0jSZ1/I7e37z8b0Et+xkX65oFkqWGM+gu3yPsMOxPmUXs N5CEfgdE9R34hEn6PZiFJ/40rWFvUJe40Ngji6u/C9HRvMMB/pmHa9JTWMas+dslxiHfPv +Dsdv1zXBARG+cuBBptFxkaTrf8rJTY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-x6uSjwJYOiyEabkt_SkOig-1; Wed, 13 Mar 2024 08:57:39 -0400 X-MC-Unique: x6uSjwJYOiyEabkt_SkOig-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 704FE1C54064; Wed, 13 Mar 2024 12:57:39 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDC2D17A90; Wed, 13 Mar 2024 12:57:36 +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 04/10] arm64: head: Enable __create_pgd_mapping() to handle pgtable's paddr Date: Wed, 13 Mar 2024 20:57:02 +0800 Message-ID: <20240313125711.20651-5-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_060004_896616_3F499D90 X-CRM114-Status: UNSURE ( 9.30 ) 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 When mmu-off or identical mapping, both of the page table: init_idmap_pg_dir and init_pg_dir can be accessed by physical address (virtual address equals physical) This patch introduces routines to avoid using fixmap to access page table. 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 | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/arch/arm64/mm/mmu_head.c b/arch/arm64/mm/mmu_head.c index ccdd0f079c49..562d036dc30a 100644 --- a/arch/arm64/mm/mmu_head.c +++ b/arch/arm64/mm/mmu_head.c @@ -10,6 +10,48 @@ #include #define INSTRUMENT_OPTION __noinstr_section(".init.text.noinstr") + +#undef pud_set_fixmap_offset +#undef pud_clear_fixmap +#undef pmd_set_fixmap_offset +#undef pmd_clear_fixmap +#undef pte_set_fixmap_offset +#undef pte_clear_fixmap + +/* This group is used to access intermedia level in no mmu or identity map */ +#define pud_set_fixmap_offset(p4dp, addr) \ +({ \ + pud_t *pudp; \ + if (CONFIG_PGTABLE_LEVELS > 3) \ + pudp = (pud_t *)__p4d_to_phys(*p4dp) + pud_index(addr); \ + else \ + pudp = (pud_t *)p4dp; \ + pudp; \ +}) + +#define pud_clear_fixmap() + +#define pmd_set_fixmap_offset(pudp, addr) \ +({ \ + pmd_t *pmdp; \ + if (CONFIG_PGTABLE_LEVELS > 2) \ + pmdp = (pmd_t *)__pud_to_phys(*pudp) + pmd_index(addr); \ + else \ + pmdp = (pmd_t *)pudp; \ + pmdp; \ +}) + +#define pmd_clear_fixmap() + +#define pte_set_fixmap_offset(pmdp, addr) \ +({ \ + pte_t *ptep; \ + ptep = (pte_t *)__pmd_to_phys(*pmdp) + pte_index(addr); \ + ptep; \ +}) + +#define pte_clear_fixmap() + #include "mmu_inc.c" void INSTRUMENT_OPTION mmu_head_create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,