From patchwork Tue Dec 17 18:33:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 181898 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp6068828och; Tue, 17 Dec 2019 10:34:19 -0800 (PST) X-Google-Smtp-Source: APXvYqxopec9NKj+Mzr8wCUddrv8iII5NAwz6rVEhddVoG8s1cd2lt11LzTl50xI0rOfPK+4QfSW X-Received: by 2002:a05:6830:1e11:: with SMTP id s17mr1605318otr.343.1576607659075; Tue, 17 Dec 2019 10:34:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576607659; cv=none; d=google.com; s=arc-20160816; b=FguEyhwB3tn1pCfExcn59lR7z4L+0YJuRaUxHWFKVIbcueQQL1KncyjnLAu5iwh0tU 5fR27gwlY55zQM6HEYUd/nPbzE+mGYopzjDKlVmJkIk36cBGQHbOmtNNb1E8+kfeusPD T3KY85xlCnvIysULaBbS0XMQKreTxC4ExFOcPALG09RWZsd6VuJ5R9xJlL/mHhfL2AY8 MmINX8/LcYC+YwVHEktzPPvSKaPxWFUM20CQsL+htYDISVq3Eii/BQylsXD+GPTHfKWw cN8X6si6F1ywUVuDQZefp3M6DnHZmiTTM4/WmBHIrrejPqmSHD3vn+jkphMinqTplbmm yLZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wJCbgZbmbh1xyanNU03h3TfmGV5gyiD+6ZMRXusMMgs=; b=h/gBNDjsz45NnrfjH8jcBgSSzDgElWQ+XZATPm0miyrSQyEpdQdbqdsy5wf3ze7Dsu 2jF0yOhj+N0j77LIVZCaSu52H41a04MMesgQR8BGJR2H6l2MBFW3xMQaHbXT1wi/Xh5b GBnYUga2po48IgdsqIxdFSs2T/zyVc1cOzEBKCd6RTB8a/65yLk9DbLq836gJN1OVDLK EA3KCrbRVQ5GtZezss0aIss1gHai5hgfEN+1LWugJogm9NyYFqnu1iR31iAgiyKAyWqZ zcm4gX/6uS8O4ZyeeO5CfScNFEFYRYGaYfcmuFpez5OZTvgSXx/h0Cv4s3nheDgUcwwo 8tvw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si1639859otq.322.2019.12.17.10.34.18; Tue, 17 Dec 2019 10:34:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728128AbfLQSeR (ORCPT + 27 others); Tue, 17 Dec 2019 13:34:17 -0500 Received: from foss.arm.com ([217.140.110.172]:44744 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726874AbfLQSeR (ORCPT ); Tue, 17 Dec 2019 13:34:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B0E3730E; Tue, 17 Dec 2019 10:34:16 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6115B3F67D; Tue, 17 Dec 2019 10:34:15 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, will@kernel.org, maz@kernel.org, mark.rutland@arm.com, dave.martin@arm.com, catalin.marinas@arm.com, ard.biesheuvel@linaro.org, christoffer.dall@arm.com, Suzuki K Poulose Subject: [PATCH v2 0/7] arm64: Fix support for no FP/SIMD Date: Tue, 17 Dec 2019 18:33:55 +0000 Message-Id: <20191217183402.2259904-1-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v5.5-rc2. 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 arch/arm64/include/asm/cpufeature.h | 5 +++ arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/mmu.h | 2 +- arch/arm64/include/asm/simd.h | 8 +++- arch/arm64/kernel/cpufeature.c | 65 +++++++++++++++++++---------- arch/arm64/kernel/fpsimd.c | 32 ++++++++++++-- arch/arm64/kernel/process.c | 2 +- arch/arm64/kernel/ptrace.c | 12 ++++++ arch/arm64/kernel/signal.c | 17 +++++++- arch/arm64/kernel/signal32.c | 12 +++++- arch/arm64/kvm/hyp/switch.c | 9 ++++ 11 files changed, 132 insertions(+), 34 deletions(-) -- 2.23.0