Skip to content

Commit a362ade

Browse files
committed
Merge tag 'loongarch-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch updates from Huacai Chen: - Define __ARCH_WANT_NEW_STAT in unistd.h - Always enumerate MADT and setup logical-physical CPU mapping - Add irq_work support via self IPIs - Add RANDOMIZE_KSTACK_OFFSET support - Add ARCH_HAS_PTE_DEVMAP support - Add ARCH_HAS_DEBUG_VM_PGTABLE support - Add writecombine support for DMW-based ioremap() - Add architectural preparation for CPUFreq - Add ACPI standard hardware register based S3 support - Add support for relocating the kernel with RELR relocation - Some bug fixes and other small changes * tag 'loongarch-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: Make the users of larch_insn_gen_break() constant LoongArch: Check TIF_LOAD_WATCH to enable user space watchpoint LoongArch: Use rustc option -Zdirect-access-external-data LoongArch: Add support for relocating the kernel with RELR relocation LoongArch: Remove a redundant checking in relocator LoongArch: Use correct API to map cmdline in relocate_kernel() LoongArch: Automatically disable KASLR for hibernation LoongArch: Add ACPI standard hardware register based S3 support LoongArch: Add architectural preparation for CPUFreq LoongArch: Add writecombine support for DMW-based ioremap() LoongArch: Add ARCH_HAS_DEBUG_VM_PGTABLE support LoongArch: Add ARCH_HAS_PTE_DEVMAP support LoongArch: Add RANDOMIZE_KSTACK_OFFSET support LoongArch: Add irq_work support via self IPIs LoongArch: Always enumerate MADT and setup logical-physical CPU mapping LoongArch: Define __ARCH_WANT_NEW_STAT in unistd.h
2 parents 539fbb9 + 998b17d commit a362ade

32 files changed

+256
-51
lines changed

Documentation/features/debug/debug-vm-pgtable/arch-support.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
| arm64: | ok |
1313
| csky: | TODO |
1414
| hexagon: | TODO |
15-
| loongarch: | TODO |
15+
| loongarch: | ok |
1616
| m68k: | TODO |
1717
| microblaze: | TODO |
1818
| mips: | TODO |

arch/loongarch/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ config LOONGARCH
1616
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
1717
select ARCH_HAS_CPU_FINALIZE_INIT
1818
select ARCH_HAS_CURRENT_STACK_POINTER
19+
select ARCH_HAS_DEBUG_VM_PGTABLE
1920
select ARCH_HAS_FAST_MULTIPLIER
2021
select ARCH_HAS_FORTIFY_SOURCE
2122
select ARCH_HAS_KCOV
2223
select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU
2324
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
2425
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
26+
select ARCH_HAS_PTE_DEVMAP
2527
select ARCH_HAS_PTE_SPECIAL
2628
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
2729
select ARCH_INLINE_READ_LOCK if !PREEMPTION
@@ -106,6 +108,7 @@ config LOONGARCH
106108
select HAVE_ARCH_KFENCE
107109
select HAVE_ARCH_KGDB if PERF_EVENTS
108110
select HAVE_ARCH_MMAP_RND_BITS if MMU
111+
select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
109112
select HAVE_ARCH_SECCOMP
110113
select HAVE_ARCH_SECCOMP_FILTER
111114
select HAVE_ARCH_TRACEHOOK
@@ -607,6 +610,7 @@ config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
607610

608611
config RELOCATABLE
609612
bool "Relocatable kernel"
613+
select ARCH_HAS_RELR
610614
help
611615
This builds the kernel as a Position Independent Executable (PIE),
612616
which retains all relocation metadata required, so as to relocate
@@ -710,6 +714,7 @@ config ARCH_HIBERNATION_POSSIBLE
710714

711715
source "kernel/power/Kconfig"
712716
source "drivers/acpi/Kconfig"
717+
source "drivers/cpufreq/Kconfig"
713718

714719
endmenu
715720

arch/loongarch/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ KBUILD_CFLAGS += -fno-jump-tables
105105
endif
106106

107107
KBUILD_RUSTFLAGS += --target=loongarch64-unknown-none-softfloat
108-
KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic
108+
KBUILD_RUSTFLAGS_KERNEL += -Zdirect-access-external-data=yes
109+
KBUILD_RUSTFLAGS_MODULE += -Zdirect-access-external-data=no
109110

110111
ifeq ($(CONFIG_RELOCATABLE),y)
111112
KBUILD_CFLAGS_KERNEL += -fPIE

arch/loongarch/include/asm/addrspace.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ extern unsigned long vm_map_base;
3737
#define UNCACHE_BASE CSR_DMW0_BASE
3838
#endif
3939

40+
#ifndef WRITECOMBINE_BASE
41+
#define WRITECOMBINE_BASE CSR_DMW2_BASE
42+
#endif
43+
4044
#define DMW_PABITS 48
4145
#define TO_PHYS_MASK ((1ULL << DMW_PABITS) - 1)
4246

arch/loongarch/include/asm/asmmacro.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@
609609
lu32i.d \reg, 0
610610
lu52i.d \reg, \reg, 0
611611
.pushsection ".la_abs", "aw", %progbits
612+
.p2align 3
612613
.dword 766b
613614
.dword \sym
614615
.popsection

arch/loongarch/include/asm/hardirq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
extern void ack_bad_irq(unsigned int irq);
1313
#define ack_bad_irq ack_bad_irq
1414

15-
#define NR_IPI 2
15+
#define NR_IPI 3
1616

1717
enum ipi_msg_type {
1818
IPI_RESCHEDULE,
1919
IPI_CALL_FUNCTION,
20+
IPI_IRQ_WORK,
2021
};
2122

2223
typedef struct {

arch/loongarch/include/asm/inst.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,9 @@ static inline void emit_##NAME(union loongarch_instruction *insn, \
532532

533533
DEF_EMIT_REG0I15_FORMAT(break, break_op)
534534

535+
/* like emit_break(imm) but returns a constant expression */
536+
#define __emit_break(imm) ((u32)((imm) | (break_op << 15)))
537+
535538
#define DEF_EMIT_REG0I26_FORMAT(NAME, OP) \
536539
static inline void emit_##NAME(union loongarch_instruction *insn, \
537540
int offset) \

arch/loongarch/include/asm/io.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ extern void __init early_iounmap(void __iomem *addr, unsigned long size);
2525
static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
2626
unsigned long prot_val)
2727
{
28-
if (prot_val & _CACHE_CC)
28+
switch (prot_val & _CACHE_MASK) {
29+
case _CACHE_CC:
2930
return (void __iomem *)(unsigned long)(CACHE_BASE + offset);
30-
else
31+
case _CACHE_SUC:
3132
return (void __iomem *)(unsigned long)(UNCACHE_BASE + offset);
33+
case _CACHE_WUC:
34+
return (void __iomem *)(unsigned long)(WRITECOMBINE_BASE + offset);
35+
default:
36+
return NULL;
37+
}
3238
}
3339

3440
#define ioremap(offset, size) \

arch/loongarch/include/asm/irq_work.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_LOONGARCH_IRQ_WORK_H
3+
#define _ASM_LOONGARCH_IRQ_WORK_H
4+
5+
static inline bool arch_irq_work_has_interrupt(void)
6+
{
7+
return IS_ENABLED(CONFIG_SMP);
8+
}
9+
10+
#endif /* _ASM_LOONGARCH_IRQ_WORK_H */

arch/loongarch/include/asm/loongarch.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@
878878
#define LOONGARCH_CSR_DMWIN2 0x182 /* 64 direct map win2: MEM */
879879
#define LOONGARCH_CSR_DMWIN3 0x183 /* 64 direct map win3: MEM */
880880

881-
/* Direct Map window 0/1 */
881+
/* Direct Map window 0/1/2/3 */
882882
#define CSR_DMW0_PLV0 _CONST64_(1 << 0)
883883
#define CSR_DMW0_VSEG _CONST64_(0x8000)
884884
#define CSR_DMW0_BASE (CSR_DMW0_VSEG << DMW_PABITS)
@@ -890,6 +890,14 @@
890890
#define CSR_DMW1_BASE (CSR_DMW1_VSEG << DMW_PABITS)
891891
#define CSR_DMW1_INIT (CSR_DMW1_BASE | CSR_DMW1_MAT | CSR_DMW1_PLV0)
892892

893+
#define CSR_DMW2_PLV0 _CONST64_(1 << 0)
894+
#define CSR_DMW2_MAT _CONST64_(2 << 4)
895+
#define CSR_DMW2_VSEG _CONST64_(0xa000)
896+
#define CSR_DMW2_BASE (CSR_DMW2_VSEG << DMW_PABITS)
897+
#define CSR_DMW2_INIT (CSR_DMW2_BASE | CSR_DMW2_MAT | CSR_DMW2_PLV0)
898+
899+
#define CSR_DMW3_INIT 0x0
900+
893901
/* Performance Counter registers */
894902
#define LOONGARCH_CSR_PERFCTRL0 0x200 /* 32 perf event 0 config */
895903
#define LOONGARCH_CSR_PERFCNTR0 0x201 /* 64 perf event 0 count value */
@@ -1054,11 +1062,14 @@
10541062
#define LOONGARCH_IOCSR_NODECNT 0x408
10551063

10561064
#define LOONGARCH_IOCSR_MISC_FUNC 0x420
1065+
#define IOCSR_MISC_FUNC_SOFT_INT BIT_ULL(10)
10571066
#define IOCSR_MISC_FUNC_TIMER_RESET BIT_ULL(21)
10581067
#define IOCSR_MISC_FUNC_EXT_IOI_EN BIT_ULL(48)
10591068

10601069
#define LOONGARCH_IOCSR_CPUTEMP 0x428
10611070

1071+
#define LOONGARCH_IOCSR_SMCMBX 0x51c
1072+
10621073
/* PerCore CSR, only accessible by local cores */
10631074
#define LOONGARCH_IOCSR_IPI_STATUS 0x1000
10641075
#define LOONGARCH_IOCSR_IPI_EN 0x1004

0 commit comments

Comments
 (0)