Commit c3137613 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'loongarch-fixes-6.5-2' of...

Merge tag 'loongarch-fixes-6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson

Pull LoongArch fixes from Huacai Chen:
 "Fix a ptrace bug, a hw_breakpoint bug, some build errors/warnings and
  some trivial cleanups"

* tag 'loongarch-fixes-6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
  LoongArch: Fix hw_breakpoint_control() for watchpoints
  LoongArch: Ensure FP/SIMD registers in the core dump file is up to date
  LoongArch: Put the body of play_dead() into arch_cpu_idle_dead()
  LoongArch: Add identifier names to arguments of die() declaration
  LoongArch: Return earlier in die() if notify_die() returns NOTIFY_STOP
  LoongArch: Do not kill the task in die() if notify_die() returns NOTIFY_STOP
  LoongArch: Remove <asm/export.h>
  LoongArch: Replace #include <asm/export.h> with #include <linux/export.h>
  LoongArch: Remove unneeded #include <asm/export.h>
  LoongArch: Replace -ffreestanding with finer-grained -fno-builtin's
  LoongArch: Remove redundant "source drivers/firmware/Kconfig"
parents 7d2f353b 9730870b
...@@ -662,5 +662,3 @@ source "kernel/power/Kconfig" ...@@ -662,5 +662,3 @@ source "kernel/power/Kconfig"
source "drivers/acpi/Kconfig" source "drivers/acpi/Kconfig"
endmenu endmenu
source "drivers/firmware/Kconfig"
...@@ -83,8 +83,8 @@ KBUILD_CFLAGS_KERNEL += -fPIE ...@@ -83,8 +83,8 @@ KBUILD_CFLAGS_KERNEL += -fPIE
LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext
endif endif
cflags-y += -ffreestanding
cflags-y += $(call cc-option, -mno-check-zero-division) cflags-y += $(call cc-option, -mno-check-zero-division)
cflags-y += -fno-builtin-memcpy -fno-builtin-memmove -fno-builtin-memset
load-y = 0x9000000000200000 load-y = 0x9000000000200000
bootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) bootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y)
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
generic-y += dma-contiguous.h generic-y += dma-contiguous.h
generic-y += export.h
generic-y += mcs_spinlock.h generic-y += mcs_spinlock.h
generic-y += parport.h generic-y += parport.h
generic-y += early_ioremap.h generic-y += early_ioremap.h
......
...@@ -173,16 +173,30 @@ static inline void restore_fp(struct task_struct *tsk) ...@@ -173,16 +173,30 @@ static inline void restore_fp(struct task_struct *tsk)
_restore_fp(&tsk->thread.fpu); _restore_fp(&tsk->thread.fpu);
} }
static inline union fpureg *get_fpu_regs(struct task_struct *tsk) static inline void save_fpu_regs(struct task_struct *tsk)
{ {
unsigned int euen;
if (tsk == current) { if (tsk == current) {
preempt_disable(); preempt_disable();
if (is_fpu_owner())
euen = csr_read32(LOONGARCH_CSR_EUEN);
#ifdef CONFIG_CPU_HAS_LASX
if (euen & CSR_EUEN_LASXEN)
_save_lasx(&current->thread.fpu);
else
#endif
#ifdef CONFIG_CPU_HAS_LSX
if (euen & CSR_EUEN_LSXEN)
_save_lsx(&current->thread.fpu);
else
#endif
if (euen & CSR_EUEN_FPEN)
_save_fp(&current->thread.fpu); _save_fp(&current->thread.fpu);
preempt_enable(); preempt_enable();
} }
return tsk->thread.fpu.fpr;
} }
static inline int is_simd_owner(void) static inline int is_simd_owner(void)
......
...@@ -162,7 +162,7 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long val ...@@ -162,7 +162,7 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long val
#define instruction_pointer(regs) ((regs)->csr_era) #define instruction_pointer(regs) ((regs)->csr_era)
#define profile_pc(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs)
extern void die(const char *, struct pt_regs *) __noreturn; extern void die(const char *str, struct pt_regs *regs);
static inline void die_if_kernel(const char *str, struct pt_regs *regs) static inline void die_if_kernel(const char *str, struct pt_regs *regs)
{ {
......
...@@ -98,8 +98,6 @@ static inline void __cpu_die(unsigned int cpu) ...@@ -98,8 +98,6 @@ static inline void __cpu_die(unsigned int cpu)
{ {
loongson_cpu_die(cpu); loongson_cpu_die(cpu);
} }
extern void __noreturn play_dead(void);
#endif #endif
#endif /* __ASM_SMP_H */ #endif /* __ASM_SMP_H */
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
* *
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <linux/export.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/asm-extable.h> #include <asm/asm-extable.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <asm/export.h>
#include <asm/fpregdef.h> #include <asm/fpregdef.h>
#include <asm/loongarch.h> #include <asm/loongarch.h>
#include <asm/regdef.h> #include <asm/regdef.h>
......
...@@ -207,8 +207,7 @@ static int hw_breakpoint_control(struct perf_event *bp, ...@@ -207,8 +207,7 @@ static int hw_breakpoint_control(struct perf_event *bp,
write_wb_reg(CSR_CFG_CTRL, i, 0, CTRL_PLV_ENABLE); write_wb_reg(CSR_CFG_CTRL, i, 0, CTRL_PLV_ENABLE);
} else { } else {
ctrl = encode_ctrl_reg(info->ctrl); ctrl = encode_ctrl_reg(info->ctrl);
write_wb_reg(CSR_CFG_CTRL, i, 1, ctrl | CTRL_PLV_ENABLE | write_wb_reg(CSR_CFG_CTRL, i, 1, ctrl | CTRL_PLV_ENABLE);
1 << MWPnCFG3_LoadEn | 1 << MWPnCFG3_StoreEn);
} }
enable = csr_read64(LOONGARCH_CSR_CRMD); enable = csr_read64(LOONGARCH_CSR_CRMD);
csr_write64(CSR_CRMD_WE | enable, LOONGARCH_CSR_CRMD); csr_write64(CSR_CRMD_WE | enable, LOONGARCH_CSR_CRMD);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Copyright (C) 2022 Loongson Technology Corporation Limited * Copyright (C) 2022 Loongson Technology Corporation Limited
*/ */
#include <asm/export.h> #include <linux/export.h>
#include <asm/ftrace.h> #include <asm/ftrace.h>
#include <asm/regdef.h> #include <asm/regdef.h>
#include <asm/stackframe.h> #include <asm/stackframe.h>
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* Copyright (C) 2022 Loongson Technology Corporation Limited * Copyright (C) 2022 Loongson Technology Corporation Limited
*/ */
#include <asm/export.h>
#include <asm/ftrace.h> #include <asm/ftrace.h>
#include <asm/regdef.h> #include <asm/regdef.h>
#include <asm/stackframe.h> #include <asm/stackframe.h>
......
...@@ -61,13 +61,6 @@ EXPORT_SYMBOL(__stack_chk_guard); ...@@ -61,13 +61,6 @@ EXPORT_SYMBOL(__stack_chk_guard);
unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE; unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
EXPORT_SYMBOL(boot_option_idle_override); EXPORT_SYMBOL(boot_option_idle_override);
#ifdef CONFIG_HOTPLUG_CPU
void __noreturn arch_cpu_idle_dead(void)
{
play_dead();
}
#endif
asmlinkage void ret_from_fork(void); asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void); asmlinkage void ret_from_kernel_thread(void);
......
...@@ -147,6 +147,8 @@ static int fpr_get(struct task_struct *target, ...@@ -147,6 +147,8 @@ static int fpr_get(struct task_struct *target,
{ {
int r; int r;
save_fpu_regs(target);
if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t)) if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))
r = gfpr_get(target, &to); r = gfpr_get(target, &to);
else else
...@@ -278,6 +280,8 @@ static int simd_get(struct task_struct *target, ...@@ -278,6 +280,8 @@ static int simd_get(struct task_struct *target,
{ {
const unsigned int wr_size = NUM_FPU_REGS * regset->size; const unsigned int wr_size = NUM_FPU_REGS * regset->size;
save_fpu_regs(target);
if (!tsk_used_math(target)) { if (!tsk_used_math(target)) {
/* The task hasn't used FP or LSX, fill with 0xff */ /* The task hasn't used FP or LSX, fill with 0xff */
copy_pad_fprs(target, regset, &to, 0); copy_pad_fprs(target, regset, &to, 0);
......
...@@ -317,7 +317,7 @@ void loongson_cpu_die(unsigned int cpu) ...@@ -317,7 +317,7 @@ void loongson_cpu_die(unsigned int cpu)
mb(); mb();
} }
void play_dead(void) void __noreturn arch_cpu_idle_dead(void)
{ {
register uint64_t addr; register uint64_t addr;
register void (*init_fn)(void); register void (*init_fn)(void);
......
...@@ -383,16 +383,15 @@ void show_registers(struct pt_regs *regs) ...@@ -383,16 +383,15 @@ void show_registers(struct pt_regs *regs)
static DEFINE_RAW_SPINLOCK(die_lock); static DEFINE_RAW_SPINLOCK(die_lock);
void __noreturn die(const char *str, struct pt_regs *regs) void die(const char *str, struct pt_regs *regs)
{ {
int ret;
static int die_counter; static int die_counter;
int sig = SIGSEGV;
oops_enter(); oops_enter();
if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_nr, ret = notify_die(DIE_OOPS, str, regs, 0,
SIGSEGV) == NOTIFY_STOP) current->thread.trap_nr, SIGSEGV);
sig = 0;
console_verbose(); console_verbose();
raw_spin_lock_irq(&die_lock); raw_spin_lock_irq(&die_lock);
...@@ -405,6 +404,9 @@ void __noreturn die(const char *str, struct pt_regs *regs) ...@@ -405,6 +404,9 @@ void __noreturn die(const char *str, struct pt_regs *regs)
oops_exit(); oops_exit();
if (ret == NOTIFY_STOP)
return;
if (regs && kexec_should_crash(current)) if (regs && kexec_should_crash(current))
crash_kexec(regs); crash_kexec(regs);
...@@ -414,7 +416,7 @@ void __noreturn die(const char *str, struct pt_regs *regs) ...@@ -414,7 +416,7 @@ void __noreturn die(const char *str, struct pt_regs *regs)
if (panic_on_oops) if (panic_on_oops)
panic("Fatal exception"); panic("Fatal exception");
make_task_dead(sig); make_task_dead(SIGSEGV);
} }
static inline void setup_vint_size(unsigned int size) static inline void setup_vint_size(unsigned int size)
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <linux/export.h>
#include <asm/alternative-asm.h> #include <asm/alternative-asm.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/asm-extable.h> #include <asm/asm-extable.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/export.h>
#include <asm/regdef.h> #include <asm/regdef.h>
.irp to, 0, 1, 2, 3, 4, 5, 6, 7 .irp to, 0, 1, 2, 3, 4, 5, 6, 7
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <linux/export.h>
#include <asm/alternative-asm.h> #include <asm/alternative-asm.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/asm-extable.h> #include <asm/asm-extable.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/export.h>
#include <asm/regdef.h> #include <asm/regdef.h>
.irp to, 0, 1, 2, 3, 4, 5, 6, 7 .irp to, 0, 1, 2, 3, 4, 5, 6, 7
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <linux/export.h>
#include <asm/alternative-asm.h> #include <asm/alternative-asm.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/export.h>
#include <asm/regdef.h> #include <asm/regdef.h>
SYM_FUNC_START(memcpy) SYM_FUNC_START(memcpy)
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <linux/export.h>
#include <asm/alternative-asm.h> #include <asm/alternative-asm.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/export.h>
#include <asm/regdef.h> #include <asm/regdef.h>
SYM_FUNC_START(memmove) SYM_FUNC_START(memmove)
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <linux/export.h>
#include <asm/alternative-asm.h> #include <asm/alternative-asm.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/export.h>
#include <asm/regdef.h> #include <asm/regdef.h>
.macro fill_to_64 r0 .macro fill_to_64 r0
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/asm-extable.h> #include <asm/asm-extable.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <asm/export.h>
#include <asm/regdef.h> #include <asm/regdef.h>
.L_fixup_handle_unaligned: .L_fixup_handle_unaligned:
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/* /*
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <linux/export.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/export.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/regdef.h> #include <asm/regdef.h>
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/ */
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/export.h>
#include <asm/loongarch.h> #include <asm/loongarch.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment