Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp725511pxj; Wed, 2 Jun 2021 09:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzKvo1gcc0p2r6v9ZaA5Zii3wOBVLFGjt95bFC0qnRRdlcJ0eqrgpvPO3bEZsD/9xohcjU X-Received: by 2002:a05:6402:1648:: with SMTP id s8mr32603182edx.256.1622652667404; Wed, 02 Jun 2021 09:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622652667; cv=none; d=google.com; s=arc-20160816; b=F7LQ46VGlJPAeDFWHHzBJUWtk8GsY26tdaN7KnjhPltoZQGwu74cSfo9Tc3loCpWyJ 5hKM3MHN9Mkydv36u01QJMskFdt0bOZoxxFDV+KAyP1cIgnR5C6VemvUEw5nwN4R/8wt 5k7fmeTHPi++aF3S8wsJlxPC/gvsNnnrOK76dXJgMiV3eCGyBR0eU8En16reoFQrfouc i5qbflr/UrEUb0fpm0CqLvX7/baiC4w0OCwjzdW2kiEKG2vnyNxqpVDKDsR86JyRZ9ZZ /QqqIItSt+nlAQ/8wcTHnXamA6g9NtWmGQzCVhfQG+vGzI7zE4D/qB3TMYDSHWItH7M9 zWQA== 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=kJ2mrD4olpDdLBEIB7j994foRoTLyPdagXZzOqN6jLY=; b=cLV8fNeBGU5iTODxGM9uFITDD33mD9fCo7oS9nHL5URujsYhpX3H0WQuK4wQIwBdpH LhTLw7ebR2cdsx9NoThjp8FIfzH+Sj+6h+HynFseDqtrcps+axaz7Sg/B+XNFV8qGfVS UgiwHCCORg7Cavid8N2q3YUjj/aXmb8IV7AXjNDywkcZnP9S5yWMj8ojT1BxSCzxTY9B NL5zeJ1bukDR1pgxzhaD6D/eartT2URmQy+FgSxzOW+MjY0nUfAbBHCYVzF+W+/MNOa9 M4ux3KOjp5itNQpVLlX03Svr6tgGYGd1p5Uzfj+TwsvIPjxzuCaztmTSGK8spDdbOOAH Xdxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aBnfLC8l; 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 z40si339090ede.300.2021.06.02.09.50.44; Wed, 02 Jun 2021 09:51:07 -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=aBnfLC8l; 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 S231448AbhFBQu1 (ORCPT + 99 others); Wed, 2 Jun 2021 12:50:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:33522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230412AbhFBQuR (ORCPT ); Wed, 2 Jun 2021 12:50:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9118261C1A; Wed, 2 Jun 2021 16:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622652514; bh=x0QP/3o6xRJ/gC/T6Aypyq2owsN7PsaVjL0+LhRfv9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aBnfLC8lVlr7fHXCOk8mA0nAY/vKDSF+BFWsimunyPFQGA+5mKZ6F4dgWi7zGHvnu DwylaewYl9cAatwBF4rvFQ6I6/vN6gYXGkEqknGS+EYwAuluMHSb8HLzE2jJohIZnl 0de3WtTvewghIQ+8CdgMRCEqPCLPQ/fM3iF3chVsCLr0Fox52NRahcu642ScVWWsBq 0FQ6eHTSobS3Q3H+jYa5+mjBLGCi998N8MQSZYdb+V8CDWvE9WMRJM+cEfQiSEaTBE 0gHV+Lb5RGqHOERkJNW1wmkmm3yssDuwrvtXJChDZhVQZDIL/HDe9QO1MNHtcJfi/a RNO7hNv6sIyPg== 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 , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , "Rafael J. Wysocki" , Dietmar Eggemann , Daniel Bristot de Oliveira , Valentin Schneider , kernel-team@android.com Subject: [PATCH v8 16/19] arm64: Advertise CPUs capable of running 32-bit applications in sysfs Date: Wed, 2 Jun 2021 17:47:16 +0100 Message-Id: <20210602164719.31777-17-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602164719.31777-1-will@kernel.org> References: <20210602164719.31777-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since 32-bit applications will be killed if they are caught trying to execute on a 64-bit-only CPU in a mismatched system, advertise the set of 32-bit capable CPUs to userspace in sysfs. Reviewed-by: Greg Kroah-Hartman Reviewed-by: Catalin Marinas Signed-off-by: Will Deacon --- .../ABI/testing/sysfs-devices-system-cpu | 9 +++++++++ arch/arm64/kernel/cpufeature.c | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index fe13baa53c59..899377b2715a 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -494,6 +494,15 @@ Description: AArch64 CPU registers 'identification' directory exposes the CPU ID registers for identifying model and revision of the CPU. +What: /sys/devices/system/cpu/aarch32_el0 +Date: May 2021 +Contact: Linux ARM Kernel Mailing list +Description: Identifies the subset of CPUs in the system that can execute + AArch32 (32-bit ARM) applications. If present, the same format as + /sys/devices/system/cpu/{offline,online,possible,present} is used. + If absent, then all or none of the CPUs can execute AArch32 + applications and execve() will behave accordingly. + What: /sys/devices/system/cpu/cpu#/cpu_capacity Date: December 2016 Contact: Linux kernel mailing list diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index b31d7a1eaed6..72efdc611b14 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -1297,6 +1298,24 @@ const struct cpumask *system_32bit_el0_cpumask(void) return cpu_possible_mask; } +static ssize_t aarch32_el0_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + const struct cpumask *mask = system_32bit_el0_cpumask(); + + return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(mask)); +} +static const DEVICE_ATTR_RO(aarch32_el0); + +static int __init aarch32_el0_sysfs_init(void) +{ + if (!allow_mismatched_32bit_el0) + return 0; + + return device_create_file(cpu_subsys.dev_root, &dev_attr_aarch32_el0); +} +device_initcall(aarch32_el0_sysfs_init); + static bool has_32bit_el0(const struct arm64_cpu_capabilities *entry, int scope) { if (!has_cpuid_feature(entry, scope)) -- 2.32.0.rc0.204.g9fa02ecfa5-goog