[PATCH 2/2] Loongarch: KGDB: fix build when CPU_HAS_LBT not set
From: Randy Dunlap
Date: Mon Aug 28 2023 - 20:25:39 EST
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'
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(¤t->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 *)¤t->thread.fpu.ftop, mem, reg_size);