Commit 62ae2162 authored by Oliver Upton's avatar Oliver Upton Committed by Marc Zyngier

KVM: arm64: Don't open code ARRAY_SIZE()

Use ARRAY_SIZE() instead of an open-coded version.
Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Reviewed-by: default avatarKalesh Singh <kaleshsingh@google.com>
Tested-by: default avatarKalesh Singh <kaleshsingh@google.com>
Link: https://lore.kernel.org/r/20220727142906.1856759-6-maz@kernel.org
parent 0e773da1
...@@ -103,14 +103,13 @@ static void notrace unwind(struct unwind_state *state, ...@@ -103,14 +103,13 @@ static void notrace unwind(struct unwind_state *state,
static bool pkvm_save_backtrace_entry(void *arg, unsigned long where) static bool pkvm_save_backtrace_entry(void *arg, unsigned long where)
{ {
unsigned long *stacktrace = this_cpu_ptr(pkvm_stacktrace); unsigned long *stacktrace = this_cpu_ptr(pkvm_stacktrace);
int size = NVHE_STACKTRACE_SIZE / sizeof(long);
int *idx = (int *)arg; int *idx = (int *)arg;
/* /*
* Need 2 free slots: 1 for current entry and 1 for the * Need 2 free slots: 1 for current entry and 1 for the
* delimiter. * delimiter.
*/ */
if (*idx > size - 2) if (*idx > ARRAY_SIZE(pkvm_stacktrace) - 2)
return false; return false;
stacktrace[*idx] = where; stacktrace[*idx] = where;
......
...@@ -187,11 +187,13 @@ static void pkvm_dump_backtrace(unsigned long hyp_offset) ...@@ -187,11 +187,13 @@ static void pkvm_dump_backtrace(unsigned long hyp_offset)
{ {
unsigned long *stacktrace unsigned long *stacktrace
= (unsigned long *) this_cpu_ptr_nvhe_sym(pkvm_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(); kvm_nvhe_dump_backtrace_start();
/* The saved stacktrace is terminated by a null entry */ /* 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_entry((void *)hyp_offset, stacktrace[i]);
kvm_nvhe_dump_backtrace_end(); kvm_nvhe_dump_backtrace_end();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment