Skip to content

Commit 438ddc3

Browse files
committed
Merge branch 'for-next/misc' into for-next/core
* for-next/misc: arm64/sysreg: refactor deprecated strncpy arm64: sysreg: Generate C compiler warnings on {read,write}_sysreg_s arguments arm64: sdei: abort running SDEI handlers during crash arm64: Explicitly include correct DT includes arm64/Kconfig: Sort the RCpc feature under the ARMv8.3 features menu arm64: vdso: remove two .altinstructions related symbols arm64/ptrace: Clean up error handling path in sve_set_common()
2 parents d36dccc + d232606 commit 438ddc3

File tree

13 files changed

+73
-19
lines changed

13 files changed

+73
-19
lines changed

arch/arm64/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,9 +1793,6 @@ config ARM64_PAN
17931793
The feature is detected at runtime, and will remain as a 'nop'
17941794
instruction if the cpu does not implement the feature.
17951795

1796-
config AS_HAS_LDAPR
1797-
def_bool $(as-instr,.arch_extension rcpc)
1798-
17991796
config AS_HAS_LSE_ATOMICS
18001797
def_bool $(as-instr,.arch_extension lse)
18011798

@@ -1933,6 +1930,9 @@ config AS_HAS_ARMV8_3
19331930
config AS_HAS_CFI_NEGATE_RA_STATE
19341931
def_bool $(as-instr,.cfi_startproc\n.cfi_negate_ra_state\n.cfi_endproc\n)
19351932

1933+
config AS_HAS_LDAPR
1934+
def_bool $(as-instr,.arch_extension rcpc)
1935+
19361936
endmenu # "ARMv8.3 architectural features"
19371937

19381938
menu "ARMv8.4 architectural features"

arch/arm64/include/asm/sdei.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
#include <asm/virt.h>
1919

20+
DECLARE_PER_CPU(struct sdei_registered_event *, sdei_active_normal_event);
21+
DECLARE_PER_CPU(struct sdei_registered_event *, sdei_active_critical_event);
22+
2023
extern unsigned long sdei_exit_mode;
2124

2225
/* Software Delegated Exception entry point from firmware*/
@@ -29,6 +32,9 @@ asmlinkage void __sdei_asm_entry_trampoline(unsigned long event_num,
2932
unsigned long pc,
3033
unsigned long pstate);
3134

35+
/* Abort a running handler. Context is discarded. */
36+
void __sdei_handler_abort(void);
37+
3238
/*
3339
* The above entry point does the minimum to call C code. This function does
3440
* anything else, before calling the driver.

arch/arm64/include/asm/sysreg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,15 +803,21 @@
803803
/*
804804
* For registers without architectural names, or simply unsupported by
805805
* GAS.
806+
*
807+
* __check_r forces warnings to be generated by the compiler when
808+
* evaluating r which wouldn't normally happen due to being passed to
809+
* the assembler via __stringify(r).
806810
*/
807811
#define read_sysreg_s(r) ({ \
808812
u64 __val; \
813+
u32 __maybe_unused __check_r = (u32)(r); \
809814
asm volatile(__mrs_s("%0", r) : "=r" (__val)); \
810815
__val; \
811816
})
812817

813818
#define write_sysreg_s(v, r) do { \
814819
u64 __val = (u64)(v); \
820+
u32 __maybe_unused __check_r = (u32)(r); \
815821
asm volatile(__msr_s(r, "%x0") : : "rZ" (__val)); \
816822
} while (0)
817823

arch/arm64/kernel/cpuidle.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <linux/acpi.h>
1010
#include <linux/cpuidle.h>
1111
#include <linux/cpu_pm.h>
12-
#include <linux/of.h>
13-
#include <linux/of_device.h>
1412
#include <linux/psci.h>
1513

1614
#ifdef CONFIG_ACPI_PROCESSOR_IDLE

arch/arm64/kernel/entry.S

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,9 +986,13 @@ SYM_CODE_START(__sdei_asm_handler)
986986

987987
mov x19, x1
988988

989-
#if defined(CONFIG_VMAP_STACK) || defined(CONFIG_SHADOW_CALL_STACK)
989+
/* Store the registered-event for crash_smp_send_stop() */
990990
ldrb w4, [x19, #SDEI_EVENT_PRIORITY]
991-
#endif
991+
cbnz w4, 1f
992+
adr_this_cpu dst=x5, sym=sdei_active_normal_event, tmp=x6
993+
b 2f
994+
1: adr_this_cpu dst=x5, sym=sdei_active_critical_event, tmp=x6
995+
2: str x19, [x5]
992996

993997
#ifdef CONFIG_VMAP_STACK
994998
/*
@@ -1055,6 +1059,14 @@ SYM_CODE_START(__sdei_asm_handler)
10551059

10561060
ldr_l x2, sdei_exit_mode
10571061

1062+
/* Clear the registered-event seen by crash_smp_send_stop() */
1063+
ldrb w3, [x4, #SDEI_EVENT_PRIORITY]
1064+
cbnz w3, 1f
1065+
adr_this_cpu dst=x5, sym=sdei_active_normal_event, tmp=x6
1066+
b 2f
1067+
1: adr_this_cpu dst=x5, sym=sdei_active_critical_event, tmp=x6
1068+
2: str xzr, [x5]
1069+
10581070
alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0
10591071
sdei_handler_exit exit_mode=x2
10601072
alternative_else_nop_endif
@@ -1065,4 +1077,15 @@ alternative_else_nop_endif
10651077
#endif
10661078
SYM_CODE_END(__sdei_asm_handler)
10671079
NOKPROBE(__sdei_asm_handler)
1080+
1081+
SYM_CODE_START(__sdei_handler_abort)
1082+
mov_q x0, SDEI_1_0_FN_SDEI_EVENT_COMPLETE_AND_RESUME
1083+
adr x1, 1f
1084+
ldr_l x2, sdei_exit_mode
1085+
sdei_handler_exit exit_mode=x2
1086+
// exit the handler and jump to the next instruction.
1087+
// Exit will stomp x0-x17, PSTATE, ELR_ELx, and SPSR_ELx.
1088+
1: ret
1089+
SYM_CODE_END(__sdei_handler_abort)
1090+
NOKPROBE(__sdei_handler_abort)
10681091
#endif /* CONFIG_ARM_SDE_INTERFACE */

arch/arm64/kernel/idreg-override.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases)
262262
if (!len)
263263
return;
264264

265-
len = min(len, ARRAY_SIZE(buf) - 1);
266-
strncpy(buf, cmdline, len);
267-
buf[len] = 0;
265+
len = strscpy(buf, cmdline, ARRAY_SIZE(buf));
266+
if (len == -E2BIG)
267+
len = ARRAY_SIZE(buf) - 1;
268268

269269
if (strcmp(buf, "--") == 0)
270270
return;

arch/arm64/kernel/pci.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include <linux/io.h>
1212
#include <linux/kernel.h>
1313
#include <linux/mm.h>
14-
#include <linux/of_pci.h>
15-
#include <linux/of_platform.h>
1614
#include <linux/pci.h>
1715
#include <linux/pci-acpi.h>
1816
#include <linux/pci-ecam.h>

arch/arm64/kernel/ptrace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,8 @@ static int sve_set_common(struct task_struct *target,
884884
break;
885885
default:
886886
WARN_ON_ONCE(1);
887-
return -EINVAL;
887+
ret = -EINVAL;
888+
goto out;
888889
}
889890

890891
/*

arch/arm64/kernel/sdei.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ DEFINE_PER_CPU(unsigned long *, sdei_shadow_call_stack_normal_ptr);
4747
DEFINE_PER_CPU(unsigned long *, sdei_shadow_call_stack_critical_ptr);
4848
#endif
4949

50+
DEFINE_PER_CPU(struct sdei_registered_event *, sdei_active_normal_event);
51+
DEFINE_PER_CPU(struct sdei_registered_event *, sdei_active_critical_event);
52+
5053
static void _free_sdei_stack(unsigned long * __percpu *ptr, int cpu)
5154
{
5255
unsigned long *p;

arch/arm64/kernel/smp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,10 +1044,8 @@ void crash_smp_send_stop(void)
10441044
* If this cpu is the only one alive at this point in time, online or
10451045
* not, there are no stop messages to be sent around, so just back out.
10461046
*/
1047-
if (num_other_online_cpus() == 0) {
1048-
sdei_mask_local_cpu();
1049-
return;
1050-
}
1047+
if (num_other_online_cpus() == 0)
1048+
goto skip_ipi;
10511049

10521050
cpumask_copy(&mask, cpu_online_mask);
10531051
cpumask_clear_cpu(smp_processor_id(), &mask);
@@ -1066,7 +1064,9 @@ void crash_smp_send_stop(void)
10661064
pr_warn("SMP: failed to stop secondary CPUs %*pbl\n",
10671065
cpumask_pr_args(&mask));
10681066

1067+
skip_ipi:
10691068
sdei_mask_local_cpu();
1069+
sdei_handler_abort();
10701070
}
10711071

10721072
bool smp_crash_stop_failed(void)

0 commit comments

Comments
 (0)