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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 DC99DC4363A for ; Thu, 29 Oct 2020 01:01:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 882DD2087E for ; Thu, 29 Oct 2020 01:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603933269; bh=YTIoP8jmk1dMFohZd6EK2lZ2rfu1qEiJDzHvGm4gTPM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=xa8Q8R6ubymp3oxZ/lwsmBYeKhE3DKGxQQ1b2uF5fzUDVeXKfeT5yKI+O7QdXOf5W JrlAXlGx92WPUdJlceZGOgJB8CXLri8WtVcW9P9OpAc1fYHCv65dVt4iyuHfOQ3v05 zAmixslhN76N6ztYAOst4Robs7QId7T5B3pJcK1c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404049AbgJ2BBG (ORCPT ); Wed, 28 Oct 2020 21:01:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:60502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731528AbgJ1WR1 (ORCPT ); Wed, 28 Oct 2020 18:17:27 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C22452465B; Wed, 28 Oct 2020 08:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603874214; bh=YTIoP8jmk1dMFohZd6EK2lZ2rfu1qEiJDzHvGm4gTPM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=br54aej6Fa3FCD729KUKrUAQOnkwSB34dXnqmrdB7pYHryrJ8bcuIUzMtqUpnnLul jZAzLh0Ol2qAkkHNXL9ZNYIbDrsmE1WhYab3+NbUHzeVI1AHuxbcg5mtfmUrA8Aiz1 BDEpUgrVSB4Gml1vH9fNb6ZO0jOFZovQ9KBQptq8= Date: Wed, 28 Oct 2020 09:37:46 +0100 From: Greg Kroah-Hartman To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Catalin Marinas , Marc Zyngier , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , kernel-team@android.com Subject: Re: [PATCH 5/6] arm64: Advertise CPUs capable of running 32-bit applcations in sysfs Message-ID: <20201028083746.GA1854746@kroah.com> References: <20201027215118.27003-1-will@kernel.org> <20201027215118.27003-6-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027215118.27003-6-will@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Tue, Oct 27, 2020 at 09:51:17PM +0000, Will Deacon wrote: > 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. > > Signed-off-by: Will Deacon > --- > .../ABI/testing/sysfs-devices-system-cpu | 8 ++++++++ > arch/arm64/kernel/cpufeature.c | 19 +++++++++++++++++++ > 2 files changed, 27 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu > index b555df825447..19893fb8e870 100644 > --- a/Documentation/ABI/testing/sysfs-devices-system-cpu > +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu > @@ -472,6 +472,14 @@ 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: October 2020 > +Contact: Linux ARM Kernel Mailing list > +Description: Identifies the subset of CPUs in the system that can execute > + AArch32 (32-bit ARM) applications. If absent, then all or none > + of the CPUs can execute AArch32 applications and execve() will > + behave accordingly. How is this value represented? A hint here would be nice. > + > 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 2e2219cbd54c..9f29d4d1ef7e 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -67,6 +67,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1236,6 +1237,24 @@ bool system_has_mismatched_32bit_el0(void) > return fld == ID_AA64PFR0_EL0_64BIT_ONLY; > } > > +static ssize_t aarch32_el0_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + const struct cpumask *mask = system_32bit_el0_cpumask(); > + return sprintf(buf, "%*pbl\n", cpumask_pr_args(mask)); sysfs_emit()? And a blank line to make checkpatch.pl happy :) > +} > +static const struct kobj_attribute aarch32_el0_attr = __ATTR_RO(aarch32_el0); DEVICE_ATTR_RO()? > + > +static int __init aarch32_el0_sysfs_init(void) > +{ > + if (!__allow_mismatched_32bit_el0) > + return 0; > + > + return sysfs_create_file(&cpu_subsys.dev_root->kobj, > + &aarch32_el0_attr.attr); device_create_file() please, dev_root is a struct device, no need to "thunk" down to a "raw" sysfs call. thanks, greg k-h