Substitute the implicit "-1" occurrence for an invalid CPU id with an unsigned int INVALID_CPU_ID that can be used in all "uint-related" comparisons.
Signed-off-by: Andrea Bastoni <[email protected]> --- hypervisor/arch/arm-common/lib.c | 2 +- hypervisor/arch/arm-common/psci.c | 4 ++-- hypervisor/control.c | 3 ++- hypervisor/include/jailhouse/control.h | 5 +++-- hypervisor/setup.c | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hypervisor/arch/arm-common/lib.c b/hypervisor/arch/arm-common/lib.c index 916cd54f..889b3d14 100644 --- a/hypervisor/arch/arm-common/lib.c +++ b/hypervisor/arch/arm-common/lib.c @@ -31,5 +31,5 @@ unsigned int arm_cpu_by_mpidr(struct cell *cell, unsigned long mpidr) if (mpidr == (public_per_cpu(cpu)->mpidr & MPIDR_CPUID_MASK)) return cpu; - return -1; + return INVALID_CPU_ID; } diff --git a/hypervisor/arch/arm-common/psci.c b/hypervisor/arch/arm-common/psci.c index 6a9abf60..242cad5b 100644 --- a/hypervisor/arch/arm-common/psci.c +++ b/hypervisor/arch/arm-common/psci.c @@ -27,7 +27,7 @@ static long psci_emulate_cpu_on(struct trap_context *ctx) long result; cpu = arm_cpu_by_mpidr(this_cell(), ctx->regs[1] & mask); - if (cpu == -1) + if (cpu == INVALID_CPU_ID) /* Virtual id not in set */ return PSCI_DENIED; @@ -63,7 +63,7 @@ static long psci_emulate_affinity_info(struct trap_context *ctx) { unsigned int cpu = arm_cpu_by_mpidr(this_cell(), ctx->regs[1]); - if (cpu == -1) + if (cpu == INVALID_CPU_ID) /* Virtual id not in set */ return PSCI_DENIED; diff --git a/hypervisor/control.c b/hypervisor/control.c index b38ac2e9..2214406f 100644 --- a/hypervisor/control.c +++ b/hypervisor/control.c @@ -48,7 +48,8 @@ unsigned long panic_cpu = -1; * @note For internal use only. Use for_each_cpu() or for_each_cpu_except() * instead. */ -unsigned int next_cpu(unsigned int cpu, struct cpu_set *cpu_set, int exception) +unsigned int next_cpu(unsigned int cpu, struct cpu_set *cpu_set, + unsigned int exception) { do cpu++; diff --git a/hypervisor/include/jailhouse/control.h b/hypervisor/include/jailhouse/control.h index 9b94f563..32a1ca2e 100644 --- a/hypervisor/include/jailhouse/control.h +++ b/hypervisor/include/jailhouse/control.h @@ -17,6 +17,7 @@ #define SHUTDOWN_NONE 0 #define SHUTDOWN_STARTED 1 +#define INVALID_CPU_ID ~(0U) extern volatile unsigned long panic_in_progress; extern unsigned long panic_cpu; @@ -34,7 +35,7 @@ extern unsigned long panic_cpu; extern struct jailhouse_system *system_config; unsigned int next_cpu(unsigned int cpu, struct cpu_set *cpu_set, - int exception); + unsigned int exception); /** * Get the first CPU in a given set. @@ -42,7 +43,7 @@ unsigned int next_cpu(unsigned int cpu, struct cpu_set *cpu_set, * * @return First CPU in set, or max_cpu_id + 1 if the set is empty. */ -#define first_cpu(set) next_cpu(-1, (set), -1) +#define first_cpu(set) next_cpu(INVALID_CPU_ID, (set), INVALID_CPU_ID) /** * Loop-generating macro for iterating over all CPUs in a set. diff --git a/hypervisor/setup.c b/hypervisor/setup.c index 6f4e22c5..f0ee0896 100644 --- a/hypervisor/setup.c +++ b/hypervisor/setup.c @@ -27,7 +27,7 @@ extern u8 __text_start[]; static const __attribute__((aligned(PAGE_SIZE))) u8 empty_page[PAGE_SIZE]; static spinlock_t init_lock; -static unsigned int master_cpu_id = -1; +static unsigned int master_cpu_id = INVALID_CPU_ID; static volatile unsigned int entered_cpus, initialized_cpus; static volatile int error; @@ -224,7 +224,7 @@ int entry(unsigned int cpu_id, struct per_cpu *cpu_data) spin_lock(&init_lock); - if (master_cpu_id == -1) { + if (master_cpu_id == INVALID_CPU_ID) { /* Only the master CPU, the first to enter this * function, performs system-wide initializations. */ master = true; -- 2.28.0 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/20201028210933.138379-4-andrea.bastoni%40tum.de.
