|
32 | 32 | #define NUM_ALPHA_EXTS ('z' - 'a' + 1) |
33 | 33 |
|
34 | 34 | static bool any_cpu_has_zicboz; |
| 35 | +static bool any_cpu_has_zicbop; |
35 | 36 | static bool any_cpu_has_zicbom; |
36 | 37 |
|
37 | 38 | unsigned long elf_hwcap __read_mostly; |
@@ -119,6 +120,21 @@ static int riscv_ext_zicboz_validate(const struct riscv_isa_ext_data *data, |
119 | 120 | return 0; |
120 | 121 | } |
121 | 122 |
|
| 123 | +static int riscv_ext_zicbop_validate(const struct riscv_isa_ext_data *data, |
| 124 | + const unsigned long *isa_bitmap) |
| 125 | +{ |
| 126 | + if (!riscv_cbop_block_size) { |
| 127 | + pr_err("Zicbop detected in ISA string, disabling as no cbop-block-size found\n"); |
| 128 | + return -EINVAL; |
| 129 | + } |
| 130 | + if (!is_power_of_2(riscv_cbop_block_size)) { |
| 131 | + pr_err("Zicbop disabled as cbop-block-size present, but is not a power-of-2\n"); |
| 132 | + return -EINVAL; |
| 133 | + } |
| 134 | + any_cpu_has_zicbop = true; |
| 135 | + return 0; |
| 136 | +} |
| 137 | + |
122 | 138 | static int riscv_ext_f_validate(const struct riscv_isa_ext_data *data, |
123 | 139 | const unsigned long *isa_bitmap) |
124 | 140 | { |
@@ -442,6 +458,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { |
442 | 458 | __RISCV_ISA_EXT_SUPERSET_VALIDATE(v, RISCV_ISA_EXT_v, riscv_v_exts, riscv_ext_vector_float_validate), |
443 | 459 | __RISCV_ISA_EXT_DATA(h, RISCV_ISA_EXT_h), |
444 | 460 | __RISCV_ISA_EXT_SUPERSET_VALIDATE(zicbom, RISCV_ISA_EXT_ZICBOM, riscv_xlinuxenvcfg_exts, riscv_ext_zicbom_validate), |
| 461 | + __RISCV_ISA_EXT_DATA_VALIDATE(zicbop, RISCV_ISA_EXT_ZICBOP, riscv_ext_zicbop_validate), |
445 | 462 | __RISCV_ISA_EXT_SUPERSET_VALIDATE(zicboz, RISCV_ISA_EXT_ZICBOZ, riscv_xlinuxenvcfg_exts, riscv_ext_zicboz_validate), |
446 | 463 | __RISCV_ISA_EXT_DATA(ziccrse, RISCV_ISA_EXT_ZICCRSE), |
447 | 464 | __RISCV_ISA_EXT_DATA(zicntr, RISCV_ISA_EXT_ZICNTR), |
@@ -1112,6 +1129,10 @@ void __init riscv_user_isa_enable(void) |
1112 | 1129 | current->thread.envcfg |= ENVCFG_CBCFE; |
1113 | 1130 | else if (any_cpu_has_zicbom) |
1114 | 1131 | pr_warn("Zicbom disabled as it is unavailable on some harts\n"); |
| 1132 | + |
| 1133 | + if (!riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOP) && |
| 1134 | + any_cpu_has_zicbop) |
| 1135 | + pr_warn("Zicbop disabled as it is unavailable on some harts\n"); |
1115 | 1136 | } |
1116 | 1137 |
|
1117 | 1138 | #ifdef CONFIG_RISCV_ALTERNATIVE |
|
0 commit comments