static bool pkvm_save_backtrace_entry(void *arg, unsigned long where)
 {
        unsigned long *stacktrace = this_cpu_ptr(pkvm_stacktrace);
-       int size = NVHE_STACKTRACE_SIZE / sizeof(long);
        int *idx = (int *)arg;
 
        /*
         * Need 2 free slots: 1 for current entry and 1 for the
         * delimiter.
         */
-       if (*idx > size - 2)
+       if (*idx > ARRAY_SIZE(pkvm_stacktrace) - 2)
                return false;
 
        stacktrace[*idx] = where;
 
 {
        unsigned long *stacktrace
                = (unsigned long *) this_cpu_ptr_nvhe_sym(pkvm_stacktrace);
-       int i, size = NVHE_STACKTRACE_SIZE / sizeof(long);
+       int i;
 
        kvm_nvhe_dump_backtrace_start();
        /* The saved stacktrace is terminated by a null entry */
-       for (i = 0; i < size && stacktrace[i]; i++)
+       for (i = 0;
+            i < ARRAY_SIZE(kvm_nvhe_sym(pkvm_stacktrace)) && stacktrace[i];
+            i++)
                kvm_nvhe_dump_backtrace_entry((void *)hyp_offset, stacktrace[i]);
        kvm_nvhe_dump_backtrace_end();
 }