Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4944760ybl; Tue, 14 Jan 2020 00:31:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxWfJ8FpRANFjI3goZioW/Ydy25/4+WL6dR1NK0hig2Tjf8/kS2goojhQ8SOYYmqxyx20IB X-Received: by 2002:aca:f507:: with SMTP id t7mr16305893oih.156.1578990703981; Tue, 14 Jan 2020 00:31:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578990703; cv=none; d=google.com; s=arc-20160816; b=aEHLb/0g0bW5tFB0S0nFzztXu51yqzb8c+5dNnZCvQEIbSauFfs6db0njoPTg2r4P6 EiCs4dGNmLX0FqfOOuYyme11HYJFRexqvWXDg6uH6jHkGeji/gIOWjEvNrUnIF7Fj723 THFi8vzyBht5JXt2JwuTkLPxdZSLCfafponyjjqXAHl4+fo7zrEMMOozefXKtoBT9Qfx l1WtQ8CJxWnnbuW25TDy+XEjwwfkPuzB1bBsnzZO3+2Fe3/8TYLcl4rKWG1CtD3mmzop chRie4ZLWJ1h6lNRDy7bdmUIf/uK33b2o0CBmqZc7wAXglE/aeycYzDzFpA2LNQIUb5X Pt1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=e3nJMNyQkRtEjdVgCzBtNOhrTK9Iwh6sRszLOAZjqV8=; b=V4PVlrbNi409BvwfxEcoQGezokr1FYM6ZFQnNyJAWpguc0H0MBlVpIhIdd3Y7mLTvo 4H9CEYOIhKthIAEAhNRYIcCBEobo6s6S2IBjPBQV7dWgH7ahowrS6PJpafDvVPlpaBXp WQYZz1jZFvBw+dbbvvLV3FlLcaVr5gc1SpLJzGHgf/N3jBM5GBMIqg8Kgqgw7g5Qs204 QKbha8nvcPUbAgoatdjdk0xSTpSi/FpeCjeTvojFTKRTXZBZ5kRt1EVaDgkCD81fJIrW ljhB5BuCeercZcRQD9+PTAjDvBn+sBhwyU5GVK8fRz86EHg00PJoY3RBuQlioMmztA+i M+QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lftlN0YN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g126si6992513oif.106.2020.01.14.00.31.32; Tue, 14 Jan 2020 00:31:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lftlN0YN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728820AbgANIaS (ORCPT + 99 others); Tue, 14 Jan 2020 03:30:18 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38485 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbgANIaS (ORCPT ); Tue, 14 Jan 2020 03:30:18 -0500 Received: by mail-wr1-f66.google.com with SMTP id y17so11216305wrh.5 for ; Tue, 14 Jan 2020 00:30:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e3nJMNyQkRtEjdVgCzBtNOhrTK9Iwh6sRszLOAZjqV8=; b=lftlN0YN81jg+wU6o3PcZ1f6aB05s504QexQgbl6VotS/qHC/jZwzm+AFVg6KUDmL3 AyvTSo/9IV0yZm2dYQH+VeZuGJPBaaJYcu+uJMXSFgVl/MCHWBh0Hamsf9/3NqrttRii 5E885wk++DjZKUtMt0Tj/q4ZsQbhrlzB6wD5g+u73IVROhjOpB1fUmu5K6D5NrCOLkSO Jq+Up8kkeYGJArUbcZctgJGp0Cj+PXA86bv80SyOBGaCxxhqhLWKPwcf6d2LQYJbdH8P hNlgBLfTysnwDX5UxMwR0wkGZk4VGIDK6hLFPnqc4/zAI7V5zk8DnOIjcrFAwo5E3lXW TijQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e3nJMNyQkRtEjdVgCzBtNOhrTK9Iwh6sRszLOAZjqV8=; b=PwkPzNNPeHXsTNRoEo42EC4omKxlYTXUN7gsuHqxdwpGmsyDec0wDKYNm3qdFwdSNf kxPuOQOKNFYN5P5B7gmkWcN7rKX7UHz9StXR2aSsEZqiqzMM9PLmqMsnWsiPvFoqXfeC bP8E7YSH1kG6wUmxKlO9olF0tu/T2Sfwc8bg13uACkoNBCfZZ51CfD7tz9wCSPej+zD6 vGvRbaFYoYpzd0GUMo2ExVwmmZxN0vRYgOH/5VZM+HcnGCHybSmC3xoB5auBVsuJ3YXW j7kxpV4FqWCBGJp481uxyAfvpd3gwC6GF3z7ugkIVtSAeIHxFwikGnyf4z7anxB/03zt Ys4g== X-Gm-Message-State: APjAAAWP3Eg7cyFr95gogFetM5AGnkpzBQ24bf7OMAgyLhMfhUdDsJZJ tpyUWULK0Udmcx4YloSmF41UpDvUfE1fHykvdIE9RQ== X-Received: by 2002:a5d:5345:: with SMTP id t5mr24518975wrv.0.1578990616356; Tue, 14 Jan 2020 00:30:16 -0800 (PST) MIME-Version: 1.0 References: <20200113233023.928028-1-suzuki.poulose@arm.com> In-Reply-To: <20200113233023.928028-1-suzuki.poulose@arm.com> From: Ard Biesheuvel Date: Tue, 14 Jan 2020 09:30:05 +0100 Message-ID: Subject: Re: [PATCH v3 0/7] arm64: Fix support for no FP/SIMD To: Suzuki K Poulose Cc: linux-arm-kernel , Linux Kernel Mailing List , Will Deacon , Marc Zyngier , Catalin Marinas , Mark Rutland Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 14 Jan 2020 at 00:30, Suzuki K Poulose wrote: > > This series fixes the support for systems without FP/SIMD unit. > > We detect the absence of FP/SIMD after the SMP cpus are brought > online (i.e, SYSTEM scope). This means, we allow a hotplugged > CPU to boot successfully even if it doesn't have the FP/SIMD > when we have decided otherwise at boot and have now advertised > the ELF HWCAP for the userspace. Fix this by turning this to a > BOOT_RESTRICTED_CPU_LOCAL feature to allow the detection of the > feature the very moment a CPU turns up without FP/SIMD and also > prevent a conflict after SMP boot. > > The COMPAT ELF_HWCAPs were statically set to indicate the > availability of VFP. Make it dynamic to set the appropriate > bits. > > Also, some of the early kernel threads (including init) could run > with their TIF_FOREIGN_FPSTATE flag set which might be inherited > by applications forked by them (e.g, modprobe from initramfs). > Now, if we detect the absence of FP/SIMD we stop clearing the > TIF flag in fpsimd_restore_current_state(). This could cause > the applications stuck in do_notify_resume() looping forever > to clear the flag. Fix this by clearing the TIF flag in > fpsimd_restore_current_state() for the tasks that may > have it set. > > This series also categorises the functions dealing with fpsimd > into two : > > - Call permitted with missing FP/SIMD support. But we bail > out early in the function. This is for functions exposed > to the generic kernel code. > > - Calls not permitted with missing FP/SIMD support. These > are functions which deal with the CPU/Task FP/SIMD registers > and/or meta-data. The callers must check for the support > before invoking them. > > See the last patch in the series for details. > > Also make sure that the SVE is initialised where supported, > before the FP/SIMD is used by the kernel. > > Tested with debian armel initramfs and rootfs. The arm64 doesn't > have a soft-float ABI, thus haven't tested it with 64bit userspace. > > Applies on linux-aarch64 for-next/core > > Changes since v2: > - Rebase on to for-next/core, resolved conflict with the E0PD > handling changes > - Address comments from Catalin > - Remove warnings from static functions > - Add WARN_ON in may_use_simd() if called before initializing > capabilities. > - Add "active" hook for FP regset > - Remove dangerous WARN_ON from KVM, replaced with an additional > check to make sure that the FP/SIMD is always trapped. > - Added tags from Catalin, Marc > > Suzuki K Poulose (7): > arm64: Introduce system_capabilities_finalized() marker > arm64: fpsimd: Make sure SVE setup is complete before SIMD is used > arm64: cpufeature: Fix the type of no FP/SIMD capability > arm64: cpufeature: Set the FP/SIMD compat HWCAP bits properly > arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations > arm64: signal: nofpsimd: Handle fp/simd context for signal frames > arm64: nofpsmid: Handle TIF_FOREIGN_FPSTATE flag cleanly > For the series, Reviewed-by: Ard Biesheuvel > arch/arm64/include/asm/cpufeature.h | 5 +++ > arch/arm64/include/asm/kvm_host.h | 2 +- > arch/arm64/include/asm/simd.h | 8 +++- > arch/arm64/kernel/cpufeature.c | 67 +++++++++++++++++++---------- > arch/arm64/kernel/fpsimd.c | 30 +++++++++++-- > arch/arm64/kernel/process.c | 2 +- > arch/arm64/kernel/ptrace.c | 21 +++++++++ > arch/arm64/kernel/signal.c | 6 ++- > arch/arm64/kernel/signal32.c | 4 +- > arch/arm64/kvm/hyp/switch.c | 10 ++++- > 10 files changed, 121 insertions(+), 34 deletions(-) > > -- > 2.24.1 >