Re: [PATCH 2/2] Loongarch: KGDB: fix build when CPU_HAS_LBT not set

From: Huacai Chen
Date: Tue Aug 29 2023 - 00:13:03 EST


Hi, Randy,

On Tue, Aug 29, 2023 at 8:23 AM Randy Dunlap <rdunlap@xxxxxxxxxxxxx> wrote:
>
> Fix build errors when CONFIG_CPU_HAS_LBT is not set:
>
> loongarch64-linux-ld: arch/loongarch/kernel/kgdb.o: in function `dbg_get_reg':
> arch/loongarch/kernel/kgdb.c:154:(.text+0xc7c): undefined reference to `_save_lbt'
> loongarch64-linux-ld: arch/loongarch/kernel/kgdb.o: in function `dbg_set_reg':
> arch/loongarch/kernel/kgdb.c:229:(.text+0x13a4): undefined reference to `_restore_lbt'
Thank you for your patch, this has been fixed in today's linux-next.

Huacai
>
> Fixes: 8968eb010689 ("LoongArch: Add basic KGDB & KDB support")
> Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Cc: Qing Zhang <zhangqing@xxxxxxxxxxx>
> Cc: Hui Li <lihui@xxxxxxxxxxx>
> Cc: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
> Cc: Huacai Chen <chenhuacai@xxxxxxxxxx>
> Cc: WANG Xuerui <kernel@xxxxxxxxxx>
> Cc: loongarch@xxxxxxxxxxxxxxx
> ---
> arch/loongarch/kernel/kgdb.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff -- a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c
> --- a/arch/loongarch/kernel/kgdb.c
> +++ b/arch/loongarch/kernel/kgdb.c
> @@ -150,7 +150,8 @@ char *dbg_get_reg(int regno, void *mem,
> }
>
> /* Handle LBT registers */
> - if ((regs->csr_euen & CSR_EUEN_LBTEN)) {
> + if (IS_ENABLED(CONFIG_CPU_HAS_LBT) &&
> + (regs->csr_euen & CSR_EUEN_LBTEN)) {
> _save_lbt(&current->thread.lbt);
>
> switch (regno) {
> @@ -211,7 +212,8 @@ int dbg_set_reg(int regno, void *mem, st
> }
>
> /* Handle LBT registers */
> - if ((regs->csr_euen & CSR_EUEN_LBTEN)) {
> + if (IS_ENABLED(CONFIG_CPU_HAS_LBT) &&
> + (regs->csr_euen & CSR_EUEN_LBTEN)) {
> switch (regno) {
> case DBG_FTOP: /* Process the ftop */
> memcpy((char *)&current->thread.fpu.ftop, mem, reg_size);