Skip to content

Commit 2eba5e0

Browse files
committed
Merge tag 'loongarch-fixes-6.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai Chen: "Use UAPI types in ptrace UAPI header to fix nolibc ptrace. Fix CPU name display, NUMA node parsing, kexec/kdump, PCI init and BPF trampoline" * tag 'loongarch-fixes-6.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: BPF: Disable trampoline for kernel module function trace LoongArch: Don't panic if no valid cache info for PCI LoongArch: Mask all interrupts during kexec/kdump LoongArch: Fix NUMA node parsing with numa_memblks LoongArch: Consolidate CPU names in /proc/cpuinfo LoongArch: Use UAPI types in ptrace UAPI header
2 parents e3fe48f + 677e612 commit 2eba5e0

File tree

8 files changed

+79
-91
lines changed

8 files changed

+79
-91
lines changed

arch/loongarch/include/asm/cpu.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@ enum cpu_type_enum {
5555
CPU_LAST
5656
};
5757

58+
static inline char *id_to_core_name(unsigned int id)
59+
{
60+
if ((id & PRID_COMP_MASK) != PRID_COMP_LOONGSON)
61+
return "Unknown";
62+
63+
switch (id & PRID_SERIES_MASK) {
64+
case PRID_SERIES_LA132:
65+
return "LA132";
66+
case PRID_SERIES_LA264:
67+
return "LA264";
68+
case PRID_SERIES_LA364:
69+
return "LA364";
70+
case PRID_SERIES_LA464:
71+
return "LA464";
72+
case PRID_SERIES_LA664:
73+
return "LA664";
74+
default:
75+
return "Unknown";
76+
}
77+
}
78+
5879
#endif /* !__ASSEMBLER__ */
5980

6081
/*

arch/loongarch/include/uapi/asm/ptrace.h

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
#include <linux/types.h>
1212

13-
#ifndef __KERNEL__
14-
#include <stdint.h>
15-
#endif
16-
1713
/*
1814
* For PTRACE_{POKE,PEEK}USR. 0 - 31 are GPRs,
1915
* 32 is syscall's original ARG0, 33 is PC, 34 is BADVADDR.
@@ -41,44 +37,44 @@ struct user_pt_regs {
4137
} __attribute__((aligned(8)));
4238

4339
struct user_fp_state {
44-
uint64_t fpr[32];
45-
uint64_t fcc;
46-
uint32_t fcsr;
40+
__u64 fpr[32];
41+
__u64 fcc;
42+
__u32 fcsr;
4743
};
4844

4945
struct user_lsx_state {
5046
/* 32 registers, 128 bits width per register. */
51-
uint64_t vregs[32*2];
47+
__u64 vregs[32*2];
5248
};
5349

5450
struct user_lasx_state {
5551
/* 32 registers, 256 bits width per register. */
56-
uint64_t vregs[32*4];
52+
__u64 vregs[32*4];
5753
};
5854

5955
struct user_lbt_state {
60-
uint64_t scr[4];
61-
uint32_t eflags;
62-
uint32_t ftop;
56+
__u64 scr[4];
57+
__u32 eflags;
58+
__u32 ftop;
6359
};
6460

6561
struct user_watch_state {
66-
uint64_t dbg_info;
62+
__u64 dbg_info;
6763
struct {
68-
uint64_t addr;
69-
uint64_t mask;
70-
uint32_t ctrl;
71-
uint32_t pad;
64+
__u64 addr;
65+
__u64 mask;
66+
__u32 ctrl;
67+
__u32 pad;
7268
} dbg_regs[8];
7369
};
7470

7571
struct user_watch_state_v2 {
76-
uint64_t dbg_info;
72+
__u64 dbg_info;
7773
struct {
78-
uint64_t addr;
79-
uint64_t mask;
80-
uint32_t ctrl;
81-
uint32_t pad;
74+
__u64 addr;
75+
__u64 mask;
76+
__u32 ctrl;
77+
__u32 pad;
8278
} dbg_regs[14];
8379
};
8480

arch/loongarch/kernel/cpu-probe.c

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static inline void cpu_probe_loongson(struct cpuinfo_loongarch *c, unsigned int
277277
uint32_t config;
278278
uint64_t *vendor = (void *)(&cpu_full_name[VENDOR_OFFSET]);
279279
uint64_t *cpuname = (void *)(&cpu_full_name[CPUNAME_OFFSET]);
280-
const char *core_name = "Unknown";
280+
const char *core_name = id_to_core_name(c->processor_id);
281281

282282
switch (BIT(fls(c->isa_level) - 1)) {
283283
case LOONGARCH_CPU_ISA_LA32R:
@@ -291,35 +291,23 @@ static inline void cpu_probe_loongson(struct cpuinfo_loongarch *c, unsigned int
291291
break;
292292
}
293293

294-
switch (c->processor_id & PRID_SERIES_MASK) {
295-
case PRID_SERIES_LA132:
296-
core_name = "LA132";
297-
break;
298-
case PRID_SERIES_LA264:
299-
core_name = "LA264";
300-
break;
301-
case PRID_SERIES_LA364:
302-
core_name = "LA364";
303-
break;
304-
case PRID_SERIES_LA464:
305-
core_name = "LA464";
306-
break;
307-
case PRID_SERIES_LA664:
308-
core_name = "LA664";
309-
break;
310-
}
311-
312294
pr_info("%s Processor probed (%s Core)\n", __cpu_family[cpu], core_name);
313295

314-
if (!cpu_has_iocsr)
296+
if (!cpu_has_iocsr) {
297+
__cpu_full_name[cpu] = "Unknown";
315298
return;
316-
317-
if (!__cpu_full_name[cpu])
318-
__cpu_full_name[cpu] = cpu_full_name;
299+
}
319300

320301
*vendor = iocsr_read64(LOONGARCH_IOCSR_VENDOR);
321302
*cpuname = iocsr_read64(LOONGARCH_IOCSR_CPUNAME);
322303

304+
if (!__cpu_full_name[cpu]) {
305+
if (((char *)vendor)[0] == 0)
306+
__cpu_full_name[cpu] = "Unknown";
307+
else
308+
__cpu_full_name[cpu] = cpu_full_name;
309+
}
310+
323311
config = iocsr_read32(LOONGARCH_IOCSR_FEATURES);
324312
if (config & IOCSRF_CSRIPI)
325313
c->options |= LOONGARCH_CPU_CSRIPI;

arch/loongarch/kernel/machine_kexec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ void machine_crash_shutdown(struct pt_regs *regs)
237237
#ifdef CONFIG_SMP
238238
crash_smp_send_stop();
239239
#endif
240+
machine_kexec_mask_interrupts();
240241
cpumask_set_cpu(crashing_cpu, &cpus_in_crash);
241242

242243
pr_info("Starting crashdump kernel...\n");
@@ -274,6 +275,7 @@ void machine_kexec(struct kimage *image)
274275

275276
/* We do not want to be bothered. */
276277
local_irq_disable();
278+
machine_kexec_mask_interrupts();
277279

278280
pr_notice("EFI boot flag: 0x%lx\n", efi_boot);
279281
pr_notice("Command line addr: 0x%lx\n", cmdline_ptr);

arch/loongarch/kernel/numa.c

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -158,35 +158,9 @@ static void __init node_mem_init(unsigned int node)
158158

159159
#ifdef CONFIG_ACPI_NUMA
160160

161-
/*
162-
* add_numamem_region
163-
*
164-
* Add a uasable memory region described by BIOS. The
165-
* routine gets each intersection between BIOS's region
166-
* and node's region, and adds them into node's memblock
167-
* pool.
168-
*
169-
*/
170-
static void __init add_numamem_region(u64 start, u64 end, u32 type)
171-
{
172-
u32 node = pa_to_nid(start);
173-
u64 size = end - start;
174-
static unsigned long num_physpages;
175-
176-
if (start >= end) {
177-
pr_debug("Invalid region: %016llx-%016llx\n", start, end);
178-
return;
179-
}
161+
static unsigned long num_physpages;
180162

181-
num_physpages += (size >> PAGE_SHIFT);
182-
pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n",
183-
node, type, start, size);
184-
pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
185-
start >> PAGE_SHIFT, end >> PAGE_SHIFT, num_physpages);
186-
memblock_set_node(start, size, &memblock.memory, node);
187-
}
188-
189-
static void __init init_node_memblock(void)
163+
static void __init info_node_memblock(void)
190164
{
191165
u32 mem_type;
192166
u64 mem_end, mem_start, mem_size;
@@ -206,12 +180,20 @@ static void __init init_node_memblock(void)
206180
case EFI_BOOT_SERVICES_DATA:
207181
case EFI_PERSISTENT_MEMORY:
208182
case EFI_CONVENTIONAL_MEMORY:
209-
add_numamem_region(mem_start, mem_end, mem_type);
183+
num_physpages += (mem_size >> PAGE_SHIFT);
184+
pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n",
185+
(u32)pa_to_nid(mem_start), mem_type, mem_start, mem_size);
186+
pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
187+
mem_start >> PAGE_SHIFT, mem_end >> PAGE_SHIFT, num_physpages);
210188
break;
211189
case EFI_PAL_CODE:
212190
case EFI_UNUSABLE_MEMORY:
213191
case EFI_ACPI_RECLAIM_MEMORY:
214-
add_numamem_region(mem_start, mem_end, mem_type);
192+
num_physpages += (mem_size >> PAGE_SHIFT);
193+
pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n",
194+
(u32)pa_to_nid(mem_start), mem_type, mem_start, mem_size);
195+
pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
196+
mem_start >> PAGE_SHIFT, mem_end >> PAGE_SHIFT, num_physpages);
215197
fallthrough;
216198
case EFI_RESERVED_TYPE:
217199
case EFI_RUNTIME_SERVICES_CODE:
@@ -249,22 +231,16 @@ int __init init_numa_memory(void)
249231
for (i = 0; i < NR_CPUS; i++)
250232
set_cpuid_to_node(i, NUMA_NO_NODE);
251233

252-
numa_reset_distance();
253-
nodes_clear(numa_nodes_parsed);
254-
nodes_clear(node_possible_map);
255-
nodes_clear(node_online_map);
256-
WARN_ON(memblock_clear_hotplug(0, PHYS_ADDR_MAX));
257-
258234
/* Parse SRAT and SLIT if provided by firmware. */
259-
ret = acpi_disabled ? fake_numa_init() : acpi_numa_init();
235+
if (!acpi_disabled)
236+
ret = numa_memblks_init(acpi_numa_init, false);
237+
else
238+
ret = numa_memblks_init(fake_numa_init, false);
239+
260240
if (ret < 0)
261241
return ret;
262242

263-
node_possible_map = numa_nodes_parsed;
264-
if (WARN_ON(nodes_empty(node_possible_map)))
265-
return -EINVAL;
266-
267-
init_node_memblock();
243+
info_node_memblock();
268244
if (!memblock_validate_numa_coverage(SZ_1M))
269245
return -EINVAL;
270246

arch/loongarch/kernel/proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1717
{
1818
unsigned long n = (unsigned long) v - 1;
1919
unsigned int isa = cpu_data[n].isa_level;
20+
unsigned int prid = cpu_data[n].processor_id;
2021
unsigned int version = cpu_data[n].processor_id & 0xff;
2122
unsigned int fp_version = cpu_data[n].fpu_vers;
2223

@@ -37,6 +38,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
3738
seq_printf(m, "global_id\t\t: %d\n", cpu_data[n].global_id);
3839
seq_printf(m, "CPU Family\t\t: %s\n", __cpu_family[n]);
3940
seq_printf(m, "Model Name\t\t: %s\n", __cpu_full_name[n]);
41+
seq_printf(m, "PRID\t\t\t: %s (%08x)\n", id_to_core_name(prid), prid);
4042
seq_printf(m, "CPU Revision\t\t: 0x%02x\n", version);
4143
seq_printf(m, "FPU Revision\t\t: 0x%02x\n", fp_version);
4244
seq_printf(m, "CPU MHz\t\t\t: %llu.%02llu\n",

arch/loongarch/net/bpf_jit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,9 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i
16241624
/* Direct jump skips 5 NOP instructions */
16251625
else if (is_bpf_text_address((unsigned long)orig_call))
16261626
orig_call += LOONGARCH_BPF_FENTRY_NBYTES;
1627+
/* Module tracing not supported - cause kernel lockups */
1628+
else if (is_module_text_address((unsigned long)orig_call))
1629+
return -ENOTSUPP;
16271630

16281631
if (flags & BPF_TRAMP_F_CALL_ORIG) {
16291632
move_addr(ctx, LOONGARCH_GPR_A0, (const u64)im);

arch/loongarch/pci/pci.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ static int __init pcibios_init(void)
5050
*/
5151
lsize = cpu_last_level_cache_line_size();
5252

53-
BUG_ON(!lsize);
53+
if (lsize) {
54+
pci_dfl_cache_line_size = lsize >> 2;
5455

55-
pci_dfl_cache_line_size = lsize >> 2;
56-
57-
pr_debug("PCI: pci_cache_line_size set to %d bytes\n", lsize);
56+
pr_debug("PCI: pci_cache_line_size set to %d bytes\n", lsize);
57+
}
5858

5959
return 0;
6060
}

0 commit comments

Comments
 (0)