[PATCH] LoongArch: Expose LBT features in cpuinfo and ELF HWCAP

From: WANG Xuerui
Date: Wed Oct 12 2022 - 07:14:01 EST


From: WANG Xuerui <git@xxxxxxxxxx>

Although proper context switching support for LBT is not present yet,
this fixes an apparent oversight where other similarly not-yet-supported
features e.g. LSX, LASX, Crypto, or LVZ are being reported but the LBT
ones are not.

Fixes: 628c3bb40e9a ("LoongArch: Add boot and setup routines")
Signed-off-by: WANG Xuerui <git@xxxxxxxxxx>
Cc: loongarch@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
arch/loongarch/kernel/cpu-probe.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/arch/loongarch/kernel/cpu-probe.c b/arch/loongarch/kernel/cpu-probe.c
index 529ab8f44ec6..82de5264d2c9 100644
--- a/arch/loongarch/kernel/cpu-probe.c
+++ b/arch/loongarch/kernel/cpu-probe.c
@@ -123,6 +123,18 @@ static void cpu_probe_common(struct cpuinfo_loongarch *c)
c->options |= LOONGARCH_CPU_LVZ;
elf_hwcap |= HWCAP_LOONGARCH_LVZ;
}
+ if (config & CPUCFG2_X86BT) {
+ c->options |= LOONGARCH_CPU_LBT_X86;
+ elf_hwcap |= HWCAP_LOONGARCH_LBT_X86;
+ }
+ if (config & CPUCFG2_ARMBT) {
+ c->options |= LOONGARCH_CPU_LBT_ARM;
+ elf_hwcap |= HWCAP_LOONGARCH_LBT_ARM;
+ }
+ if (config & CPUCFG2_MIPSBT) {
+ c->options |= LOONGARCH_CPU_LBT_MIPS;
+ elf_hwcap |= HWCAP_LOONGARCH_LBT_MIPS;
+ }

config = read_cpucfg(LOONGARCH_CPUCFG6);
if (config & CPUCFG6_PMP)
--
2.38.0