]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: Add cpu_hwcap bitmap
authorJulien Grall <julien.grall@arm.com>
Wed, 22 Jun 2016 11:15:19 +0000 (12:15 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Wed, 24 Jan 2018 22:08:53 +0000 (14:08 -0800)
This will be used to know if a feature, which Xen cares, is available accross
all the CPUs.

This code is a light version of arch/arm64/kernel/cpufeature.c from
Linux v4.6-rc3.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
(cherry picked from commit bfb489629c0c5f36c60dec879383cbed4080a509)

Conflicts:
xen/arch/arm/Makefile

xen/arch/arm/Makefile
xen/arch/arm/cpufeature.c [new file with mode: 0644]
xen/include/asm-arm/cpufeature.h

index 9e38da39572320b0354450bed6823bbbf2320db6..48613206d4230d738c0be498901f08f086b96b86 100644 (file)
@@ -6,6 +6,7 @@ subdir-$(CONFIG_ACPI) += acpi
 
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += cpu.o
+obj-y += cpufeature.o
 obj-y += domain.o
 obj-y += psci.o
 obj-y += vpsci.o
diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c
new file mode 100644 (file)
index 0000000..7a1b56b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Contains CPU feature definitions
+ *
+ * Copyright (C) 2015 ARM Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/init.h>
+#include <xen/smp.h>
+#include <asm/cpufeature.h>
+
+DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS);
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 6079fa1336c4ee17a0a757c6f50ab51acfdb491f..e5ff974e0bb80a3aecf02df0df88f1e26fc92164 100644 (file)
 #endif
 #define cpu_has_security  (boot_cpu_feature32(security) > 0)
 
+#define ARM_NCAPS           0
+
+#ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/bitops.h>
+
+extern DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS);
+
+static inline bool_t cpus_have_cap(unsigned int num)
+{
+    if ( num >= ARM_NCAPS )
+        return 0;
+
+    return test_bit(num, cpu_hwcaps);
+}
+
+static inline void cpus_set_cap(unsigned int num)
+{
+    if (num >= ARM_NCAPS)
+        printk(XENLOG_WARNING "Attempt to set an illegal CPU capability (%d >= %d)\n",
+               num, ARM_NCAPS);
+    else
+        __set_bit(num, cpu_hwcaps);
+}
+
+#endif /* __ASSEMBLY__ */
+
 #endif
 /*
  * Local variables: