From mboxrd@z Thu Jan 1 00:00:00 1970 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=-20.9 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 BAE02C6369E for ; Thu, 19 Nov 2020 09:24:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57E5C2468D for ; Thu, 19 Nov 2020 09:24:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ln4/GRPs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726693AbgKSJYP (ORCPT ); Thu, 19 Nov 2020 04:24:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbgKSJYO (ORCPT ); Thu, 19 Nov 2020 04:24:14 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 104F3C0613D4 for ; Thu, 19 Nov 2020 01:24:13 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id s8so5607611wrw.10 for ; Thu, 19 Nov 2020 01:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=zaC6HLGL+omaruF7IeeV6ol/EWI+2CFXnsLBGa9N2h8=; b=ln4/GRPsn1eE/mc4KtEhAra4RNxg2QN/XCka1Lm+SO2cFGcTgSz9JuA78/6LQkmPyJ nkkLeNCQ/OYPaQ9dGsJCCZmb9NJstm4EHu/gk4E23pILzrpw81pglIJJYC7PsR0UPMZe Y1NKVSYJ3N3sv3kd7Fzh1JfdJuqUw7HtX3G8hRSz0ga1xYFJ2r2G2QuGMfuivBO7cIX9 E+Kk+0rSrYUicEpXsxUtZrPPpBoJtTy0ll5MkIi93UttK3WoWY0WfDcBIvnQfeji71wh KxXGz5pCBE2HIrHwg7D+bsoiUqqH/CeRN5FI3v2GoZUodzlwHRNctRvsX0ysVcbdQSRV Haew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zaC6HLGL+omaruF7IeeV6ol/EWI+2CFXnsLBGa9N2h8=; b=oprevk8c1Ec1yZTfjJ1b23bG0zanqIGdVEhB0vZQETinobdbzetXHQFd+Uktr0UPSd SGdJaDzJwYOYQx6fitstiygVqUsMyrPVK+yMeW/zVN7DNCqGvYULlX6VAYXixH1tkaIr hDrM+7UA0HQbDi2U7EdrPSy/+QOjDOraGR0+Yro7fpAzXTGVZe6QhuMglEa/Sig2p4Yg XxVaNWIdy1hhIqiBbMJEztC9GnXgeIL99Dr9EUuADCZrqHW973Q/HjIgAZ9SHMSiheMv ufcJhB/2l8JlOaSInAlCi8NzMD4tdf0UMt0FLdvojLdAlfKL7ynboeqm0xdh0rgHdu4T XtOg== X-Gm-Message-State: AOAM533lpn0b846QVWNGSiZ01YrbF+VjJZ/mizyzFCeNRbAlN7qtVs9D EBEjaI4Kh6GV4287e9y57aG/VdOJV/ZeAA== X-Google-Smtp-Source: ABdhPJzg7aVYJrdLm/oL4IR42qo7g1ZbElMa34XwzM/Q9EDRF18UfbTJHr9aX3EK8RKHDuNBE14BdQ== X-Received: by 2002:adf:c147:: with SMTP id w7mr9965825wre.60.1605777851508; Thu, 19 Nov 2020 01:24:11 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id l3sm9717175wmf.0.2020.11.19.01.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 01:24:11 -0800 (PST) Date: Thu, 19 Nov 2020 09:24:07 +0000 From: Quentin Perret To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , kernel-team@android.com Subject: Re: [PATCH v3 08/14] arm64: exec: Adjust affinity for compat tasks with mismatched 32-bit EL0 Message-ID: <20201119092407.GB2416649@google.com> References: <20201113093720.21106-1-will@kernel.org> <20201113093720.21106-9-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201113093720.21106-9-will@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 13 Nov 2020 at 09:37:13 (+0000), Will Deacon wrote: > When exec'ing a 32-bit task on a system with mismatched support for > 32-bit EL0, try to ensure that it starts life on a CPU that can actually > run it. > > Signed-off-by: Will Deacon > --- > arch/arm64/kernel/process.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 1540ab0fbf23..17b94007fed4 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -625,6 +625,16 @@ unsigned long arch_align_stack(unsigned long sp) > return sp & ~0xf; > } > > +static void adjust_compat_task_affinity(struct task_struct *p) > +{ > + const struct cpumask *mask = system_32bit_el0_cpumask(); > + > + if (restrict_cpus_allowed_ptr(p, mask)) > + set_cpus_allowed_ptr(p, mask); My understanding of this call to set_cpus_allowed_ptr() is that you're mimicking the hotplug vs affinity case behaviour in some ways. That is, if a task is pinned to a CPU and userspace hotplugs that CPU, then the kernel will reset the affinity of the task to the remaining online CPUs. I guess that is a sensible fallback path when userspace gives contradictory commands to the kernel, but that most certainly deserves a comment :) > + > + set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); > +} > > /* > * Called from setup_new_exec() after (COMPAT_)SET_PERSONALITY. > */ > @@ -635,7 +645,7 @@ void arch_setup_new_exec(void) > if (is_compat_task()) { > mmflags = MMCF_AARCH32; > if (static_branch_unlikely(&arm64_mismatched_32bit_el0)) > - set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); > + adjust_compat_task_affinity(current); > } > > current->mm->context.flags = mmflags; > -- > 2.29.2.299.gdc1121823c-goog > From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 1B706C2D0E4 for ; Thu, 19 Nov 2020 09:25:47 +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 783582468D for ; Thu, 19 Nov 2020 09:25:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mwWPjmTM"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ln4/GRPs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 783582468D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+J390dzdlSdqqbGqXTKuLXUW6RPuJFVBbcG8tMACdUg=; b=mwWPjmTMWbpV6htNvh+zCcCYV T6mFctdwCqWq1hQDGO6gdf2kzoTOClm+/EH/I9ZtJa4m/5QyLvG990HI0LqgC/go8Bfb+vA7qJw8q DrlqVm8fC24tv5YyM6oTscdmuAWrEWzKyuVP57syclysrpaXRvqg2TDJIFr4BWMVOI5yAQBEor5wx QSZ6kvbKQPmP51NDRLEUbZmi8zW8icPXqfH9N0zDCI5Q85y/sBAwjcjiwJWhUTMhDuNvpAWJJMM4l qGCIprJNimR8AjpLuNr3F6WlN1bCaD8WnVX5p7i94M753rhp3s2LUfa3NM/TnPEFYLRr1H1hfyrYC Wr1hKgY1A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfgAp-0006Yb-Qg; Thu, 19 Nov 2020 09:24:15 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfgAn-0006Xq-0q for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2020 09:24:14 +0000 Received: by mail-wr1-x443.google.com with SMTP id 23so5624399wrc.8 for ; Thu, 19 Nov 2020 01:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=zaC6HLGL+omaruF7IeeV6ol/EWI+2CFXnsLBGa9N2h8=; b=ln4/GRPsn1eE/mc4KtEhAra4RNxg2QN/XCka1Lm+SO2cFGcTgSz9JuA78/6LQkmPyJ nkkLeNCQ/OYPaQ9dGsJCCZmb9NJstm4EHu/gk4E23pILzrpw81pglIJJYC7PsR0UPMZe Y1NKVSYJ3N3sv3kd7Fzh1JfdJuqUw7HtX3G8hRSz0ga1xYFJ2r2G2QuGMfuivBO7cIX9 E+Kk+0rSrYUicEpXsxUtZrPPpBoJtTy0ll5MkIi93UttK3WoWY0WfDcBIvnQfeji71wh KxXGz5pCBE2HIrHwg7D+bsoiUqqH/CeRN5FI3v2GoZUodzlwHRNctRvsX0ysVcbdQSRV Haew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zaC6HLGL+omaruF7IeeV6ol/EWI+2CFXnsLBGa9N2h8=; b=AaGQQ1UEoJcApRPJ1kT4svsEF8WGVSvVIL4XB4bdSuP0JUp9MyGMQVfHzWAUoEz+uj 9zF4yH+SOWE0EewgHBHGrog6jNoXC3qyCH0puBcOCJ8L5U9x/snLNh3IrEtrSVZaqc/k /xAWgRhHiKjv8gqzgqgal4iztqkwUx6+hSGk9kcsjoUhAO73SqPWeufTcShvQAjsyS0R c4TZV0PidJ3aPSfFOnq9q/UbbjcR+ybDkOm2bRfJVnqUvGxoJdxu2CnRKga0UeooJn7j IIq89fpNC++CA8pPZu56jvasvrsiKYClDkw39/Xjitg5FaAhvkXvkJb95BAiqsZ4a0sY WNOA== X-Gm-Message-State: AOAM530VERj4y4XFEkz0hFbxT+kZf+FUteWryAI1pqR3lC8L02gC0Ykf 03/lC794AhTm8qrgRR/0C8ismQ== X-Google-Smtp-Source: ABdhPJzg7aVYJrdLm/oL4IR42qo7g1ZbElMa34XwzM/Q9EDRF18UfbTJHr9aX3EK8RKHDuNBE14BdQ== X-Received: by 2002:adf:c147:: with SMTP id w7mr9965825wre.60.1605777851508; Thu, 19 Nov 2020 01:24:11 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id l3sm9717175wmf.0.2020.11.19.01.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 01:24:11 -0800 (PST) Date: Thu, 19 Nov 2020 09:24:07 +0000 From: Quentin Perret To: Will Deacon Subject: Re: [PATCH v3 08/14] arm64: exec: Adjust affinity for compat tasks with mismatched 32-bit EL0 Message-ID: <20201119092407.GB2416649@google.com> References: <20201113093720.21106-1-will@kernel.org> <20201113093720.21106-9-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201113093720.21106-9-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201119_042413_180599_BA7379FD X-CRM114-Status: GOOD ( 24.78 ) 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 , Ingo Molnar , Peter Zijlstra , Catalin Marinas , Johannes Weiner , linux-kernel@vger.kernel.org, Qais Yousef , Li Zefan , Greg Kroah-Hartman , Tejun Heo , Suren Baghdasaryan , Morten Rasmussen , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Friday 13 Nov 2020 at 09:37:13 (+0000), Will Deacon wrote: > When exec'ing a 32-bit task on a system with mismatched support for > 32-bit EL0, try to ensure that it starts life on a CPU that can actually > run it. > > Signed-off-by: Will Deacon > --- > arch/arm64/kernel/process.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 1540ab0fbf23..17b94007fed4 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -625,6 +625,16 @@ unsigned long arch_align_stack(unsigned long sp) > return sp & ~0xf; > } > > +static void adjust_compat_task_affinity(struct task_struct *p) > +{ > + const struct cpumask *mask = system_32bit_el0_cpumask(); > + > + if (restrict_cpus_allowed_ptr(p, mask)) > + set_cpus_allowed_ptr(p, mask); My understanding of this call to set_cpus_allowed_ptr() is that you're mimicking the hotplug vs affinity case behaviour in some ways. That is, if a task is pinned to a CPU and userspace hotplugs that CPU, then the kernel will reset the affinity of the task to the remaining online CPUs. I guess that is a sensible fallback path when userspace gives contradictory commands to the kernel, but that most certainly deserves a comment :) > + > + set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); > +} > > /* > * Called from setup_new_exec() after (COMPAT_)SET_PERSONALITY. > */ > @@ -635,7 +645,7 @@ void arch_setup_new_exec(void) > if (is_compat_task()) { > mmflags = MMCF_AARCH32; > if (static_branch_unlikely(&arm64_mismatched_32bit_el0)) > - set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); > + adjust_compat_task_affinity(current); > } > > current->mm->context.flags = mmflags; > -- > 2.29.2.299.gdc1121823c-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel