Skip to content

Commit 948752d

Browse files
committed
Merge tag 'riscv-for-linus-6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - A fix to avoid dropping some of the internal pseudo-extensions, which breaks *envcfg dependency parsing - The kernel entry address is now aligned in purgatory, which avoids a misaligned load that can lead to crash on systems that don't support misaligned accesses early in boot - The FW_SFENCE_VMA_RECEIVED perf event was duplicated in a handful of perf JSON configurations, one of them been updated to FW_SFENCE_VMA_ASID_SENT - The starfive cache driver is now restricted to 64-bit systems, as it isn't 32-bit clean - A fix for to avoid aliasing legacy-mode perf counters with software perf counters - VM_FAULT_SIGSEGV is now handled in the page fault code - A fix for stalls during CPU hotplug due to IPIs being disabled - A fix for memblock bounds checking. This manifests as a crash on systems with discontinuous memory maps that have regions that don't fit in the linear map * tag 'riscv-for-linus-6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Fix linear mapping checks for non-contiguous memory regions RISC-V: Enable the IPI before workqueue_online_cpu() riscv/mm: Add handling for VM_FAULT_SIGSEGV in mm_fault_error() perf: riscv: Fix selecting counters in legacy mode cache: StarFive: Require a 64-bit system perf arch events: Fix duplicate RISC-V SBI firmware event name riscv/purgatory: align riscv_kernel_entry riscv: cpufeature: Do not drop Linux-internal extensions
2 parents 66242ef + 3b65644 commit 948752d

File tree

13 files changed

+37
-27
lines changed

13 files changed

+37
-27
lines changed

arch/riscv/kernel/cpufeature.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,28 +432,26 @@ static void __init riscv_resolve_isa(unsigned long *source_isa,
432432
bitmap_copy(prev_resolved_isa, resolved_isa, RISCV_ISA_EXT_MAX);
433433
for_each_set_bit(bit, source_isa, RISCV_ISA_EXT_MAX) {
434434
ext = riscv_get_isa_ext_data(bit);
435-
if (!ext)
436-
continue;
437435

438-
if (ext->validate) {
436+
if (ext && ext->validate) {
439437
ret = ext->validate(ext, resolved_isa);
440438
if (ret == -EPROBE_DEFER) {
441439
loop = true;
442440
continue;
443441
} else if (ret) {
444442
/* Disable the extension entirely */
445-
clear_bit(ext->id, source_isa);
443+
clear_bit(bit, source_isa);
446444
continue;
447445
}
448446
}
449447

450-
set_bit(ext->id, resolved_isa);
448+
set_bit(bit, resolved_isa);
451449
/* No need to keep it in source isa now that it is enabled */
452-
clear_bit(ext->id, source_isa);
450+
clear_bit(bit, source_isa);
453451

454452
/* Single letter extensions get set in hwcap */
455-
if (ext->id < RISCV_ISA_EXT_BASE)
456-
*this_hwcap |= isa2hwcap[ext->id];
453+
if (bit < RISCV_ISA_EXT_BASE)
454+
*this_hwcap |= isa2hwcap[bit];
457455
}
458456
} while (loop && memcmp(prev_resolved_isa, resolved_isa, sizeof(prev_resolved_isa)));
459457
}

arch/riscv/kernel/sbi-ipi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void __init sbi_ipi_init(void)
7171
* the masking/unmasking of virtual IPIs is done
7272
* via generic IPI-Mux
7373
*/
74-
cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
74+
cpuhp_setup_state(CPUHP_AP_IRQ_RISCV_SBI_IPI_STARTING,
7575
"irqchip/sbi-ipi:starting",
7676
sbi_ipi_starting_cpu, NULL);
7777

arch/riscv/mm/fault.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,27 @@ static inline void no_context(struct pt_regs *regs, unsigned long addr)
6161

6262
static inline void mm_fault_error(struct pt_regs *regs, unsigned long addr, vm_fault_t fault)
6363
{
64+
if (!user_mode(regs)) {
65+
no_context(regs, addr);
66+
return;
67+
}
68+
6469
if (fault & VM_FAULT_OOM) {
6570
/*
6671
* We ran out of memory, call the OOM killer, and return the userspace
6772
* (which will retry the fault, or kill us if we got oom-killed).
6873
*/
69-
if (!user_mode(regs)) {
70-
no_context(regs, addr);
71-
return;
72-
}
7374
pagefault_out_of_memory();
7475
return;
7576
} else if (fault & (VM_FAULT_SIGBUS | VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) {
7677
/* Kernel mode? Handle exceptions or die */
77-
if (!user_mode(regs)) {
78-
no_context(regs, addr);
79-
return;
80-
}
8178
do_trap(regs, SIGBUS, BUS_ADRERR, addr);
8279
return;
80+
} else if (fault & VM_FAULT_SIGSEGV) {
81+
do_trap(regs, SIGSEGV, SEGV_MAPERR, addr);
82+
return;
8383
}
84+
8485
BUG();
8586
}
8687

arch/riscv/mm/init.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ static void __init setup_bootmem(void)
234234
*/
235235
memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
236236

237-
phys_ram_end = memblock_end_of_DRAM();
238-
239237
/*
240238
* Make sure we align the start of the memory on a PMD boundary so that
241239
* at worst, we map the linear mapping with PMD mappings.
@@ -250,6 +248,16 @@ static void __init setup_bootmem(void)
250248
if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU))
251249
kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base;
252250

251+
/*
252+
* The size of the linear page mapping may restrict the amount of
253+
* usable RAM.
254+
*/
255+
if (IS_ENABLED(CONFIG_64BIT)) {
256+
max_mapped_addr = __pa(PAGE_OFFSET) + KERN_VIRT_SIZE;
257+
memblock_cap_memory_range(phys_ram_base,
258+
max_mapped_addr - phys_ram_base);
259+
}
260+
253261
/*
254262
* Reserve physical address space that would be mapped to virtual
255263
* addresses greater than (void *)(-PAGE_SIZE) because:
@@ -266,6 +274,7 @@ static void __init setup_bootmem(void)
266274
memblock_reserve(max_mapped_addr, (phys_addr_t)-max_mapped_addr);
267275
}
268276

277+
phys_ram_end = memblock_end_of_DRAM();
269278
min_low_pfn = PFN_UP(phys_ram_base);
270279
max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end);
271280
high_memory = (void *)(__va(PFN_PHYS(max_low_pfn)));
@@ -1284,8 +1293,6 @@ static void __init create_linear_mapping_page_table(void)
12841293
if (start <= __pa(PAGE_OFFSET) &&
12851294
__pa(PAGE_OFFSET) < end)
12861295
start = __pa(PAGE_OFFSET);
1287-
if (end >= __pa(PAGE_OFFSET) + memory_limit)
1288-
end = __pa(PAGE_OFFSET) + memory_limit;
12891296

12901297
create_linear_mapping_range(start, end, 0, NULL);
12911298
}

arch/riscv/purgatory/entry.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Author: Li Zhengyu ([email protected])
88
*
99
*/
10+
#include <asm/asm.h>
1011
#include <linux/linkage.h>
1112

1213
.text
@@ -34,6 +35,7 @@ SYM_CODE_END(purgatory_start)
3435

3536
.data
3637

38+
.align LGREG
3739
SYM_DATA(riscv_kernel_entry, .quad 0)
3840

3941
.end

drivers/cache/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ config STARFIVE_STARLINK_CACHE
1818
bool "StarFive StarLink Cache controller"
1919
depends on RISCV
2020
depends on ARCH_STARFIVE
21+
depends on 64BIT
2122
select RISCV_DMA_NONCOHERENT
2223
select RISCV_NONSTANDARD_CACHE_OPS
2324
help

drivers/perf/riscv_pmu_sbi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event)
416416
* but not in the user access mode as we want to use the other counters
417417
* that support sampling/filtering.
418418
*/
419-
if (hwc->flags & PERF_EVENT_FLAG_LEGACY) {
419+
if ((hwc->flags & PERF_EVENT_FLAG_LEGACY) && (event->attr.type == PERF_TYPE_HARDWARE)) {
420420
if (event->attr.config == PERF_COUNT_HW_CPU_CYCLES) {
421421
cflags |= SBI_PMU_CFG_FLAG_SKIP_MATCH;
422422
cmask = 1;

include/linux/cpuhotplug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ enum cpuhp_state {
147147
CPUHP_AP_IRQ_LOONGARCH_STARTING,
148148
CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING,
149149
CPUHP_AP_IRQ_RISCV_IMSIC_STARTING,
150+
CPUHP_AP_IRQ_RISCV_SBI_IPI_STARTING,
150151
CPUHP_AP_ARM_MVEBU_COHERENCY,
151152
CPUHP_AP_PERF_X86_AMD_UNCORE_STARTING,
152153
CPUHP_AP_PERF_X86_STARTING,

tools/perf/pmu-events/arch/riscv/andes/ax45/firmware.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"ArchStdEvent": "FW_SFENCE_VMA_RECEIVED"
3737
},
3838
{
39-
"ArchStdEvent": "FW_SFENCE_VMA_RECEIVED"
39+
"ArchStdEvent": "FW_SFENCE_VMA_ASID_SENT"
4040
},
4141
{
4242
"ArchStdEvent": "FW_SFENCE_VMA_ASID_RECEIVED"

tools/perf/pmu-events/arch/riscv/riscv-sbi-firmware.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
{
7575
"PublicDescription": "Sent SFENCE.VMA with ASID request to other HART event",
7676
"ConfigCode": "0x800000000000000c",
77-
"EventName": "FW_SFENCE_VMA_RECEIVED",
77+
"EventName": "FW_SFENCE_VMA_ASID_SENT",
7878
"BriefDescription": "Sent SFENCE.VMA with ASID request to other HART event"
7979
},
8080
{

0 commit comments

Comments
 (0)