From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:32904 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751905AbdJDNAk (ORCPT ); Wed, 4 Oct 2017 09:00:40 -0400 Subject: Re: [PATCH] arm64: Enable MRS emulation early To: Mark Rutland , Catalin Marinas Cc: Will Deacon , linux-kernel@vger.kernel.org, stable@vger.kernel.org, matwey.kornilov@gmail.com, James Morse , Dave Martin , linux-arm-kernel@lists.infradead.org References: <20171004094805.24009-1-suzuki.poulose@arm.com> <20171004101425.GB23092@leverpostej> <20171004111040.vumbc3bk7sj2enc6@armageddon.cambridge.arm.com> <20171004113212.GC23092@leverpostej> From: Suzuki K Poulose Message-ID: <15df3286-0784-a01e-d860-8ae13f2e6696@arm.com> Date: Wed, 4 Oct 2017 14:00:35 +0100 MIME-Version: 1.0 In-Reply-To: <20171004113212.GC23092@leverpostej> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On 04/10/17 12:32, Mark Rutland wrote: > On Wed, Oct 04, 2017 at 12:10:40PM +0100, Catalin Marinas wrote: >> On Wed, Oct 04, 2017 at 11:14:26AM +0100, Mark Rutland wrote: >>> On Wed, Oct 04, 2017 at 10:48:05AM +0100, Suzuki K Poulose wrote: >>>> Make sure the MRS emulation is enabled early enough, such that the >>>> early userspace applications (e.g, those run from initrd) could >>>> use the facility without crashing them. >>>> >>>> Fixes: commit 77c97b4ee2129 ("arm64: cpufeature: Expose CPUID registers by emulation") >>>> Reported-by: Matwey V. Kornilov >>>> Cc: James Morse >>>> Cc: Dave Martin >>>> Cc: Catalin Marinas >>>> Cc: Will Deacon >>>> Cc: stable@vger.kernel.org >>>> Cc: Mark Rutland >>>> Signed-off-by: Suzuki K Poulose >>> >>> This looks sensible, but shouldn't we do the same for other >>> late_inicalls can affect initrd userspace? >>> >>> e.g. armv8_deprecated_init, fpsimd_init, sys_reg_genericv8_init? >> >> I think we should, though not all of them are concerned with the user >> code. For example, fpsimd_init() takes care of the pm/hotplug aspect and >> nothing to do with user space. > > My worry was that without the pm/hotplug notifiers, things could go > wrong during the initrd. e.g. we could lose userspace fp state without > the pm notifier, or userspace could trigger hotplpug that we wouldn't > manage correctly > > So even if it's not directly userspace related, it can affect (or can be > affected by) initrd userspace. You're right. In fact, I had a version of the patch which enables the emulation as soon as we have initialised the ELF_HWCAPs from setup_cpu_features(), rather than depending on an initcall. But that requires moving the setup_cpu_features() to the bottom, which makes the hunk look a bit more complex than it is. And similarly, we should be able to do the fpsimd_init from setup_cpu_features(), as we have finalised the HWCAPs and pm_register_notifier any adds the entry to a static list of notifiers ( even though the cpu_pm callbacks are registered as a core_initcall() ). Similarly for sys_reg_genericv8_init & armv8_deprecated_init could be made a core initcall. I think it would be good to separate them out. i.e, enable_mrs_emulation & fpsimd_init from setup_cpu_features() and the other two promoted as core_initcalls. Thoughts ? Suzuki