Skip to content

Commit 7fcad02

Browse files
committed
fix RVV 1.0 detection code
There were a couple of issues with the detection code used to check for RVV 1.0 on kernels that do not support hwprobe. 1. The vtype clobber was missing 2. The wrong form of vsetvli was being used. The vsetvli x0, x0 form is inappropriate for this use case as it can only be safely used in code where the value of vtype is known. The use of vsetvli x0, x0 here can lead to a failure to detect RVV 1.0, if, for example, the vill bit happens to be set before detect_riscv64_rvv100 is called. We fix both issues by adding the missing clobber and replacing the first parameter to vsetvli with t0 (which we add to our clobbers).
1 parent 06c09de commit 7fcad02

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

driver/others/detect_riscv64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ uint64_t detect_riscv64_rvv100(void)
6363
* RVV 1.0 and we return 0.
6464
*/
6565

66-
asm volatile("vsetvli x0, x0, e8, m1, ta, ma\n\t"
66+
asm volatile("vsetvli t0, x0, e8, m1, ta, ma\n\t"
6767
"csrr %0, vtype\n\t"
6868
"slt %0, x0, %0\n"
6969
: "=r" (rvv10_supported)
7070
:
71-
:);
71+
:"t0", "vtype");
7272

7373
return rvv10_supported;
7474
}

0 commit comments

Comments
 (0)