]> git.baikalelectronics.ru Git - kernel.git/commitdiff
arm64: Make cpu_logical_map() take unsigned int
authorDavid Brazdil <dbrazdil@google.com>
Wed, 2 Dec 2020 18:41:03 +0000 (18:41 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 4 Dec 2020 08:44:24 +0000 (08:44 +0000)
CPU index should never be negative. Change the signature of
(set_)cpu_logical_map to take an unsigned int.

This still works even if the users treat the CPU index as an int,
and will allow the hypervisor's implementation to check that the index
is valid with a single upper-bound check.

Signed-off-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201202184122.26046-8-dbrazdil@google.com
arch/arm64/include/asm/smp.h
arch/arm64/kernel/setup.c

index 2e7f529ec5a6559138137ee5b5143a70b0702965..bcb01ca15325182bcdda653d5990bfd363ec811d 100644 (file)
@@ -46,9 +46,9 @@ DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
  * Logical CPU mapping.
  */
 extern u64 __cpu_logical_map[NR_CPUS];
-extern u64 cpu_logical_map(int cpu);
+extern u64 cpu_logical_map(unsigned int cpu);
 
-static inline void set_cpu_logical_map(int cpu, u64 hwid)
+static inline void set_cpu_logical_map(unsigned int cpu, u64 hwid)
 {
        __cpu_logical_map[cpu] = hwid;
 }
index 133257ffd8591d692f5f64abf8f41fb2d0e0910c..2f2973bc67c756886a4d991d5b48db56d09c52d0 100644 (file)
@@ -276,7 +276,7 @@ arch_initcall(reserve_memblock_reserved_regions);
 
 u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
 
-u64 cpu_logical_map(int cpu)
+u64 cpu_logical_map(unsigned int cpu)
 {
        return __cpu_logical_map[cpu];
 }