projects/linux·commit 56ec8e4c

Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

56ec8e4c · Linus Torvalds <[email protected]> · 2023-11-01 09:34:55 -10:00

Pull arm64 updates from Catalin Marinas:
 "No major architecture features this time around, just some new HWCAP
  definitions, support for the Ampere SoC PMUs and a few fixes/cleanups.

  The bulk of the changes is reworking of the CPU capability checking
  code (cpus_have_cap() etc).

   - Major refactoring of the CPU capability detection logic resulting
     in the removal of the cpus_have_const_cap() function and migrating
     the code to "alternative" branches where possible

   - Backtrace/kgdb: use IPIs and pseudo-NMI

   - Perf and PMU:

      - Add support for Ampere SoC PMUs

      - Multi-DTC improvements for larger CMN configurations with
        multiple Debug & Trace Controllers

      - Rework the Arm CoreSight PMU driver to allow separate
        registration of vendor backend modules

      - Fixes: add missing MODULE_DEVICE_TABLE to the amlogic perf
        driver; use device_get_match_data() in the xgene driver; fix
        NULL pointer dereference in the hisi driver caused by calling
        cpuhp_state_remove_instance(); use-after-free in the hisi driver

   - HWCAP updates:

      - FEAT_SVE_B16B16 (BFloat16)

      - FEAT_LRCPC3 (release consistency model)

      - FEAT_LSE128 (128-bit atomic instructions)

   - SVE: remove a couple of pseudo registers from the cpufeature code.
     There is logic in place already to detect mismatched SVE features

   - Miscellaneous:

      - Reduce the default swiotlb size (currently 64MB) if no ZONE_DMA
        bouncing is needed. The buffer is still required for small
        kmalloc() buffers

      - Fix module PLT counting with !RANDOMIZE_BASE

      - Restrict CPU_BIG_ENDIAN to LLVM IAS 15.x or newer move
        synchronisation code out of the set_ptes() loop

      - More compact cpufeature displaying enabled cores

      - Kselftest updates for the new CPU features"

 * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (83 commits)
  arm64: Restrict CPU_BIG_ENDIAN to GNU as or LLVM IAS 15.x or newer
  arm64: module: Fix PLT counting when CONFIG_RANDOMIZE_BASE=n
  arm64, irqchip/gic-v3, ACPI: Move MADT GICC enabled check into a helper
  perf: hisi: Fix use-after-free when register pmu fails
  drivers/perf: hisi_pcie: Initialize event->cpu only on success
  drivers/perf: hisi_pcie: Check the type first in pmu::event_init()
  arm64: cpufeature: Change DBM to display enabled cores
  arm64: cpufeature: Display the set of cores with a feature
  perf/arm-cmn: Enable per-DTC counter allocation
  perf/arm-cmn: Rework DTC counters (again)
  perf/arm-cmn: Fix DTC domain detection
  drivers: perf: arm_pmuv3: Drop some unused arguments from armv8_pmu_init()
  drivers: perf: arm_pmuv3: Read PMMIR_EL1 unconditionally
  drivers/perf: hisi: use cpuhp_state_remove_instance_nocalls() for hisi_hns3_pmu uninit process
  clocksource/drivers/arm_arch_timer: limit XGene-1 workaround
  arm64: Remove system_uses_lse_atomics()
  arm64: Mark the 'addr' argument to set_ptes() and __set_pte_at() as unused
  drivers/perf: xgene: Use device_get_match_data()
  perf/amlogic: add missing MODULE_DEVICE_TABLE
  arm64/mm: Hoist synchronization out of set_ptes() loop
  ...
Commit
56ec8e4cd8cbff3c96c53cd8303bba924613b5ce
Parents
7d461b29 · 14dcf78a

Merge commit. Changes below are compared with the first parent: 7d461b29.

Changes

89 files changed · +1459 −734

FileStatusAddDelContent
Documentation/admin-guide/perf/ampere_cspmu.rstadded+29−0View file
Documentation/admin-guide/perf/index.rstmodified+1−0View file
Documentation/arch/arm64/cpu-feature-registers.rstmodified+2−0View file
Documentation/arch/arm64/elf_hwcaps.rstmodified+9−0View file
arch/arm/xen/enlighten.cmodified+16−9View file
arch/arm64/Kconfigmodified+2−0View file
arch/arm64/include/asm/Kbuildmodified+1−1View file
arch/arm64/include/asm/alternative-macros.hmodified+4−4View file
arch/arm64/include/asm/arch_gicv3.hmodified+8−0View file
arch/arm64/include/asm/archrandom.hmodified+1−1View file
arch/arm64/include/asm/cacheflush.hmodified+1−1View file
arch/arm64/include/asm/cpu.hmodified+0−6View file
arch/arm64/include/asm/cpucaps.hadded+67−0View file
arch/arm64/include/asm/cpufeature.hmodified+43−55View file
arch/arm64/include/asm/cputype.hmodified+2−1View file
arch/arm64/include/asm/fpsimd.hmodified+31−5View file
arch/arm64/include/asm/hwcap.hmodified+3−0View file
arch/arm64/include/asm/irq.hmodified+3−0View file
arch/arm64/include/asm/irqflags.hmodified+7−13View file
arch/arm64/include/asm/kvm_emulate.hmodified+2−2View file
arch/arm64/include/asm/kvm_host.hmodified+1−1View file
arch/arm64/include/asm/kvm_mmu.hmodified+1−1View file
arch/arm64/include/asm/lse.hmodified+1−8View file
arch/arm64/include/asm/mmu.hmodified+1−1View file
arch/arm64/include/asm/mmu_context.hmodified+17−11View file
arch/arm64/include/asm/module.hmodified+1−2View file
arch/arm64/include/asm/mte.hmodified+2−2View file
arch/arm64/include/asm/pgtable-prot.hmodified+1−5View file
arch/arm64/include/asm/pgtable.hmodified+21−13View file
arch/arm64/include/asm/smp.hmodified+2−2View file
arch/arm64/include/asm/spectre.hmodified+1−1View file
arch/arm64/include/asm/tlbflush.hmodified+3−4View file
arch/arm64/include/asm/vectors.hmodified+1−1View file
arch/arm64/include/uapi/asm/hwcap.hmodified+3−0View file
arch/arm64/kernel/acpi_parking_protocol.cmodified+1−1View file
arch/arm64/kernel/cpu_errata.cmodified+0−17View file
arch/arm64/kernel/cpufeature.cmodified+131−141View file
arch/arm64/kernel/cpuinfo.cmodified+3−0View file
arch/arm64/kernel/efi.cmodified+1−2View file
arch/arm64/kernel/fpsimd.cmodified+55−94View file
arch/arm64/kernel/idle.cmodified+2−2View file
arch/arm64/kernel/module-plts.cmodified+3−10View file
arch/arm64/kernel/mte.cmodified+2−2View file
arch/arm64/kernel/process.cmodified+1−1View file
arch/arm64/kernel/proton-pack.cmodified+1−1View file
arch/arm64/kernel/smp.cmodified+117−30View file
arch/arm64/kernel/suspend.cmodified+11−2View file
arch/arm64/kernel/sys_compat.cmodified+1−1View file
arch/arm64/kernel/traps.cmodified+1−1View file
arch/arm64/kernel/vdso.cmodified+1−1View file
arch/arm64/kvm/arm.cmodified+5−5View file
arch/arm64/kvm/guest.cmodified+3−3View file
arch/arm64/kvm/hyp/pgtable.cmodified+2−2View file
arch/arm64/kvm/mmu.cmodified+1−1View file
arch/arm64/kvm/sys_regs.cmodified+1−1View file
arch/arm64/kvm/vgic/vgic-v3.cmodified+1−1View file
arch/arm64/lib/delay.cmodified+1−1View file
arch/arm64/mm/fault.cmodified+1−1View file
arch/arm64/mm/hugetlbpage.cmodified+1−2View file
arch/arm64/mm/init.cmodified+10−1View file
arch/arm64/mm/mmap.cmodified+1−1View file
arch/arm64/mm/mmu.cmodified+1−2View file
arch/arm64/mm/proc.Smodified+1−2View file
arch/arm64/tools/Makefilemodified+2−2View file
arch/arm64/tools/cpucapsmodified+1−1View file
arch/arm64/tools/gen-cpucaps.awkmodified+3−3View file
arch/arm64/tools/sysregmodified+7−1View file
drivers/acpi/processor_core.cmodified+1−1View file
drivers/clocksource/arm_arch_timer.cmodified+29−7View file
drivers/irqchip/irq-gic-v3.cmodified+46−36View file
drivers/perf/amlogic/meson_g12_ddr_pmu.cmodified+1−0View file
drivers/perf/arm-cmn.cmodified+85−69View file
drivers/perf/arm_cspmu/Kconfigmodified+18−1View file
drivers/perf/arm_cspmu/Makefilemodified+6−2View file
drivers/perf/arm_cspmu/ampere_cspmu.cadded+272−0View file
drivers/perf/arm_cspmu/arm_cspmu.cmodified+160−41View file
drivers/perf/arm_cspmu/arm_cspmu.hmodified+31−1View file
drivers/perf/arm_cspmu/nvidia_cspmu.cmodified+30−4View file
drivers/perf/arm_cspmu/nvidia_cspmu.hdeleted+0−17View before deletion
drivers/perf/arm_pmuv3.cmodified+13−33View file
drivers/perf/hisilicon/hisi_pcie_pmu.cmodified+5−4View file
drivers/perf/hisilicon/hisi_uncore_pa_pmu.cmodified+2−2View file
drivers/perf/hisilicon/hisi_uncore_sllc_pmu.cmodified+2−2View file
drivers/perf/hisilicon/hns3_pmu.cmodified+4−4View file
drivers/perf/xgene_pmu.cmodified+13−24View file
include/linux/acpi.hmodified+5−0View file
include/linux/cpuhotplug.hmodified+2−0View file
tools/testing/selftests/arm64/abi/hwcap.cmodified+54−0View file
tools/testing/selftests/arm64/fp/sve-test.Smodified+19−0View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/admin-guide/perf/ampere_cspmu.rst

View file
diff --git a/Documentation/admin-guide/perf/ampere_cspmu.rst b/Documentation/admin-guide/perf/ampere_cspmu.rst
new file mode 100644
index 0000000..94f93f5
--- /dev/null
+++ b/Documentation/admin-guide/perf/ampere_cspmu.rst
@@ -0,0 +1,29 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+============================================
+Ampere SoC Performance Monitoring Unit (PMU)
+============================================
+
+Ampere SoC PMU is a generic PMU IP that follows Arm CoreSight PMU architecture.
+Therefore, the driver is implemented as a submodule of arm_cspmu driver. At the
+first phase it's used for counting MCU events on AmpereOne.
+
+
+MCU PMU events
+--------------
+
+The PMU driver supports setting filters for "rank", "bank", and "threshold".
+Note, that the filters are per PMU instance rather than per event.
+
+
+Example for perf tool use::
+
+ / # perf list ampere
+
+ ampere_mcu_pmu_0/act_sent/ [Kernel PMU event]
+ <...>
+ ampere_mcu_pmu_1/rd_sent/ [Kernel PMU event]
+ <...>
+
+ / # perf stat -a -e ampere_mcu_pmu_0/act_sent,bank=5,rank=3,threshold=2/,ampere_mcu_pmu_1/rd_sent/ \
+ sleep 1

Documentation/admin-guide/perf/index.rst

View file
diff --git a/Documentation/admin-guide/perf/index.rst b/Documentation/admin-guide/perf/index.rst
index f60be04..a2e6f2c 100644
--- a/Documentation/admin-guide/perf/index.rst
+++ b/Documentation/admin-guide/perf/index.rst
@@ -22,3 +22,4 @@ Performance monitor support
nvidia-pmu
meson-ddr-pmu
cxl
+ ampere_cspmu

Documentation/arch/arm64/cpu-feature-registers.rst

View file
diff --git a/Documentation/arch/arm64/cpu-feature-registers.rst b/Documentation/arch/arm64/cpu-feature-registers.rst
index de6d8a4..44f9bd7 100644
--- a/Documentation/arch/arm64/cpu-feature-registers.rst
+++ b/Documentation/arch/arm64/cpu-feature-registers.rst
@@ -268,6 +268,8 @@ infrastructure:
+------------------------------+---------+---------+
| SHA3 | [35-32] | y |
+------------------------------+---------+---------+
+ | B16B16 | [27-24] | y |
+ +------------------------------+---------+---------+
| BF16 | [23-20] | y |
+------------------------------+---------+---------+
| BitPerm | [19-16] | y |

Documentation/arch/arm64/elf_hwcaps.rst

View file
diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst
index 76ff9d7..4b8399a 100644
--- a/Documentation/arch/arm64/elf_hwcaps.rst
+++ b/Documentation/arch/arm64/elf_hwcaps.rst
@@ -308,6 +308,15 @@ HWCAP2_MOPS
HWCAP2_HBC
Functionality implied by ID_AA64ISAR2_EL1.BC == 0b0001.
+HWCAP2_SVE_B16B16
+ Functionality implied by ID_AA64ZFR0_EL1.B16B16 == 0b0001.
+
+HWCAP2_LRCPC3
+ Functionality implied by ID_AA64ISAR1_EL1.LRCPC == 0b0011.
+
+HWCAP2_LSE128
+ Functionality implied by ID_AA64ISAR0_EL1.Atomic == 0b0011.
+
4. Unused AT_HWCAP bits
-----------------------

arch/arm/xen/enlighten.c

View file
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index c392e18..9afdc4c 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -164,9 +164,6 @@ static int xen_starting_cpu(unsigned int cpu)
BUG_ON(err);
per_cpu(xen_vcpu, cpu) = vcpup;
- if (!xen_kernel_unmapped_at_usr())
- xen_setup_runstate_info(cpu);
-
after_register_vcpu_info:
enable_percpu_irq(xen_events_irq, 0);
return 0;
@@ -523,9 +520,6 @@ static int __init xen_guest_init(void)
return -EINVAL;
}
- if (!xen_kernel_unmapped_at_usr())
- xen_time_setup_guest();
-
if (xen_initial_domain())
pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier);
@@ -535,7 +529,13 @@ static int __init xen_guest_init(void)
}
early_initcall(xen_guest_init);
-static int __init xen_pm_init(void)
+static int xen_starting_runstate_cpu(unsigned int cpu)
+{
+ xen_setup_runstate_info(cpu);
+ return 0;
+}
+
+static int __init xen_late_init(void)
{
if (!xen_domain())
return -ENODEV;
@@ -548,9 +548,16 @@ static int __init xen_pm_init(void)
do_settimeofday64(&ts);
}
- return 0;
+ if (xen_kernel_unmapped_at_usr())
+ return 0;
+
+ xen_time_setup_guest();
+
+ return cpuhp_setup_state(CPUHP_AP_ARM_XEN_RUNSTATE_STARTING,
+ "arm/xen_runstate:starting",
+ xen_starting_runstate_cpu, NULL);
}
-late_initcall(xen_pm_init);
+late_initcall(xen_late_init);
/* empty stubs */

arch/arm64/Kconfig

View file
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 78f20e6..6062a52 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1368,6 +1368,8 @@ choice
config CPU_BIG_ENDIAN
bool "Build big-endian kernel"
depends on !LD_IS_LLD || LLD_VERSION >= 130000
+ # https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c
+ depends on AS_IS_GNU || AS_VERSION >= 150000
help
Say Y if you plan on running a kernel with a big-endian userspace.

arch/arm64/include/asm/Kbuild

View file
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 5c8ee5a..4b6d2d5 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -6,5 +6,5 @@ generic-y += qspinlock.h
generic-y += parport.h
generic-y += user.h
-generated-y += cpucaps.h
+generated-y += cpucap-defs.h
generated-y += sysreg-defs.h

arch/arm64/include/asm/alternative-macros.h

View file
diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h
index 94b4861..210bb43 100644
--- a/arch/arm64/include/asm/alternative-macros.h
+++ b/arch/arm64/include/asm/alternative-macros.h
@@ -226,8 +226,8 @@ alternative_endif
static __always_inline bool
alternative_has_cap_likely(const unsigned long cpucap)
{
- compiletime_assert(cpucap < ARM64_NCAPS,
- "cpucap must be < ARM64_NCAPS");
+ if (!cpucap_is_possible(cpucap))
+ return false;
asm_volatile_goto(
ALTERNATIVE_CB("b %l[l_no]", %[cpucap], alt_cb_patch_nops)
@@ -244,8 +244,8 @@ l_no:
static __always_inline bool
alternative_has_cap_unlikely(const unsigned long cpucap)
{
- compiletime_assert(cpucap < ARM64_NCAPS,
- "cpucap must be < ARM64_NCAPS");
+ if (!cpucap_is_possible(cpucap))
+ return false;
asm_volatile_goto(
ALTERNATIVE("nop", "b %l[l_yes]", %[cpucap])

arch/arm64/include/asm/arch_gicv3.h

View file
diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index 01281a5..5f17261 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -79,6 +79,14 @@ static inline u64 gic_read_iar_cavium_thunderx(void)
return 0x3ff;
}
+static u64 __maybe_unused gic_read_iar(void)
+{
+ if (alternative_has_cap_unlikely(ARM64_WORKAROUND_CAVIUM_23154))
+ return gic_read_iar_cavium_thunderx();
+ else
+ return gic_read_iar_common();
+}
+
static inline void gic_write_ctlr(u32 val)
{
write_sysreg_s(val, SYS_ICC_CTLR_EL1);

arch/arm64/include/asm/archrandom.h

View file
diff --git a/arch/arm64/include/asm/archrandom.h b/arch/arm64/include/asm/archrandom.h
index b0abc64..ecdb3cf 100644
--- a/arch/arm64/include/asm/archrandom.h
+++ b/arch/arm64/include/asm/archrandom.h
@@ -63,7 +63,7 @@ static __always_inline bool __cpu_has_rng(void)
{
if (unlikely(!system_capabilities_finalized() && !preemptible()))
return this_cpu_has_cap(ARM64_HAS_RNG);
- return cpus_have_const_cap(ARM64_HAS_RNG);
+ return alternative_has_cap_unlikely(ARM64_HAS_RNG);
}
static inline size_t __must_check arch_get_random_longs(unsigned long *v, size_t max_longs)

arch/arm64/include/asm/cacheflush.h

View file
diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h
index d115451..fefac75 100644
--- a/arch/arm64/include/asm/cacheflush.h
+++ b/arch/arm64/include/asm/cacheflush.h
@@ -132,7 +132,7 @@ void flush_dcache_folio(struct folio *);
static __always_inline void icache_inval_all_pou(void)
{
- if (cpus_have_const_cap(ARM64_HAS_CACHE_DIC))
+ if (alternative_has_cap_unlikely(ARM64_HAS_CACHE_DIC))
return;
asm("ic ialluis");

arch/arm64/include/asm/cpu.h

View file
diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h
index e749838..f303409 100644
--- a/arch/arm64/include/asm/cpu.h
+++ b/arch/arm64/include/asm/cpu.h
@@ -63,12 +63,6 @@ struct cpuinfo_arm64 {
u64 reg_id_aa64smfr0;
struct cpuinfo_32bit aarch32;
-
- /* pseudo-ZCR for recording maximum ZCR_EL1 LEN value: */
- u64 reg_zcr;
-
- /* pseudo-SMCR for recording maximum SMCR_EL1 LEN value: */
- u64 reg_smcr;
};
DECLARE_PER_CPU(struct cpuinfo_arm64, cpu_data);

arch/arm64/include/asm/cpucaps.h

View file
diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h
new file mode 100644
index 0000000..270680e
--- /dev/null
+++ b/arch/arm64/include/asm/cpucaps.h
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_CPUCAPS_H
+#define __ASM_CPUCAPS_H
+
+#include <asm/cpucap-defs.h>
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+/*
+ * Check whether a cpucap is possible at compiletime.
+ */
+static __always_inline bool
+cpucap_is_possible(const unsigned int cap)
+{
+ compiletime_assert(__builtin_constant_p(cap),
+ "cap must be a constant");
+ compiletime_assert(cap < ARM64_NCAPS,
+ "cap must be < ARM64_NCAPS");
+
+ switch (cap) {
+ case ARM64_HAS_PAN:
+ return IS_ENABLED(CONFIG_ARM64_PAN);
+ case ARM64_HAS_EPAN:
+ return IS_ENABLED(CONFIG_ARM64_EPAN);
+ case ARM64_SVE:
+ return IS_ENABLED(CONFIG_ARM64_SVE);
+ case ARM64_SME:
+ case ARM64_SME2:
+ case ARM64_SME_FA64:
+ return IS_ENABLED(CONFIG_ARM64_SME);
+ case ARM64_HAS_CNP:
+ return IS_ENABLED(CONFIG_ARM64_CNP);
+ case ARM64_HAS_ADDRESS_AUTH:
+ case ARM64_HAS_GENERIC_AUTH:
+ return IS_ENABLED(CONFIG_ARM64_PTR_AUTH);
+ case ARM64_HAS_GIC_PRIO_MASKING:
+ return IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI);
+ case ARM64_MTE:
+ return IS_ENABLED(CONFIG_ARM64_MTE);
+ case ARM64_BTI:
+ return IS_ENABLED(CONFIG_ARM64_BTI);
+ case ARM64_HAS_TLB_RANGE:
+ return IS_ENABLED(CONFIG_ARM64_TLB_RANGE);
+ case ARM64_UNMAP_KERNEL_AT_EL0:
+ return IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0);
+ case ARM64_WORKAROUND_843419:
+ return IS_ENABLED(CONFIG_ARM64_ERRATUM_843419);
+ case ARM64_WORKAROUND_1742098:
+ return IS_ENABLED(CONFIG_ARM64_ERRATUM_1742098);
+ case ARM64_WORKAROUND_2645198:
+ return IS_ENABLED(CONFIG_ARM64_ERRATUM_2645198);
+ case ARM64_WORKAROUND_2658417:
+ return IS_ENABLED(CONFIG_ARM64_ERRATUM_2658417);
+ case ARM64_WORKAROUND_CAVIUM_23154:
+ return IS_ENABLED(CONFIG_CAVIUM_ERRATUM_23154);
+ case ARM64_WORKAROUND_NVIDIA_CARMEL_CNP:
+ return IS_ENABLED(CONFIG_NVIDIA_CARMEL_CNP_ERRATUM);
+ case ARM64_WORKAROUND_REPEAT_TLBI:
+ return IS_ENABLED(CONFIG_ARM64_WORKAROUND_REPEAT_TLBI);
+ }
+
+ return true;
+}
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_CPUCAPS_H */

arch/arm64/include/asm/cpufeature.h

View file
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 5bba393..f6d416f 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -23,6 +23,7 @@
#include <linux/bug.h>
#include <linux/jump_label.h>
#include <linux/kernel.h>
+#include <linux/cpumask.h>
/*
* CPU feature register tracking
@@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
* method is robust against being called multiple times.
*/
const struct arm64_cpu_capabilities *match_list;
+ const struct cpumask *cpus;
};
static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
@@ -438,6 +440,11 @@ unsigned long cpu_get_elf_hwcap2(void);
#define cpu_set_named_feature(name) cpu_set_feature(cpu_feature(name))
#define cpu_have_named_feature(name) cpu_have_feature(cpu_feature(name))
+static __always_inline bool boot_capabilities_finalized(void)
+{
+ return alternative_has_cap_likely(ARM64_ALWAYS_BOOT);
+}
+
static __always_inline bool system_capabilities_finalized(void)
{
return alternative_has_cap_likely(ARM64_ALWAYS_SYSTEM);
@@ -450,6 +457,8 @@ static __always_inline bool system_capabilities_finalized(void)
*/
static __always_inline bool cpus_have_cap(unsigned int num)
{
+ if (__builtin_constant_p(num) && !cpucap_is_possible(num))
+ return false;
if (num >= ARM64_NCAPS)
return false;
return arch_test_bit(num, system_cpucaps);
@@ -458,55 +467,37 @@ static __always_inline bool cpus_have_cap(unsigned int num)
/*
* Test for a capability without a runtime check.
*
- * Before capabilities are finalized, this returns false.
- * After capabilities are finalized, this is patched to avoid a runtime check.
+ * Before boot capabilities are finalized, this will BUG().
+ * After boot capabilities are finalized, this is patched to avoid a runtime
+ * check.
*
* @num must be a compile-time constant.
*/
-static __always_inline bool __cpus_have_const_cap(int num)
+static __always_inline bool cpus_have_final_boot_cap(int num)
{
- if (num >= ARM64_NCAPS)
- return false;
- return alternative_has_cap_unlikely(num);
+ if (boot_capabilities_finalized())
+ return alternative_has_cap_unlikely(num);
+ else
+ BUG();
}
/*
* Test for a capability without a runtime check.
*
- * Before capabilities are finalized, this will BUG().
- * After capabilities are finalized, this is patched to avoid a runtime check.
+ * Before system capabilities are finalized, this will BUG().
+ * After system capabilities are finalized, this is patched to avoid a runtime
+ * check.
*
* @num must be a compile-time constant.
*/
static __always_inline bool cpus_have_final_cap(int num)
{
if (system_capabilities_finalized())
- return __cpus_have_const_cap(num);
+ return alternative_has_cap_unlikely(num);
else
BUG();
}
-/*
- * Test for a capability, possibly with a runtime check for non-hyp code.
- *
- * For hyp code, this behaves the same as cpus_have_final_cap().
- *
- * For non-hyp code:
- * Before capabilities are finalized, this behaves as cpus_have_cap().
- * After capabilities are finalized, this is patched to avoid a runtime check.
- *
- * @num must be a compile-time constant.
- */
-static __always_inline bool cpus_have_const_cap(int num)
-{
- if (is_hyp_code())
- return cpus_have_final_cap(num);
- else if (system_capabilities_finalized())
- return __cpus_have_const_cap(num);
- else
- return cpus_have_cap(num);
-}
-
static inline int __attribute_const__
cpuid_feature_extract_signed_field_width(u64 features, int field, int width)
{
@@ -626,7 +617,9 @@ static inline bool id_aa64pfr1_mte(u64 pfr1)
return val >= ID_AA64PFR1_EL1_MTE_MTE2;
}
-void __init setup_cpu_features(void);
+void __init setup_system_features(void);
+void __init setup_user_features(void);
+
void check_local_cpu_capabilities(void);
u64 read_sanitised_ftr_reg(u32 id);
@@ -735,13 +728,12 @@ static inline bool system_supports_mixed_endian(void)
static __always_inline bool system_supports_fpsimd(void)
{
- return !cpus_have_const_cap(ARM64_HAS_NO_FPSIMD);
+ return alternative_has_cap_likely(ARM64_HAS_FPSIMD);
}
static inline bool system_uses_hw_pan(void)
{
- return IS_ENABLED(CONFIG_ARM64_PAN) &&
- cpus_have_const_cap(ARM64_HAS_PAN);
+ return alternative_has_cap_unlikely(ARM64_HAS_PAN);
}
static inline bool system_uses_ttbr0_pan(void)
@@ -752,26 +744,22 @@ static inline bool system_uses_ttbr0_pan(void)
static __always_inline bool system_supports_sve(void)
{
- return IS_ENABLED(CONFIG_ARM64_SVE) &&
- cpus_have_const_cap(ARM64_SVE);
+ return alternative_has_cap_unlikely(ARM64_SVE);
}
static __always_inline bool system_supports_sme(void)
{
- return IS_ENABLED(CONFIG_ARM64_SME) &&
- cpus_have_const_cap(ARM64_SME);
+ return alternative_has_cap_unlikely(ARM64_SME);
}
static __always_inline bool system_supports_sme2(void)
{
- return IS_ENABLED(CONFIG_ARM64_SME) &&
- cpus_have_const_cap(ARM64_SME2);
+ return alternative_has_cap_unlikely(ARM64_SME2);
}
static __always_inline bool system_supports_fa64(void)
{
- return IS_ENABLED(CONFIG_ARM64_SME) &&
- cpus_have_const_cap(ARM64_SME_FA64);
+ return alternative_has_cap_unlikely(ARM64_SME_FA64);
}
static __always_inline bool system_supports_tpidr2(void)
@@ -781,20 +769,17 @@ static __always_inline bool system_supports_tpidr2(void)
static __always_inline bool system_supports_cnp(void)
{
- return IS_ENABLED(CONFIG_ARM64_CNP) &&
- cpus_have_const_cap(ARM64_HAS_CNP);
+ return alternative_has_cap_unlikely(ARM64_HAS_CNP);
}
static inline bool system_supports_address_auth(void)
{
- return IS_ENABLED(CONFIG_ARM64_PTR_AUTH) &&
- cpus_have_const_cap(ARM64_HAS_ADDRESS_AUTH);
+ return cpus_have_final_boot_cap(ARM64_HAS_ADDRESS_AUTH);
}
static inline bool system_supports_generic_auth(void)
{
- return IS_ENABLED(CONFIG_ARM64_PTR_AUTH) &&
- cpus_have_const_cap(ARM64_HAS_GENERIC_AUTH);
+ return alternative_has_cap_unlikely(ARM64_HAS_GENERIC_AUTH);
}
static inline bool system_has_full_ptr_auth(void)
@@ -804,14 +789,12 @@ static inline bool system_has_full_ptr_auth(void)
static __always_inline bool system_uses_irq_prio_masking(void)
{
- return IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) &&
- cpus_have_const_cap(ARM64_HAS_GIC_PRIO_MASKING);
+ return alternative_has_cap_unlikely(ARM64_HAS_GIC_PRIO_MASKING);
}
static inline bool system_supports_mte(void)
{
- return IS_ENABLED(CONFIG_ARM64_MTE) &&
- cpus_have_const_cap(ARM64_MTE);
+ return alternative_has_cap_unlikely(ARM64_MTE);
}
static inline bool system_has_prio_mask_debugging(void)
@@ -822,13 +805,18 @@ static inline bool system_has_prio_mask_debugging(void)
static inline bool system_supports_bti(void)
{
- return IS_ENABLED(CONFIG_ARM64_BTI) && cpus_have_const_cap(ARM64_BTI);
+ return cpus_have_final_cap(ARM64_BTI);
+}
+
+static inline bool system_supports_bti_kernel(void)
+{
+ return IS_ENABLED(CONFIG_ARM64_BTI_KERNEL) &&
+ cpus_have_final_boot_cap(ARM64_BTI);
}
static inline bool system_supports_tlb_range(void)
{
- return IS_ENABLED(CONFIG_ARM64_TLB_RANGE) &&
- cpus_have_const_cap(ARM64_HAS_TLB_RANGE);
+ return alternative_has_cap_unlikely(ARM64_HAS_TLB_RANGE);
}
int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);

arch/arm64/include/asm/cputype.h

View file
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index 74d00fe..7c7493c 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -86,7 +86,8 @@
#define ARM_CPU_PART_NEOVERSE_N2 0xD49
#define ARM_CPU_PART_CORTEX_A78C 0xD4B
-#define APM_CPU_PART_POTENZA 0x000
+#define APM_CPU_PART_XGENE 0x000
+#define APM_CPU_VAR_POTENZA 0x00
#define CAVIUM_CPU_PART_THUNDERX 0x0A1
#define CAVIUM_CPU_PART_THUNDERX_81XX 0x0A2

arch/arm64/include/asm/fpsimd.h

View file
diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
index 8df46f1..50e5f25 100644
--- a/arch/arm64/include/asm/fpsimd.h
+++ b/arch/arm64/include/asm/fpsimd.h
@@ -32,6 +32,32 @@
#define VFP_STATE_SIZE ((32 * 8) + 4)
#endif
+static inline unsigned long cpacr_save_enable_kernel_sve(void)
+{
+ unsigned long old = read_sysreg(cpacr_el1);
+ unsigned long set = CPACR_EL1_FPEN_EL1EN | CPACR_EL1_ZEN_EL1EN;
+
+ write_sysreg(old | set, cpacr_el1);
+ isb();
+ return old;
+}
+
+static inline unsigned long cpacr_save_enable_kernel_sme(void)
+{
+ unsigned long old = read_sysreg(cpacr_el1);
+ unsigned long set = CPACR_EL1_FPEN_EL1EN | CPACR_EL1_SMEN_EL1EN;
+
+ write_sysreg(old | set, cpacr_el1);
+ isb();
+ return old;
+}
+
+static inline void cpacr_restore(unsigned long cpacr)
+{
+ write_sysreg(cpacr, cpacr_el1);
+ isb();
+}
+
/*
* When we defined the maximum SVE vector length we defined the ABI so

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/hwcap.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/irq.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/irqflags.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_emulate.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_mmu.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/lse.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/mmu.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/mmu_context.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/module.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/mte.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/pgtable-prot.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/pgtable.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/smp.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/spectre.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/tlbflush.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/vectors.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/uapi/asm/hwcap.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/acpi_parking_protocol.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/cpu_errata.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/cpufeature.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/cpuinfo.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/efi.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/fpsimd.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/idle.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/module-plts.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/mte.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/process.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/proton-pack.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/smp.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/suspend.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/sys_compat.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/traps.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/vdso.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/arm.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/guest.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/hyp/pgtable.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/sys_regs.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/vgic/vgic-v3.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/lib/delay.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/mm/fault.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/mm/hugetlbpage.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/mm/init.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/mm/mmap.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/mm/mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/mm/proc.S

View file

This diff is incomplete. Download the complete patch.

arch/arm64/tools/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/arm64/tools/cpucaps

View file

This diff is incomplete. Download the complete patch.

arch/arm64/tools/gen-cpucaps.awk

View file

This diff is incomplete. Download the complete patch.

arch/arm64/tools/sysreg

View file

This diff is incomplete. Download the complete patch.

drivers/acpi/processor_core.c

View file

This diff is incomplete. Download the complete patch.

drivers/clocksource/arm_arch_timer.c

View file

This diff is incomplete. Download the complete patch.

drivers/irqchip/irq-gic-v3.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/amlogic/meson_g12_ddr_pmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm-cmn.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm_cspmu/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm_cspmu/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm_cspmu/ampere_cspmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm_cspmu/arm_cspmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm_cspmu/arm_cspmu.h

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm_cspmu/nvidia_cspmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/arm_cspmu/nvidia_cspmu.h

View before deletion

This diff is incomplete. Download the complete patch.

drivers/perf/arm_pmuv3.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/hisilicon/hisi_pcie_pmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/hisilicon/hisi_uncore_pa_pmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/hisilicon/hns3_pmu.c

View file

This diff is incomplete. Download the complete patch.

drivers/perf/xgene_pmu.c

View file

This diff is incomplete. Download the complete patch.

include/linux/acpi.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cpuhotplug.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/arm64/abi/hwcap.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/arm64/fp/sve-test.S

View file

This diff is incomplete. Download the complete patch.