From: Marc Zyngier <maz@kernel.org>
To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Ard Biesheuvel <ardb@kernel.org>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Zenghui Yu <yuzenghui@huawei.com>,
Vladimir Murzin <vladimir.murzin@arm.com>
Subject: [PATCH 3/5] arm64: Drop support for CnP
Date: Thu, 1 Jun 2023 15:24:27 +0100 [thread overview]
Message-ID: <20230601142429.12835-4-maz@kernel.org> (raw)
In-Reply-To: <20230601142429.12835-1-maz@kernel.org>
Using CnP in the core architecture code was always fragile (such
as the interactions with MTE), and removing this stuff feels like
a good cleanup.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/include/asm/mmu_context.h | 14 +-------------
arch/arm64/kernel/cpufeature.c | 7 -------
arch/arm64/kernel/mte.c | 12 ------------
arch/arm64/kernel/suspend.c | 4 ----
arch/arm64/mm/context.c | 7 -------
5 files changed, 1 insertion(+), 43 deletions(-)
diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h
index 56911691bef0..2d3953d65387 100644
--- a/arch/arm64/include/asm/mmu_context.h
+++ b/arch/arm64/include/asm/mmu_context.h
@@ -139,7 +139,7 @@ static inline void cpu_install_ttbr0(phys_addr_t ttbr0, unsigned long t0sz)
local_flush_tlb_all();
__cpu_set_tcr_t0sz(t0sz);
- /* avoid cpu_switch_mm() and its SW-PAN and CNP interactions */
+ /* avoid cpu_switch_mm() and its SW-PAN interactions */
write_sysreg(ttbr0, ttbr0_el1);
isb();
}
@@ -158,18 +158,6 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap)
/* phys_to_ttbr() zeros lower 2 bits of ttbr with 52-bit PA */
phys_addr_t ttbr1 = phys_to_ttbr(virt_to_phys(pgdp));
- if (system_supports_cnp() && !WARN_ON(pgdp != lm_alias(swapper_pg_dir))) {
- /*
- * cpu_replace_ttbr1() is used when there's a boot CPU
- * up (i.e. cpufeature framework is not up yet) and
- * latter only when we enable CNP via cpufeature's
- * enable() callback.
- * Also we rely on the cpu_hwcap bit being set before
- * calling the enable() function.
- */
- ttbr1 |= TTBR_CNP_BIT;
- }
-
replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1);
__cpu_install_idmap(idmap);
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index ca4e7e1fc9fa..8f86dca5ee75 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -171,8 +171,6 @@ void dump_cpu_features(void)
.width = 0, \
}
-static void cpu_enable_cnp(struct arm64_cpu_capabilities const *cap);
-
static bool __system_matches_cap(unsigned int n);
/*
@@ -3312,11 +3310,6 @@ static int __init init_32bit_el0_mask(void)
}
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);
-}
-
/*
* We emulate only the following system register space.
* Op0 = 0x3, CRn = 0x0, Op1 = 0x0, CRm = [0, 2 - 7]
diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
index 7e89968bd282..e51ee92c58df 100644
--- a/arch/arm64/kernel/mte.c
+++ b/arch/arm64/kernel/mte.c
@@ -290,18 +290,6 @@ void mte_cpu_setup(void)
{
u64 rgsr;
- /*
- * CnP must be enabled only after the MAIR_EL1 register has been set
- * up. Inconsistent MAIR_EL1 between CPUs sharing the same TLB may
- * lead to the wrong memory type being used for a brief window during
- * CPU power-up.
- *
- * CnP is not a boot feature so MTE gets enabled before CnP, but let's
- * make sure that is the case.
- */
- BUG_ON(read_sysreg(ttbr0_el1) & TTBR_CNP_BIT);
- BUG_ON(read_sysreg(ttbr1_el1) & TTBR_CNP_BIT);
-
/* Normal Tagged memory type at the corresponding MAIR index */
sysreg_clear_set(mair_el1,
MAIR_ATTRIDX(MAIR_ATTR_MASK, MT_NORMAL_TAGGED),
diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index 0fbdf5fe64d8..af92e2d1d55f 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -53,10 +53,6 @@ void notrace __cpu_suspend_exit(void)
*/
cpu_uninstall_idmap();
- /* Restore CnP bit in TTBR1_EL1 */
- if (system_supports_cnp())
- cpu_replace_ttbr1(lm_alias(swapper_pg_dir), idmap_pg_dir);
-
/*
* PSTATE was not saved over suspend/resume, re-enable any detected
* features that might not have been set correctly.
diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c
index e1e0dca01839..3c65644ed770 100644
--- a/arch/arm64/mm/context.c
+++ b/arch/arm64/mm/context.c
@@ -218,9 +218,6 @@ void check_and_switch_context(struct mm_struct *mm)
unsigned int cpu;
u64 asid, old_active_asid;
- if (system_supports_cnp())
- cpu_set_reserved_ttbr0();
-
asid = atomic64_read(&mm->context.id);
/*
@@ -352,10 +349,6 @@ void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm)
unsigned long asid = ASID(mm);
unsigned long ttbr0 = phys_to_ttbr(pgd_phys);
- /* Skip CNP for the reserved ASID */
- if (system_supports_cnp() && asid)
- ttbr0 |= TTBR_CNP_BIT;
-
/* SW PAN needs a copy of the ASID in TTBR0 for entry */
if (IS_ENABLED(CONFIG_ARM64_SW_TTBR0_PAN))
ttbr0 |= FIELD_PREP(TTBR_ASID_MASK, asid);
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-06-01 14:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 14:24 [PATCH 0/5] arm64: Get rid of CnP Marc Zyngier
2023-06-01 14:24 ` [PATCH 1/5] arm64: Remove CnP detection Marc Zyngier
2023-06-01 14:24 ` [PATCH 2/5] arm64: Drop NVIDIA Carmel CnP workaround Marc Zyngier
2023-06-01 14:24 ` Marc Zyngier [this message]
2023-06-01 14:24 ` [PATCH 4/5] KVM: arm64: Remove CnP usage Marc Zyngier
2023-06-01 14:24 ` [PATCH 5/5] arm64: Remove CONFIG_ARM64_CNP Marc Zyngier
2023-06-01 14:31 ` [PATCH 0/5] arm64: Get rid of CnP Marc Zyngier
2023-06-02 8:41 ` Vladimir Murzin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230601142429.12835-4-maz@kernel.org \
--to=maz@kernel.org \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=vladimir.murzin@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).