summaryrefslogtreecommitdiff
path: root/sys/arch/riscv64
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2022-01-18 07:44:38 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2022-01-18 07:44:38 +0000
commitd9dbedca495c57d86b76e4508a01ece7e1cd87ee (patch)
tree9d1793ddd93a737610bed5a6e3dbb261447d7c82 /sys/arch/riscv64
parentcb176dc9418838fa8dfd0d1e6cc476d0fe78e278 (diff)
plic: Fix cpuid handling
Make `cpu' signed so that the possible return value -1 from plic_get_cpuid() gets handled correctly in the (cpu < 0) condition. This prevents plic_attach() from updating sc_contexts[] out of bounds. When plic_get_cpuid() returns -1, ignore the entry and continue processing. The error is not fatal. It is normal that secondary CPUs are not found when running a non-MULTIPROCESSOR kernel on a multiprocessor machine. OK kettenis@
Diffstat (limited to 'sys/arch/riscv64')
-rw-r--r--sys/arch/riscv64/dev/plic.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/arch/riscv64/dev/plic.c b/sys/arch/riscv64/dev/plic.c
index f058d66aae7..a9f53b5b622 100644
--- a/sys/arch/riscv64/dev/plic.c
+++ b/sys/arch/riscv64/dev/plic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: plic.c,v 1.8 2022/01/03 03:06:50 jsg Exp $ */
+/* $OpenBSD: plic.c,v 1.9 2022/01/18 07:44:37 visa Exp $ */
/*
* Copyright (c) 2020, Mars Li <mengshi.li.mars@gmail.com>
@@ -162,7 +162,7 @@ plic_attach(struct device *parent, struct device *dev, void *aux)
struct fdt_attach_args *faa;
uint32_t *cells;
uint32_t irq;
- uint32_t cpu;
+ int cpu;
int node;
int len;
int ncell;
@@ -251,11 +251,8 @@ plic_attach(struct device *parent, struct device *dev, void *aux)
/* Get the corresponding cpuid. */
cpu = plic_get_cpuid(OF_getnodebyphandle(cells[i]));
- if (cpu < 0) {
- printf(": invalid hart!\n");
- free(cells, M_TEMP, len);
- return;
- }
+ if (cpu < 0)
+ continue;
/*
* Set the enable and context register offsets for the CPU.