From b4571cc96c78b1a84e41c134cce91d50c44ae3cd Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Mon, 25 Jan 2021 15:01:07 +0000 Subject: [PATCH] Revert "ANDROID: arm64: Handle AArch32 tasks running on non AArch32 cpu" This reverts commit cacae105edea2e47f2fac2695ef566f80d4877b4. Bug: 178507149 Signed-off-by: Will Deacon Change-Id: I26369490f2f8b5c4eb47559cd1a8a197cdda1d75 --- arch/arm64/Kconfig | 7 ++++--- arch/arm64/kernel/signal.c | 32 ++++++-------------------------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 38d1434df290..80936aefb541 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1903,9 +1903,10 @@ config ASYMMETRIC_AARCH32 Enable this option to allow support for asymmetric AArch32 EL0 CPU configurations. Once the AArch32 EL0 support is detected on a CPU, the feature is made available to user space to allow - the execution of 32-bit (compat) applications by migrating - them to the capable CPUs. Offlining such CPUs leads to 32-bit - applications being killed. + the execution of 32-bit (compat) applications. If the affinity + of the 32-bit application contains a non-AArch32 capable CPU + or the last AArch32 capable CPU is offlined, the application + will be killed. If unsure say N. diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 9c7327f22fa4..236b58a65e79 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -912,34 +912,14 @@ static void do_signal(struct pt_regs *regs) restore_saved_sigmask(); } -static void set_32bit_cpus_allowed(void) +static void check_aarch32_cpumask(void) { - int ret; - /* - * Try to honour as best as possible whatever affinity request this - * task has. If it spans no compatible CPU, disregard it entirely. + * The task must be a subset of aarch32_el0_mask or it could end up + * migrating and running on the wrong CPU. */ - if (cpumask_intersects(current->cpus_ptr, &aarch32_el0_mask)) { - cpumask_var_t cpus_allowed; - - if (!alloc_cpumask_var(&cpus_allowed, GFP_ATOMIC)) { - - ret = set_cpus_allowed_ptr(current, &aarch32_el0_mask); - - } else { - - cpumask_and(cpus_allowed, current->cpus_ptr, &aarch32_el0_mask); - ret = set_cpus_allowed_ptr(current, cpus_allowed); - free_cpumask_var(cpus_allowed); - - } - } else { - ret = set_cpus_allowed_ptr(current, &aarch32_el0_mask); - } - - if (ret) { - pr_warn_once("No CPUs capable of running 32-bit tasks\n"); + if (!cpumask_subset(current->cpus_ptr, &aarch32_el0_mask)) { + pr_warn_once("CPU affinity contains CPUs that are not capable of running 32-bit tasks\n"); force_sig(SIGKILL); } } @@ -959,7 +939,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, if (IS_ENABLED(CONFIG_ASYMMETRIC_AARCH32) && thread_flags & _TIF_CHECK_32BIT_AFFINITY) { clear_thread_flag(TIF_CHECK_32BIT_AFFINITY); - set_32bit_cpus_allowed(); + check_aarch32_cpumask(); } if (thread_flags & _TIF_UPROBE)