Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1505200lqt; Sat, 8 Jun 2024 00:33:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEYjBjl94QB8cY1cGCvyd8ykVPcQ6SsnapuxC5VYfBalcNfZXUQMP3DYm80wUwP3GJdh4+13Nfnm9xonPQsc3Oqec+HQosHpEmMOoXYQ== X-Google-Smtp-Source: AGHT+IGgEGq/DOXDJ0ainr9pnGRXMBaPMltKqOPDpb2MWAb+pwAdWjVdBjcq1V1XshFAAx14irUa X-Received: by 2002:a50:c345:0:b0:57c:54af:713b with SMTP id 4fb4d7f45d1cf-57c54af72admr2533144a12.14.1717831991114; Sat, 08 Jun 2024 00:33:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717831991; cv=pass; d=google.com; s=arc-20160816; b=kX9fO2J00R7CZwx3JH6DdCkKG1zAK1crWIDV20bKn5Kwm8D7OKHJ1X6Dj1Ew0pZ9Yz S1cr31xzbptnCqOPbdE00jP9tH/y+8GqHa/lnCMiJUtN1K0m/cbB5qMFVXk994O5e2EQ UO4svL5suEbrA4avM9ZsZ66U1gVEQafHK7IfOT9QU8BJa8aHAF8VdSMdlnrWq6qdcrz+ 7HPBgIErj6FB4g967T4CsHSw/Ri7FDxnKBu3KhVjDzRuM2I2UVHQAlqzM+yGaLdsLuEE rEEiLespSq2pM4ap3PYZ7Nhgi+B5p6J+0MxXoKg/WnWIhYtuR0++qNWiJo5zl7MGvOEV dp2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:sender:dkim-signature; bh=p0Ptq0zYXtCgwiXoL8ayk/kDTAsQ3v0jXZk6Fq+9owA=; fh=ZrHbDSiANSBCmvivbV48JgZ35KGtehFV6ZNj4vR8U9I=; b=YnIoQw4PCLIuTdSNrpKlXmEbuFfRGUOb95tlBuVg6DL7/Ik2Yi3H8jP4kOKe4cGSoh RURiMm3dQN8AS7AEuhqCg0/oIWQgMZBBnslvAx5nBZE2/M/6MkIqjGJgOPbAxjyL67hi tymafopY4oUY4rwDtMFjM3/GF3RUQ90ZEc5WKy1lUAYrnI1a1HIJDdcy9lAruyRbfDem gF24tk/GDwDuJ5ruO7noMGgRPAzoFeZBr6gNfACYswxG6CBpOvNh/OXtDa6TN5FzJp/r EQS94Mf2vS8Ry34HmwslXdNxnI9HdAfh69jGZviTjs2pBQG92hv2zJ4bASlyHe+YhFTb c+1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Wg6EN9TH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae226619si2514691a12.345.2024.06.08.00.33.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:33:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Wg6EN9TH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-206929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206929-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A9E091F21D0E for ; Sat, 8 Jun 2024 07:33:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02210178383; Sat, 8 Jun 2024 07:32:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wg6EN9TH" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 993EA1779A5 for ; Sat, 8 Jun 2024 07:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831945; cv=none; b=AX4o9XXdi6UI8K7YDtssEhvlBovi0oqe+WcOqyTYBURgspDejgC8sSTBUs1iVGSxEa7BDOSmdLO4YGaoHu9xQKXqQWCf3SWfVDuFlcqs7s5N7/Y1Cl4IBxCjiKbECPnM4R2eitsrEkZMuZOacElzkUcq3Zxh4RRwD4YNtsccEKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717831945; c=relaxed/simple; bh=Oy+NHG6mD/cGCqU1rGUvREyzGkIQ+RAhqrNHdtGEKsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r9gbw7svaVnaISmlXHO41lyIocHuOmpo5uNhphM8U0Oo/MbEcS17w19vHzxoSHLUjQcQWg+2TD40bv9XPhM0AOMzfTt11N+x0rRdi0JiiQKOaFTUyZW3/hkYF6xvCpJhxh1CD4v4GIQXvb1AwZTxUeaMt0tlDc0W2cVBvGEEUlw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Wg6EN9TH; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a6f0dc80ab9so10862266b.2 for ; Sat, 08 Jun 2024 00:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717831942; x=1718436742; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=p0Ptq0zYXtCgwiXoL8ayk/kDTAsQ3v0jXZk6Fq+9owA=; b=Wg6EN9THMw8OWpJs9GcYhZ5bmidZqzhy9BtiHpTwnYjoNMwbYB7ohHzHyUnQFlfFWt 7yM5qDuHgCVUYKPoHV1Eg18v870bzoDadeBEwwySTljWGf4JuzfeZCJ4ASpPoQafi86O H0U2A2elKcl+77Ybl8YniPo0QXvJgkx2SrhZ2e97V3AcoiWn86lRURREUV2j/unrq9zg +cWQ361bXhYygd86LBUCpoJXOIdC7o3Ic8Cc+K4pcO/iahLfZm9bclVGmM08nJ/A+kcJ inP8RiXFex5nuR2e8pQIZHrYTj+5LUts77OpLNGXz98TpQLMuXWpQv5/hAP7Tm99sUEF jPtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717831942; x=1718436742; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=p0Ptq0zYXtCgwiXoL8ayk/kDTAsQ3v0jXZk6Fq+9owA=; b=dh9+1/jIpqDH/M1/jjKo7CZBlRR5ydUqXh6o3JxYDIXTuKoJUzqaWOEAVQnwUdV4Y8 WONxqtLJmtUVajYW74f/n08nUCaPImlYOrA+X6NxF/NJ2E+nCH4W6RTbWVXwdBH9HBRn QsPokbg5xsd/d+BXbsNzGV7vAE7Y4seDHZnuht5sdqGo4OIz2tMBdpcM2QwKJmWk3yPV NIkgGx80iHQkh4lNBogkXRbudnPAtPvUC00W0murr11P2GDVFbSbp6zs/OvmwpoTQQfG 7jTCkYequhUi78Iw8yC5l7WRjxlsD5/8AoTbL2pjJhZNjnJzuvwiOJ9SlCT0mqDAKopK hVkA== X-Gm-Message-State: AOJu0YwztEmmNoLvdIdMKPyiXBL9SQy3NG+gKBW5m4UbOKZ2bmqclZOy znTw0KliUOHNhydUbBbQWey8ljpzfW/RamtQlF+2Z2q8qq12o5oqweMSTQGQ X-Received: by 2002:a17:906:2694:b0:a6e:ffa2:3cce with SMTP id a640c23a62f3a-a6effa23df7mr52363166b.41.1717831941983; Sat, 08 Jun 2024 00:32:21 -0700 (PDT) Received: from kepler.. (1F2EF20A.nat.pool.telekom.hu. [31.46.242.10]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6efe5262cdsm61350466b.117.2024.06.08.00.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:32:21 -0700 (PDT) Sender: Ingo Molnar From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Andrew Morton , Dave Hansen , Peter Zijlstra , Borislav Petkov , Brian Gerst , "H . Peter Anvin" , Linus Torvalds , Oleg Nesterov , Thomas Gleixner , Uros Bizjak Subject: [PATCH 6/9] x86/fpu: Make sure x86_task_fpu() doesn't get called for PF_KTHREAD tasks during exit Date: Sat, 8 Jun 2024 09:31:31 +0200 Message-ID: <20240608073134.264210-7-mingo@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240608073134.264210-1-mingo@kernel.org> References: <20240608073134.264210-1-mingo@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit fpu__drop() calls x86_task_fpu() unconditionally, while the FPU context area will not be present if it's the init task, and should not be in use when it's some other type of kthread. Return early for PF_KTHREAD tasks. The debug warning in x86_task_fpu() will catch any kthreads attempting to use the FPU save area. Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index c85667c0695d..52d5843c886c 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -674,7 +674,13 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal, */ void fpu__drop(struct task_struct *tsk) { - struct fpu *fpu = x86_task_fpu(tsk); + struct fpu *fpu; + + /* PF_KTHREAD tasks do not use the FPU context area: */ + if (tsk->flags & PF_KTHREAD) + return; + + fpu = x86_task_fpu(tsk); preempt_disable(); -- 2.43.0