Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4488654rdb; Tue, 12 Dec 2023 00:16:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHz4H3p5ESM/F8QPDUIZSPMSVz5r2k0nzITxeLSd2cQvGPO2Caid/r5opuS2jTciO2kMmtT X-Received: by 2002:a05:6870:3325:b0:1fb:75b:2fc6 with SMTP id x37-20020a056870332500b001fb075b2fc6mr6835949oae.93.1702368997215; Tue, 12 Dec 2023 00:16:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702368997; cv=none; d=google.com; s=arc-20160816; b=a6sUcdOdHZj06uhgrq107vt0aGvjbxm5kqx+SOm4ZPEqy9DEr8jhKjTNWr44XETw9m 2ouCAuruGwpnctiquCRT+QKLwGWLqM8CqpHGmV4WyZQxQ7BZr+P+e6SA1L8afGSg7QMZ 6PtwUfcl3UwxXgrJIlwrIqH97VJfmsDfjT+GeaJTOpJ193DOrrvJHYLy3u0u1HHEbQoT hLNyOjYp+TAuqv72R4MNEcFdW9FPeJ2D81A9EXwj158t7aSFqu0KL44VPB8tH/XT0Y6L 4r+tEqAQ4WSITQPjH/EhMWH41A/6rB33LCCDb68ypSSztpMmx7b7Jb/Qv3uhpzbxfP8p 169A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=qXeZMYPSavRoW2IEAl+p2BOI6GFDZBj4a95e4eC3bQw=; fh=DjkvYCoZLTrWGAc7uAVrIx0E8BlKkRWHbTkLHfePHjc=; b=xdgdLlygRxhVyge1DDrypFAXbPIyygovh+Q7DGUjo3Z7m+XI764oD+1FlVSl/mT6vu ZOzCQq/MKBPlKvUWYpghW7tnWI8iHTe3HsmmncPvxj46HtOql4KIRecS0RRBO3bCSkaM 0jIoDy1FaqcbR4M561GbKoTpPGJl/hYzs0TMCpMh3aQg+YmZqfAW3O7f/2viL/gc4fEM 7/LQJc4Wp/S8TP/zXwyR89/YzzRZ9pj+Rrp9ivE2o60VqoiiUr4saBRhCySBkU2jem4s NCTHl/CxW2m3qeSteOOowhz8IHuf8HqqAwqsAB3snLeDvi07xBYupLYDNvgz9Y3fbAIW XR3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RkKFiRBt; spf=pass (google.com: domain of linux-crypto+bounces-734-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-734-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b23-20020a63cf57000000b005c66ca527ffsi7439054pgj.846.2023.12.12.00.16.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:16:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-734-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RkKFiRBt; spf=pass (google.com: domain of linux-crypto+bounces-734-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-734-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 90AE1B20C15 for ; Tue, 12 Dec 2023 08:16:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBEC11805A; Tue, 12 Dec 2023 08:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RkKFiRBt" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B5F77F5 for ; Tue, 12 Dec 2023 08:16:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00A49C433C9 for ; Tue, 12 Dec 2023 08:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702368986; bh=rda77atF9tL/SazTiETXJS/w0A0m5Bw3q6mdv2bB/Po=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RkKFiRBtPEYpgJvGynwIAFG2LIOLY7a10skpL61Zub+H71xrPitzZh0xoDUqlIQHw SMFjwU5VQfafBDfHxzYSzcbL1Rr/86QLINEvsRYCSiSdIMfccsAxcbHhXezQD+lC84 j1z6SU5KlLkoEoD79OomW42g6cnUuaAwbDWgSF7SapuWExgN1MMfoq3VtSYI18PQPB PvuK95U3pO7uVTOrS5mZ7MbCgYuapfPKTSKz5P0XoBYPGiwUR7NbkNxofhxoP0+Q5v 7wpgMxvKo+JEqWDilyLutotqmy6qqTrXLve3fNFPi37w8RoFpyLglXA7jYPDmKcvfq tMfJ7LVoVvt1Q== Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2c9f7fe6623so67431581fa.3 for ; Tue, 12 Dec 2023 00:16:25 -0800 (PST) X-Gm-Message-State: AOJu0YyRSV/2ngFZ489WFuOzRToPfbLTJZpNBSFKIXLs3r1J8yzhFB/+ CGxus+WeIG0I5nqGG4FVHwd+QBLrAxrZishxmf8= X-Received: by 2002:a05:651c:549:b0:2cb:30e6:540d with SMTP id q9-20020a05651c054900b002cb30e6540dmr1415462ljp.76.1702368984187; Tue, 12 Dec 2023 00:16:24 -0800 (PST) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231208113218.3001940-6-ardb@google.com> <170231871028.1857077.10318072500676133330.b4-ty@kernel.org> In-Reply-To: <170231871028.1857077.10318072500676133330.b4-ty@kernel.org> From: Ard Biesheuvel Date: Tue, 12 Dec 2023 09:16:13 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 0/4] arm64: Run kernel mode NEON with preemption enabled To: Will Deacon Cc: Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, kernel-team@android.com, Mark Rutland , Sebastian Andrzej Siewior , Eric Biggers , Kees Cook , Marc Zyngier , Mark Brown , linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Mon, 11 Dec 2023 at 21:27, Will Deacon wrote: > > Hey Ard, > > On Fri, 8 Dec 2023 12:32:19 +0100, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > > > Currently, kernel mode NEON (SIMD) support is implemented in a way that > > requires preemption to be disabled while the SIMD registers are live. > > The reason for this is that those registers are not in the set that is > > preserved/restored on exception entry/exit and context switch, as this > > would impact performance generally, even for workloads where kernel mode > > SIMD is not the bottleneck. > > > > [...] > > I applied the first three patches to for-next/fpsimd: > Thanks > [1/4] arm64: fpsimd: Drop unneeded 'busy' flag > https://git.kernel.org/arm64/c/e109130b0e5e > [2/4] arm64: fpsimd: Preserve/restore kernel mode NEON at context switch > https://git.kernel.org/arm64/c/1e3a3de1ff6c I spotted a typo in the commit log of this patch: TIF_USING_KMODE_FPSIMD -> TIF_KERNEL_FPSTATE > [3/4] arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD > https://git.kernel.org/arm64/c/035262623959 > > It would be nice to have an Ack from Herbert on the last one so that > he's aware of the possible conflicts. > > The other thing I tangentially wondered about is what happens now if code > calls uaccess routines (e.g. get_user()) within a kernel_neon_{begin,end} > section? I think previously the fact that preemption had to be disabled > would've caused the might_fault() to explode, but now I suppose the BUG_ON() > in kernel_neon_begin() will save us. Is that right? > Not sure what you mean by 'save us'. Is there anything fundamentally wrong with doing user access from a kernel mode NEON region if preemption remains enabled? The BUG_ON() will only catch uses from hardirq/NMI context, or cases where FP/SIMD is not implemented/enabled in the first place so it will not trigger on a user access.