1 #ifndef __ASM_ARM_CPUFEATURE_H
2 #define __ASM_ARM_CPUFEATURE_H
3 
4 #ifdef CONFIG_ARM_64
5 #define cpu_feature64(c, feat)         ((c)->pfr64.feat)
6 #define boot_cpu_feature64(feat)       (boot_cpu_data.pfr64.feat)
7 
8 #define cpu_has_el0_32    (boot_cpu_feature64(el0) == 2)
9 #define cpu_has_el0_64    (boot_cpu_feature64(el0) >= 1)
10 #define cpu_has_el1_32    (boot_cpu_feature64(el1) == 2)
11 #define cpu_has_el1_64    (boot_cpu_feature64(el1) >= 1)
12 #define cpu_has_el2_32    (boot_cpu_feature64(el2) == 2)
13 #define cpu_has_el2_64    (boot_cpu_feature64(el2) >= 1)
14 #define cpu_has_el3_32    (boot_cpu_feature64(el3) == 2)
15 #define cpu_has_el3_64    (boot_cpu_feature64(el3) >= 1)
16 #define cpu_has_fp        (boot_cpu_feature64(fp) == 0)
17 #define cpu_has_simd      (boot_cpu_feature64(simd) == 0)
18 #define cpu_has_gicv3     (boot_cpu_feature64(gic) == 1)
19 #endif
20 
21 #define cpu_feature32(c, feat)         ((c)->pfr32.feat)
22 #define boot_cpu_feature32(feat)       (boot_cpu_data.pfr32.feat)
23 
24 #define cpu_has_arm       (boot_cpu_feature32(arm) == 1)
25 #define cpu_has_thumb     (boot_cpu_feature32(thumb) >= 1)
26 #define cpu_has_thumb2    (boot_cpu_feature32(thumb) >= 3)
27 #define cpu_has_jazelle   (boot_cpu_feature32(jazelle) > 0)
28 #define cpu_has_thumbee   (boot_cpu_feature32(thumbee) == 1)
29 #define cpu_has_aarch32   (cpu_has_arm || cpu_has_thumb)
30 
31 #ifdef CONFIG_ARM_32
32 #define cpu_has_gentimer  (boot_cpu_feature32(gentimer) == 1)
33 #else
34 #define cpu_has_gentimer  (1)
35 #endif
36 #define cpu_has_security  (boot_cpu_feature32(security) > 0)
37 
38 #define ARM64_WORKAROUND_CLEAN_CACHE    0
39 #define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE    1
40 #define ARM32_WORKAROUND_766422 2
41 #define ARM64_WORKAROUND_834220 3
42 #define LIVEPATCH_FEATURE   4
43 #define SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT 5
44 #define SKIP_CTXT_SWITCH_SERROR_SYNC 6
45 
46 #define ARM_NCAPS           7
47 
48 #ifndef __ASSEMBLY__
49 
50 #include <xen/types.h>
51 #include <xen/lib.h>
52 #include <xen/bitops.h>
53 
54 extern DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS);
55 
cpus_have_cap(unsigned int num)56 static inline bool cpus_have_cap(unsigned int num)
57 {
58     if ( num >= ARM_NCAPS )
59         return false;
60 
61     return test_bit(num, cpu_hwcaps);
62 }
63 
cpus_set_cap(unsigned int num)64 static inline void cpus_set_cap(unsigned int num)
65 {
66     if (num >= ARM_NCAPS)
67         printk(XENLOG_WARNING "Attempt to set an illegal CPU capability (%d >= %d)\n",
68                num, ARM_NCAPS);
69     else
70         __set_bit(num, cpu_hwcaps);
71 }
72 
73 struct arm_cpu_capabilities {
74     const char *desc;
75     u16 capability;
76     bool (*matches)(const struct arm_cpu_capabilities *);
77     union {
78         struct {    /* To be used for eratum handling only */
79             u32 midr_model;
80             u32 midr_range_min, midr_range_max;
81         };
82     };
83 };
84 
85 void update_cpu_capabilities(const struct arm_cpu_capabilities *caps,
86                              const char *info);
87 
88 #endif /* __ASSEMBLY__ */
89 
90 #endif
91 /*
92  * Local variables:
93  * mode: C
94  * c-file-style: "BSD"
95  * c-basic-offset: 4
96  * indent-tabs-mode: nil
97  * End:
98  */
99