Skip to content

Commit 5ad0ec0

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Will Deacon: - Fix panic() when it occurs during secondary CPU startup - Fix "kpti=off" when KASLR is enabled - Fix howler in compat syscall table for vDSO clock_getres() fallback * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: compat: Fix syscall number of compat_clock_getres arm64: kpti: Fix "kpti=off" when KASLR is enabled arm64: smp: fix crash_smp_send_stop() behaviour arm64: smp: fix smp_send_stop() behaviour
2 parents f014d2b + 3568b88 commit 5ad0ec0

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

arch/arm64/include/asm/mmu.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ typedef struct {
2929
*/
3030
#define ASID(mm) ((mm)->context.id.counter & 0xffff)
3131

32-
extern bool arm64_use_ng_mappings;
33-
3432
static inline bool arm64_kernel_unmapped_at_el0(void)
3533
{
36-
return arm64_use_ng_mappings;
34+
return cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0);
3735
}
3836

3937
typedef void (*bp_hardening_cb_t)(void);

arch/arm64/include/asm/pgtable-prot.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323

2424
#include <asm/pgtable-types.h>
2525

26+
extern bool arm64_use_ng_mappings;
27+
2628
#define _PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED)
2729
#define _PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S)
2830

29-
#define PTE_MAYBE_NG (arm64_kernel_unmapped_at_el0() ? PTE_NG : 0)
30-
#define PMD_MAYBE_NG (arm64_kernel_unmapped_at_el0() ? PMD_SECT_NG : 0)
31+
#define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0)
32+
#define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0)
3133

3234
#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG)
3335
#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG)

arch/arm64/include/asm/unistd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#define __NR_compat_gettimeofday 78
2626
#define __NR_compat_sigreturn 119
2727
#define __NR_compat_rt_sigreturn 173
28-
#define __NR_compat_clock_getres 247
2928
#define __NR_compat_clock_gettime 263
29+
#define __NR_compat_clock_getres 264
3030
#define __NR_compat_clock_gettime64 403
3131
#define __NR_compat_clock_getres_time64 406
3232

arch/arm64/kernel/smp.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -958,11 +958,22 @@ void tick_broadcast(const struct cpumask *mask)
958958
}
959959
#endif
960960

961+
/*
962+
* The number of CPUs online, not counting this CPU (which may not be
963+
* fully online and so not counted in num_online_cpus()).
964+
*/
965+
static inline unsigned int num_other_online_cpus(void)
966+
{
967+
unsigned int this_cpu_online = cpu_online(smp_processor_id());
968+
969+
return num_online_cpus() - this_cpu_online;
970+
}
971+
961972
void smp_send_stop(void)
962973
{
963974
unsigned long timeout;
964975

965-
if (num_online_cpus() > 1) {
976+
if (num_other_online_cpus()) {
966977
cpumask_t mask;
967978

968979
cpumask_copy(&mask, cpu_online_mask);
@@ -975,10 +986,10 @@ void smp_send_stop(void)
975986

976987
/* Wait up to one second for other CPUs to stop */
977988
timeout = USEC_PER_SEC;
978-
while (num_online_cpus() > 1 && timeout--)
989+
while (num_other_online_cpus() && timeout--)
979990
udelay(1);
980991

981-
if (num_online_cpus() > 1)
992+
if (num_other_online_cpus())
982993
pr_warn("SMP: failed to stop secondary CPUs %*pbl\n",
983994
cpumask_pr_args(cpu_online_mask));
984995

@@ -1001,15 +1012,19 @@ void crash_smp_send_stop(void)
10011012

10021013
cpus_stopped = 1;
10031014

1004-
if (num_online_cpus() == 1) {
1015+
/*
1016+
* If this cpu is the only one alive at this point in time, online or
1017+
* not, there are no stop messages to be sent around, so just back out.
1018+
*/
1019+
if (num_other_online_cpus() == 0) {
10051020
sdei_mask_local_cpu();
10061021
return;
10071022
}
10081023

10091024
cpumask_copy(&mask, cpu_online_mask);
10101025
cpumask_clear_cpu(smp_processor_id(), &mask);
10111026

1012-
atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
1027+
atomic_set(&waiting_for_crash_ipi, num_other_online_cpus());
10131028

10141029
pr_crit("SMP: stopping secondary CPUs\n");
10151030
smp_cross_call(&mask, IPI_CPU_CRASH_STOP);

0 commit comments

Comments
 (0)