Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1239768 > unrolled thread
| Started by | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| First post | 2015-10-05 19:10 +0200 |
| Last post | 2015-10-05 19:20 +0200 |
| Articles | 20 on this page of 22 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH v2 00/22] arm64: Consolidate CPU feature handling "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
[PATCH v2 15/22] arm64: Move FP/ASIMD hwcap handling to common code "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
[PATCH v2 05/22] arm64: Move /proc/cpuinfo handling code "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
[PATCH v2 16/22] arm64/debug: Make use of the system wide safe value "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value Catalin Marinas <catalin.marinas@arm.com> - 2015-10-08 13:20 +0200
Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> - 2015-10-08 14:00 +0200
Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value Catalin Marinas <catalin.marinas@arm.com> - 2015-10-08 17:10 +0200
Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> - 2015-10-08 18:00 +0200
[PATCH v2 14/22] arm64: Cleanup HWCAP handling "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-10-08 13:20 +0200
Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling Catalin Marinas <catalin.marinas@arm.com> - 2015-10-08 15:10 +0200
Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling Edward Nevill <edward.nevill@linaro.org> - 2015-10-08 17:00 +0200
Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling Catalin Marinas <catalin.marinas@arm.com> - 2015-10-08 13:20 +0200
[PATCH v2 18/22] arm64: Add helper to decode register from instruction "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
[PATCH v2 02/22] arm64: Delay ELF HWCAP initialisation until all CPUs are up "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
[PATCH v2 17/22] arm64/kvm: Make use of the system wide safe values "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
Re: [PATCH v2 17/22] arm64/kvm: Make use of the system wide safe values Christoffer Dall <christoffer.dall@linaro.org> - 2015-10-10 17:20 +0200
[PATCH v2 11/22] arm64: Populate cpuinfo after notify_cpu_starting "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:10 +0200
Re: [PATCH v2 11/22] arm64: Populate cpuinfo after notify_cpu_starting Catalin Marinas <catalin.marinas@arm.com> - 2015-10-08 12:20 +0200
Re: [PATCH v2 11/22] arm64: Populate cpuinfo after notify_cpu_starting "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> - 2015-10-08 12:50 +0200
Re: [PATCH v2 11/22] arm64: Populate cpuinfo after notify_cpu_starting "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> - 2015-10-09 17:10 +0200
[PATCH v2 01/22] arm64: Make the CPU information more clear "Suzuki K. Poulose" <suzuki.poulose@arm.com> - 2015-10-05 19:20 +0200
Page 1 of 2 [1] 2 Next page →
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 00/22] arm64: Consolidate CPU feature handling |
| Message-ID | <qghqV-5ar-3@gated-at.bofh.it> |
This series introduces a new infrastructure to keep track of the CPU feature registers on ARMv8-A for arm64 kernel. It provides the safe value of a CPU feature register across all the CPUs on (a heterogeneous) system. The infrastructure checks the individual CPU feature registers as they are brought online (during system boot up) and udpates the status of each of the feature bits across the system. Once all the active CPUs are brought online (i.e, smp_cpus_done() ), the system can compute a reliable set of capabilities (arm64_features CPU capability and ELF HWCAP). This allows system to operate safely on CPUs with differing capabilities. Any new CPU brought up(hotplugged in) should have all the established capabilities, failing which could be disastrous. (e.g, alternative code patched in for a feature avaialble on the system). We add a hotplug notifier to check if the new CPU is missing any of the advertised capabilities and prevents it from turning online if it is. Also consolidates the users of the feature registers, (KVM, debug, CPU capability, ELF HWCAP, cpuinfo and CPU feature Sanity check) to make use of the system wide safe value of the feature to make safer decisions. As mentioned above, the calculation of the system CPU capabilities and ELF HWCAP is delayed until smp_cpus_done() and makes use of the value from the infrastructure. The cpu_errata capability checks still go through each CPU and is not impacted by this series (not delayed). At the end, we add a new ABI to expose the CPU feature registers to the user space via emulation of MRS. The system exposes only a limited set of feature values (See the documentation patch) from the above infrastructure. The feature bits that are not exposed are set to the 'safe value' which implies 'not supported'. Apart from the selected feature registers, we expose MIDR_EL1 (Main ID Register). The user should be aware that, reading MIDR_EL1 can be tricky on a heterogeneous system (just like getcpu()). We export the value of the current CPU where 'MRS' is executed. REVIDR is not exposed via MRS, since we cannot guarantee atomic access to both MIDR and REVIDR (task migration). So they both are exposed via sysfs under : /sys/devices/system/cpu/cpu$ID/identification/ \- midr \- revidr The ABI useful for the toolchains (e.g, gcc, dynamic linker, JIT) to make better runtime decisions based on what is available. The series is also available here : git://linux-arm.org/linux-skp.git cpu-ftr/v2-4.3-rc4 Older versions: [1] https://lkml.org/lkml/2015/7/24/152 - RFC [2] https://lkml.org/lkml/2015/9/16/452 - V1 Changes since V1: - Rebased to 4.3-rc4 - Fixed patch errors reported by Dave Martin - Fixed build break with !CONFIG_PERF_EVENTS reported by Vladimir Murzin - Updated documentation on the types of features - Added Tested-by: James Morse for cpu capability checks Changes since RFC: - Rebased to 4.3-rc1 - Consolidate HWCAP, capability check into the new infrastructure - Add a new HWCAP 'cpuid' to announce the ABI - Pulled in Steve's patch to expose midr/revidr via sysfs - Changes to documentation. Steve Capper (1): arm64: cpuinfo: Expose MIDR_EL1 and REVIDR_EL1 to sysfs Suzuki K. Poulose (21): arm64: Make the CPU information more clear arm64: Delay ELF HWCAP initialisation until all CPUs are up arm64: Move cpu feature detection code arm64: Move mixed endian support detection arm64: Move /proc/cpuinfo handling code arm64: sys_reg: Define System register encoding arm64: Keep track of CPU feature registers arm64: Consolidate CPU Sanity check to CPU Feature infrastructure arm64: Read system wide CPUID value arm64: Cleanup mixed endian support detection arm64: Populate cpuinfo after notify_cpu_starting arm64: Delay cpu feature checks arm64: Make use of system wide capability checks arm64: Cleanup HWCAP handling arm64: Move FP/ASIMD hwcap handling to common code arm64/debug: Make use of the system wide safe value arm64/kvm: Make use of the system wide safe values arm64: Add helper to decode register from instruction arm64: cpufeature: Track the user visible fields arm64: Expose feature registers by emulating MRS arm64: feature registers: Documentation Documentation/arm64/cpu-feature-registers.txt | 224 ++++++ arch/arm64/include/asm/cpu.h | 5 + arch/arm64/include/asm/cpufeature.h | 72 +- arch/arm64/include/asm/cputype.h | 15 - arch/arm64/include/asm/hw_breakpoint.h | 9 +- arch/arm64/include/asm/hwcap.h | 8 + arch/arm64/include/asm/insn.h | 2 + arch/arm64/include/asm/processor.h | 2 +- arch/arm64/include/asm/sysreg.h | 177 ++++- arch/arm64/include/uapi/asm/hwcap.h | 1 + arch/arm64/kernel/cpufeature.c | 923 ++++++++++++++++++++++++- arch/arm64/kernel/cpuinfo.c | 305 ++++---- arch/arm64/kernel/debug-monitors.c | 6 +- arch/arm64/kernel/fpsimd.c | 16 +- arch/arm64/kernel/insn.c | 29 + arch/arm64/kernel/setup.c | 233 +------ arch/arm64/kernel/smp.c | 12 +- arch/arm64/kvm/reset.c | 2 +- arch/arm64/kvm/sys_regs.c | 12 +- arch/arm64/mm/fault.c | 2 +- 20 files changed, 1608 insertions(+), 447 deletions(-) create mode 100644 Documentation/arm64/cpu-feature-registers.txt -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 15/22] arm64: Move FP/ASIMD hwcap handling to common code |
| Message-ID | <qghqX-5ar-47@gated-at.bofh.it> |
| In reply to | #1239768 |
The FP/ASIMD is detected in fpsimd_init(), which is built-in
unconditionally. Lets move the hwcap handling to the central place.
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
arch/arm64/kernel/cpufeature.c | 2 ++
arch/arm64/kernel/fpsimd.c | 16 +++++-----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 5313413..a1c6d3c 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -650,6 +650,8 @@ static const struct arm64_cpu_capabilities arm64_hwcaps[] = {
HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_SHA2_SHIFT, 1, CAP_HWCAP, HWCAP_SHA2),
HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_CRC32_SHIFT, 1, CAP_HWCAP, HWCAP_CRC32),
HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_ATOMICS_SHIFT, 2, CAP_HWCAP, HWCAP_ATOMICS),
+ HWCAP_CAP(SYS_ID_AA64PFR0_EL1, ID_AA64PFR0_FP_SHIFT, 0, CAP_HWCAP, HWCAP_FP),
+ HWCAP_CAP(SYS_ID_AA64PFR0_EL1, ID_AA64PFR0_ASIMD_SHIFT, 0, CAP_HWCAP, HWCAP_ASIMD),
#ifdef CONFIG_COMPAT
HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_AES_SHIFT, 2, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_PMULL),
HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_AES_SHIFT, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_AES),
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index c56956a..4c46c54 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -332,21 +332,15 @@ static inline void fpsimd_hotplug_init(void) { }
*/
static int __init fpsimd_init(void)
{
- u64 pfr = read_cpuid(ID_AA64PFR0_EL1);
-
- if (pfr & (0xf << 16)) {
+ if (elf_hwcap & HWCAP_FP) {
+ fpsimd_pm_init();
+ fpsimd_hotplug_init();
+ } else {
pr_notice("Floating-point is not implemented\n");
- return 0;
}
- elf_hwcap |= HWCAP_FP;
- if (pfr & (0xf << 20))
+ if (!(elf_hwcap & HWCAP_ASIMD))
pr_notice("Advanced SIMD is not implemented\n");
- else
- elf_hwcap |= HWCAP_ASIMD;
-
- fpsimd_pm_init();
- fpsimd_hotplug_init();
return 0;
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 05/22] arm64: Move /proc/cpuinfo handling code |
| Message-ID | <qghqX-5ar-49@gated-at.bofh.it> |
| In reply to | #1239768 |
This patch moves the /proc/cpuinfo handling code:
arch/arm64/kernel/{setup.c to cpuinfo.c}
No functional changes
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
arch/arm64/kernel/cpuinfo.c | 124 +++++++++++++++++++++++++++++++++++++++++++
arch/arm64/kernel/setup.c | 123 ------------------------------------------
2 files changed, 124 insertions(+), 123 deletions(-)
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index 8307b33..0dadb69 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -24,8 +24,11 @@
#include <linux/bug.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/personality.h>
#include <linux/preempt.h>
#include <linux/printk.h>
+#include <linux/seq_file.h>
+#include <linux/sched.h>
#include <linux/smp.h>
/*
@@ -45,6 +48,127 @@ static char *icache_policy_str[] = {
unsigned long __icache_flags;
+static const char *hwcap_str[] = {
+ "fp",
+ "asimd",
+ "evtstrm",
+ "aes",
+ "pmull",
+ "sha1",
+ "sha2",
+ "crc32",
+ "atomics",
+ NULL
+};
+
+#ifdef CONFIG_COMPAT
+static const char *compat_hwcap_str[] = {
+ "swp",
+ "half",
+ "thumb",
+ "26bit",
+ "fastmult",
+ "fpa",
+ "vfp",
+ "edsp",
+ "java",
+ "iwmmxt",
+ "crunch",
+ "thumbee",
+ "neon",
+ "vfpv3",
+ "vfpv3d16",
+ "tls",
+ "vfpv4",
+ "idiva",
+ "idivt",
+ "vfpd32",
+ "lpae",
+ "evtstrm"
+};
+
+static const char *compat_hwcap2_str[] = {
+ "aes",
+ "pmull",
+ "sha1",
+ "sha2",
+ "crc32",
+ NULL
+};
+#endif /* CONFIG_COMPAT */
+
+static int c_show(struct seq_file *m, void *v)
+{
+ int i, j;
+
+ for_each_online_cpu(i) {
+ struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
+ u32 midr = cpuinfo->reg_midr;
+
+ /*
+ * glibc reads /proc/cpuinfo to determine the number of
+ * online processors, looking for lines beginning with
+ * "processor". Give glibc what it expects.
+ */
+ seq_printf(m, "processor\t: %d\n", i);
+
+ /*
+ * Dump out the common processor features in a single line.
+ * Userspace should read the hwcaps with getauxval(AT_HWCAP)
+ * rather than attempting to parse this, but there's a body of
+ * software which does already (at least for 32-bit).
+ */
+ seq_puts(m, "Features\t:");
+ if (personality(current->personality) == PER_LINUX32) {
+#ifdef CONFIG_COMPAT
+ for (j = 0; compat_hwcap_str[j]; j++)
+ if (compat_elf_hwcap & (1 << j))
+ seq_printf(m, " %s", compat_hwcap_str[j]);
+
+ for (j = 0; compat_hwcap2_str[j]; j++)
+ if (compat_elf_hwcap2 & (1 << j))
+ seq_printf(m, " %s", compat_hwcap2_str[j]);
+#endif /* CONFIG_COMPAT */
+ } else {
+ for (j = 0; hwcap_str[j]; j++)
+ if (elf_hwcap & (1 << j))
+ seq_printf(m, " %s", hwcap_str[j]);
+ }
+ seq_puts(m, "\n");
+
+ seq_printf(m, "CPU implementer\t: 0x%02x\n",
+ MIDR_IMPLEMENTOR(midr));
+ seq_printf(m, "CPU architecture: 8\n");
+ seq_printf(m, "CPU variant\t: 0x%x\n", MIDR_VARIANT(midr));
+ seq_printf(m, "CPU part\t: 0x%03x\n", MIDR_PARTNUM(midr));
+ seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
+ }
+
+ return 0;
+}
+
+static void *c_start(struct seq_file *m, loff_t *pos)
+{
+ return *pos < 1 ? (void *)1 : NULL;
+}
+
+static void *c_next(struct seq_file *m, void *v, loff_t *pos)
+{
+ ++*pos;
+ return NULL;
+}
+
+static void c_stop(struct seq_file *m, void *v)
+{
+}
+
+const struct seq_operations cpuinfo_op = {
+ .start = c_start,
+ .next = c_next,
+ .stop = c_stop,
+ .show = c_show
+};
+
static void cpuinfo_detect_icache_policy(struct cpuinfo_arm64 *info)
{
unsigned int cpu = smp_processor_id();
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 4c7bca8..7b651cc 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -28,7 +28,6 @@
#include <linux/console.h>
#include <linux/cache.h>
#include <linux/bootmem.h>
-#include <linux/seq_file.h>
#include <linux/screen_info.h>
#include <linux/init.h>
#include <linux/kexec.h>
@@ -44,7 +43,6 @@
#include <linux/of_fdt.h>
#include <linux/of_platform.h>
#include <linux/efi.h>
-#include <linux/personality.h>
#include <linux/psci.h>
#include <asm/acpi.h>
@@ -383,124 +381,3 @@ static int __init topology_init(void)
return 0;
}
subsys_initcall(topology_init);
-
-static const char *hwcap_str[] = {
- "fp",
- "asimd",
- "evtstrm",
- "aes",
- "pmull",
- "sha1",
- "sha2",
- "crc32",
- "atomics",
- NULL
-};
-
-#ifdef CONFIG_COMPAT
-static const char *compat_hwcap_str[] = {
- "swp",
- "half",
- "thumb",
- "26bit",
- "fastmult",
- "fpa",
- "vfp",
- "edsp",
- "java",
- "iwmmxt",
- "crunch",
- "thumbee",
- "neon",
- "vfpv3",
- "vfpv3d16",
- "tls",
- "vfpv4",
- "idiva",
- "idivt",
- "vfpd32",
- "lpae",
- "evtstrm"
-};
-
-static const char *compat_hwcap2_str[] = {
- "aes",
- "pmull",
- "sha1",
- "sha2",
- "crc32",
- NULL
-};
-#endif /* CONFIG_COMPAT */
-
-static int c_show(struct seq_file *m, void *v)
-{
- int i, j;
-
- for_each_online_cpu(i) {
- struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
- u32 midr = cpuinfo->reg_midr;
-
- /*
- * glibc reads /proc/cpuinfo to determine the number of
- * online processors, looking for lines beginning with
- * "processor". Give glibc what it expects.
- */
- seq_printf(m, "processor\t: %d\n", i);
-
- /*
- * Dump out the common processor features in a single line.
- * Userspace should read the hwcaps with getauxval(AT_HWCAP)
- * rather than attempting to parse this, but there's a body of
- * software which does already (at least for 32-bit).
- */
- seq_puts(m, "Features\t:");
- if (personality(current->personality) == PER_LINUX32) {
-#ifdef CONFIG_COMPAT
- for (j = 0; compat_hwcap_str[j]; j++)
- if (compat_elf_hwcap & (1 << j))
- seq_printf(m, " %s", compat_hwcap_str[j]);
-
- for (j = 0; compat_hwcap2_str[j]; j++)
- if (compat_elf_hwcap2 & (1 << j))
- seq_printf(m, " %s", compat_hwcap2_str[j]);
-#endif /* CONFIG_COMPAT */
- } else {
- for (j = 0; hwcap_str[j]; j++)
- if (elf_hwcap & (1 << j))
- seq_printf(m, " %s", hwcap_str[j]);
- }
- seq_puts(m, "\n");
-
- seq_printf(m, "CPU implementer\t: 0x%02x\n",
- MIDR_IMPLEMENTOR(midr));
- seq_printf(m, "CPU architecture: 8\n");
- seq_printf(m, "CPU variant\t: 0x%x\n", MIDR_VARIANT(midr));
- seq_printf(m, "CPU part\t: 0x%03x\n", MIDR_PARTNUM(midr));
- seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
- }
-
- return 0;
-}
-
-static void *c_start(struct seq_file *m, loff_t *pos)
-{
- return *pos < 1 ? (void *)1 : NULL;
-}
-
-static void *c_next(struct seq_file *m, void *v, loff_t *pos)
-{
- ++*pos;
- return NULL;
-}
-
-static void c_stop(struct seq_file *m, void *v)
-{
-}
-
-const struct seq_operations cpuinfo_op = {
- .start = c_start,
- .next = c_next,
- .stop = c_stop,
- .show = c_show
-};
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value |
| Message-ID | <qghqY-5ar-61@gated-at.bofh.it> |
| In reply to | #1239768 |
Use the system wide value of ID_AA64DFR0 to make safer decisions
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
arch/arm64/include/asm/hw_breakpoint.h | 9 +++++++--
arch/arm64/kernel/debug-monitors.c | 6 ++++--
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/include/asm/hw_breakpoint.h b/arch/arm64/include/asm/hw_breakpoint.h
index 4c47cb2..e54415e 100644
--- a/arch/arm64/include/asm/hw_breakpoint.h
+++ b/arch/arm64/include/asm/hw_breakpoint.h
@@ -17,6 +17,7 @@
#define __ASM_HW_BREAKPOINT_H
#include <asm/cputype.h>
+#include <asm/cpufeature.h>
#ifdef __KERNEL__
@@ -137,13 +138,17 @@ extern struct pmu perf_ops_bp;
/* Determine number of BRP registers available. */
static inline int get_num_brps(void)
{
- return ((read_cpuid(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1;
+ return 1 +
+ cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
+ ID_AA64DFR0_BRPS_SHIFT);
}
/* Determine number of WRP registers available. */
static inline int get_num_wrps(void)
{
- return ((read_cpuid(ID_AA64DFR0_EL1) >> 20) & 0xf) + 1;
+ return 1 +
+ cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
+ ID_AA64DFR0_WRPS_SHIFT);
}
#endif /* __KERNEL__ */
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index cebf786..c0a2327 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -26,14 +26,16 @@
#include <linux/stat.h>
#include <linux/uaccess.h>
-#include <asm/debug-monitors.h>
+#include <asm/cpufeature.h>
#include <asm/cputype.h>
+#include <asm/debug-monitors.h>
#include <asm/system_misc.h>
/* Determine debug architecture. */
u8 debug_monitors_arch(void)
{
- return read_cpuid(ID_AA64DFR0_EL1) & 0xf;
+ return cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
+ ID_AA64DFR0_DEBUGVER_SHIFT);
}
/*
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Catalin Marinas <catalin.marinas@arm.com> |
|---|---|
| Date | 2015-10-08 13:20 +0200 |
| Subject | Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value |
| Message-ID | <qhhoS-1PL-23@gated-at.bofh.it> |
| In reply to | #1239772 |
On Mon, Oct 05, 2015 at 06:02:05PM +0100, Suzuki K. Poulose wrote:
> @@ -137,13 +138,17 @@ extern struct pmu perf_ops_bp;
> /* Determine number of BRP registers available. */
> static inline int get_num_brps(void)
> {
> - return ((read_cpuid(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1;
> + return 1 +
> + cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
> + ID_AA64DFR0_BRPS_SHIFT);
> }
cpuid_feature_extract_field() is fine but we should we bother with
read_system_reg vs just read_cpuid?
Similar question for patch 17/22.
--
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> |
|---|---|
| Date | 2015-10-08 14:00 +0200 |
| Subject | Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value |
| Message-ID | <qhi1A-2A7-13@gated-at.bofh.it> |
| In reply to | #1242206 |
On 08/10/15 12:11, Catalin Marinas wrote:
> On Mon, Oct 05, 2015 at 06:02:05PM +0100, Suzuki K. Poulose wrote:
>> @@ -137,13 +138,17 @@ extern struct pmu perf_ops_bp;
>> /* Determine number of BRP registers available. */
>> static inline int get_num_brps(void)
>> {
>> - return ((read_cpuid(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1;
>> + return 1 +
>> + cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
>> + ID_AA64DFR0_BRPS_SHIFT);
>> }
>
> cpuid_feature_extract_field() is fine but we should we bother with
> read_system_reg vs just read_cpuid?
> Similar question for patch 17/22.
Well, we would have already TAINTed the kernel, if these fields are different.
It is just the matter of, whether we want to provide the safer value on a tainted
kernel or not. I am open to suggestions.
Thanks
Suzuki
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Catalin Marinas <catalin.marinas@arm.com> |
|---|---|
| Date | 2015-10-08 17:10 +0200 |
| Subject | Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value |
| Message-ID | <qhkZs-76Q-13@gated-at.bofh.it> |
| In reply to | #1242280 |
On Thu, Oct 08, 2015 at 12:56:28PM +0100, Suzuki K. Poulose wrote:
> On 08/10/15 12:11, Catalin Marinas wrote:
> >On Mon, Oct 05, 2015 at 06:02:05PM +0100, Suzuki K. Poulose wrote:
> >>@@ -137,13 +138,17 @@ extern struct pmu perf_ops_bp;
> >> /* Determine number of BRP registers available. */
> >> static inline int get_num_brps(void)
> >> {
> >>- return ((read_cpuid(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1;
> >>+ return 1 +
> >>+ cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
> >>+ ID_AA64DFR0_BRPS_SHIFT);
> >> }
> >
> >cpuid_feature_extract_field() is fine but we should we bother with
> >read_system_reg vs just read_cpuid?
> >Similar question for patch 17/22.
>
> Well, we would have already TAINTed the kernel, if these fields are different.
> It is just the matter of, whether we want to provide the safer value on a tainted
> kernel or not. I am open to suggestions.
Ah, sorry, I mixed read_system_reg() with read_cpu_sysreg(). I think we
need to rename the latter as it gets confusing. Maybe something like
read_native_sys_reg() or __raw_read_system_reg().
--
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> |
|---|---|
| Date | 2015-10-08 18:00 +0200 |
| Subject | Re: [PATCH v2 16/22] arm64/debug: Make use of the system wide safe value |
| Message-ID | <qhlLP-81t-3@gated-at.bofh.it> |
| In reply to | #1242497 |
On 08/10/15 16:08, Catalin Marinas wrote:
> On Thu, Oct 08, 2015 at 12:56:28PM +0100, Suzuki K. Poulose wrote:
>> On 08/10/15 12:11, Catalin Marinas wrote:
>>> On Mon, Oct 05, 2015 at 06:02:05PM +0100, Suzuki K. Poulose wrote:
>>>> @@ -137,13 +138,17 @@ extern struct pmu perf_ops_bp;
>>>> /* Determine number of BRP registers available. */
>>>> static inline int get_num_brps(void)
>>>> {
>>>> - return ((read_cpuid(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1;
>>>> + return 1 +
>>>> + cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
>>>> + ID_AA64DFR0_BRPS_SHIFT);
>>>> }
>>>
>>> cpuid_feature_extract_field() is fine but we should we bother with
>>> read_system_reg vs just read_cpuid?
>>> Similar question for patch 17/22.
>>
>> Well, we would have already TAINTed the kernel, if these fields are different.
>> It is just the matter of, whether we want to provide the safer value on a tainted
>> kernel or not. I am open to suggestions.
>
> Ah, sorry, I mixed read_system_reg() with read_cpu_sysreg(). I think we
Oh, ok. I think we should rename it as you suggest below to avoid the
confusion.
> need to rename the latter as it gets confusing. Maybe something like
> read_native_sys_reg() or __raw_read_system_reg().
>
Thanks
Suzuki
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 14/22] arm64: Cleanup HWCAP handling |
| Message-ID | <qghqY-5ar-55@gated-at.bofh.it> |
| In reply to | #1239768 |
Extend struct arm64_cpu_capabilities to handle the HWCAP detection
and make use of the system wide value for the feature register.
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
arch/arm64/include/asm/cpufeature.h | 2 +
arch/arm64/include/asm/hwcap.h | 8 ++
arch/arm64/kernel/cpufeature.c | 153 ++++++++++++++++++-----------------
3 files changed, 91 insertions(+), 72 deletions(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 1234c9c..38400dc 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -82,6 +82,8 @@ struct arm64_cpu_capabilities {
u32 sys_reg;
int field_pos;
int min_field_value;
+ int hwcap_type;
+ unsigned long hwcap;
};
};
};
diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h
index 0ad7351..400b80b 100644
--- a/arch/arm64/include/asm/hwcap.h
+++ b/arch/arm64/include/asm/hwcap.h
@@ -52,6 +52,14 @@
extern unsigned int compat_elf_hwcap, compat_elf_hwcap2;
#endif
+enum {
+ CAP_HWCAP = 1,
+#ifdef CONFIG_COMPAT
+ CAP_COMPAT_HWCAP,
+ CAP_COMPAT_HWCAP2,
+#endif
+};
+
extern unsigned long elf_hwcap;
#endif
#endif
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 1278752..5313413 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -632,6 +632,79 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
{},
};
+#define HWCAP_CAP(reg, field, min_value, type, cap) \
+ { \
+ .desc = #cap, \
+ .matches = has_cpuid_feature, \
+ .sys_reg = reg, \
+ .field_pos = field, \
+ .min_field_value = min_value, \
+ .hwcap_type = type, \
+ .hwcap = cap, \
+ }
+
+static const struct arm64_cpu_capabilities arm64_hwcaps[] = {
+ HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_AES_SHIFT, 2, CAP_HWCAP, HWCAP_PMULL),
+ HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_AES_SHIFT, 1, CAP_HWCAP, HWCAP_AES),
+ HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_SHA1_SHIFT, 1, CAP_HWCAP, HWCAP_SHA1),
+ HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_SHA2_SHIFT, 1, CAP_HWCAP, HWCAP_SHA2),
+ HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_CRC32_SHIFT, 1, CAP_HWCAP, HWCAP_CRC32),
+ HWCAP_CAP(SYS_ID_AA64ISAR0_EL1, ID_AA64ISAR0_ATOMICS_SHIFT, 2, CAP_HWCAP, HWCAP_ATOMICS),
+#ifdef CONFIG_COMPAT
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_AES_SHIFT, 2, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_PMULL),
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_AES_SHIFT, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_AES),
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_SHA1_SHIFT, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_SHA1),
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_SHA2_SHIFT, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_SHA2),
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_CRC32_SHIFT, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_CRC32),
+#endif
+};
+
+static void cap_set_hwcap(const struct arm64_cpu_capabilities * cap)
+{
+ switch(cap->hwcap_type) {
+ case CAP_HWCAP:
+ elf_hwcap |= cap->hwcap;
+ break;
+#ifdef CONFIG_COMPAT
+ case CAP_COMPAT_HWCAP:
+ compat_elf_hwcap |= (u32)cap->hwcap;
+ break;
+ case CAP_COMPAT_HWCAP2:
+ compat_elf_hwcap2 |= (u32)cap->hwcap;
+ break;
+#endif
+ default:
+ BUG();
+ break;
+ }
+}
+
+static bool cpus_have_hwcap(const struct arm64_cpu_capabilities *cap)
+{
+ switch(cap->hwcap_type) {
+ case CAP_HWCAP:
+ return !!(elf_hwcap & cap->hwcap);
+#ifdef CONFIG_COMPAT
+ case CAP_COMPAT_HWCAP:
+ return !!(compat_elf_hwcap & (u32)cap->hwcap);
+ case CAP_COMPAT_HWCAP2:
+ return !!(compat_elf_hwcap2 & (u32)cap->hwcap);
+#endif
+ default:
+ BUG();
+ return false;
+ }
+}
+
+void check_cpu_hwcaps(void)
+{
+ int i;
+ const struct arm64_cpu_capabilities *hwcaps = arm64_hwcaps;
+ for(i = 0; i < ARRAY_SIZE(arm64_hwcaps); i ++)
+ if (hwcaps[i].matches(&hwcaps[i]))
+ cap_set_hwcap(&hwcaps[i]);
+}
+
void check_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
const char *info)
{
@@ -739,6 +812,13 @@ void cpu_enable_features(void)
if (caps[i].enable)
caps[i].enable(NULL);
}
+
+ for(i =0, caps = arm64_hwcaps; caps[i].desc; i++) {
+ if (!cpus_have_hwcap(&caps[i]))
+ continue;
+ if (!feature_matches(read_cpu_sysreg(caps[i].sys_reg), &caps[i]))
+ fail_incapable_cpu("arm64_hwcaps", &caps[i]);
+ }
}
static int cpu_feature_hotplug_notify(struct notifier_block *nb,
@@ -773,12 +853,11 @@ bool system_supports_mixed_endian_el0(void)
void __init setup_cpu_features(void)
{
- u64 features;
- s64 block;
u32 cwg;
int cls;
check_cpu_features();
+ check_cpu_hwcaps();
/*
* Check for sane CTR_EL0.CWG value.
*/
@@ -790,74 +869,4 @@ void __init setup_cpu_features(void)
if (L1_CACHE_BYTES < cls)
pr_warn("L1_CACHE_BYTES smaller than the Cache Writeback Granule (%d < %d)\n",
L1_CACHE_BYTES, cls);
-
- /*
- * ID_AA64ISAR0_EL1 contains 4-bit wide signed feature blocks.
- * The blocks we test below represent incremental functionality
- * for non-negative values. Negative values are reserved.
- */
- features = read_cpuid(ID_AA64ISAR0_EL1);
- block = cpuid_feature_extract_field(features, 4);
- if (block > 0) {
- switch (block) {
- default:
- case 2:
- elf_hwcap |= HWCAP_PMULL;
- case 1:
- elf_hwcap |= HWCAP_AES;
- case 0:
- break;
- }
- }
-
- if (cpuid_feature_extract_field(features, 8) > 0)
- elf_hwcap |= HWCAP_SHA1;
-
- if (cpuid_feature_extract_field(features, 12) > 0)
- elf_hwcap |= HWCAP_SHA2;
-
- if (cpuid_feature_extract_field(features, 16) > 0)
- elf_hwcap |= HWCAP_CRC32;
-
- block = cpuid_feature_extract_field(features, 20);
- if (block > 0) {
- switch (block) {
- default:
- case 2:
- elf_hwcap |= HWCAP_ATOMICS;
- case 1:
- /* RESERVED */
- case 0:
- break;
- }
- }
-
-#ifdef CONFIG_COMPAT
- /*
- * ID_ISAR5_EL1 carries similar information as above, but pertaining to
- * the AArch32 32-bit execution state.
- */
- features = read_cpuid(ID_ISAR5_EL1);
- block = cpuid_feature_extract_field(features, 4);
- if (block > 0) {
- switch (block) {
- default:
- case 2:
- compat_elf_hwcap2 |= COMPAT_HWCAP2_PMULL;
- case 1:
- compat_elf_hwcap2 |= COMPAT_HWCAP2_AES;
- case 0:
- break;
- }
- }
-
- if (cpuid_feature_extract_field(features, 8) > 0)
- compat_elf_hwcap2 |= COMPAT_HWCAP2_SHA1;
-
- if (cpuid_feature_extract_field(features, 12) > 0)
- compat_elf_hwcap2 |= COMPAT_HWCAP2_SHA2;
-
- if (cpuid_feature_extract_field(features, 16) > 0)
- compat_elf_hwcap2 |= COMPAT_HWCAP2_CRC32;
-#endif
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Russell King - ARM Linux <linux@arm.linux.org.uk> |
|---|---|
| Date | 2015-10-08 13:20 +0200 |
| Subject | Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling |
| Message-ID | <qhhoS-1PL-37@gated-at.bofh.it> |
| In reply to | #1239774 |
On Thu, Oct 08, 2015 at 12:10:00PM +0100, Catalin Marinas wrote:
> On Mon, Oct 05, 2015 at 06:02:03PM +0100, Suzuki K. Poulose wrote:
> > +static bool cpus_have_hwcap(const struct arm64_cpu_capabilities *cap)
> > +{
> > + switch(cap->hwcap_type) {
> > + case CAP_HWCAP:
> > + return !!(elf_hwcap & cap->hwcap);
> > +#ifdef CONFIG_COMPAT
> > + case CAP_COMPAT_HWCAP:
> > + return !!(compat_elf_hwcap & (u32)cap->hwcap);
> > + case CAP_COMPAT_HWCAP2:
> > + return !!(compat_elf_hwcap2 & (u32)cap->hwcap);
> > +#endif
> > + default:
> > + BUG();
> > + return false;
> > + }
> > +}
>
> Apart from the multiple returns, you don't really need !! since the
> return type is bool already.
That's wrong. a & b doesn't return 0 or 1, but the bitwise-and result.
http://yarchive.net/comp/linux/bool.html
especially hpa's response.
--
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Catalin Marinas <catalin.marinas@arm.com> |
|---|---|
| Date | 2015-10-08 15:10 +0200 |
| Subject | Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling |
| Message-ID | <qhj7k-4pv-17@gated-at.bofh.it> |
| In reply to | #1242209 |
On Thu, Oct 08, 2015 at 12:17:09PM +0100, Russell King - ARM Linux wrote:
> On Thu, Oct 08, 2015 at 12:10:00PM +0100, Catalin Marinas wrote:
> > On Mon, Oct 05, 2015 at 06:02:03PM +0100, Suzuki K. Poulose wrote:
> > > +static bool cpus_have_hwcap(const struct arm64_cpu_capabilities *cap)
> > > +{
> > > + switch(cap->hwcap_type) {
> > > + case CAP_HWCAP:
> > > + return !!(elf_hwcap & cap->hwcap);
> > > +#ifdef CONFIG_COMPAT
> > > + case CAP_COMPAT_HWCAP:
> > > + return !!(compat_elf_hwcap & (u32)cap->hwcap);
> > > + case CAP_COMPAT_HWCAP2:
> > > + return !!(compat_elf_hwcap2 & (u32)cap->hwcap);
> > > +#endif
> > > + default:
> > > + BUG();
> > > + return false;
> > > + }
> > > +}
> >
> > Apart from the multiple returns, you don't really need !! since the
> > return type is bool already.
>
> That's wrong. a & b doesn't return 0 or 1, but the bitwise-and result.
a & b is indeed a bitwise operation and, in this particular case, its
type is an unsigned long. However, because the return type of the
function is a bool, the result of the bitwise operation (unsigned long)
is converted to a bool.
The above may be true only for gcc, I haven't checked other compilers,
nor the standard (AFAIK, it appeared in C99).
On AArch64, the compiler generates something like:
tst x0, x1
cset w0, ne
ret
On AArch32, Thumb-2, I get:
tst r2, r3
ite ne
movne r0, #1
moveq r0, #0
bx lr
So a bool type function always returns 0 or 1 and does the appropriate
conversion.
> http://yarchive.net/comp/linux/bool.html
>
> especially hpa's response.
This seems to be more about a union of int and bool rather than
automatic type conversion. But I can see in the simple test that Linus
did towards the end of the thread that x86 does something similar with
converting a char to a bool:
testb %al, %al
setne %al
ret
I stand by my original comment.
--
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Edward Nevill <edward.nevill@linaro.org> |
|---|---|
| Date | 2015-10-08 17:00 +0200 |
| Subject | Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling |
| Message-ID | <qhkPL-6FW-3@gated-at.bofh.it> |
| In reply to | #1242329 |
On Thu, 2015-10-08 at 14:00 +0100, Catalin Marinas wrote:
> On Thu, Oct 08, 2015 at 12:17:09PM +0100, Russell King - ARM Linux wrote:
> > On Thu, Oct 08, 2015 at 12:10:00PM +0100, Catalin Marinas wrote:
> > > On Mon, Oct 05, 2015 at 06:02:03PM +0100, Suzuki K. Poulose wrote:
> > > > +static bool cpus_have_hwcap(const struct arm64_cpu_capabilities *cap)
> > > > +{
> > > > + switch(cap->hwcap_type) {
> > > > + case CAP_HWCAP:
> > > > + return !!(elf_hwcap & cap->hwcap);
> > > > +#ifdef CONFIG_COMPAT
> > > > + case CAP_COMPAT_HWCAP:
> > > > + return !!(compat_elf_hwcap & (u32)cap->hwcap);
> > > > + case CAP_COMPAT_HWCAP2:
> > > > + return !!(compat_elf_hwcap2 & (u32)cap->hwcap);
> > > > +#endif
> > > > + default:
> > > > + BUG();
> > > > + return false;
> > > > + }
> > > > +}
> > >
> > > Apart from the multiple returns, you don't really need !! since the
> > > return type is bool already.
> >
> > That's wrong. a & b doesn't return 0 or 1, but the bitwise-and result.
>
> a & b is indeed a bitwise operation and, in this particular case, its
> type is an unsigned long. However, because the return type of the
> function is a bool, the result of the bitwise operation (unsigned long)
> is converted to a bool.
Why not just write what you mean
return (elf_hwcap & cap->hwcap) != 0;
So much clearer. And every compiler will compile it correctly and
optimally. The !!() syntax is just so ugly it is untrue. Its like people
who write
if (strcmp(..., ...)) ...
Break their fingers!
Ed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Catalin Marinas <catalin.marinas@arm.com> |
|---|---|
| Date | 2015-10-08 13:20 +0200 |
| Subject | Re: [PATCH v2 14/22] arm64: Cleanup HWCAP handling |
| Message-ID | <qhhoS-1PL-39@gated-at.bofh.it> |
| In reply to | #1239774 |
On Mon, Oct 05, 2015 at 06:02:03PM +0100, Suzuki K. Poulose wrote:
> +static bool cpus_have_hwcap(const struct arm64_cpu_capabilities *cap)
> +{
> + switch(cap->hwcap_type) {
> + case CAP_HWCAP:
> + return !!(elf_hwcap & cap->hwcap);
> +#ifdef CONFIG_COMPAT
> + case CAP_COMPAT_HWCAP:
> + return !!(compat_elf_hwcap & (u32)cap->hwcap);
> + case CAP_COMPAT_HWCAP2:
> + return !!(compat_elf_hwcap2 & (u32)cap->hwcap);
> +#endif
> + default:
> + BUG();
> + return false;
> + }
> +}
Apart from the multiple returns, you don't really need !! since the
return type is bool already.
--
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 18/22] arm64: Add helper to decode register from instruction |
| Message-ID | <qghqY-5ar-57@gated-at.bofh.it> |
| In reply to | #1239768 |
Add a helper to extract the register field from a given
instruction.
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
arch/arm64/include/asm/insn.h | 2 ++
arch/arm64/kernel/insn.c | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h
index 30e50eb..6dea3bc 100644
--- a/arch/arm64/include/asm/insn.h
+++ b/arch/arm64/include/asm/insn.h
@@ -289,6 +289,8 @@ enum aarch64_insn_encoding_class aarch64_get_insn_class(u32 insn);
u64 aarch64_insn_decode_immediate(enum aarch64_insn_imm_type type, u32 insn);
u32 aarch64_insn_encode_immediate(enum aarch64_insn_imm_type type,
u32 insn, u64 imm);
+u32 aarch64_insn_decode_register(enum aarch64_insn_register_type type,
+ u32 insn);
u32 aarch64_insn_gen_branch_imm(unsigned long pc, unsigned long addr,
enum aarch64_insn_branch_type type);
u32 aarch64_insn_gen_comp_branch_imm(unsigned long pc, unsigned long addr,
diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c
index f341866..4286fed 100644
--- a/arch/arm64/kernel/insn.c
+++ b/arch/arm64/kernel/insn.c
@@ -388,6 +388,35 @@ u32 __kprobes aarch64_insn_encode_immediate(enum aarch64_insn_imm_type type,
return insn;
}
+u32 aarch64_insn_decode_register(enum aarch64_insn_register_type type,
+ u32 insn)
+{
+ int shift;
+
+ switch (type) {
+ case AARCH64_INSN_REGTYPE_RT:
+ case AARCH64_INSN_REGTYPE_RD:
+ shift = 0;
+ break;
+ case AARCH64_INSN_REGTYPE_RN:
+ shift = 5;
+ break;
+ case AARCH64_INSN_REGTYPE_RT2:
+ case AARCH64_INSN_REGTYPE_RA:
+ shift = 10;
+ break;
+ case AARCH64_INSN_REGTYPE_RM:
+ shift = 16;
+ break;
+ default:
+ pr_err("%s: unknown register type encoding %d\n", __func__,
+ type);
+ return 0;
+ }
+
+ return (insn >> shift) & GENMASK(4, 0);
+}
+
static u32 aarch64_insn_encode_register(enum aarch64_insn_register_type type,
u32 insn,
enum aarch64_insn_register reg)
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 02/22] arm64: Delay ELF HWCAP initialisation until all CPUs are up |
| Message-ID | <qghqY-5ar-63@gated-at.bofh.it> |
| In reply to | #1239768 |
Delay the ELF HWCAP initialisation untill all the (enabled) CPUs are
up, i.e, smp_cpus_done(). This is in preparation for detecting the
common features across the CPUS and creating a consistent ELF HWCAP
for the system.
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
arch/arm64/include/asm/cpufeature.h | 1 +
arch/arm64/kernel/setup.c | 16 ++++++++--------
arch/arm64/kernel/smp.c | 1 +
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 1715707..b7769f6 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -81,6 +81,7 @@ static inline int __attribute_const__ cpuid_feature_extract_field(u64 features,
return (s64)(features << (64 - 4 - field)) >> (64 - 4);
}
+void __init setup_cpu_features(void);
void check_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
const char *info);
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 60fc9a9..d149c18 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -195,20 +195,13 @@ static void __init smp_build_mpidr_hash(void)
__flush_dcache_area(&mpidr_hash, sizeof(struct mpidr_hash));
}
-static void __init setup_processor(void)
+void __init setup_cpu_features(void)
{
u64 features;
s64 block;
u32 cwg;
int cls;
- pr_info("Boot CPU: AArch64 Processor [%08x]\n", read_cpuid_id());
-
- sprintf(init_utsname()->machine, ELF_PLATFORM);
- elf_hwcap = 0;
-
- cpuinfo_store_boot_cpu();
-
/*
* Check for sane CTR_EL0.CWG value.
*/
@@ -292,6 +285,13 @@ static void __init setup_processor(void)
#endif
}
+static void __init setup_processor(void)
+{
+ pr_info("Boot CPU: AArch64 Processor [%08x]\n", read_cpuid_id());
+ sprintf(init_utsname()->machine, ELF_PLATFORM);
+ cpuinfo_store_boot_cpu();
+}
+
static void __init setup_machine_fdt(phys_addr_t dt_phys)
{
void *dt_virt = fixmap_remap_fdt(dt_phys);
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 641f529..cb3e0d8 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -326,6 +326,7 @@ static void __init hyp_mode_check(void)
void __init smp_cpus_done(unsigned int max_cpus)
{
pr_info("SMP: Total of %d processors activated.\n", num_online_cpus());
+ setup_cpu_features();
hyp_mode_check();
apply_alternatives_all();
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 17/22] arm64/kvm: Make use of the system wide safe values |
| Message-ID | <qghqY-5ar-69@gated-at.bofh.it> |
| In reply to | #1239768 |
Use the system wide safe value from the new API for safer
decisions
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: kvmarm@lists.cs.columbia.edu
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
---
arch/arm64/kvm/reset.c | 2 +-
arch/arm64/kvm/sys_regs.c | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
index 91cf535..f34745c 100644
--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -53,7 +53,7 @@ static bool cpu_has_32bit_el1(void)
{
u64 pfr0;
- pfr0 = read_cpuid(ID_AA64PFR0_EL1);
+ pfr0 = read_system_reg(SYS_ID_AA64PFR0_EL1);
return !!(pfr0 & 0x20);
}
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index d03d3af..87a64e8 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -693,13 +693,13 @@ static bool trap_dbgidr(struct kvm_vcpu *vcpu,
if (p->is_write) {
return ignore_write(vcpu, p);
} else {
- u64 dfr = read_cpuid(ID_AA64DFR0_EL1);
- u64 pfr = read_cpuid(ID_AA64PFR0_EL1);
- u32 el3 = !!((pfr >> 12) & 0xf);
+ u64 dfr = read_system_reg(SYS_ID_AA64DFR0_EL1);
+ u64 pfr = read_system_reg(SYS_ID_AA64PFR0_EL1);
+ u32 el3 = !!cpuid_feature_extract_field(pfr, ID_AA64PFR0_EL3_SHIFT);
- *vcpu_reg(vcpu, p->Rt) = ((((dfr >> 20) & 0xf) << 28) |
- (((dfr >> 12) & 0xf) << 24) |
- (((dfr >> 28) & 0xf) << 20) |
+ *vcpu_reg(vcpu, p->Rt) = ((((dfr >> ID_AA64DFR0_WRPS_SHIFT) & 0xf) << 28) |
+ (((dfr >> ID_AA64DFR0_BRPS_SHIFT) & 0xf) << 24) |
+ (((dfr >> ID_AA64DFR0_CTX_CMPS_SHIFT) & 0xf) << 20) |
(6 << 16) | (el3 << 14) | (el3 << 12));
return true;
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Christoffer Dall <christoffer.dall@linaro.org> |
|---|---|
| Date | 2015-10-10 17:20 +0200 |
| Subject | Re: [PATCH v2 17/22] arm64/kvm: Make use of the system wide safe values |
| Message-ID | <qi46d-4HV-1@gated-at.bofh.it> |
| In reply to | #1239777 |
On Mon, Oct 05, 2015 at 06:02:06PM +0100, Suzuki K. Poulose wrote:
> Use the system wide safe value from the new API for safer
> decisions
>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: kvmarm@lists.cs.columbia.edu
> Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
> ---
> arch/arm64/kvm/reset.c | 2 +-
> arch/arm64/kvm/sys_regs.c | 12 ++++++------
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
> index 91cf535..f34745c 100644
> --- a/arch/arm64/kvm/reset.c
> +++ b/arch/arm64/kvm/reset.c
> @@ -53,7 +53,7 @@ static bool cpu_has_32bit_el1(void)
> {
> u64 pfr0;
>
> - pfr0 = read_cpuid(ID_AA64PFR0_EL1);
> + pfr0 = read_system_reg(SYS_ID_AA64PFR0_EL1);
> return !!(pfr0 & 0x20);
> }
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index d03d3af..87a64e8 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -693,13 +693,13 @@ static bool trap_dbgidr(struct kvm_vcpu *vcpu,
> if (p->is_write) {
> return ignore_write(vcpu, p);
> } else {
> - u64 dfr = read_cpuid(ID_AA64DFR0_EL1);
> - u64 pfr = read_cpuid(ID_AA64PFR0_EL1);
> - u32 el3 = !!((pfr >> 12) & 0xf);
> + u64 dfr = read_system_reg(SYS_ID_AA64DFR0_EL1);
> + u64 pfr = read_system_reg(SYS_ID_AA64PFR0_EL1);
> + u32 el3 = !!cpuid_feature_extract_field(pfr, ID_AA64PFR0_EL3_SHIFT);
>
> - *vcpu_reg(vcpu, p->Rt) = ((((dfr >> 20) & 0xf) << 28) |
> - (((dfr >> 12) & 0xf) << 24) |
> - (((dfr >> 28) & 0xf) << 20) |
> + *vcpu_reg(vcpu, p->Rt) = ((((dfr >> ID_AA64DFR0_WRPS_SHIFT) & 0xf) << 28) |
> + (((dfr >> ID_AA64DFR0_BRPS_SHIFT) & 0xf) << 24) |
> + (((dfr >> ID_AA64DFR0_CTX_CMPS_SHIFT) & 0xf) << 20) |
> (6 << 16) | (el3 << 14) | (el3 << 12));
> return true;
> }
> --
> 1.7.9.5
>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <suzuki.poulose@arm.com> |
|---|---|
| Date | 2015-10-05 19:10 +0200 |
| Subject | [PATCH v2 11/22] arm64: Populate cpuinfo after notify_cpu_starting |
| Message-ID | <qghqZ-5ar-75@gated-at.bofh.it> |
| In reply to | #1239768 |
This patch delays populating the cpuinfo for a new (hotplugged) CPU until the notifiers have executed. This will enable us to verify if the new (hotplugged) CPU has all the capabilities which the system already has. If it doesn't, we could prevent it from turning online and also modifying the system wide feature register status. Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com> --- arch/arm64/kernel/smp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index cb3e0d8..6987de4 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -163,14 +163,14 @@ asmlinkage void secondary_start_kernel(void) cpu_ops[cpu]->cpu_postboot(); /* - * Log the CPU info before it is marked online and might get read. + * Enable GIC and timers. */ - cpuinfo_store_cpu(); + notify_cpu_starting(cpu); /* - * Enable GIC and timers. + * Log the CPU info before it is marked online and might get read. */ - notify_cpu_starting(cpu); + cpuinfo_store_cpu(); smp_store_cpu_info(cpu); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Catalin Marinas <catalin.marinas@arm.com> |
|---|---|
| Date | 2015-10-08 12:20 +0200 |
| Subject | Re: [PATCH v2 11/22] arm64: Populate cpuinfo after notify_cpu_starting |
| Message-ID | <qhgsP-u9-29@gated-at.bofh.it> |
| In reply to | #1239779 |
On Mon, Oct 05, 2015 at 06:02:00PM +0100, Suzuki K. Poulose wrote: > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index cb3e0d8..6987de4 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -163,14 +163,14 @@ asmlinkage void secondary_start_kernel(void) > cpu_ops[cpu]->cpu_postboot(); > > /* > - * Log the CPU info before it is marked online and might get read. > + * Enable GIC and timers. > */ > - cpuinfo_store_cpu(); > + notify_cpu_starting(cpu); > > /* > - * Enable GIC and timers. > + * Log the CPU info before it is marked online and might get read. > */ > - notify_cpu_starting(cpu); > + cpuinfo_store_cpu(); > > smp_store_cpu_info(cpu); You can move the cpuinfo_store_cpu() call directly to smp_store_cpu_info(). -- Catalin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Suzuki K. Poulose" <Suzuki.Poulose@arm.com> |
|---|---|
| Date | 2015-10-08 12:50 +0200 |
| Subject | Re: [PATCH v2 11/22] arm64: Populate cpuinfo after notify_cpu_starting |
| Message-ID | <qhgVQ-12b-15@gated-at.bofh.it> |
| In reply to | #1242161 |
On 08/10/15 11:15, Catalin Marinas wrote: > On Mon, Oct 05, 2015 at 06:02:00PM +0100, Suzuki K. Poulose wrote: >> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c >> index cb3e0d8..6987de4 100644 >> --- a/arch/arm64/kernel/smp.c >> +++ b/arch/arm64/kernel/smp.c >> @@ -163,14 +163,14 @@ asmlinkage void secondary_start_kernel(void) >> cpu_ops[cpu]->cpu_postboot(); >> >> /* >> - * Log the CPU info before it is marked online and might get read. >> + * Enable GIC and timers. >> */ >> - cpuinfo_store_cpu(); >> + notify_cpu_starting(cpu); >> >> /* >> - * Enable GIC and timers. >> + * Log the CPU info before it is marked online and might get read. >> */ >> - notify_cpu_starting(cpu); >> + cpuinfo_store_cpu(); >> >> smp_store_cpu_info(cpu); > > You can move the cpuinfo_store_cpu() call directly to > smp_store_cpu_info(). > That looks better, Thanks. Suzuki -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web