From patchwork Tue May 30 14:05:21 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: 13260150 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 2256DC7EE2C for ; Tue, 30 May 2023 14:06:21 +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=fFrALfB9/FvDW080kvu1ZAYuz0gNSLx5bMTttsaOcn8=; b=keSHzkOn0x59VI FIZ7wc2zICbPpt8wENZlj+BE8gZ+WntsOOxVJ3zGp6XJBZ6SGliZ55B6T1DGgI4mpvqy79yMTzIxZ G/dSW19CHb6Tz+LOM41VMEWCHSE5PViXGiorhgXguNKvQH2tnL7EORrUBrxfFYzdRR/lnDRpwjTiK FiaBzgBzvg6SdL9I9etF2kIXTCnKDYntzgcDS7Sc5ir/zmYM3t1QZRGu/utVW1CqBPl+dBqfL9VJk trja1ZWRw+0duhjREdC5OglHLrU4LoYEgIXs2jL5d9juzSc0UBaIKO8tEbw3mJIJeLZi5/DNXCzzz 9Zg3SGcu7mE4d7Ipy1dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3zz2-00E9fM-2X; Tue, 30 May 2023 14:05:56 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3zyV-00E9Pl-18 for linux-arm-kernel@lists.infradead.org; Tue, 30 May 2023 14:05:25 +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=nBBrF3BbR5Lwl8Cc/QvChlKOe5ANaMj83t0gXJYwyIY=; b=oQ5cbCl+2ssMheOt0eV7lHvx6M dxxhnEXbZLp54vSQvkkdmNayzD2ZdDqYEi+j40AJGCzdcpK6k0HSV09c7BMAYsbZ1EbGC+gYpeyNa Zyt7am/soPWFwXgQLdnyFYrPOC5N2U+dJmIwKTv0MWyMkJfsVpHst1jgl+XuWSwe98fQ+Big+sIJy Ecf2sWV1+2w4/U+X0BZnqqHLaV7r3WqnT5EViQ74qgW1ord8v7UJQuW90GiNZ2tcfBa0+9/k+Djwm gufjuMo5Y4yxyT/ob+tuFBHAMCtLl+1dq2iQk+B2wera0WoVCGbZ0obIXxdEIMETFv1YOKZiVE91S YI5xLVQA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:48812 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.94.2) (envelope-from ) id 1q3zyT-0002rc-TN; Tue, 30 May 2023 15:05:21 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q3zyT-00A5LC-9X; Tue, 30 May 2023 15:05:21 +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 RFC 10/17] arm64: text replication: add swapper page directory helpers MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Tue, 30 May 2023 15:05:21 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230530_070523_714227_C9FBC416 X-CRM114-Status: GOOD ( 12.53 ) 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 788597a6b6a2..2236119bf16d 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -114,7 +114,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 85fc97877d75..ac5754972a09 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;