Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3326611rdg; Tue, 17 Oct 2023 11:01:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE46xftEMZFpBYaGrMjUZO8SxU42TFVtMGv74SCXOuBwLdsPVchLA6IFaINmOeaIZWPC7B7 X-Received: by 2002:a17:90b:a43:b0:27d:4283:b8a2 with SMTP id gw3-20020a17090b0a4300b0027d4283b8a2mr2844850pjb.14.1697565715011; Tue, 17 Oct 2023 11:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697565714; cv=none; d=google.com; s=arc-20160816; b=k32FXvr+7g7mT4OEY5nQhGtATfZ/PzNKWx+N2llI6kamuQWv/NJO032dWUnNNXeR1R pJuvoXAunc6OM1f//H8loJhSYmvm4/NVlzeQ7z8zoxGjc+COXkwPsMNBuz3l19sZX9Xc nIstZ8eCbXERoGOguKu0AZsgLpupebELHZNrRpT2nNwBl1akW4R+Gdj++/DZUkyNeTy4 AP1XyuxVzEwjmAFKIdbtQdZFAHpnD5MdeHqChDDrWDRUsEHgXExL9//AerjOSkEmMIWv dRQTKA4X+Ne1QjQU98X0UQDOyPpbExuTl5+ZgZXIlINybXmPGUIFYYYHBdevYJ2HkwZZ GkFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=BR9Br34+eAgYfQkQPmz95VbvpHYGj7o5DoZpFxMXQmk=; fh=fqeL8KyHImrS3TUEOpd0TdmTWgGvJzbuM96M12TYQXI=; b=zSAlwtnohE5yqEb505zcu5oq6x7P85bEBYp5XAGLZ5dh2ZGu1KrDSuvi3If/12FE+m rRsNLvAjMgR/wBHWpJ1i68M7OENPKBGR3Jt6TWhevih8svWvA0pivb68VPye5GdxJGiz pGpPzUy8up5xEhBBjlvBXGCa9Yaz2DRG9q+kHtgkXaHTA3AAMpmENab1p5pGkL/83H1x hX7ThTaArB5Gg+H1ynti4ctzhSM0Pf9Jxp0KNeIn6rUSQcgL1KBmInp81N+DO8BorUGY 81zfCB3+Q6KelPug6HmNHTngOjxscZLyDl+iIOg+TsPa56aJABORR723QrK8w+14z5rj xmOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j78keP0P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ot9-20020a17090b3b4900b00278eb61c0ebsi9719236pjb.118.2023.10.17.11.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 11:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j78keP0P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1CA4080C7119; Tue, 17 Oct 2023 11:01:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234889AbjJQSBj (ORCPT + 99 others); Tue, 17 Oct 2023 14:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbjJQSBh (ORCPT ); Tue, 17 Oct 2023 14:01:37 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D31A83 for ; Tue, 17 Oct 2023 11:01:36 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB6C4C433C7; Tue, 17 Oct 2023 18:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697565695; bh=9QOF2LaITsJiw+ZOY61+ER4WRD2Fy/PdmQnO9/gNCyE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=j78keP0PEWrmURhBzr30Jittvaz+ApZ05brfL+3nMn8+2LtboNjyNjCuOyMiFF47f U8yxiZqseoFFwGrzesC3tgoA7KR0zK1dsTe9jnCKtwfof8KZ0oIyhVFDbeoNo65n2N X3+hfxnBZcHv39gSXYBOB3sfCrmS8jD1UlP82/kgmh68TgAAQkggGy9u+Gnz459yzk n2szxwMg4PQQZaEs2/MHfji/oI7z9mKeAmvII2ex47AGc54bgLD1QfCIPx35rjoEem 5557M0zqc7H0a9HB6OSDh/RjDSyQtiTUw087zowdlvWoKY3TltYLkWNVbxqbnI+VpM t4C6E7vxYV99w== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qsoNo-0055P7-M4; Tue, 17 Oct 2023 19:01:33 +0100 Date: Tue, 17 Oct 2023 19:01:31 +0100 Message-ID: <86ttqpm8lg.wl-maz@kernel.org> From: Marc Zyngier To: Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, anshuman.khandual@arm.com, krisman@suse.de, broonie@kernel.org, james.morse@arm.com, ionela.voinescu@arm.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] arm64: cpufeature: Change 32-bit EL0 to display enabled cores In-Reply-To: <20231017052322.1211099-4-jeremy.linton@arm.com> References: <20231017052322.1211099-1-jeremy.linton@arm.com> <20231017052322.1211099-4-jeremy.linton@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: jeremy.linton@arm.com, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, anshuman.khandual@arm.com, krisman@suse.de, broonie@kernel.org, james.morse@arm.com, ionela.voinescu@arm.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 17 Oct 2023 11:01:52 -0700 (PDT) On Tue, 17 Oct 2023 06:23:22 +0100, Jeremy Linton wrote: > > Now that we have the ability to display the list of cores > with a feature when it is selectivly enabled, lets display the > cores enabled for 32-bit use at EL0. > > Signed-off-by: Jeremy Linton > --- > arch/arm64/kernel/cpufeature.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index b7b67bac0e60..512cbe446b41 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -1533,8 +1533,17 @@ static bool has_32bit_el0(const struct arm64_cpu_capabilities *entry, int scope) > if (!has_cpuid_feature(entry, scope)) > return allow_mismatched_32bit_el0; > > - if (scope == SCOPE_SYSTEM) > - pr_info("detected: 32-bit EL0 Support\n"); > + if (scope == SCOPE_SYSTEM) { > + struct arm64_cpu_capabilities *has_32bit; > + > + has_32bit = (struct arm64_cpu_capabilities *)entry; > + > + has_32bit->cpus = system_32bit_el0_cpumask(); This seems rather dodgy. 'entry' comes from a static const array which will, in all likelihood be mapped R/O pretty soon after the initial CPU bringup. Try offlining/onlining a CPU and you should see a firework similar to what I have below (I hacked the CnP property, but that's no different from what you are doing): bash-5.1# echo 0 >/sys/devices/system/cpu/cpu2/online [ 51.367137] psci: CPU2 killed (polled 0 ms) bash-5.1# echo 1 >/sys/devices/system/cpu/cpu2/online [ 56.703092] Unable to handle kernel write to read-only memory at virtual address ffff800080d63db0 [ 56.703494] Mem abort info: [ 56.703627] ESR = 0x000000009600004f [ 56.703799] EC = 0x25: DABT (current EL), IL = 32 bits [ 56.704052] SET = 0, FnV = 0 [ 56.704196] EA = 0, S1PTW = 0 [ 56.704340] FSC = 0x0f: level 3 permission fault [ 56.704575] Data abort info: [ 56.704715] ISV = 0, ISS = 0x0000004f, ISS2 = 0x00000000 [ 56.704961] CM = 0, WnR = 1, TnD = 0, TagAccess = 0 [ 56.705195] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 56.705435] swapper pgtable: 4k pages, 48-bit VAs, pgdp=000000008142e000 [ 56.705742] [ffff800080d63db0] pgd=10000000dbfff003, p4d=10000000dbfff003, pud=10000000dbffe003, pmd=10000000dbffc003, pte=0060000080d63783 [ 56.706310] Internal error: Oops: 000000009600004f [#1] PREEMPT SMP [ 56.706591] Modules linked in: [ 56.706741] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 6.6.0-rc1-00007-g805cc7d30885-dirty #1702 [ 56.707145] Hardware name: linux,dummy-virt (DT) [ 56.707359] pstate: 800001c5 (Nzcv dAIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 56.707676] pc : cpu_enable_cnp+0x24/0x60 [ 56.707873] lr : verify_local_cpu_caps+0x6c/0x140 [ 56.708046] sp : ffff800082103e10 [ 56.708201] x29: ffff800082103e10 x28: 0000000000000000 x27: 0000000000000000 [ 56.708517] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [ 56.708837] x23: ffff800081eec540 x22: 0000000000000003 x21: ffff8000813945f0 [ 56.709166] x20: ffff800081394358 x19: ffff800080d63db0 x18: 0000000000000000 [ 56.709488] x17: 000000040044ffff x16: 00500073b5503510 x15: 0000000000000000 [ 56.709805] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 [ 56.710100] x11: 0000000000000000 x10: 0000000000000000 x9 : ffff8000800273ac [ 56.710416] x8 : ffff80008003b640 x7 : 0000000000000000 x6 : 0000000000000000 [ 56.710738] x5 : 0000000000000000 x4 : ffff800081394000 x3 : ffff800081394000 [ 56.711070] x2 : ffff800081241ef8 x1 : ffff800080027218 x0 : ffff800080d63db0 [ 56.711396] Call trace: [ 56.711512] cpu_enable_cnp+0x24/0x60 [ 56.711684] verify_local_cpu_caps+0x6c/0x140 [ 56.711885] verify_local_cpu_capabilities+0x1c/0x198 [ 56.712112] check_local_cpu_capabilities+0x28/0x50 [ 56.712337] secondary_start_kernel+0xb4/0x1a0 [ 56.712546] __secondary_switched+0xb8/0xc0 [ 56.712739] Code: 910003fd b0009b63 d00090c2 913be042 (f9000002) [ 56.713013] ---[ end trace 0000000000000000 ]--- [ 56.713224] Kernel panic - not syncing: Attempted to kill the idle task! [ 56.713518] SMP: stopping secondary CPUs [ 56.713752] Kernel Offset: disabled [ 56.713908] CPU features: 0x00000000,50024d43,1947f723 [ 56.714144] Memory Limit: none [ 56.714292] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]--- Thanks, M. -- Without deviation from the norm, progress is not possible.