8 char buf
[64] __attribute__((aligned(64)));
9 unsigned long check_dc_zva
;
10 unsigned long check_dc_cvap
;
11 memset(buf
, 0xAA, 64);
12 asm volatile("mrs %0, dczid_el0" : "=r" (check_dc_zva
));
13 asm volatile("dc cvac, %0" :: "r" (buf
));
14 asm volatile("dc cvau, %0" :: "r" (buf
));
15 asm volatile("mrs %0, id_aa64isar1_el1" : "=r" (check_dc_cvap
));
16 if (check_dc_cvap
& 0x3) {
17 asm volatile("add x8, sp, #0x40\n"
18 ".inst 0xd50b7c28\n");
20 if (check_dc_cvap
& 0x2) {
21 asm volatile("add x8, sp, #0x40\n"
24 asm volatile("dc civac, %0" :: "r" (buf
));
25 if (!(check_dc_zva
& 0x10)) {
26 size_t buf_size
= (1U << ((check_dc_zva
& 0xf) + 2));
27 //printf("lg 2 word count %lu byte count %zu\n", check_dc_zva & 0xfUL, buf_size);
29 if (posix_memalign((void**)&var_buf
, buf_size
, buf_size
) == 0) {
30 asm volatile("dc zva, %0" :: "r" (var_buf
));
31 assert(var_buf
[0] == 0);
32 assert(var_buf
[buf_size
- 1] == 0);
35 perror("posix_memalign failed:");