From patchwork Thu Jul 27 15:30:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13330301 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 4A259C001DC for ; Thu, 27 Jul 2023 15:31:40 +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:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IKnnOAsJ+Tmnv1F8pcpyRnjKGJjEpl9Hsn6BJMvdjbM=; b=c6+BbdPxOB14yA qLwgjDEE+xPhMe7xKfMPgrjTRL6CVraA0S3w2dBlsFqeqX+2sZsaDYRWsTr77g2It86epUmgJG4iM km8DqGHUVwUmwrLqt2a0CN8wj5WPzAxfE7KH9ZzeTg9k0tcRsUP+UfkNicdd3qGoRZ6YFLyBEksNp HERTSRL/edq4+OwrRh7FM8MT3rrPXEwNYvEW8JeqPWZ9kqSo748wRZelmtDpvxvRJiZmZucvRZbrJ v/OB+qoQWnZSQMNHds/OFAJKj5Yo8vomWbvv4luR12304wrGxhH/raMDeNvaqUBKohUUZoAB6zJHh MXg/tznh9vJY9fY+DFgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qP2xU-00FvCm-1F; Thu, 27 Jul 2023 15:31:20 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qP2wu-00FueA-0A for linux-arm-kernel@lists.infradead.org; Thu, 27 Jul 2023 15:30:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=H/bsnJ3nxuaPYk8WVBKA64ofddky6JIAr3Z9JZdkWE0=; b=rwwK7hWh69mXMulm6Lyj8ENCmS 3V8Hhm048cnQAyM0EYGXpM+vH+/EImP5q3DHuua+f2mXftSTXq6rrKQckRqYwCqI2BpZwCFFLyLJK Z8g4q2xFCA5NP+szKiWfr6ixU7KoWdys+BY7vK38sRYhHPTTi/++OGXTO3JVJsVKbO7hG2Yqz/KFa hJZXBBYvGrWbNk8VUQQtP58jGtX9P9fRPfiLFdqszNd0mDXcNOHM39UbgNVVgage7OtVbpt7wQmi6 ayRnL9pGOAKOlzZU5wl+IKoBqAD7vpEi6KBNzbqhbkyzox+npuD8dJlsH0L1YbFXYM5jgX6o421+w m+RVuO1g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43366 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qP2wr-000642-1O; Thu, 27 Jul 2023 16:30:41 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qP2wr-001CXk-JZ; Thu, 27 Jul 2023 16:30:41 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Catalin Marinas , Jonathan Corbet , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org Subject: [PATCH v2 09/16] arm64: text replication: add swapper page directory helpers MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 27 Jul 2023 16:30:41 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230727_083044_295326_6C1E9789 X-CRM114-Status: GOOD ( 12.78 ) 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 Add a series of helpers for the swapper page directories - a set which return those for the calling CPU, and those which take the NUMA node number. Signed-off-by: Russell King (Oracle) --- arch/arm64/include/asm/pgtable.h | 19 +++++++++++++++++++ arch/arm64/kernel/hibernate.c | 2 +- arch/arm64/mm/ktext.c | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 1e72067d1e9e..5cfff64e4944 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -627,6 +627,25 @@ extern struct pgtables pgtable_node0; #ifdef CONFIG_REPLICATE_KTEXT extern struct pgtables *pgtables[MAX_NUMNODES]; + +pgd_t *swapper_pg_dir_node(void); +phys_addr_t __swapper_pg_dir_node_phys(int nid); +phys_addr_t swapper_pg_dir_node_phys(void); +#else +static inline pgd_t *swapper_pg_dir_node(void) +{ + return swapper_pg_dir; +} + +static inline phys_addr_t __swapper_pg_dir_node_phys(int nid) +{ + return __pa_symbol(swapper_pg_dir); +} + +static inline phys_addr_t swapper_pg_dir_node_phys(void) +{ + return __pa_symbol(swapper_pg_dir); +} #endif extern void set_swapper_pgd(pgd_t *pgdp, pgd_t pgd); diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index 02870beb271e..be69515da802 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -113,7 +113,7 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size) return -EOVERFLOW; arch_hdr_invariants(&hdr->invariants); - hdr->ttbr1_el1 = __pa_symbol(swapper_pg_dir); + hdr->ttbr1_el1 = swapper_pg_dir_node_phys(); hdr->reenter_kernel = _cpu_resume; /* We can't use __hyp_get_vectors() because kvm may still be loaded */ diff --git a/arch/arm64/mm/ktext.c b/arch/arm64/mm/ktext.c index 48d7943d6907..7b9a1f1b12a1 100644 --- a/arch/arm64/mm/ktext.c +++ b/arch/arm64/mm/ktext.c @@ -21,6 +21,26 @@ struct pgtables *pgtables[MAX_NUMNODES] = { static void *kernel_texts[MAX_NUMNODES]; +static pgd_t *__swapper_pg_dir_node(int nid) +{ + return pgtables[nid]->swapper_pg_dir; +} + +pgd_t *swapper_pg_dir_node(void) +{ + return __swapper_pg_dir_node(numa_node_id()); +} + +phys_addr_t __swapper_pg_dir_node_phys(int nid) +{ + return __pa(__swapper_pg_dir_node(nid)); +} + +phys_addr_t swapper_pg_dir_node_phys(void) +{ + return __swapper_pg_dir_node_phys(numa_node_id()); +} + void __kprobes ktext_replication_patch(u32 *tp, __le32 insn) { unsigned long offset;