Skip to contentSkip to conversation

Loongarch: KGDB: fix build when CPU_HAS_LBT not set

PATCH In review Randy Dunlap 2 participants 2 messages Aug 29, 2023 LoongArch

lore
Share & tools
lore
#0 lore raw

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

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")
Cc Qing Zhang <[email protected]>
Cc Hui Li <[email protected]>
Cc Binbin Zhou <[email protected]>
Cc Huacai Chen <[email protected]>
Cc WANG Xuerui <[email protected]>
---
 arch/loongarch/kernel/kgdb.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/loongarch/kernel/kgdb.c +4 -2
diff -- 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);
maintainer
#1 lore raw

Hi, Randy,

Quoted 7 lines · Randy Dunlap

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

Quoted 36 lines
Fixes 8968eb010689 ("LoongArch: Add basic KGDB & KDB support")
Cc Qing Zhang <[email protected]>
Cc Hui Li <[email protected]>
Cc Binbin Zhou <[email protected]>
Cc Huacai Chen <[email protected]>
Cc WANG Xuerui <[email protected]>
---
 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

arch/loongarch/kernel/kgdb.c +4 -2
@@ -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);