From: Conor Dooley RISCV_ISA_EXT_BUNDLE actually made sense when it was originally added, since it presented a simple interface where users (be that in kernel or userspace via things they are presented by the kernel) would check the exact extension needed for a feature, rather than muddying the water with parent extensions. As a result, the kernel does not track the status of the parent extension in the bundle, nor expose it to userspace. This is in comparison to RISCV_ISA_EXT_SUPERSET, where the parent extension provided some explicit value, and would have to be checked for itself for some potential feature, and therefore we actually track the status of both child and parent extensions, and let userspace detect them independently. Since we added this stuff, there's been some retroactive extension releases by RVI that have made previous monolithic extensions into pure wrappers that we intended using RISCV_ISA_EXT_BUNDLE for. Since we previously tracked that as one extension, and exported it to users as one extension, we can't just use RISCV_ISA_EXT_BUNDLE, and have to use RISCV_ISA_EXT_SUPERSET instead and nobody seems to know what to use each actually for anymore. Just delete RISCV_ISA_EXT_BUNDLE for the sake of consistency between things that were always a bundle from ratification and for those retroactively made into bundles, with the side benefit of being less confusing for those adding extensions to the kernel. Signed-off-by: Conor Dooley --- No idea if this works properly, I wrote it in the middle of a talk on a laptop that has nothing needed to do the testing on it. I brought this up during some view the other day, dunno if people actually latched onto what I was getting at, so just posting it to see what folks think. Not 100% on if my comments on the initial rationale are right, they're just my recollection... Cheers, Conor --- arch/riscv/include/asm/cpufeature.h | 8 --- arch/riscv/include/asm/hwcap.h | 10 +++ arch/riscv/kernel/cpufeature.c | 97 ++++++++++++++++------------- 3 files changed, 63 insertions(+), 52 deletions(-) diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h index 739fcc84b..74b3e34b5 100644 --- a/arch/riscv/include/asm/cpufeature.h +++ b/arch/riscv/include/asm/cpufeature.h @@ -54,14 +54,6 @@ void __init riscv_user_isa_enable(void); #define __RISCV_ISA_EXT_DATA_VALIDATE(_name, _id, _validate) \ _RISCV_ISA_EXT_DATA(_name, _id, NULL, 0, _validate) -/* Used to declare pure "lasso" extension (Zk for instance) */ -#define __RISCV_ISA_EXT_BUNDLE(_name, _bundled_exts) \ - _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, \ - ARRAY_SIZE(_bundled_exts), NULL) -#define __RISCV_ISA_EXT_BUNDLE_VALIDATE(_name, _bundled_exts, _validate) \ - _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, \ - ARRAY_SIZE(_bundled_exts), _validate) - /* Used to declare extensions that are a superset of other extensions (Zvbb for instance) */ #define __RISCV_ISA_EXT_SUPERSET(_name, _id, _sub_exts) \ _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts), NULL) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index f8db798b2..823e8506c 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -122,6 +122,16 @@ #define RISCV_ISA_EXT_ZICCAMOA 113 #define RISCV_ISA_EXT_ZICCIF 114 #define RISCV_ISA_EXT_ZA64RS 115 +#define RISCV_ISA_EXT_ZK 116 +#define RISCV_ISA_EXT_ZKN 117 +#define RISCV_ISA_EXT_ZKS 118 +#define RISCV_ISA_EXT_ZVKN 119 +#define RISCV_ISA_EXT_ZVKNC 120 +#define RISCV_ISA_EXT_ZVKNG 121 +#define RISCV_ISA_EXT_ZVKS 122 +#define RISCV_ISA_EXT_ZVKSC 123 +#define RISCV_ISA_EXT_ZVKSG 124 + #define RISCV_ISA_EXT_XLINUXENVCFG 127 diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 61d21f714..b1f2a9626 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -322,14 +322,6 @@ static const unsigned int riscv_a_exts[] = { RISCV_ISA_EXT_ZALRSC, }; -#define RISCV_ISA_EXT_ZKN \ - RISCV_ISA_EXT_ZBKB, \ - RISCV_ISA_EXT_ZBKC, \ - RISCV_ISA_EXT_ZBKX, \ - RISCV_ISA_EXT_ZKND, \ - RISCV_ISA_EXT_ZKNE, \ - RISCV_ISA_EXT_ZKNH - static int riscv_ext_smcdeleg_validate(const struct riscv_isa_ext_data *data, const unsigned long *isa_bitmap) { @@ -351,60 +343,77 @@ static int riscv_ext_ssccfg_validate(const struct riscv_isa_ext_data *data, return -EPROBE_DEFER; } -static const unsigned int riscv_zk_bundled_exts[] = { - RISCV_ISA_EXT_ZKN, +static const unsigned int riscv_zk_sub_exts[] = { + RISCV_ISA_EXT_ZBKB, + RISCV_ISA_EXT_ZBKC, + RISCV_ISA_EXT_ZBKX, + RISCV_ISA_EXT_ZKND, + RISCV_ISA_EXT_ZKNE, + RISCV_ISA_EXT_ZKNH, RISCV_ISA_EXT_ZKR, RISCV_ISA_EXT_ZKT }; -static const unsigned int riscv_zkn_bundled_exts[] = { - RISCV_ISA_EXT_ZKN +static const unsigned int riscv_zkn_sub_exts[] = { + RISCV_ISA_EXT_ZBKB, + RISCV_ISA_EXT_ZBKC, + RISCV_ISA_EXT_ZBKX, + RISCV_ISA_EXT_ZKND, + RISCV_ISA_EXT_ZKNE, + RISCV_ISA_EXT_ZKNH }; -static const unsigned int riscv_zks_bundled_exts[] = { +static const unsigned int riscv_zks_sub_exts[] = { RISCV_ISA_EXT_ZBKB, RISCV_ISA_EXT_ZBKC, RISCV_ISA_EXT_ZKSED, RISCV_ISA_EXT_ZKSH }; -#define RISCV_ISA_EXT_ZVKN \ - RISCV_ISA_EXT_ZVKNED, \ - RISCV_ISA_EXT_ZVKNHB, \ - RISCV_ISA_EXT_ZVKB, \ - RISCV_ISA_EXT_ZVKT -static const unsigned int riscv_zvkn_bundled_exts[] = { - RISCV_ISA_EXT_ZVKN +static const unsigned int riscv_zvkn_sub_exts[] = { + RISCV_ISA_EXT_ZVKNED, + RISCV_ISA_EXT_ZVKNHB, + RISCV_ISA_EXT_ZVKB, + RISCV_ISA_EXT_ZVKT }; -static const unsigned int riscv_zvknc_bundled_exts[] = { - RISCV_ISA_EXT_ZVKN, +static const unsigned int riscv_zvknc_sub_exts[] = { + RISCV_ISA_EXT_ZVKNED, + RISCV_ISA_EXT_ZVKNHB, + RISCV_ISA_EXT_ZVKB, + RISCV_ISA_EXT_ZVKT, RISCV_ISA_EXT_ZVBC }; -static const unsigned int riscv_zvkng_bundled_exts[] = { - RISCV_ISA_EXT_ZVKN, +static const unsigned int riscv_zvkng_sub_exts[] = { + RISCV_ISA_EXT_ZVKNED, + RISCV_ISA_EXT_ZVKNHB, + RISCV_ISA_EXT_ZVKB, + RISCV_ISA_EXT_ZVKT, RISCV_ISA_EXT_ZVKG }; -#define RISCV_ISA_EXT_ZVKS \ - RISCV_ISA_EXT_ZVKSED, \ - RISCV_ISA_EXT_ZVKSH, \ - RISCV_ISA_EXT_ZVKB, \ +static const unsigned int riscv_zvks_sub_exts[] = { + RISCV_ISA_EXT_ZVKSED, + RISCV_ISA_EXT_ZVKSH, + RISCV_ISA_EXT_ZVKB, RISCV_ISA_EXT_ZVKT - -static const unsigned int riscv_zvks_bundled_exts[] = { - RISCV_ISA_EXT_ZVKS }; -static const unsigned int riscv_zvksc_bundled_exts[] = { - RISCV_ISA_EXT_ZVKS, +static const unsigned int riscv_zvksc_sub_exts[] = { + RISCV_ISA_EXT_ZVKSED, + RISCV_ISA_EXT_ZVKSH, + RISCV_ISA_EXT_ZVKB, + RISCV_ISA_EXT_ZVKT, RISCV_ISA_EXT_ZVBC }; -static const unsigned int riscv_zvksg_bundled_exts[] = { - RISCV_ISA_EXT_ZVKS, +static const unsigned int riscv_zvksg_sub_exts[] = { + RISCV_ISA_EXT_ZVKSED, + RISCV_ISA_EXT_ZVKSH, + RISCV_ISA_EXT_ZVKB, + RISCV_ISA_EXT_ZVKT, RISCV_ISA_EXT_ZVKG }; @@ -580,13 +589,13 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(zbkc, RISCV_ISA_EXT_ZBKC), __RISCV_ISA_EXT_DATA(zbkx, RISCV_ISA_EXT_ZBKX), __RISCV_ISA_EXT_DATA(zbs, RISCV_ISA_EXT_ZBS), - __RISCV_ISA_EXT_BUNDLE(zk, riscv_zk_bundled_exts), - __RISCV_ISA_EXT_BUNDLE(zkn, riscv_zkn_bundled_exts), + __RISCV_ISA_EXT_SUPERSET(zk, RISCV_ISA_EXT_ZK, riscv_zk_sub_exts), + __RISCV_ISA_EXT_SUPERSET(zkn, RISCV_ISA_EXT_ZKN, riscv_zkn_sub_exts), __RISCV_ISA_EXT_DATA(zknd, RISCV_ISA_EXT_ZKND), __RISCV_ISA_EXT_DATA(zkne, RISCV_ISA_EXT_ZKNE), __RISCV_ISA_EXT_DATA(zknh, RISCV_ISA_EXT_ZKNH), __RISCV_ISA_EXT_DATA(zkr, RISCV_ISA_EXT_ZKR), - __RISCV_ISA_EXT_BUNDLE(zks, riscv_zks_bundled_exts), + __RISCV_ISA_EXT_SUPERSET(zks, RISCV_ISA_EXT_ZKS, riscv_zks_sub_exts), __RISCV_ISA_EXT_DATA(zkt, RISCV_ISA_EXT_ZKT), __RISCV_ISA_EXT_DATA(zksed, RISCV_ISA_EXT_ZKSED), __RISCV_ISA_EXT_DATA(zksh, RISCV_ISA_EXT_ZKSH), @@ -606,17 +615,17 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(zvfhmin, RISCV_ISA_EXT_ZVFHMIN), __RISCV_ISA_EXT_DATA_VALIDATE(zvkb, RISCV_ISA_EXT_ZVKB, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zvkg, RISCV_ISA_EXT_ZVKG, riscv_ext_vector_crypto_validate), - __RISCV_ISA_EXT_BUNDLE_VALIDATE(zvkn, riscv_zvkn_bundled_exts, riscv_ext_vector_crypto_validate), - __RISCV_ISA_EXT_BUNDLE_VALIDATE(zvknc, riscv_zvknc_bundled_exts, riscv_ext_vector_crypto_validate), + __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvkn, RISCV_ISA_EXT_ZVKN, riscv_zvkn_sub_exts, riscv_ext_vector_crypto_validate), + __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvknc, RISCV_ISA_EXT_ZVKNC, riscv_zvknc_sub_exts, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zvkned, RISCV_ISA_EXT_ZVKNED, riscv_ext_vector_crypto_validate), - __RISCV_ISA_EXT_BUNDLE_VALIDATE(zvkng, riscv_zvkng_bundled_exts, riscv_ext_vector_crypto_validate), + __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvkng, RISCV_ISA_EXT_ZVKNG, riscv_zvkng_sub_exts, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zvknha, RISCV_ISA_EXT_ZVKNHA, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zvknhb, RISCV_ISA_EXT_ZVKNHB, riscv_ext_vector_crypto_validate), - __RISCV_ISA_EXT_BUNDLE_VALIDATE(zvks, riscv_zvks_bundled_exts, riscv_ext_vector_crypto_validate), - __RISCV_ISA_EXT_BUNDLE_VALIDATE(zvksc, riscv_zvksc_bundled_exts, riscv_ext_vector_crypto_validate), + __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvks, RISCV_ISA_EXT_ZVKS, riscv_zvks_sub_exts, riscv_ext_vector_crypto_validate), + __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvksc, RISCV_ISA_EXT_ZVKSC, riscv_zvksc_sub_exts, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zvksed, RISCV_ISA_EXT_ZVKSED, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zvksh, RISCV_ISA_EXT_ZVKSH, riscv_ext_vector_crypto_validate), - __RISCV_ISA_EXT_BUNDLE_VALIDATE(zvksg, riscv_zvksg_bundled_exts, riscv_ext_vector_crypto_validate), + __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvksg, RISCV_ISA_EXT_ZVKSG, riscv_zvksg_sub_exts, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zvkt, RISCV_ISA_EXT_ZVKT, riscv_ext_vector_crypto_validate), __RISCV_ISA_EXT_DATA(smaia, RISCV_ISA_EXT_SMAIA), __RISCV_ISA_EXT_DATA_VALIDATE(smcdeleg, RISCV_ISA_EXT_SMCDELEG, -- 2.55.0