From patchwork Tue Mar 7 14:05:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2461026wrd; Tue, 7 Mar 2023 06:29:12 -0800 (PST) X-Google-Smtp-Source: AK7set8TDHh0XdSZxPVKEO65sdL00DZxSF3arHJM01ZsrWmYOC89vy1wL+Jxs5oV8p/PlSV5tmAw X-Received: by 2002:a17:902:ea0d:b0:19a:f9b5:2f2f with SMTP id s13-20020a170902ea0d00b0019af9b52f2fmr19006002plg.55.1678199352631; Tue, 07 Mar 2023 06:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678199352; cv=none; d=google.com; s=arc-20160816; b=Vk3nLnzTrr3mYOlJsEr9AYWxzCLPPVm6DswClD31y4YLnxRaaDNR9+v5FIADha5YxS N7lf70M51VgPqlNwF9B3QEnPwobKZG52e+DvB9qPvNukNjuLeuLAjf/O56RrChS7Tx3o PkUJqTZS2dA3aYO3HjA6c6VS/0jw69Jiikknjm0YhjwTCr2NOakhMTJc9JITeHdq9T78 PXH1owNG/NpQ9xSRLdQAWgSUXOjO0+eitvInPBvBgI3Hqcccqe/Oydfm4BQExexZpDKc wV8vaRjaOOF9Gpwh2lGbtP0d66ii6Lqz96uwKkKw3C28ruM5F178IPiOTZDyZTunNm6L 7Nug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=omawqPVQHuo/+Mn2I+NdA2+P02gtMnu0CXGAIfoEyWI=; b=mQqoEiVrMbe1shE8GRcD+R3fWRmRGFMrMpWG99Fe0QT252TRVA/aIC/FEGZJb+y5TN g6pYbcREG/V0xQgOdozybAmukRzlEsf/KXOKJsPc4l/pbUxjQr9LCOo7JTppBCohezQ5 sTWuZSdvCrj1lSwLMuM/Jy9CFynozJmK3wv+V7eO9N4rJIjj8SLwK72L7fKj5xTpCwQ6 MUGdHgUUFlIbssGEbW8soPII8uNOXA8gzp2XGXQOJNdmberprN39ibh4CJn1wFFudaar MYLxXoojnJuHJWMms4Tsj2/9YVx2ieFsJCCVwBL1YL21KS43zgQviVktcusBVOeL2H8E rduw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WFMQQf+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a17090341cb00b0019a7ef5e99fsi14682042ple.86.2023.03.07.06.28.59; Tue, 07 Mar 2023 06:29:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WFMQQf+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231324AbjCGOMZ (ORCPT + 99 others); Tue, 7 Mar 2023 09:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbjCGOLR (ORCPT ); Tue, 7 Mar 2023 09:11:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B82C8B05B for ; Tue, 7 Mar 2023 06:08:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4A60B61458 for ; Tue, 7 Mar 2023 14:08:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFAAFC4339C; Tue, 7 Mar 2023 14:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678198094; bh=PQI4coC3/ibnm3/mD+JXkBCOdMxxUJnhmcG2A1VOyNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WFMQQf+WtXmiw+m8jB4brIlFnzMWsBhXfd1g7Fi+I27gwyc4e+efcJWcx+zrK/lnd dqWFRmz/WUSohHI9wDlpJ4OcVTuFAX4oyxaWH5bo4lzuROE1XH/BDIB7fN/HNTz/ch aXBb/8ZFPa3KGsH8ApheDzEGNp16+JhGsdI8VWTqtIGs5BJZTAa6qYcex2EKfqWyc7 ekLRxzbTkVH0ywzgZuvE1uy3qefbdZGvncYUmYv4oqiIigy/7MIjwDDiKivY4xVE4V a5sVneCSA0o0ulki0bdQ1N9SxrDjvu0scgqXv24OcAbbirW80Idvu7tpxwlGZgR1O+ 8zoWg774s3Y/g== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: [PATCH v3 40/60] arm64: Revert "mm: provide idmap pointer to cpu_replace_ttbr1()" Date: Tue, 7 Mar 2023 15:05:02 +0100 Message-Id: <20230307140522.2311461-41-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307140522.2311461-1-ardb@kernel.org> References: <20230307140522.2311461-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3767; i=ardb@kernel.org; h=from:subject; bh=PQI4coC3/ibnm3/mD+JXkBCOdMxxUJnhmcG2A1VOyNA=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIYXdJd2wI3XZxHcbg78XCtwqTV+vbr7kpe/3iLab5bumb WZrPcDQUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACZSzM3wV2zxykVWmnOXrzXh LrtUMvFc6C95va8cShmx+tl33kX4izL8dz/y46OtypvzP1qfVqxOT/m8pvNTAbdWVI757YMWBb4 6LAA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759719564426181601?= X-GMAIL-MSGID: =?utf-8?q?1759719564426181601?= This reverts commit 1682c45b920643c, which is no longer needed now that we create the permanent kernel mapping directly during early boot. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/mmu_context.h | 13 ++++--------- arch/arm64/kernel/cpufeature.c | 2 +- arch/arm64/kernel/suspend.c | 2 +- arch/arm64/mm/kasan_init.c | 4 ++-- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index f9ae2891e4c72c7f..bc1cef5002d60e02 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -104,18 +104,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,7 +141,7 @@ static inline void cpu_install_ttbr0(phys_addr_t ttbr0, unsigned long t0sz) * Atomically replaces the active TTBR1_EL1 PGD with a new VA-compatible PGD, * avoiding the possibility of conflicting TLB entries being allocated. */ -static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap) +static inline void cpu_replace_ttbr1(pgd_t *pgdp) { typedef void (ttbr_replace_func)(phys_addr_t); extern ttbr_replace_func idmap_cpu_replace_ttbr1; @@ -170,7 +165,7 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap) 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 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index e9788671be044a47..b206de4758ce6fb3 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -3456,7 +3456,7 @@ subsys_initcall_sync(init_32bit_el0_mask); static void __maybe_unused cpu_enable_cnp(struct arm64_cpu_capabilities const *cap) { - cpu_replace_ttbr1(lm_alias(swapper_pg_dir), idmap_pg_dir); + cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); } /* diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c index 0fbdf5fe64d8da08..7c2391851db6c198 100644 --- a/arch/arm64/kernel/suspend.c +++ b/arch/arm64/kernel/suspend.c @@ -55,7 +55,7 @@ void notrace __cpu_suspend_exit(void) /* Restore CnP bit in TTBR1_EL1 */ if (system_supports_cnp()) - cpu_replace_ttbr1(lm_alias(swapper_pg_dir), idmap_pg_dir); + cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); /* * PSTATE was not saved over suspend/resume, re-enable any detected diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index df98f496539f0e39..7e32f21fb8e1e227 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -221,7 +221,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); @@ -265,7 +265,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)