Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1654847pxj; Wed, 19 May 2021 10:44:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTKb5q+X+tZFohIgiMc93rcXQU2qaGTKO7kQRdXxmTeJnwOFwjpT9GvnlkyQiEr73pwmTH X-Received: by 2002:a92:502:: with SMTP id q2mr121348ile.203.1621446240129; Wed, 19 May 2021 10:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621446240; cv=none; d=google.com; s=arc-20160816; b=R3cU/8ObAil7vR97kAUREkIs2/i+5ldDd4yI2PERrl7uNCMcuxO/xyh8TyoR9tg5GU Q6Ym0AhqXjqA5axstwBgbrPeCCYHJALxEB31gii2R7GmPDQMboMAjfCnbAbpZ9CXeEjh 0z8QHnL6r6NvMw6wf5oDQgaIgH5Jocl60sS3M57fPoBHiYtcAxzKfb8Aj2tLdRmIcgWY +ZpWQ4lpk+1jWHACxox5UhEqvZFfhNJUKMzsnFc5H6ykbVoVmZtQlAJGespXf64ypXHC j1xeDgar1Fd1UC2pbAEK18DyrPypHD3hxDPZFMsNg+1Iyll5Ai+oxqgjHbp2hkgKr3XO TdHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=21zMtIdWAx7slZJEppOPAVloi7y0XLQyP0p6eiABDQg=; b=vPcElTAoLnCe0MsAS39J3ITcvJZ/4QObvz1/lELV7NQeDEByQINCwscYg3lcfcRQZL M4aAOZSam8Xp7pF1FL7BJWJDY8GmD0Tlq0/L+7vhvNwuArP7/XLqiPCWuoci8botmDwU Zn8eYnd7ndk5fPGdSZLRK5xIw64Hkg48JjX4DmVlOXKc4bPbIo2yjYqv7AOosYeVNzOZ 18HwA9JB9tuJuIARvzYgsdJ6I/+IaWmgb+IYIoPAAxN2xx8tcnUWG2jzw0mM1LEAXwdH IzD+OZmfNBqj0uoxTaBWeJUwKtqybzzcl5uXyD9IjPk7U+FSqZp3YdAxrQGgFrsDfoNr UhYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DHYBKJsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h11si258714ila.129.2021.05.19.10.43.46; Wed, 19 May 2021 10:44:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DHYBKJsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348243AbhERJux (ORCPT + 99 others); Tue, 18 May 2021 05:50:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:50550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241535AbhERJt6 (ORCPT ); Tue, 18 May 2021 05:49:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E50961400; Tue, 18 May 2021 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621331318; bh=R9BW6P5F0BMcxqhawbpZj55WsxoJwynPUjScPCDvTIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHYBKJslYl+OETsyFh81LkpiXQ1cFVBDLzO/naT40uQr2B1dNxMIsDbm5QRs9oU2Z S704c6CqM37DEqMAX0U1NLMEWmSGkBhw5PpD5NpFNbIGNQ3riHGvsT8egS7XIvaRYc ddfJGNtVY1A3jNpKyKyqog2WD5Q8DJX9RdW2aVHD2GoCAvv+3AA1rEkASemwoWStaC STSqemDuneUVF9rEaqO9Azitdtec7reffxVPEc8srAEWY16QDZHqSLl5ly02jgPuPx I/jsjzw8Vp6IGqYqyJGRJLNXDL35IPBuaz+TLXET7FpPkHE7OAVtibCRod2500RmUR LwPBykiMdhBBQ== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , "Rafael J. Wysocki" , kernel-team@android.com Subject: [PATCH v6 17/21] arm64: exec: Adjust affinity for compat tasks with mismatched 32-bit EL0 Date: Tue, 18 May 2021 10:47:21 +0100 Message-Id: <20210518094725.7701-18-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210518094725.7701-1-will@kernel.org> References: <20210518094725.7701-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Similarly, when exec'ing a 64-bit task on such a system, try to restore the old affinity mask if it was previously restricted. Reviewed-by: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kernel/process.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index f4a91bf1ce0c..8e0da06c4e77 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -647,8 +647,22 @@ void arch_setup_new_exec(void) if (is_compat_task()) { mmflags = MMCF_AARCH32; - if (static_branch_unlikely(&arm64_mismatched_32bit_el0)) + + /* + * Restrict the CPU affinity mask for a 32-bit task so that + * it contains only 32-bit-capable CPUs. + * + * From the perspective of the task, this looks similar to + * what would happen if the 64-bit-only CPUs were hot-unplugged + * at the point of execve(), although we try a bit harder to + * honour the cpuset hierarchy. + */ + if (static_branch_unlikely(&arm64_mismatched_32bit_el0)) { + force_compatible_cpus_allowed_ptr(current); set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); + } + } else if (static_branch_unlikely(&arm64_mismatched_32bit_el0)) { + relax_compatible_cpus_allowed_ptr(current); } current->mm->context.flags = mmflags; -- 2.31.1.751.gd2f1c929bd-goog