struct cpuinfo_arm __read_mostly guest_cpuinfo;
+#ifdef CONFIG_ARM_64
+static bool has_sb_instruction(const struct arm_cpu_capabilities *entry)
+{
+ return system_cpuinfo.isa64.sb;
+}
+#endif
+
+static const struct arm_cpu_capabilities arm_features[] = {
+#ifdef CONFIG_ARM_64
+ {
+ .desc = "Speculation barrier instruction (SB)",
+ .capability = ARM_HAS_SB,
+ .matches = has_sb_instruction,
+ },
+#endif
+ {},
+};
+
void update_cpu_capabilities(const struct arm_cpu_capabilities *caps,
const char *info)
{
}
}
+void check_local_cpu_features(void)
+{
+ update_cpu_capabilities(arm_features, "enabled support for");
+}
+
+void __init enable_cpu_features(void)
+{
+ enable_cpu_capabilities(arm_features);
+}
+
/*
* Run through the enabled capabilities and enable() them on the calling CPU.
* If enabling of any capability fails the error is returned. After enabling a
#define ARM_WORKAROUND_BHB_LOOP_24 13
#define ARM_WORKAROUND_BHB_LOOP_32 14
#define ARM_WORKAROUND_BHB_SMCC_3 15
+#define ARM_HAS_SB 16
-#define ARM_NCAPS 16
+#define ARM_NCAPS 17
#ifndef __ASSEMBLY__
extern DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS);
+void check_local_cpu_features(void);
+void enable_cpu_features(void);
+
static inline bool cpus_have_cap(unsigned int num)
{
if ( num >= ARM_NCAPS )
# error "This file should only be included in assembly file"
#endif
+#include <asm/alternative.h>
+
/*
* Speculative barrier
- * XXX: Add support for the 'sb' instruction
*/
.macro sb
+alternative_if_not ARM_HAS_SB
dsb nsh
isb
+alternative_else
+ /*
+ * SB encoding in hexadecimal to prevent recursive macro.
+ * extra nop is required to keep same number of instructions on both sides
+ * of the alternative.
+ */
+#if defined(CONFIG_ARM_32)
+ .inst 0xf57ff070
+#elif defined(CONFIG_ARM_64)
+ .inst 0xd50330ff
+#else
+# error "missing sb encoding for ARM variant"
+#endif
+ nop
+alternative_endif
.endm
#if defined (CONFIG_ARM_32)
*/
check_local_cpu_errata();
+ check_local_cpu_features();
+
init_xen_time();
gic_init();
*/
apply_alternatives_all();
enable_errata_workarounds();
+ enable_cpu_features();
/* Create initial domain 0. */
if ( !is_dom0less_mode() )
local_abort_enable();
check_local_cpu_errata();
+ check_local_cpu_features();
printk(XENLOG_DEBUG "CPU %u booted.\n", smp_processor_id());