From patchwork Tue Nov 24 15:50:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 11929289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF879C2D0E4 for ; Tue, 24 Nov 2020 15:54:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F00E206F7 for ; Tue, 24 Nov 2020 15:54:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MSz5Ga7T"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="bnV/JAag" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F00E206F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8FCi5Gc9OSKT1BXCcD9HU3M1m9DiAfMLE7irHgdF774=; b=MSz5Ga7TEsMwwIIcOuhIsGZFC g1UEQWvAXT+gkTv01KP2AsX5iQyiAjQ84HT+4kGYPujj0iA8rqTLFjoOgGdSvasntlTfzFlE7JWGi l2P6phY5NgYntyrRyMiYTDWxbsVlgXTKoM4LBsYzTM+zbH9FyQ/3phtP+NiMdeauYttG6O8sy1pXg rtyV+TmIMosgnBNMQdGXJX2ZTqjbqtH49sYg0E3zq8JNvOfKAVlrvDZoXqFohYM2EFIejSjKE/4fY CNAt+jhoOBdGauVvahYZrKi9qXmYSEupyjN7vcjLsrPtigh8EheJbju1vGVtXPnHYdsS8ZKOMkKYZ WXQ60rESA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khad7-000619-3L; Tue, 24 Nov 2020 15:53:22 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khaba-0005Bh-NY for linux-arm-kernel@lists.infradead.org; Tue, 24 Nov 2020 15:51:49 +0000 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A01D42073C; Tue, 24 Nov 2020 15:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606233105; bh=+z+guEczWGGY8Fmi0RRJrJK9CwM5f159lXd/SraCCFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bnV/JAag6M9SPuRfaIgWp4z8vCZLmbv8aAxTi+ozopUO4lqOSHo7THpdvCRtt0cUx yRhIx5t+PEIs7S6OIP3LwxfOm8zw909m/mwqHyr5UXoTd7eQy/7A7W8rtoOIu+9t+I 2sgUr7azoMjBvRv5sspfclA2NlVQ3Q+U4pEHMq+0= From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 14/14] arm64: Remove logic to kill 32-bit tasks on 64-bit-only cores Date: Tue, 24 Nov 2020 15:50:39 +0000 Message-Id: <20201124155039.13804-15-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201124155039.13804-1-will@kernel.org> References: <20201124155039.13804-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201124_105147_656429_4997C9A6 X-CRM114-Status: GOOD ( 16.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Marc Zyngier , kernel-team@android.com, Vincent Guittot , Juri Lelli , Quentin Perret , Peter Zijlstra , Catalin Marinas , Johannes Weiner , linux-kernel@vger.kernel.org, Qais Yousef , Suren Baghdasaryan , Ingo Molnar , Li Zefan , Greg Kroah-Hartman , Tejun Heo , Will Deacon , Morten Rasmussen Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The scheduler now knows enough about these braindead systems to place 32-bit tasks accordingly, so throw out the safety checks and allow the ret-to-user path to avoid do_notify_resume() if there is nothing to do. Signed-off-by: Will Deacon --- arch/arm64/kernel/process.c | 14 +------------- arch/arm64/kernel/signal.c | 26 -------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 72116b0c7c73..e21c631c8b17 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -543,15 +543,6 @@ static void erratum_1418040_thread_switch(struct task_struct *prev, write_sysreg(val, cntkctl_el1); } -static void compat_thread_switch(struct task_struct *next) -{ - if (!is_compat_thread(task_thread_info(next))) - return; - - if (static_branch_unlikely(&arm64_mismatched_32bit_el0)) - set_tsk_thread_flag(next, TIF_NOTIFY_RESUME); -} - /* * Thread switching. */ @@ -568,7 +559,6 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev, uao_thread_switch(next); ssbs_thread_switch(next); erratum_1418040_thread_switch(prev, next); - compat_thread_switch(next); /* * Complete any pending TLB or cache maintenance on this CPU in case @@ -644,7 +634,7 @@ static void adjust_compat_task_affinity(struct task_struct *p) * execve(). */ if (!restrict_cpus_allowed_ptr(p, possible_mask)) - goto out; + return; if (alloc_cpumask_var(&cpuset_mask, GFP_KERNEL)) { cpuset_cpus_allowed(p, cpuset_mask); @@ -661,8 +651,6 @@ static void adjust_compat_task_affinity(struct task_struct *p) out_set_mask: set_cpus_allowed_ptr(p, newmask); free_cpumask_var(cpuset_mask); -out: - set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); } /* diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index bcb6ca2d9a7c..a8184cad8890 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -911,19 +911,6 @@ static void do_signal(struct pt_regs *regs) restore_saved_sigmask(); } -static bool cpu_affinity_invalid(struct pt_regs *regs) -{ - if (!compat_user_mode(regs)) - return false; - - /* - * We're preemptible, but a reschedule will cause us to check the - * affinity again. - */ - return !cpumask_test_cpu(raw_smp_processor_id(), - system_32bit_el0_cpumask()); -} - asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags) { @@ -961,19 +948,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, if (thread_flags & _TIF_NOTIFY_RESUME) { tracehook_notify_resume(regs); rseq_handle_notify_resume(NULL, regs); - - /* - * If we reschedule after checking the affinity - * then we must ensure that TIF_NOTIFY_RESUME - * is set so that we check the affinity again. - * Since tracehook_notify_resume() clears the - * flag, ensure that the compiler doesn't move - * it after the affinity check. - */ - barrier(); - - if (cpu_affinity_invalid(regs)) - force_sig(SIGKILL); } if (thread_flags & _TIF_FOREIGN_FPSTATE)