From patchwork Tue Jan 23 14:53:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13527550 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 E196EC47258 for ; Tue, 23 Jan 2024 14:57:11 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Lzd5wcoAyYyYPNbrDKC1Ch1kFP2yMrEc8GjeQqoPdgQ=; b=LIXL43seXrGYvFcvmRqA/zgkRD eHYOBC38XHuF9SQ9XQet4rcL9ckCfq4jcce4EegmhKJRWB7Wlk2PpF1ZDTWuXEifJvmN/WFT3Xf2w 2h5Ci3nnmquWbN4d45htusHAgF9yoXy+Rsr7VmV40u7yk++7Xeiqv1B8CkZ/Nuu6X0e+qWNvCCVKJ O+7nipAEIug/jteC1W/jn+IlRANKR4V8zMqHwdhm3GIpAqWcvKKDwBolPuYrxCiGFvEKur55GDZYM y0cv8PT12YlR4DR/9qhnA0fW7FA2cKzr2jaJGf/NwRWqnfO1HaGN2F8Vu20AbkD+gd/kTVYKqgdXG AKGl4sxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSICc-00GukR-1m; Tue, 23 Jan 2024 14:56:38 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSIBo-00GuL9-18 for linux-arm-kernel@bombadil.infradead.org; Tue, 23 Jan 2024 14:55:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=U8NkWuOcE5Bvqh+HJIC2fKSUV/GoC1TWDkBkhd+IbL8=; b=B1wXegTEfmXadz0k81Icd5W6S7 OSwC9TMzTbhjDn8VGkZC+7NwLw7Ht9f3ItMiAr55vdP/n13W3TphLMqMOTiE2UFOJGSDwWbmiMaxK 0UZ3WFGf8fHwy0ojoNRoiyuuvfvW20iJZDfoeSZX7WNM7SFXQwnLyZPBet82MrctoDgdKO8j8E+tR FVbWSkcjLQrovt8S488JcEncRS0K4gBf2Rta6nJd7Guh967u6u71hQ9hGFLAg2IPbwgyrC1bMhTLm 8H5wyimCegGhpXMEqaMdrTZSO7EoJYJ4H+VrXUfnstUHbIb5gAIEpqEPaY53a1U6t8rv2t9qvtrbT 9JGMDYmQ==; Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rSIBi-00000003TnI-3tqN for linux-arm-kernel@lists.infradead.org; Tue, 23 Jan 2024 14:55:47 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3392c9e8001so1157934f8f.0 for ; Tue, 23 Jan 2024 06:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706021734; x=1706626534; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=U8NkWuOcE5Bvqh+HJIC2fKSUV/GoC1TWDkBkhd+IbL8=; b=k9tH5MGccexEAW1vuRjwH4PibFVER2YT8Huh+c4J22+zlEdH3jpOeO+ajSmopk2jWl poJ33FnsNFVUZ43t0Fqdc6in8tYsNbr2uHrU+IYtwDeisw+rHzN7sAyHohrEV6pqV/sq r79sgzA0Qa7q/ZyYA16qbflAFPWhoDPLf2woE7lnVwlUuUvHyUoaEJaMp22Wz0kWUAhz oesdZ9E8Gccm/9mTTIiAnjtTJQBR/9lVpoWnOUyk9Kfa2VXqeyBuIHd6QP3BXsO5bI0Y RqfFhpbzrZVeoxmj4/iwnMHEqlQrBXmc1IJEQkyIk7+EGZ2cgk+4zzLTKmPdGchxF0bs pMjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706021734; x=1706626534; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U8NkWuOcE5Bvqh+HJIC2fKSUV/GoC1TWDkBkhd+IbL8=; b=tr8nIIVfImGcEeS/RlD0+5HqHWoxg/7/2b0er0ayuxQ/uqPSjqjcNKMcfU9feAcKnt EScYf4orCbtBgzwf3CU0IVk0ocPqFKiDNJAKDSaUzvcp3vHRxQUIB3DBm9TK7O3Ib3ad o8q1Dc0iQPNwCjjCIszCL5OsCbkOJLSIycThnWE6+ioMIGyoVMHvJ+asiOFlqSUl3h/j p/eS8I9r2On7LxMPyTII3azIpwvYP8nKIljaGwHzNN6L8yG4QlIAeuMtEmvWmD6s9DtQ PS7NXmAtkVpsvgVVvmkbhMoTeVJFVxnCKemy+/y4xe99JF5LFXDSNFcfhdEoZ92RpK7L EJxA== X-Gm-Message-State: AOJu0Ywc4TQJbfki9SAfcLf8p9iB6BuF7nIT9q6RUPfLx7tcub3pJhvn R1UwV118KP9IJnKtQ+9IwlrfX5EB6SvyHXoUZ94tVUpipFbbNp9Gg7B8PwAEdnatQ1SGgboqDO5 t8cngYzAiFVy6LIr9nVhxKaDr3USR/z0M66ocI7YuZB3kPS0Yqxmkw9FoGRVXBlVb4r0zrG9DQv 3gjy9b0b9cW3TQaQhWuGB9fF4/mM1aY0hGUiW0G362 X-Google-Smtp-Source: AGHT+IEnBJQoPuhwcAzimhLs2Jpfo4quMRAFJN0xof852tqNI9aPKgHQETd/q+3FppYz1sVPYJEW+AkZ X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:adf:e7d1:0:b0:337:d361:8cb1 with SMTP id e17-20020adfe7d1000000b00337d3618cb1mr29877wrn.5.1706021734035; Tue, 23 Jan 2024 06:55:34 -0800 (PST) Date: Tue, 23 Jan 2024 15:53:30 +0100 In-Reply-To: <20240123145258.1462979-52-ardb+git@google.com> Mime-Version: 1.0 References: <20240123145258.1462979-52-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=3830; i=ardb@kernel.org; h=from:subject; bh=QtwsFhFXFFl5f0qjSh5EloEd18nAeBQ/5XD49A0gve8=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX9pTfc/j1X7j/Jb3W/eWKqf5NIp9nxX8dnvXvwlrd6f ZOWZ7JsRykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZjI6kZGhm1H6ha9na0366vv HEvrZ6c52FyfZE5aFHT9melhrmcXbDUY/op9/vmxuVyHv45lgzvnXbnVRQW5lRIrL/NF2Uid0Vv lxwIA X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240123145258.1462979-83-ardb+git@google.com> Subject: [PATCH v7 31/50] arm64: Revert "mm: provide idmap pointer to cpu_replace_ttbr1()" From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240123_145544_355387_9477AE3D X-CRM114-Status: GOOD ( 13.47 ) 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 From: Ard Biesheuvel This reverts commit 1682c45b920643c, which is no longer needed now that we create the permanent kernel mapping directly during early boot. This is a RINO (revert in name only) given that some of the code has moved around, but the changes are straight-forward. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/mmu_context.h | 17 ++++++----------- arch/arm64/mm/kasan_init.c | 4 ++-- arch/arm64/mm/mmu.c | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index a8a89a0f2867..c768d16b81a4 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -108,18 +108,13 @@ static inline void cpu_uninstall_idmap(void) cpu_switch_mm(mm->pgd, mm); } -static inline void __cpu_install_idmap(pgd_t *idmap) +static inline void cpu_install_idmap(void) { cpu_set_reserved_ttbr0(); local_flush_tlb_all(); cpu_set_idmap_tcr_t0sz(); - cpu_switch_mm(lm_alias(idmap), &init_mm); -} - -static inline void cpu_install_idmap(void) -{ - __cpu_install_idmap(idmap_pg_dir); + cpu_switch_mm(lm_alias(idmap_pg_dir), &init_mm); } /* @@ -146,21 +141,21 @@ static inline void cpu_install_ttbr0(phys_addr_t ttbr0, unsigned long t0sz) isb(); } -void __cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap, bool cnp); +void __cpu_replace_ttbr1(pgd_t *pgdp, bool cnp); static inline void cpu_enable_swapper_cnp(void) { - __cpu_replace_ttbr1(lm_alias(swapper_pg_dir), idmap_pg_dir, true); + __cpu_replace_ttbr1(lm_alias(swapper_pg_dir), true); } -static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap) +static inline void cpu_replace_ttbr1(pgd_t *pgdp) { /* * Only for early TTBR1 replacement before cpucaps are finalized and * before we've decided whether to use CNP. */ WARN_ON(system_capabilities_finalized()); - __cpu_replace_ttbr1(pgdp, idmap, false); + __cpu_replace_ttbr1(pgdp, false); } /* diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index 89828ad2bca7..a86ab99587c9 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -225,7 +225,7 @@ static void __init kasan_init_shadow(void) */ memcpy(tmp_pg_dir, swapper_pg_dir, sizeof(tmp_pg_dir)); dsb(ishst); - cpu_replace_ttbr1(lm_alias(tmp_pg_dir), idmap_pg_dir); + cpu_replace_ttbr1(lm_alias(tmp_pg_dir)); clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); @@ -261,7 +261,7 @@ static void __init kasan_init_shadow(void) PAGE_KERNEL_RO)); memset(kasan_early_shadow_page, KASAN_SHADOW_INIT, PAGE_SIZE); - cpu_replace_ttbr1(lm_alias(swapper_pg_dir), idmap_pg_dir); + cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); } static void __init kasan_init_depth(void) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 3db40b517947..a3d23da92d87 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1445,7 +1445,7 @@ void ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte * Atomically replaces the active TTBR1_EL1 PGD with a new VA-compatible PGD, * avoiding the possibility of conflicting TLB entries being allocated. */ -void __cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap, bool cnp) +void __cpu_replace_ttbr1(pgd_t *pgdp, bool cnp) { typedef void (ttbr_replace_func)(phys_addr_t); extern ttbr_replace_func idmap_cpu_replace_ttbr1; @@ -1460,7 +1460,7 @@ void __cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap, bool cnp) replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1); - __cpu_install_idmap(idmap); + cpu_install_idmap(); /* * We really don't want to take *any* exceptions while TTBR1 is