]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/64: don't refer nr_cpu_ids in asm code when it's undefined
authorYury Norov <yury.norov@gmail.com>
Tue, 20 Sep 2022 13:13:12 +0000 (06:13 -0700)
committerYury Norov <yury.norov@gmail.com>
Tue, 20 Sep 2022 23:11:44 +0000 (16:11 -0700)
commite2c93e3e6000b2d3a80cbbc0189a97fd727fbe4e
treea10422c8025db39ef7540a85e61bacfe1ff400ae
parent72738d15e92db85cce12a90c3eeda27cdc7abd14
powerpc/64: don't refer nr_cpu_ids in asm code when it's undefined

generic_secondary_common_init() calls LOAD_REG_ADDR(r7, nr_cpu_ids)
conditionally on CONFIG_SMP. However, if 'NR_CPUS == 1', kernel doesn't
use the nr_cpu_ids, and in C code, it's just:
  #if NR_CPUS == 1
  #define nr_cpu_ids
  ...

This series makes declaration of nr_cpu_ids conditional on NR_CPUS == 1,
and that reveals the issue, because compiler can't link the
LOAD_REG_ADDR(r7, nr_cpu_ids) against nonexisting symbol.

Current code looks unsafe for those who build kernel with CONFIG_SMP=y and
NR_CPUS == 1. This is weird configuration, but not disallowed.

Fix the linker error by replacing LOAD_REG_ADDR() with LOAD_REG_IMMEDIATE()
conditionally on NR_CPUS == 1.

As the following patch adds CONFIG_FORCE_NR_CPUS option that has the
similar effect on nr_cpu_ids, make the generic_secondary_common_init()
conditional on it too.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
arch/powerpc/kernel/head_64.S