Skip to content

Commit 5b376a6

Browse files
author
Alexandre Ghiti
committed
Merge patch series "riscv: add support for Zaamo and Zalrsc extensions"
Clément Léger <cleger@rivosinc.com> says: Since commit e87412e621f1 ("integrate Zaamo and Zalrsc text (#1304)"), the A extension has been described as a set of instructions provided by Zaamo and Zalrsc. Add these two extensions. This series is based on the Zc one [1]. Link: https://lore.kernel.org/linux-riscv/20240619113529.676940-1-cleger@rivosinc.com/ [1] * patches from https://lore.kernel.org/lkml/20240619153913.867263-1-cleger@rivosinc.com/: dt-bindings: riscv: add Zaamo and Zalrsc ISA extension description riscv: add parsing for Zaamo and Zalrsc extensions riscv: hwprobe: export Zaamo and Zalrsc extensions RISC-V: KVM: Allow Zaamo/Zalrsc extensions for Guest/VM KVM: riscv: selftests: Add Zaamo/Zalrsc extensions to get-reg-list test Link: https://lore.kernel.org/lkml/20240619153913.867263-1-cleger@rivosinc.com/ Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
2 parents 67a5ba8 + 7a9827e commit 5b376a6

File tree

9 files changed

+55
-1
lines changed

9 files changed

+55
-1
lines changed

Documentation/arch/riscv/hwprobe.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ The following keys are defined:
245245
ratified in commit 98918c844281 ("Merge pull request #1217 from
246246
riscv/zawrs") of riscv-isa-manual.
247247

248+
* :c:macro:`RISCV_HWPROBE_EXT_ZAAMO`: The Zaamo extension is supported as
249+
defined in the in the RISC-V ISA manual starting from commit e87412e621f1
250+
("integrate Zaamo and Zalrsc text (#1304)").
251+
252+
* :c:macro:`RISCV_HWPROBE_EXT_ZALRSC`: The Zalrsc extension is supported as
253+
defined in the in the RISC-V ISA manual starting from commit e87412e621f1
254+
("integrate Zaamo and Zalrsc text (#1304)").
255+
248256
* :c:macro:`RISCV_HWPROBE_EXT_SUPM`: The Supm extension is supported as
249257
defined in version 1.0 of the RISC-V Pointer Masking extensions.
250258

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ properties:
224224
as ratified at commit 4a69197e5617 ("Update to ratified state") of
225225
riscv-svvptc.
226226

227+
- const: zaamo
228+
description: |
229+
The standard Zaamo extension for atomic memory operations as
230+
ratified at commit e87412e621f1 ("integrate Zaamo and Zalrsc text
231+
(#1304)") of the unprivileged ISA specification.
232+
227233
- const: zabha
228234
description: |
229235
The Zabha extension for Byte and Halfword Atomic Memory Operations
@@ -236,6 +242,12 @@ properties:
236242
is supported as ratified at commit 5059e0ca641c ("update to
237243
ratified") of the riscv-zacas.
238244
245+
- const: zalrsc
246+
description: |
247+
The standard Zalrsc extension for load-reserved/store-conditional as
248+
ratified at commit e87412e621f1 ("integrate Zaamo and Zalrsc text
249+
(#1304)") of the unprivileged ISA specification.
250+
239251
- const: zawrs
240252
description: |
241253
The Zawrs extension for entering a low-power state or for trapping
@@ -718,6 +730,13 @@ properties:
718730
const: zfbfmin
719731
- contains:
720732
const: zvfbfmin
733+
# Zacas depends on Zaamo
734+
- if:
735+
contains:
736+
const: zacas
737+
then:
738+
contains:
739+
const: zaamo
721740

722741
allOf:
723742
# Zcf extension does not exist on rv64

arch/riscv/include/asm/hwcap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
#define RISCV_ISA_EXT_ZFBFMIN 94
104104
#define RISCV_ISA_EXT_ZVFBFMIN 95
105105
#define RISCV_ISA_EXT_ZVFBFWMA 96
106+
#define RISCV_ISA_EXT_ZAAMO 97
107+
#define RISCV_ISA_EXT_ZALRSC 98
106108

107109
#define RISCV_ISA_EXT_XLINUXENVCFG 127
108110

arch/riscv/include/uapi/asm/hwprobe.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ struct riscv_hwprobe {
7979
#define RISCV_HWPROBE_EXT_ZVFBFMIN (1ULL << 53)
8080
#define RISCV_HWPROBE_EXT_ZVFBFWMA (1ULL << 54)
8181
#define RISCV_HWPROBE_EXT_ZICBOM (1ULL << 55)
82+
#define RISCV_HWPROBE_EXT_ZAAMO (1ULL << 56)
83+
#define RISCV_HWPROBE_EXT_ZALRSC (1ULL << 57)
8284
#define RISCV_HWPROBE_KEY_CPUPERF_0 5
8385
#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)
8486
#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)

arch/riscv/include/uapi/asm/kvm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ enum KVM_RISCV_ISA_EXT_ID {
182182
KVM_RISCV_ISA_EXT_SVVPTC,
183183
KVM_RISCV_ISA_EXT_ZABHA,
184184
KVM_RISCV_ISA_EXT_ZICCRSE,
185+
KVM_RISCV_ISA_EXT_ZAAMO,
186+
KVM_RISCV_ISA_EXT_ZALRSC,
185187
KVM_RISCV_ISA_EXT_MAX,
186188
};
187189

arch/riscv/kernel/cpufeature.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ static int riscv_ext_svadu_validate(const struct riscv_isa_ext_data *data,
182182
return 0;
183183
}
184184

185+
static const unsigned int riscv_a_exts[] = {
186+
RISCV_ISA_EXT_ZAAMO,
187+
RISCV_ISA_EXT_ZALRSC,
188+
};
189+
185190
static const unsigned int riscv_zk_bundled_exts[] = {
186191
RISCV_ISA_EXT_ZBKB,
187192
RISCV_ISA_EXT_ZBKC,
@@ -353,7 +358,7 @@ static const unsigned int riscv_c_exts[] = {
353358
const struct riscv_isa_ext_data riscv_isa_ext[] = {
354359
__RISCV_ISA_EXT_DATA(i, RISCV_ISA_EXT_i),
355360
__RISCV_ISA_EXT_DATA(m, RISCV_ISA_EXT_m),
356-
__RISCV_ISA_EXT_DATA(a, RISCV_ISA_EXT_a),
361+
__RISCV_ISA_EXT_SUPERSET(a, RISCV_ISA_EXT_a, riscv_a_exts),
357362
__RISCV_ISA_EXT_DATA(f, RISCV_ISA_EXT_f),
358363
__RISCV_ISA_EXT_DATA(d, RISCV_ISA_EXT_d),
359364
__RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_q),
@@ -373,8 +378,10 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
373378
__RISCV_ISA_EXT_DATA(zihintpause, RISCV_ISA_EXT_ZIHINTPAUSE),
374379
__RISCV_ISA_EXT_DATA(zihpm, RISCV_ISA_EXT_ZIHPM),
375380
__RISCV_ISA_EXT_DATA(zimop, RISCV_ISA_EXT_ZIMOP),
381+
__RISCV_ISA_EXT_DATA(zaamo, RISCV_ISA_EXT_ZAAMO),
376382
__RISCV_ISA_EXT_DATA(zabha, RISCV_ISA_EXT_ZABHA),
377383
__RISCV_ISA_EXT_DATA(zacas, RISCV_ISA_EXT_ZACAS),
384+
__RISCV_ISA_EXT_DATA(zalrsc, RISCV_ISA_EXT_ZALRSC),
378385
__RISCV_ISA_EXT_DATA(zawrs, RISCV_ISA_EXT_ZAWRS),
379386
__RISCV_ISA_EXT_DATA(zfa, RISCV_ISA_EXT_ZFA),
380387
__RISCV_ISA_EXT_DATA_VALIDATE(zfbfmin, RISCV_ISA_EXT_ZFBFMIN, riscv_ext_f_depends),

arch/riscv/kernel/sys_hwprobe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
9595
* regardless of the kernel's configuration, as no other checks, besides
9696
* presence in the hart_isa bitmap, are made.
9797
*/
98+
EXT_KEY(ZAAMO);
9899
EXT_KEY(ZACAS);
100+
EXT_KEY(ZALRSC);
99101
EXT_KEY(ZAWRS);
100102
EXT_KEY(ZBA);
101103
EXT_KEY(ZBB);

arch/riscv/kvm/vcpu_onereg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ static const unsigned long kvm_isa_ext_arr[] = {
4747
KVM_ISA_EXT_ARR(SVNAPOT),
4848
KVM_ISA_EXT_ARR(SVPBMT),
4949
KVM_ISA_EXT_ARR(SVVPTC),
50+
KVM_ISA_EXT_ARR(ZAAMO),
5051
KVM_ISA_EXT_ARR(ZABHA),
5152
KVM_ISA_EXT_ARR(ZACAS),
53+
KVM_ISA_EXT_ARR(ZALRSC),
5254
KVM_ISA_EXT_ARR(ZAWRS),
5355
KVM_ISA_EXT_ARR(ZBA),
5456
KVM_ISA_EXT_ARR(ZBB),
@@ -149,8 +151,10 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext)
149151
case KVM_RISCV_ISA_EXT_SVINVAL:
150152
case KVM_RISCV_ISA_EXT_SVNAPOT:
151153
case KVM_RISCV_ISA_EXT_SVVPTC:
154+
case KVM_RISCV_ISA_EXT_ZAAMO:
152155
case KVM_RISCV_ISA_EXT_ZABHA:
153156
case KVM_RISCV_ISA_EXT_ZACAS:
157+
case KVM_RISCV_ISA_EXT_ZALRSC:
154158
case KVM_RISCV_ISA_EXT_ZAWRS:
155159
case KVM_RISCV_ISA_EXT_ZBA:
156160
case KVM_RISCV_ISA_EXT_ZBB:

tools/testing/selftests/kvm/riscv/get-reg-list.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ bool filter_reg(__u64 reg)
5353
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVNAPOT:
5454
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVPBMT:
5555
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVVPTC:
56+
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_ZAAMO:
5657
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_ZABHA:
5758
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_ZACAS:
59+
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_ZALRSC:
5860
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_ZAWRS:
5961
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_ZBA:
6062
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_ZBB:
@@ -434,8 +436,10 @@ static const char *isa_ext_single_id_to_str(__u64 reg_off)
434436
KVM_ISA_EXT_ARR(SVNAPOT),
435437
KVM_ISA_EXT_ARR(SVPBMT),
436438
KVM_ISA_EXT_ARR(SVVPTC),
439+
KVM_ISA_EXT_ARR(ZAAMO),
437440
KVM_ISA_EXT_ARR(ZABHA),
438441
KVM_ISA_EXT_ARR(ZACAS),
442+
KVM_ISA_EXT_ARR(ZALRSC),
439443
KVM_ISA_EXT_ARR(ZAWRS),
440444
KVM_ISA_EXT_ARR(ZBA),
441445
KVM_ISA_EXT_ARR(ZBB),
@@ -974,8 +978,10 @@ KVM_ISA_EXT_SIMPLE_CONFIG(svinval, SVINVAL);
974978
KVM_ISA_EXT_SIMPLE_CONFIG(svnapot, SVNAPOT);
975979
KVM_ISA_EXT_SIMPLE_CONFIG(svpbmt, SVPBMT);
976980
KVM_ISA_EXT_SIMPLE_CONFIG(svvptc, SVVPTC);
981+
KVM_ISA_EXT_SIMPLE_CONFIG(zaamo, ZAAMO);
977982
KVM_ISA_EXT_SIMPLE_CONFIG(zabha, ZABHA);
978983
KVM_ISA_EXT_SIMPLE_CONFIG(zacas, ZACAS);
984+
KVM_ISA_EXT_SIMPLE_CONFIG(zalrsc, ZALRSC);
979985
KVM_ISA_EXT_SIMPLE_CONFIG(zawrs, ZAWRS);
980986
KVM_ISA_EXT_SIMPLE_CONFIG(zba, ZBA);
981987
KVM_ISA_EXT_SIMPLE_CONFIG(zbb, ZBB);
@@ -1045,8 +1051,10 @@ struct vcpu_reg_list *vcpu_configs[] = {
10451051
&config_svnapot,
10461052
&config_svpbmt,
10471053
&config_svvptc,
1054+
&config_zaamo,
10481055
&config_zabha,
10491056
&config_zacas,
1057+
&config_zalrsc,
10501058
&config_zawrs,
10511059
&config_zba,
10521060
&config_zbb,

0 commit comments

Comments
 (0)